Merge branch 'wip-MDL-61663-34' of git://github.com/abgreeve/moodle into MOODLE_34_STABLE

This commit is contained in:
Andrew Nicols
2018-04-17 11:46:32 +08:00
23 changed files with 1141 additions and 0 deletions
+1
View File
@@ -166,6 +166,7 @@ $string['plugincouldnotpackage'] = 'Failed to package up your data for export: o
$string['pluginismisconfigured'] = 'Portfolio plugin is misconfigured, skipping. Error was: {$a}';
$string['portfolio'] = 'Portfolio';
$string['portfolios'] = 'Portfolios';
$string['privacy:metadata'] = 'The portfolio subsystem acts as a channel, passing requests from plugins to the various portfolio plugins.';
$string['queuesummary'] = 'Currently queued transfers';
$string['returntowhereyouwere'] = 'Return to where you were';
$string['save'] = 'Save';
@@ -0,0 +1,79 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy class for requesting user data.
*
* @package portfolio_boxnet
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace portfolio_boxnet\privacy;
defined('MOODLE_INTERNAL') || die();
use core_privacy\local\metadata\collection;
/**
* Provider for the portfolio_boxnet plugin.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements
// This portfolio plugin does not store any data itself.
// It has no database tables, and it purely acts as a conduit, sending data externally.
\core_portfolio\privacy\portfolio_provider {
/**
* Returns meta data about this system.
*
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection) : collection {
return $collection->add_external_location_link('box.net', ['data' => 'privacy:metadata:data'],
'privacy:metadata');
}
/**
* Export all portfolio data from each portfolio plugin for the specified userid and context.
*
* @param int $userid The user to export.
* @param \context $context The context to export.
* @param array $subcontext The subcontext within the context to export this information to.
* @param array $linkarray The weird and wonderful link array used to display information for a specific item
*/
public static function export_portfolio_user_data(int $userid, \context $context, array $subcontext, array $linkarray) {
}
/**
* Delete all user information for the provided context.
*
* @param \context $context The context to delete user data for.
*/
public static function delete_portfolio_for_context(\context $context) {
}
/**
* Delete all user information for the provided user and context.
*
* @param int $userid The user to delete
* @param \context $context The context to refine the deletion.
*/
public static function delete_portfolio_for_user(int $userid, \context $context) {
}
}
@@ -39,6 +39,8 @@ $string['notarget'] = 'You must specify either an existing folder or a new folde
$string['noticket'] = 'Could not retrieve a ticket from Box to begin the authentication session';
$string['password'] = 'Your Box password (will not be stored)';
$string['pluginname'] = 'Box';
$string['privacy:metadata'] = 'This plugin sends data externally to a linked Box account. It does not store data locally.';
$string['privacy:metadata:data'] = 'Personal data passed through from the portfolio subsystem.';
$string['sendfailed'] = 'Failed to send content to Box: {$a}';
$string['setupinfo'] = 'Setup instructions';
$string['setupinfodetails'] = 'To obtain a client ID and secret, log in to Box and visit the <a href="{$a->servicesurl}">Box developers page</a>. Follow \'Create new application\' and create a new application for your Moodle site. The client ID and secret are displayed in the \'OAuth2 parameters\' section of the application edit form. Optionally, you can also provide other information about your Moodle site.';
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy provider tests.
*
* @package portfolio_boxnet
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Privacy provider tests class.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class portfolio_boxnet_privacy_provider_test extends \core_privacy\tests\provider_testcase {
/**
* Verify that a collection of metadata is returned for this component and that it just links to an external location.
*/
public function test_get_metadata() {
$collection = new \core_privacy\local\metadata\collection('portfolio_boxnet');
$collection = \portfolio_boxnet\privacy\provider::get_metadata($collection);
$this->assertNotEmpty($collection);
$items = $collection->get_collection();
$this->assertEquals(1, count($items));
$this->assertInstanceOf(\core_privacy\local\metadata\types\external_location::class, $items[0]);
}
}
@@ -0,0 +1,65 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the polyfill to allow a plugin to operate with Moodle 3.3 up.
*
* @package core_portfolio
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_portfolio\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* The trait used to provide a backwards compatibility for third-party plugins.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
trait legacy_polyfill {
/**
* Export all portfolio data from each portfolio plugin for the specified userid and context.
*
* @param int $userid The user to export.
* @param \context $context The context to export.
* @param array $subcontext The subcontext within the context to export this information to.
* @param array $linkarray The weird and wonderful link array used to display information for a specific item
*/
public static function export_portfolio_user_data(int $userid, \context $context, array $subcontext, array $linkarray) {
static::_export_portfolio_user_data($userid, $context, $subcontext, $linkarray);
}
/**
* Delete all user information for the provided context.
*
* @param \context $context The context to delete user data for.
*/
public static function delete_portfolio_for_context(\context $context) {
static::_delete_portfolio_for_context($context);
}
/**
* Delete all user information for the provided user and context.
*
* @param int $userid The user to delete
* @param \context $context The context to refine the deletion.
*/
public static function delete_portfolio_for_user(int $userid, \context $context) {
static::_delete_portfolio_for_user($userid, $context);
}
}
@@ -0,0 +1,63 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy class for requesting user data.
*
* @package core_portfolio
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_portfolio\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Provider for the portfolio API.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
interface portfolio_provider extends
// The portfolio_provider should be implemented by plugins which only provide information to a subsystem.
\core_privacy\local\request\plugin\subsystem_provider {
/**
* Export all portfolio data from each portfolio plugin for the specified userid and context.
*
* @param int $userid The user to export.
* @param \context $context The context to export.
* @param array $subcontext The subcontext within the context to export this information to.
* @param array $linkarray The weird and wonderful link array used to display information for a specific item
*/
public static function export_portfolio_user_data(int $userid, \context $context, array $subcontext, array $linkarray);
/**
* Delete all user information for the provided context.
*
* @param \context $context The context to delete user data for.
*/
public static function delete_portfolio_for_context(\context $context);
/**
* Delete all user information for the provided user and context.
*
* @param int $userid The user to delete
* @param \context $context The context to refine the deletion.
*/
public static function delete_portfolio_for_user(int $userid, \context $context);
}
+121
View File
@@ -0,0 +1,121 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy class for requesting user data.
*
* @package core_portfolio
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_portfolio\privacy;
defined('MOODLE_INTERNAL') || die();
use core_privacy\local\metadata\collection;
use core_privacy\local\request\context;
/**
* Provider for the portfolio API.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements
// The Portfolio subsystem does not store any data itself.
// It has no database tables, and it purely acts as a conduit to the various portfolio plugins.
\core_privacy\local\metadata\provider,
// The portfolio subsystem will be called by other components.
\core_privacy\local\request\subsystem\plugin_provider {
/**
* Returns meta data about this system.
*
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection) : collection {
return $collection->add_plugintype_link('portfolio', [], 'privacy:metadata');
}
/**
* Export all portfolio data from each portfolio plugin for the specified userid and context.
*
* @param int $userid The user to export.
* @param \context $context The context to export.
* @param array $subcontext The subcontext within the context to export this information to.
* @param array $linkarray The weird and wonderful link array used to display information for a specific item
*/
public static function export_portfolio_user_data(int $userid, \context $context, array $subcontext, array $linkarray) {
static::call_plugin_method('export_portfolio_user_data', [$userid, $context, $subcontext, $linkarray]);
}
/**
* Deletes all user content for a context in all portfolio plugins.
*
* @param \context $context The context to delete user data for.
*/
public static function delete_portfolio_for_context(\context $context) {
static::call_plugin_method('delete_portfolio_for_context', [$context]);
}
/**
* Deletes all user content for a user in a context in all portfolio plugins.
*
* @param int $userid The user to delete
* @param \context $context The context to refine the deletion.
*/
public static function delete_portfolio_for_user(int $userid, \context $context) {
static::call_plugin_method('delete_portfolio_for_user', [$userid, $context]);
}
/**
* Checks whether the component's provider class implements the specified interface.
* This can either be implemented directly, or by implementing a descendant (extension) of the specified interface.
*
* @param string $providerclass the provider class name.
* @param string $interface the name of the interface we want to check.
* @return bool True if an implementation was found, false otherwise.
*/
protected static function component_implements(string $providerclass, string $interface) : bool {
if (class_exists($providerclass)) {
$rc = new \ReflectionClass($providerclass);
return $rc->implementsInterface($interface);
}
return false;
}
/**
* Internal method for looping through all of the portfolio plugins and calling a method.
*
* @param string $methodname Name of the method to call on the plugins.
* @param array $params The parameters that go with the method being called.
*/
protected static function call_plugin_method($methodname, $params) {
// Note: Even if portfolio is _now_ disabled, there may be legacy data to export.
$plugins = \core_component::get_plugin_list('portfolio');
foreach (array_keys($plugins) as $plugin) {
$component = "portfolio_{$plugin}";
$classname = manager::get_provider_classname_for_component($component);
if (static::component_implements($classname, portfolio_provider::class)) {
// This portfolio plugin implements the portfolio_provider.
component_class_callback($classname, $methodname, $params);
}
}
}
}
@@ -0,0 +1,48 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy class for requesting user data.
*
* @package portfolio_download
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace portfolio_download\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Provider for the portfolio_download plugin.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements
// This portfolio plugin does not store any data itself.
// It has no database tables, and it purely acts as a conduit, sending data externally.
\core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
return 'privacy:metadata';
}
}
@@ -26,3 +26,4 @@
$string['downloadfile'] = 'Download your portfolio export file';
$string['downloading'] = 'Downloading ...';
$string['pluginname'] = 'File download';
$string['privacy:metadata'] = 'This plugin does not store personal data, nor does it export personal data to an external location.';
@@ -0,0 +1,78 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy class for requesting user data.
*
* @package portfolio_flickr
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace portfolio_flickr\privacy;
defined('MOODLE_INTERNAL') || die();
use core_privacy\local\metadata\collection;
/**
* Provider for the portfolio_flickr plugin.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements
// This portfolio plugin does not store any data itself.
// It has no database tables, and it purely acts as a conduit, sending data externally.
\core_portfolio\privacy\portfolio_provider {
/**
* Returns meta data about this system.
*
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection) : collection {
return $collection->add_external_location_link('flickr.com', ['data' => 'privacy:metadata:data'], 'privacy:metadata');
}
/**
* Export all portfolio data from each portfolio plugin for the specified userid and context.
*
* @param int $userid The user to export.
* @param \context $context The context to export.
* @param array $subcontext The subcontext within the context to export this information to.
* @param array $linkarray The weird and wonderful link array used to display information for a specific item
*/
public static function export_portfolio_user_data(int $userid, \context $context, array $subcontext, array $linkarray) {
}
/**
* Delete all user information for the provided context.
*
* @param \context $context The context to delete user data for.
*/
public static function delete_portfolio_for_context(\context $context) {
}
/**
* Delete all user information for the provided user and context.
*
* @param int $userid The user to delete
* @param \context $context The context to refine the deletion.
*/
public static function delete_portfolio_for_user(int $userid, \context $context) {
}
}
@@ -36,6 +36,8 @@ $string['noauthtoken'] = 'Could not retrieve an authentication token for use in
$string['other'] = 'Art, illustration, CGI, or other non-photographic images';
$string['photo'] = 'Photos';
$string['pluginname'] = 'Flickr.com';
$string['privacy:metadata'] = 'This plugin sends data externally to a linked Flickr account. It does not store data locally.';
$string['privacy:metadata:data'] = 'Personal data passed through from the portfolio subsystem.';
$string['restricted'] = 'Restricted';
$string['safe'] = 'Safe';
$string['safetylevel'] = 'Safety level';
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy provider tests.
*
* @package portfolio_flickr
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Privacy provider tests class.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class portfolio_flickr_privacy_provider_test extends \core_privacy\tests\provider_testcase {
/**
* Verify that a collection of metadata is returned for this component and that it just links to an external location.
*/
public function test_get_metadata() {
$collection = new \core_privacy\local\metadata\collection('portfolio_flickr');
$collection = \portfolio_flickr\privacy\provider::get_metadata($collection);
$this->assertNotEmpty($collection);
$items = $collection->get_collection();
$this->assertEquals(1, count($items));
$this->assertInstanceOf(\core_privacy\local\metadata\types\external_location::class, $items[0]);
}
}
@@ -0,0 +1,79 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy class for requesting user data.
*
* @package portfolio_googledocs
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace portfolio_googledocs\privacy;
defined('MOODLE_INTERNAL') || die();
use core_privacy\local\metadata\collection;
/**
* Provider for the portfolio_googledocs plugin.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements
// This portfolio plugin does not store any data itself.
// It has no database tables, and it purely acts as a conduit, sending data externally.
\core_portfolio\privacy\portfolio_provider {
/**
* Returns meta data about this system.
*
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection) : collection {
return $collection->add_external_location_link('docs.google.com', ['data' => 'privacy:metadata:data'],
'privacy:metadata');
}
/**
* Export all portfolio data from each portfolio plugin for the specified userid and context.
*
* @param int $userid The user to export.
* @param \context $context The context to export.
* @param array $subcontext The subcontext within the context to export this information to.
* @param array $linkarray The weird and wonderful link array used to display information for a specific item
*/
public static function export_portfolio_user_data(int $userid, \context $context, array $subcontext, array $linkarray) {
}
/**
* Delete all user information for the provided context.
*
* @param \context $context The context to delete user data for.
*/
public static function delete_portfolio_for_context(\context $context) {
}
/**
* Delete all user information for the provided user and context.
*
* @param int $userid The user to delete
* @param \context $context The context to refine the deletion.
*/
public static function delete_portfolio_for_user(int $userid, \context $context) {
}
}
@@ -29,5 +29,7 @@ $string['nooauthcredentials_help'] = 'To use the Google Drive portfolio plugin y
$string['nosessiontoken'] = 'A session token does not exist preventing export to google.';
$string['oauthinfo'] = '<p>To use this plugin, you must register your site with Google, as described in the documentation <a href="{$a->docsurl}">Google OAuth 2.0 setup</a>.</p><p>As part of the registration process, you will need to enter the following URL as \'Authorized Redirect URIs\':</p><p>{$a->callbackurl}</p><p>Once registered, you will be provided with a client ID and secret which can be used to configure all Google Drive and Picasa plugins.</p>';
$string['pluginname'] = 'Google Drive';
$string['privacy:metadata'] = 'This plugin sends data externally to a linked Google account. It does not store data locally.';
$string['privacy:metadata:data'] = 'Personal data passed through from the portfolio subsystem.';
$string['sendfailed'] = 'The file {$a} failed to transfer to google';
$string['secret'] = 'Secret';
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy provider tests.
*
* @package portfolio_googledocs
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Privacy provider tests class.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class portfolio_googledocs_privacy_provider_test extends \core_privacy\tests\provider_testcase {
/**
* Verify that a collection of metadata is returned for this component and that it just links to an external location.
*/
public function test_get_metadata() {
$collection = new \core_privacy\local\metadata\collection('portfolio_googledocs');
$collection = \portfolio_googledocs\privacy\provider::get_metadata($collection);
$this->assertNotEmpty($collection);
$items = $collection->get_collection();
$this->assertEquals(1, count($items));
$this->assertInstanceOf(\core_privacy\local\metadata\types\external_location::class, $items[0]);
}
}
@@ -0,0 +1,78 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy class for requesting user data.
*
* @package portfolio_mahara
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace portfolio_mahara\privacy;
defined('MOODLE_INTERNAL') || die();
use core_privacy\local\metadata\collection;
/**
* Provider for the portfolio_mahara plugin.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements
// This portfolio plugin does not store any data itself.
// It has no database tables, and it purely acts as a conduit, sending data externally.
\core_portfolio\privacy\portfolio_provider {
/**
* Returns meta data about this system.
*
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection) : collection {
return $collection->add_external_location_link('mahara', ['data' => 'privacy:metadata:data'], 'privacy:metadata');
}
/**
* Export all portfolio data from each portfolio plugin for the specified userid and context.
*
* @param int $userid The user to export.
* @param \context $context The context to export.
* @param array $subcontext The subcontext within the context to export this information to.
* @param array $linkarray The weird and wonderful link array used to display information for a specific item
*/
public static function export_portfolio_user_data(int $userid, \context $context, array $subcontext, array $linkarray) {
}
/**
* Delete all user information for the provided context.
*
* @param \context $context The context to delete user data for.
*/
public static function delete_portfolio_for_context(\context $context) {
}
/**
* Delete all user information for the provided user and context.
*
* @param int $userid The user to delete
* @param \context $context The context to refine the deletion.
*/
public static function delete_portfolio_for_user(int $userid, \context $context) {
}
}
@@ -43,5 +43,7 @@ $string['mnet_wronghost'] = 'Remote host did not match the transfer record for t
$string['pf_description'] = 'Allow users to push Moodle content to this host<br />Subscribe to <b>and</b> publish this service to allow authenticated users in your site to push content to {$a}<br /><ul><li><em>Dependency</em>: You must also <strong>publish</strong> the SSO (Identify Provider) service to {$a}.</li><li><em>Dependency</em>: You must also <strong>subscribe</strong> to the SSO (Service Provider) service on {$a}</li><li><em>Dependency</em>: You must also enable the MNet authentication plugin.</li></ul><br />';
$string['pf_name'] = 'Portfolio services';
$string['pluginname'] = 'Mahara ePortfolio';
$string['privacy:metadata'] = 'This plugin sends data externally to a linked Mahara application. It does not store data locally.';
$string['privacy:metadata:data'] = 'Personal data passed through from the portfolio subsystem.';
$string['senddisallowed'] = 'You cannot transfer files to Mahara at this time';
$string['url'] = 'URL';
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy provider tests.
*
* @package portfolio_mahara
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Privacy provider tests class.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class portfolio_mahara_privacy_provider_test extends \core_privacy\tests\provider_testcase {
/**
* Verify that a collection of metadata is returned for this component and that it just links to an external location.
*/
public function test_get_metadata() {
$collection = new \core_privacy\local\metadata\collection('portfolio_mahara');
$collection = \portfolio_mahara\privacy\provider::get_metadata($collection);
$this->assertNotEmpty($collection);
$items = $collection->get_collection();
$this->assertEquals(1, count($items));
$this->assertInstanceOf(\core_privacy\local\metadata\types\external_location::class, $items[0]);
}
}
@@ -0,0 +1,79 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy class for requesting user data.
*
* @package portfolio_picasa
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace portfolio_picasa\privacy;
defined('MOODLE_INTERNAL') || die();
use core_privacy\local\metadata\collection;
/**
* Provider for the portfolio_picasa plugin.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements
// This portfolio plugin does not store any data itself.
// It has no database tables, and it purely acts as a conduit, sending data externally.
\core_portfolio\privacy\portfolio_provider {
/**
* Returns meta data about this system.
*
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection) : collection {
return $collection->add_external_location_link('picasa.google.com', ['data' => 'privacy:metadata:data'],
'privacy:metadata');
}
/**
* Export all portfolio data from each portfolio plugin for the specified userid and context.
*
* @param int $userid The user to export.
* @param \context $context The context to export.
* @param array $subcontext The subcontext within the context to export this information to.
* @param array $linkarray The weird and wonderful link array used to display information for a specific item
*/
public static function export_portfolio_user_data(int $userid, \context $context, array $subcontext, array $linkarray) {
}
/**
* Delete all user information for the provided context.
*
* @param \context $context The context to delete user data for.
*/
public static function delete_portfolio_for_context(\context $context) {
}
/**
* Delete all user information for the provided user and context.
*
* @param int $userid The user to delete
* @param \context $context The context to refine the deletion.
*/
public static function delete_portfolio_for_user(int $userid, \context $context) {
}
}
@@ -28,5 +28,7 @@ $string['nooauthcredentials'] = 'OAuth credentials required.';
$string['nooauthcredentials_help'] = 'To use the Picasa portfolio plugin you must configure OAuth credentials in the portfolio settings.';
$string['oauthinfo'] = '<p>To use this plugin, you must register your site with Google, as described in the documentation <a href="{$a->docsurl}">Google OAuth 2.0 setup</a>.</p><p>As part of the registration process, you will need to enter the following URL as \'Authorized Redirect URIs\':</p><p>{$a->callbackurl}</p><p>Once registered, you will be provided with a client ID and secret which can be used to configure all Google Drive and Picasa plugins.</p>';
$string['pluginname'] = 'Picasa';
$string['privacy:metadata'] = 'This plugin sends data externally to a linked Picasa account. It does not store data locally.';
$string['privacy:metadata:data'] = 'Personal data passed through from the portfolio subsystem.';
$string['sendfailed'] = 'The file {$a} failed to transfer to Picasa';
$string['secret'] = 'Secret';
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy provider tests.
*
* @package portfolio_picasa
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Privacy provider tests class.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class portfolio_picasa_privacy_provider_test extends \core_privacy\tests\provider_testcase {
/**
* Verify that a collection of metadata is returned for this component and that it just links to an external location.
*/
public function test_get_metadata() {
$collection = new \core_privacy\local\metadata\collection('portfolio_picasa');
$collection = \portfolio_picasa\privacy\provider::get_metadata($collection);
$this->assertNotEmpty($collection);
$items = $collection->get_collection();
$this->assertEquals(1, count($items));
$this->assertInstanceOf(\core_privacy\local\metadata\types\external_location::class, $items[0]);
}
}
@@ -0,0 +1,163 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the privacy legacy polyfill for portfolio.
*
* @package core_privacy
* @category test
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Unit tests for the Portfolio API's privacy legacy_polyfill.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_portfolio_privacy_legacy_polyfill_test extends advanced_testcase {
/**
* Test that the core_portfolio\privacy\legacy_polyfill works and that the static _export_portfolio_user_data can be called.
*/
public function test_export_portfolio_user_data() {
$userid = 476;
$context = context_system::instance();
$mock = $this->createMock(test_portfolio_legacy_polyfill_mock_wrapper::class);
$mock->expects($this->once())
->method('get_return_value')
->with('_export_portfolio_user_data', [$userid, $context, [], []]);
test_legacy_polyfill_portfolio_provider::$mock = $mock;
test_legacy_polyfill_portfolio_provider::export_portfolio_user_data($userid, $context, [], []);
}
/**
* Test for _get_metadata shim.
*/
public function test_get_metadata() {
$collection = new \core_privacy\local\metadata\collection('core_portfolio');
$this->assertSame($collection, test_legacy_polyfill_portfolio_provider::get_metadata($collection));
}
/**
* Test the _delete_portfolio_for_context shim.
*/
public function test_delete_portfolio_for_context() {
$context = context_system::instance();
$mock = $this->createMock(test_portfolio_legacy_polyfill_mock_wrapper::class);
$mock->expects($this->once())
->method('get_return_value')
->with('_delete_portfolio_for_context', [$context]);
test_legacy_polyfill_portfolio_provider::$mock = $mock;
test_legacy_polyfill_portfolio_provider::delete_portfolio_for_context($context);
}
/**
* Test the _delete_portfolio_for_context shim.
*/
public function test_delete_portfolio_for_user() {
$userid = 696;
$context = \context_system::instance();
$mock = $this->createMock(test_portfolio_legacy_polyfill_mock_wrapper::class);
$mock->expects($this->once())
->method('get_return_value')
->with('_delete_portfolio_for_user', [$userid, $context]);
test_legacy_polyfill_portfolio_provider::$mock = $mock;
test_legacy_polyfill_portfolio_provider::delete_portfolio_for_user($userid, $context);
}
}
/**
* Legacy polyfill test class for the portfolio_provider.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class test_legacy_polyfill_portfolio_provider implements
\core_privacy\local\metadata\provider,
\core_portfolio\privacy\portfolio_provider {
use \core_portfolio\privacy\legacy_polyfill;
use \core_privacy\local\legacy_polyfill;
/**
* @var test_legacy_polyfill_portfolio_provider $mock.
*/
public static $mock = null;
/**
* Export all user data for the portfolio plugin.
*
* @param int $userid
* @param context $context
* @param array $subcontext
* @param array $linkarray
*/
protected static function _export_portfolio_user_data($userid, \context $context, array $subcontext, array $linkarray) {
static::$mock->get_return_value(__FUNCTION__, func_get_args());
}
/**
* Deletes all user data for the given context.
*
* @param context $context
*/
protected static function _delete_portfolio_for_context(\context $context) {
static::$mock->get_return_value(__FUNCTION__, func_get_args());
}
/**
* Delete personal data for the given user and context.
*
* @param int $userid
* @param context $context
*/
protected static function _delete_portfolio_for_user($userid, \context $context) {
static::$mock->get_return_value(__FUNCTION__, func_get_args());
}
/**
* Returns metadata about this plugin.
*
* @param \core_privacy\local\metadata\collection $collection The initialised collection to add items to.
* @return \core_privacy\local\metadata\collection A listing of user data stored through this system.
*/
protected static function _get_metadata(\core_privacy\local\metadata\collection $collection) {
return $collection;
}
}
/**
* Called inside the polyfill methods in the test polyfill provider, allowing us to ensure these are called with correct params.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class test_portfolio_legacy_polyfill_mock_wrapper {
/**
* Get the return value for the specified item.
*/
public function get_return_value() {
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy provider tests.
*
* @package core_portfolio
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Privacy provider tests class.
*
* @copyright 2018 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class portfolio_privacy_provider_test extends \core_privacy\tests\provider_testcase {
/**
* Verify that a collection of metadata is returned for this component and that it just links to the plugintype 'portfolio'.
*/
public function test_get_metadata() {
$collection = new \core_privacy\local\metadata\collection('core_portfolio');
$collection = \core_portfolio\privacy\provider::get_metadata($collection);
$this->assertNotEmpty($collection);
$items = $collection->get_collection();
$this->assertEquals(1, count($items));
$this->assertInstanceOf(\core_privacy\local\metadata\types\plugintype_link::class, $items[0]);
}
}