From 94181b2c2c1fe610a457dcb0615ed0667db12fdd Mon Sep 17 00:00:00 2001 From: nfreear Date: Thu, 23 Nov 2006 11:59:25 +0000 Subject: [PATCH] Replaced isteacheredit with has_capability, as in moodlelib (Bug MDL-7380 "groups".) --- group/lib/legacylib.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/group/lib/legacylib.php b/group/lib/legacylib.php index 89b5092080..a18e8e6e3a 100644 --- a/group/lib/legacylib.php +++ b/group/lib/legacylib.php @@ -5,7 +5,7 @@ * @@@ Don't look at this file - still tons to do! * * @copyright © 2006 The Open University - * @author J.White AT open.ac.uk + * @author J.White AT open.ac.uk and others * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package groups */ @@ -292,9 +292,10 @@ function get_and_set_current_group($course, $groupmode, $groupid=-1) { return $currentgroupid; } + $context = get_context_instance(CONTEXT_COURSE, $course->id); if ($groupid) { // Try to change the current group to this groupid if ($group = get_record('groups', 'id', $groupid, 'courseid', $course->id)) { // Exists - if (isteacheredit($course->id)) { // Sets current default group + if (has_capability('moodle/site:accessallgroups', $context)) { // Sets current default group $currentgroupid = set_current_group($course->id, $group->id); } elseif ($groupmode == VISIBLEGROUPS) { @@ -316,7 +317,7 @@ function get_and_set_current_group($course, $groupmode, $groupid=-1) { } else { // When groupid = 0 it means show ALL groups // this is changed, non editting teacher needs access to group 0 as well, // for viewing work in visible groups (need to set current group for multiple pages) - if (isteacheredit($course->id) OR (isteacher($course->id) AND ($groupmode == VISIBLEGROUPS))) { // Sets current default group + if (has_capability('moodle/site:accessallgroups', $context) AND ($groupmode == VISIBLEGROUPS)) { // Sets current default group $currentgroupid = set_current_group($course->id, 0); } elseif ($groupmode == VISIBLEGROUPS) { // All groups are visible @@ -354,7 +355,10 @@ function setup_and_print_groups($course, $groupmode, $urlroot) { return false; } - if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) { + $context = get_context_instance(CONTEXT_COURSE, $course->id); + + if ($groupmode == VISIBLEGROUPS + or ($groupmode and has_capability('moodle/site:accessallgroups', $context))) { groups_instance_print_grouping_selector(); }//added code here to allow non-editting teacher to swap in-between his own groups //added code for students in separategrous to swtich groups @@ -368,14 +372,16 @@ function setup_and_print_groups($course, $groupmode, $urlroot) { function oldgroups_print_user_group_info($currentgroup, $isseparategroups, $courseid) { global $CFG; - if ($currentgroup and (!$isseparategroups or isteacheredit($courseid))) { /// Display info about the group + $context = get_context_instance(CONTEXT_COURSE, $courseid); + + if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', $context))) { /// Display info about the group if ($group = get_record('groups', 'id', $currentgroup)) { if (!empty($group->description) or (!empty($group->picture) and empty($group->hidepicture))) { echo '
'; print_group_picture($group, $course->id, true, false, false); echo ''; echo '

'.$group->name; - if (isteacheredit($courseid)) { + if (has_capability('moodle/site:accessallgroups', $context)) { echo ' '; echo ''; echo ''; -- 2.39.5