From c279acb99cbc0525080145cb3cbcb1dda97d58eb Mon Sep 17 00:00:00 2001 From: mrblippy Date: Tue, 28 Jan 2020 12:52:03 +1100 Subject: [PATCH 1/6] #63 implement moodle course retrieval optimisation fix courtesy of @jonof --- externallib.php | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/externallib.php b/externallib.php index 445ae8e..956d755 100644 --- a/externallib.php +++ b/externallib.php @@ -230,24 +230,31 @@ public static function get_course_code_returns() { public static function list_courses_for_user($username, $modifiable, $archived) { global $DB, $CFG; - $courselist = array(); - $params = self::validate_parameters(self::list_courses_for_user_parameters(), array('user' => $username,'modifiable' => $modifiable,'archived' => $archived)); + $params = self::validate_parameters(self::list_courses_for_user_parameters(), + array('user' => $username, 'modifiable' => $modifiable, 'archived' => $archived)); + $userobj = self::get_user_by_username($params['user']); + + $fields = 'fullname, visible, idnumber'; if ($modifiable) { - $userobj = self::get_user_by_username($params['user']); + $courses = get_user_capability_course(self::WRITE_PERMISSION, $userobj->id, true, $fields); } else { - $userobj = null; + // The courses enrolled within. + $enrolledcourses = enrol_get_users_courses($userobj->id, true, $fields); + + // The courses viewable without participation. + $viewcourses = get_user_capability_course(self::READ_PERMISSION, $userobj->id, true, $fields); + if ($viewcourses === false) { + $viewcourses = array(); + } else { + // Reindex with the course id. + $viewcourses = array_column($viewcourses, null, 'id'); + } + + $courses = $enrolledcourses + $viewcourses; } - $coursefields = "c.id,c.fullname,c.visible,c.idnumber"; - $contextfields = "ctx.id AS contextid,ctx.contextlevel,ctx.instanceid,ctx.path,ctx.depth"; - $sql = "SELECT $coursefields,$contextfields - FROM {context} ctx - JOIN {course} c ON c.id=ctx.instanceid - WHERE ctx.contextlevel=? "; - - $courses = $DB->get_recordset_sql($sql, array(CONTEXT_COURSE)); - foreach($courses as $course) { - // Ignore site level course + $courselist = array(); + foreach ($courses as $course) { if ($course->id == SITEID) { continue; } @@ -270,7 +277,7 @@ public static function list_courses_for_user($username, $modifiable, $archived) 'courseid' => $course->id, 'coursecode' => $course->idnumber, 'coursename' => $course->fullname, - 'archived' => !($course->visible) + 'archived' => !($course->visible), ); } } From 56c807c6e307b128a15ab36e67e68c60cce678f0 Mon Sep 17 00:00:00 2001 From: Jonathon Fowler Date: Thu, 20 Jun 2019 12:06:32 +1000 Subject: [PATCH 2/6] Fix attachmentuuid and activation fields losing digits --- callbackmulti.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/callbackmulti.php b/callbackmulti.php index 834c8fd..d9e0104 100644 --- a/callbackmulti.php +++ b/callbackmulti.php @@ -36,7 +36,7 @@ $mod->name = htmlspecialchars($link['name'], ENT_COMPAT, 'UTF-8'); $mod->intro = htmlspecialchars($link['description']); $mod->introformat = FORMAT_HTML; - $mod->attachmentuuid = clean_param($link['attachmentUuid'], PARAM_ALPHAEXT); + $mod->attachmentuuid = clean_param($link['attachmentUuid'], PARAM_ALPHANUMEXT); $mod->url = clean_param($link['url'], PARAM_URL); $mod->metadata = serialize($link); $targetsection = $sectionnum; @@ -57,7 +57,7 @@ } if (isset($link['activationUuid'])) { - $mod->activation = clean_param($link['activationUuid'], PARAM_ALPHAEXT); + $mod->activation = clean_param($link['activationUuid'], PARAM_ALPHANUMEXT); } $equellaid = equella_add_instance($mod); From 8109408b4a5aa697f4ad93838f7b2ca74e8c01c6 Mon Sep 17 00:00:00 2001 From: Jonathon Fowler Date: Wed, 28 Aug 2019 10:59:52 +1000 Subject: [PATCH 3/6] preserve filename and metadata fields on backup/restore Most obvious for instances of the module where the icon used in Moodle on the course page is derived from the filename rather than the mimetype field, e.g. MP3. The generic icon gets used instead on the restored resources. --- backup/moodle2/backup_equella_stepslib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup/moodle2/backup_equella_stepslib.php b/backup/moodle2/backup_equella_stepslib.php index 66d284a..f2a4ebe 100644 --- a/backup/moodle2/backup_equella_stepslib.php +++ b/backup/moodle2/backup_equella_stepslib.php @@ -18,7 +18,7 @@ class backup_equella_activity_structure_step extends backup_activity_structure_s protected function define_structure() { $equella = new backup_nested_element('equella', array('id'), - array('course','name','intro','introformat','timecreated','timemodified','url','mimetype','popup','activation','uuid','version','path','attachmentuuid','ltisalt') + array('course','name','intro','introformat','timecreated','timemodified','url','mimetype','popup','activation','uuid','version','path','attachmentuuid','ltisalt','filename','metadata') ); $equella->set_source_table('equella', array('id' => backup::VAR_ACTIVITYID)); $equella->annotate_files('mod_equella', 'intro', null); From b8eda5ec91e63c1456488f3367121e353e9d13ec Mon Sep 17 00:00:00 2001 From: nick charles Date: Fri, 13 Mar 2020 14:42:24 +1100 Subject: [PATCH 4/6] added privacy provider, including lti launch details --- ChangeLog | 4 ++ classes/privacy/provider.php | 90 ++++++++++++++++++++++++++++++++++++ lang/en/equella.php | 13 +++++- version.php | 2 +- 4 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 classes/privacy/provider.php diff --git a/ChangeLog b/ChangeLog index 72797c9..9ea7a27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-03-13 Nick Charles + + GDPR compliance + 2020-03-11 Nick Charles Replace starburst icons with open sourced versions diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php new file mode 100644 index 0000000..a5e3a66 --- /dev/null +++ b/classes/privacy/provider.php @@ -0,0 +1,90 @@ +add_external_location_link('lti_client', [ + 'userid' => 'privacy:metadata:lti_client:userid', + 'roles' => 'privacy:metadata:lti_client:roles', + 'fullname' => 'privacy:metadata:lti_client:fullname', + 'givenname' => 'privacy:metadata:lti_client:givenname', + 'familyname' => 'privacy:metadata:lti_client:familyname', + 'email' => 'privacy:metadata:lti_client:email', + + ], 'privacy:metadata:lti_client'); + + 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(int $userid) : contextlist { + return new contextlist(); + } + + /** + * Get the list of users who have data within a context. + * + * @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination. + */ + public static function get_users_in_context(userlist $userlist) { + } + + /** + * 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 data for all users in the specified context. + * + * @param context $context The specific context to delete data for. + */ + 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) { + } + + /** + * Delete multiple users within a single context. + * + * @param approved_userlist $userlist The approved context and user information to delete information for. + */ + public static function delete_data_for_users(approved_userlist $userlist) { + } +} diff --git a/lang/en/equella.php b/lang/en/equella.php index 05d0bdf..9ae25ae 100644 --- a/lang/en/equella.php +++ b/lang/en/equella.php @@ -164,4 +164,15 @@ $string['push.attachment'] = 'Selected attachment'; */ -$string['webserviceerror'] = '{$a}'; \ No newline at end of file +$string['webserviceerror'] = '{$a}'; + +//////////////////////////////////////////////////////// +// GDPR compliance + +$string['privacy:metadata:lti_client'] = 'In order to integrate with a remote openEQUELLA LTI service, user data needs to be exchanged with that service. Contact your openEQUELLA administrator for more information'; +$string['privacy:metadata:lti_client:userid'] = 'The userid is sent from Moodle to allow you to access your data on the remote system.'; +$string['privacy:metadata:lti_client:givenname'] = 'Your given name is sent to the openEQUELLA system for SSO login'; +$string['privacy:metadata:lti_client:familyname'] = 'Your family name is sent to the openEQUELLA system for SSO login'; +$string['privacy:metadata:lti_client:fullname'] = 'Your full name is sent to the openEQUELLA system for SSO login'; +$string['privacy:metadata:lti_client:email'] = 'Your email address is sent to the openEQUELLA system for SSO login'; +$string['privacy:metadata:lti_client:roles'] = 'Your moodle roles are sent to the openEQUELLA system, which allows to allow you to access your data on the remote system.'; \ No newline at end of file diff --git a/version.php b/version.php index 7829464..ab316e0 100644 --- a/version.php +++ b/version.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2020031100; +$plugin->version = 2020031301; $plugin->requires = 2014041101; // Requires this Moodle version $plugin->component = 'mod_equella'; // Full name of the plugin (used for diagnostics) $plugin->release = '1.0'; From 2ebce3806bc48c9d89cdc9dc2fb241a915bbd059 Mon Sep 17 00:00:00 2001 From: edalex-ian <43919233+edalex-ian@users.noreply.github.com> Date: Fri, 20 Mar 2020 17:45:13 +1100 Subject: [PATCH 5/6] Add full stop to privacy:metadata:lti_client string Feedback from #74 --- lang/en/equella.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lang/en/equella.php b/lang/en/equella.php index 9ae25ae..085f9cc 100644 --- a/lang/en/equella.php +++ b/lang/en/equella.php @@ -169,10 +169,10 @@ //////////////////////////////////////////////////////// // GDPR compliance -$string['privacy:metadata:lti_client'] = 'In order to integrate with a remote openEQUELLA LTI service, user data needs to be exchanged with that service. Contact your openEQUELLA administrator for more information'; +$string['privacy:metadata:lti_client'] = 'In order to integrate with a remote openEQUELLA LTI service, user data needs to be exchanged with that service. Contact your openEQUELLA administrator for more information.'; $string['privacy:metadata:lti_client:userid'] = 'The userid is sent from Moodle to allow you to access your data on the remote system.'; $string['privacy:metadata:lti_client:givenname'] = 'Your given name is sent to the openEQUELLA system for SSO login'; $string['privacy:metadata:lti_client:familyname'] = 'Your family name is sent to the openEQUELLA system for SSO login'; $string['privacy:metadata:lti_client:fullname'] = 'Your full name is sent to the openEQUELLA system for SSO login'; $string['privacy:metadata:lti_client:email'] = 'Your email address is sent to the openEQUELLA system for SSO login'; -$string['privacy:metadata:lti_client:roles'] = 'Your moodle roles are sent to the openEQUELLA system, which allows to allow you to access your data on the remote system.'; \ No newline at end of file +$string['privacy:metadata:lti_client:roles'] = 'Your moodle roles are sent to the openEQUELLA system, which allows to allow you to access your data on the remote system.'; From 44fb9b74148b4f3cfae7c32526be5ed81ea450ea Mon Sep 17 00:00:00 2001 From: edalex-ian <43919233+edalex-ian@users.noreply.github.com> Date: Fri, 20 Mar 2020 17:48:29 +1100 Subject: [PATCH 6/6] Fix typo in privacy:metadata:lti_client:roles Part of feedback for #74 --- lang/en/equella.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en/equella.php b/lang/en/equella.php index 085f9cc..02dc7fa 100644 --- a/lang/en/equella.php +++ b/lang/en/equella.php @@ -175,4 +175,4 @@ $string['privacy:metadata:lti_client:familyname'] = 'Your family name is sent to the openEQUELLA system for SSO login'; $string['privacy:metadata:lti_client:fullname'] = 'Your full name is sent to the openEQUELLA system for SSO login'; $string['privacy:metadata:lti_client:email'] = 'Your email address is sent to the openEQUELLA system for SSO login'; -$string['privacy:metadata:lti_client:roles'] = 'Your moodle roles are sent to the openEQUELLA system, which allows to allow you to access your data on the remote system.'; +$string['privacy:metadata:lti_client:roles'] = 'Your Moodle roles are sent to the openEQUELLA system, which allows you to access your data on the remote system.';