From: tjhunt Date: Fri, 12 Jan 2007 18:03:36 +0000 (+0000) Subject: MDL-8165 - Admin setting to control which roles are synced to metacourses X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b3170072129d93cf3427b08ae1019decf2465d0e;p=moodle.git MDL-8165 - Admin setting to control which roles are synced to metacourses --- diff --git a/admin/settings/users.php b/admin/settings/users.php index ef49ac922b..2332faa9dc 100644 --- a/admin/settings/users.php +++ b/admin/settings/users.php @@ -43,6 +43,10 @@ $temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('def 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(), diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 4e67aa2d61..25f8855f8e 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -125,6 +125,7 @@ $string['configmaxeditingtime'] = 'This specifies the amount of time people have $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?'; @@ -360,6 +361,7 @@ $string['nobookmarksforuser'] = 'You do not have any bookmarks.'; $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'; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 12f2902125..c18904ea8e 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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 @@ -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 @@ -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,