diff --git a/message/output/email/classes/privacy/provider.php b/message/output/email/classes/privacy/provider.php new file mode 100644 index 00000000000..5e91715e631 --- /dev/null +++ b/message/output/email/classes/privacy/provider.php @@ -0,0 +1,98 @@ +. + +/** + * Privacy class for requesting user data. + * + * @package message_email + * @copyright 2018 Mihail Geshoski + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace message_email\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_email + * @copyright 2018 Mihail Geshoski + * @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->link_external_location('smtp', [ + 'recipient' => 'privacy:metadata:recipient', + 'userfrom' => 'privacy:metadata:userfrom', + 'subject' => 'privacy:metadata:subject', + 'fullmessage' => 'privacy:metadata:fullmessage', + 'fullmessagehtml' => 'privacy:metadata:fullmessagehtml', + 'attachment' => 'privacy:metadata:attachment', + 'attachname' => 'privacy:metadata:attachname', + 'replyto' => 'privacy:metadata:replyto', + 'replytoname' => 'privacy:metadata:replytoname' + ], '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 $contextlist The contextlist containing the list of contexts used in this plugin. + */ + public static function get_contexts_for_userid($userid) { + $contextlist = new contextlist(); + return $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) { + } +} diff --git a/message/output/email/lang/en/message_email.php b/message/output/email/lang/en/message_email.php index dffd89171c5..ad806bf0c8d 100644 --- a/message/output/email/lang/en/message_email.php +++ b/message/output/email/lang/en/message_email.php @@ -26,3 +26,13 @@ $string['email'] = 'Send email notifications to'; $string['emailonlyfromnoreplyaddress'] = 'Always send email from the no-reply address?'; $string['ifemailleftempty'] = 'Leave empty to send notifications to {$a}'; $string['pluginname'] = 'Email'; +$string['privacy:metadata:attachment'] = 'A file on the filesystem.'; +$string['privacy:metadata:attachname'] = 'The name of the attached file (extension indicates MIME).'; +$string['privacy:metadata:externalpurpose'] = 'This information is sent to an external SMTP server to be ultimately delivered as an email to the recipient.'; +$string['privacy:metadata:fullmessage'] = 'The full message in a given format.'; +$string['privacy:metadata:fullmessagehtml'] = 'The full version of the message.'; +$string['privacy:metadata:recipient'] = 'The recipient of the message.'; +$string['privacy:metadata:replyto'] = 'The email address to reply to.'; +$string['privacy:metadata:replytoname'] = 'Name of reply to recipient.'; +$string['privacy:metadata:subject'] = 'The subject line of the message.'; +$string['privacy:metadata:userfrom'] = 'The user sending the message.'; diff --git a/message/output/email/tests/privacy_test.php b/message/output/email/tests/privacy_test.php new file mode 100644 index 00000000000..dbfd9ba18a0 --- /dev/null +++ b/message/output/email/tests/privacy_test.php @@ -0,0 +1,60 @@ +. +/** + * Base class for unit tests for message_email. + * + * @package message_email + * @copyright 2018 Mihail Geshoski + * @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\email\classes\privacy\provider.php + * + * @copyright 2018 Mihail Geshoski + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class message_email_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_email'); + $collection = \message_email\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_email\privacy\provider::get_contexts_for_userid($user->id); + $this->assertEmpty($contextlist); + } +} +