$temp->add(new admin_setting_special_gradebookroles());
$ADMIN->add('appearance', $temp);
+// new CFG variable for coursemanager (what roles to display)
+$temp = new admin_settingpage('coursemanager', get_string('coursemanager', 'admin'));
+$temp->add(new admin_setting_special_coursemanager());
+$ADMIN->add('appearance', $temp);
$ADMIN->add('appearance', new admin_externalpage('stickyblocks', get_string('stickyblocks', 'admin'), "$CFG->wwwroot/$CFG->admin/stickyblocks.php"));
$linkcss.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.
$course->fullname.'</a></b><br />';
- if ($teachers = get_users_by_capability($context, 'moodle/course:update',
- 'u.*, ul.timeaccess as lastaccess',
- 'r.sortorder ASC', '','','','', false, true)) {
- $namesarray = array();
- foreach ($teachers as $teacher) {
- if ($roles = get_user_roles($context, $teacher->id, true, 'r.sortorder ASC', true)) {
- $role = array_shift($roles); // First one
- $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
- $namesarray[] = format_string($role->name).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
+ /// first find all roles that are supposed to be displayed
+ if ($managerroles = get_config('', 'coursemanager')) {
+ $coursemanagerroles = split(',', $managerroles->value);
+ foreach ($coursemanagerroles as $roleid) {
+ $role = get_record('role','id',$roleid);
+ if ($users = get_role_users($roleid, $context, true, '', 'u.lastname ASC', true)) {
+ foreach ($users as $teacher) {
+ $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
+ $namesarray[] = format_string($role->name).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
$teacher->id.'&course='.SITEID.'">'.$fullname.'</a>';
+ }
}
}
- if ($namesarray) {
+
+ if (!empty($namesarray)) {
echo "<ul class=\"teachers\">\n<li>";
echo implode('</li><li>', $namesarray);
echo "</li></ul>";
}
}
-
+
require_once("$CFG->dirroot/enrol/enrol.class.php");
$enrol = enrolment_factory::factory($course->enrol);
echo $enrol->get_access_icons($course);
$string['configclamdonothing'] = 'Treat files as OK';
$string['configclamfailureonupload'] = 'If you have configured clam to scan uploaded files, but it is configured incorrectly or fails to run for some unknown reason, how should it behave? If you choose \'Treat files like viruses\', they\'ll be moved into the quarantine area, or deleted. If you choose \'Treat files as OK\', the files will be moved to the desination directory like normal. Either way, admins will be alerted that clam has failed. If you choose \'Treat files like viruses\' and for some reason clam fails to run (usually because you have entered an invalid pathtoclam), ALL files that are uploaded will be moved to the given quarantine area, or deleted. Be careful with this setting.';
$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['configcoursesperpage'] = 'Enter the number of courses to be display per page in a course listing.';
$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.';
$string['configdebug'] = 'If you turn this on, then PHP\'s error_reporting will be increased so that more warnings are printed. This is only useful for developers.';
$string['confirmation'] = 'Confirmation';
$string['confirminstall'] = 'You are about to install language pack ($a), are you sure?';
$string['country'] = 'Default country';
+$string['coursemanager'] = 'Course managers';
$string['coursemgmt'] = 'Add/edit courses';
$string['courseoverview'] = 'Course overview';
$string['courserequests'] = 'Course Requests';
// filter for roles with all hidden assignments
// no need to return when only pulling roles for reviewing
// e.g. participants page.
- $hiddensql = ($view && has_capability('moodle/role:viewhiddenassigns', $context))? '':' AND ra.hidden = 0 ';
+ $hiddensql = ($view && !has_capability('moodle/role:viewhiddenassigns', $context))? ' AND ra.hidden = 0 ':'';
$contextlist = get_related_contexts_string($context);
$sql = "SELECT DISTINCT r.id,
$userid = $USER->id;
}
// set up hidden sql
- $hiddensql = ($view && has_capability('moodle/role:viewhiddenassigns', $context))? '':' AND ra.hidden = 0 ';
+ $hiddensql = ($view && !has_capability('moodle/role:viewhiddenassigns', $context))? ' AND ra.hidden = 0 ':'';
if ($checkparentcontexts && ($parents = get_parent_contexts($context))) {
$contexts = ' ra.contextid IN ('.implode(',' , $parents).','.$context->id.')';
$sortby = $sort ? " ORDER BY $sort " : '';
/// Set up hidden sql
- $hiddensql = ($view && has_capability('moodle/role:viewhiddenassigns', $context))? '':' AND ra.hidden = 0 ';
+ $hiddensql = ($view && !has_capability('moodle/role:viewhiddenassigns', $context))? ' AND ra.hidden = 0 ':'';
/// If context is a course, then construct sql for ul
if ($context->contextlevel == CONTEXT_COURSE) {
* @param bool parent if true, get list of users assigned in higher context too
* @return array()
*/
-function get_role_users($roleid, $context, $parent=false, $fields='', $sort='u.lastname ASC') {
+function get_role_users($roleid, $context, $parent=false, $fields='', $sort='u.lastname ASC', $view=false) {
global $CFG;
if (empty($fields)) {
'u.emailstop, u.lang, u.timezone';
}
+ // whether this assignment is hidden
+ $hiddensql = ($view && !has_capability('moodle/role:viewhiddenassigns', $context))? ' AND r.hidden = 0 ':'';
if ($parent) {
if ($contexts = get_parent_contexts($context)) {
$parentcontexts = ' OR r.contextid IN ('.implode(',', $contexts).')';
{$CFG->prefix}user u
WHERE (r.contextid = $context->id $parentcontexts)
AND u.id = r.userid $roleselect
+ $hiddensql
ORDER BY $sort
"; // join now so that we can just use fullname() later
}
+/*
+ * this is used in config->appearance->coursemanager
+ * (which roles to show on course decription page)
+ */
+class admin_setting_special_coursemanager extends admin_setting {
+
+ function admin_setting_special_coursemanager() {
+ $name = 'coursemanager';
+ $visiblename = get_string('coursemanager', 'admin');
+ $description = get_string('configcoursemanager', 'admin');
+ $default = array(3=>'1'); // The teahcer role in a default install
+ parent::admin_setting($name, $visiblename, $description, $default);
+ }
+
+ function get_setting() {
+
+ global $CFG;
+ if (!empty($CFG->{$this->name})) {
+ $result = explode(',', $CFG->{$this->name});
+ foreach ($result as $roleid) {
+ $array[$roleid] = 1;
+ }
+ return $array;
+ } else {
+ return null;
+ }
+ }
+
+ function write_setting($data) {
+
+ if (!empty($data)) {
+ $str = '';
+ foreach ($data as $key => $value) {
+ if ($value) {
+ $str .= $key.',';
+ }
+ }
+ return set_config($this->name, rtrim($str, ","))?'':get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+ } else {
+ return set_config($this->name, '')?'':get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+ }
+ }
+
+ function output_html() {
+
+ if ($this->get_setting() === NULL) {
+ $currentsetting = $this->defaultsetting;
+ } else {
+ $currentsetting = $this->get_setting();
+ }
+ // from to process which roles to display
+ if ($roles = get_records('role')) {
+ $return = '<div class="form-group">';
+ $first = true;
+ foreach ($roles as $roleid=>$role) {
+ if (is_array($currentsetting) && in_array($roleid, array_keys($currentsetting))) {
+ $checked = 'checked="checked"';
+ } else {
+ $checked = '';
+ }
+ if ($first) {
+ $first = false;
+ } else {
+ $return .= '<br />';
+ }
+ $return .= '<input type="checkbox" name="s_'.$this->name.'['.$roleid.']" value="1" '.$checked.'> '.$role->name;
+ }
+ $return .= '</div>';
+ }
+ return format_admin_setting($this->name, $this->visiblename, $return, $this->description);
+ }
+}
+
class admin_setting_special_perfdebug extends admin_setting_configcheckbox {
function admin_setting_special_perfdebug() {
}
function write_setting($data) {
+
if ($data == '1') {
return (set_config($this->name,15) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
} else {
}
function output_html() {
+
if ($this->get_setting() === NULL) {
$currentsetting = $this->defaultsetting;
} else {