Index: course/request.php =================================================================== RCS file: /cvsroot/moodle/moodle/course/request.php,v retrieving revision 1.20 diff -u -r1.20 request.php --- course/request.php 10 Dec 2008 02:57:41 -0000 1.20 +++ course/request.php 6 Jan 2009 06:16:10 -0000 @@ -68,8 +68,10 @@ /// Notify the admin if required. if ($CFG->courserequestnotify) { - if ($user = $user = $DB->get_record('user', array('username' => $CFG->courserequestnotify, - 'mnethostid' => $CFG->mnet_localhost_id))) { + list($where, $params) = $DB->get_in_or_equal(explode(',', $CFG->courserequestnotify)); + $params[] = $CFG->mnet_localhost_id; + $users = $DB->get_records_select('user', 'username ' . $where . ' AND mnethostid = ?', $params); + foreach ($users as $user) { $eventdata = new object(); $eventdata->modulename = 'moodle'; $eventdata->component = 'course'; Index: lang/en_utf8/admin.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/admin.php,v retrieving revision 1.252 diff -u -r1.252 admin.php --- lang/en_utf8/admin.php 31 Dec 2008 15:50:46 -0000 1.252 +++ lang/en_utf8/admin.php 6 Jan 2009 06:16:11 -0000 @@ -91,6 +91,7 @@ $string['configcountry'] = 'If you set a country here, then this country will be selected by default on new user accounts. To force users to choose a country, just leave this unset.'; $string['configcoursemanager'] = 'This setting allows you to control who appears on the course description. Users need to have at least one of these roles in a course to be shown on the course description for that course.'; $string['configcourserequestnotify'] = 'Type username of user to be notified when new course requested.'; +$string['configcourserequestnotify2'] = 'Users who will be notified when a course is requested. Only users who can approve course requests are listed here.'; $string['configcoursesperpage'] = 'Enter the number of courses to be display per page in a course listing.'; $string['configcreatornewroleid'] = 'This role is automatically assigned to creators in new courses they created. This role is not assigned if creator already has needed capabilities in parent context.'; $string['configdbsessions'] = 'If enabled, this setting will use the database to store information about current sessions. This is especially useful for large/busy sites or sites built on cluster of servers. For most sites this should probably be left disabled so that the server disk is used instead. Note that changing this setting now will log out all current users (including you). If you are using MySQL please make sure that \'max_allowed_packet\' in my.cnf (or my.ini) is at least 4M.'; Index: lib/adminlib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/adminlib.php,v retrieving revision 1.295 diff -u -r1.295 adminlib.php --- lib/adminlib.php 2 Jan 2009 21:05:16 -0000 1.295 +++ lib/adminlib.php 6 Jan 2009 06:16:14 -0000 @@ -3412,6 +3412,34 @@ } /** + * An admin setting for selecting one or more users, who have a particular capability + * in the system context. Warning, make sure the list will never be too long. There is + * no paging or searching of this list. + */ +class admin_setting_users_with_capability extends admin_setting_configmultiselect { + protected $capability; + + /** + * Constructor. + * + * @param string $name unique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting' for ones in config_plugins. + * @param string $visiblename localised name + * @param string $description localised long description + * @param array $defaultsetting array of usernames + * @param mixed $capabilities string capability name, or an array fo capability names. + */ + function __construct($name, $visiblename, $description, $defaultsetting, $capabilities) { + $users = get_users_by_capability(get_context_instance(CONTEXT_SYSTEM), + $capabilities, 'username,firstname,lastname', 'lastname,firstname'); + $choices = array(); + foreach ($users as $user) { + $choices[$user->username] = fullname($user); + } + parent::admin_setting_configmultiselect($name, $visiblename, $description, $defaultsetting, $choices); + } +} + +/** * Special checkbox for calendar - resets SESSION vars. */ class admin_setting_special_adminseesall extends admin_setting_configcheckbox { Index: admin/settings/courses.php =================================================================== RCS file: /cvsroot/moodle/moodle/admin/settings/courses.php,v retrieving revision 1.30 diff -u -r1.30 courses.php --- admin/settings/courses.php 15 Dec 2008 21:35:47 -0000 1.30 +++ admin/settings/courses.php 6 Jan 2009 06:16:10 -0000 @@ -122,7 +122,7 @@ $temp = new admin_settingpage('courserequest', get_string('courserequest')); $temp->add(new admin_setting_configcheckbox('enablecourserequests', get_string('enablecourserequests', 'admin'), get_string('configenablecourserequests', 'admin'), 0)); $temp->add(new admin_settings_coursecat_select('defaultrequestcategory', get_string('defaultrequestcategory', 'admin'), get_string('configdefaultrequestcategory', 'admin'), 1)); - $temp->add(new admin_setting_configtext('courserequestnotify', get_string('courserequestnotify', 'admin'), get_string('configcourserequestnotify', 'admin'), '')); + $temp->add(new admin_setting_users_with_capability('courserequestnotify', get_string('courserequestnotify', 'admin'), get_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse')); $ADMIN->add('courses', $temp); /// Pending course requests.