Skip to content

Commit

Permalink
MDL-8165 - Admin setting to control which roles are synced to metacou…
Browse files Browse the repository at this point in the history
…rses
  • Loading branch information
tjhunt committed Jan 12, 2007
1 parent 474debf commit b317007
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions admin/settings/users.php
Expand Up @@ -43,6 +43,10 @@
get_string('configdefaultcourseroleid', 'admin'), $studentrole->id, $assignableroles));

$temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));

$temp->add(new admin_setting_configmultiselect('nonmetacoursesyncroleids', get_string('nonmetacoursesyncroleids', 'admin'),
get_string('confignonmetacoursesyncroleids', 'admin'), '', $assignableroles));

//$temp->add(new admin_setting_configcheckbox('allusersaresitestudents', get_string('allusersaresitestudents', 'admin'), get_string('configallusersaresitestudents','admin'), 1));
$temp->add(new admin_setting_configmultiselect('hiddenuserfields', get_string('hiddenuserfields', 'admin'),
get_string('confighiddenuserfields', 'admin'), array(),
Expand Down
2 changes: 2 additions & 0 deletions lang/en_utf8/admin.php
Expand Up @@ -125,6 +125,7 @@
$string['configmaxevents'] = 'Events to Lookahead';
$string['configmessaging'] = 'Should the messaging system between site users be enabled?';
$string['configmymoodleredirect'] = 'This setting forces redirects to /my on login for non-admins and replaces the top level site breadcrumb with /my';
$string['confignonmetacoursesyncroleids'] = 'By default all enrolments from child courses are synchronised to metacourses. Roles that are selected here will not be included in the synchronisation process.';
$string['confignoreplyaddress'] = 'Emails are sometimes sent out on behalf of a user (eg forum posts). The email address you specify here will be used as the \"From\" address in those cases when the recipients should not be able to reply directly to the user (eg when a user chooses to keep their address private).';
$string['confignotifyloginfailures'] = 'If login failures have been recorded, email notifications can be sent out. Who should see these notifications?';
$string['confignotifyloginthreshold'] = 'If notifications about failed logins are active, how many failed login attempts by one user or one IP address is it worth notifying about?';
Expand Down Expand Up @@ -360,6 +361,7 @@
$string['nolangupdateneeded'] = 'All your language packs are up to date, no update is needed';
$string['nonewsettings'] = 'No new settings were added during this upgrade.';
$string['nonexistentbookmark'] = 'The bookmark you requested does not exist.';
$string['nonmetacoursesyncroleids'] = 'Roles that are not synchronised to metacourses';
$string['noreplyaddress'] = 'No-reply address';
$string['noresults'] = 'No results found.';
$string['notifications'] = 'Notifications';
Expand Down
9 changes: 9 additions & 0 deletions lib/moodlelib.php
Expand Up @@ -1990,6 +1990,13 @@ function sync_metacourse($course) {
return false;
}

// Get a list of roles that should not be synced.
if ($CFG->nonmetacoursesyncroleids) {
$roleexclusions = 'ra.roleid NOT IN (' . $CFG->nonmetacoursesyncroleids . ') AND';
} else {
$roleexclusions = '';
}

// Get the context of the metacourse.
$context = get_context_instance(CONTEXT_COURSE, $course->id); // SITEID can not be a metacourse

Expand All @@ -2014,6 +2021,7 @@ function sync_metacourse($course) {
con.contextlevel = " . CONTEXT_COURSE . " AND
con.instanceid = cm.child_course AND
cm.parent_course = {$course->id} AND
$roleexclusions
NOT EXISTS (
SELECT 1 FROM
{$CFG->prefix}role_assignments ra2
Expand All @@ -2035,6 +2043,7 @@ function sync_metacourse($course) {
{$CFG->prefix}role_assignments ra
WHERE
ra.contextid = {$context->id} AND
$roleexclusions
NOT EXISTS (
SELECT 1 FROM
{$CFG->prefix}role_assignments ra2,
Expand Down

0 comments on commit b317007

Please sign in to comment.