Merge branch 'MDL-61761-master' of git://github.com/mihailges/moodle

This commit is contained in:
Jake Dallimore
2018-04-05 13:17:53 +08:00
3 changed files with 157 additions and 0 deletions
@@ -0,0 +1,92 @@
<?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 message_jabber
* @copyright 2018 Mihail Geshoski <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace message_jabber\privacy;
defined('MOODLE_INTERNAL') || die();
use \core_privacy\local\metadata\collection;
use \core_privacy\local\request\contextlist;
use \core_privacy\local\request\approved_contextlist;
/**
* Privacy class for requesting user data.
*
* @package message_jabber
* @copyright 2018 Mihail Geshoski <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements
\core_privacy\local\metadata\provider,
\core_privacy\local\request\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 {
$collection->link_external_location('External Jabber server.', [
'userto' => 'privacy:metadata:userto',
'userfrom' => 'privacy:metadata:userfrom',
'smallmessage' => 'privacy:metadata:smallmessage',
'contexturl' => 'privacy:metadata:contexturl',
], 'privacy:metadata:externalpurpose');
return $collection;
}
/**
* Get the list of contexts that contain user information for the specified user.
*
* @param int $userid The user to search.
* @return contextlist The contextlist containing the list of contexts used in this plugin.
*/
public static function get_contexts_for_userid(int $userid) : contextlist {
return new contextlist();
}
/**
* Export all user data for the specified user, in the specified contexts.
*
* @param approved_contextlist $contextlist The approved contexts to export information for.
*/
public static function export_user_data(approved_contextlist $contextlist) {
}
/**
* Delete all use data which matches the specified deletion_criteria.
*
* @param context $context A user context.
*/
public static function delete_data_for_all_users_in_context(\context $context) {
}
/**
* Delete all user data for the specified user, in the specified contexts.
*
* @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
*/
public static function delete_data_for_user(approved_contextlist $contextlist) {
}
}
@@ -35,3 +35,8 @@ $string['jabberpassword'] = 'Jabber password';
$string['jabberport'] = 'Jabber port';
$string['notconfigured'] = 'The Jabber server hasn\'t been configured so Jabber messages cannot be sent';
$string['pluginname'] = 'Jabber';
$string['privacy:metadata:contexturl'] = 'The url to view the event.';
$string['privacy:metadata:externalpurpose'] = 'This information is sent to an external Jabber server to be ultimately delivered as a notification message to the recipient.';
$string['privacy:metadata:smallmessage'] = 'The small version of the message.';
$string['privacy:metadata:userfrom'] = 'The user sending the notification message.';
$string['privacy:metadata:userto'] = 'The recipient of the notification message.';
@@ -0,0 +1,60 @@
<?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/>.
/**
* Base class for unit tests for message_jabber.
*
* @package message_jabber
* @copyright 2018 Mihail Geshoski <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
use \core_privacy\tests\provider_testcase;
/**
* Unit tests for message\output\jabber\classes\privacy\provider.php
*
* @copyright 2018 Mihail Geshoski <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class message_jabber_testcase extends provider_testcase {
/**
* Basic setup for these tests.
*/
public function setUp() {
$this->resetAfterTest(true);
}
/**
* Test returning metadata.
*/
public function test_get_metadata() {
$collection = new \core_privacy\local\metadata\collection('message_jabber');
$collection = \message_jabber\privacy\provider::get_metadata($collection);
$this->assertNotEmpty($collection);
}
/**
* Test getting the context for the user ID related to this plugin.
*/
public function test_get_contexts_for_userid() {
$user = $this->getDataGenerator()->create_user();
$contextlist = \message_jabber\privacy\provider::get_contexts_for_userid($user->id);
$this->assertEmpty($contextlist);
}
}