Skip to content

Commit

Permalink
MDL-63500 enrol_meta: refactoring get_contexts_for_userid
Browse files Browse the repository at this point in the history
This issue is part of the MDL-62560 Epic.
  • Loading branch information
rezaies authored and David Monllao committed Oct 22, 2018
1 parent 3afb545 commit 3fcb71b
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions enrol/meta/classes/privacy/provider.php
Expand Up @@ -68,23 +68,7 @@ public static function get_metadata(collection $collection) : collection {
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
*/
public static function get_contexts_for_userid(int $userid) : contextlist {
$contextlist = new contextlist();

$sql = "SELECT ctx.id
FROM {groups_members} gm
JOIN {groups} g ON gm.groupid = g.id
JOIN {context} ctx ON g.courseid = ctx.instanceid AND ctx.contextlevel = :contextlevel
WHERE gm.userid = :userid
AND gm.component = 'enrol_meta'";

$params = [
'contextlevel' => CONTEXT_COURSE,
'userid' => $userid
];

$contextlist->add_from_sql($sql, $params);

return $contextlist;
return \core_group\privacy\provider::get_contexts_for_group_member($userid, 'enrol_meta');
}

/**
Expand Down

0 comments on commit 3fcb71b

Please sign in to comment.