* @@@ 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
*/
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) {
} 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
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
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 '<table class="groupinfobox"><tr><td class="left side picture">';
print_group_picture($group, $course->id, true, false, false);
echo '</td><td class="content">';
echo '<h3>'.$group->name;
- if (isteacheredit($courseid)) {
+ if (has_capability('moodle/site:accessallgroups', $context)) {
echo ' <a title="'.get_string('editgroupprofile').'" href="../course/groups.php?id='.$course->id.'&group='.$group->id.'">';
echo '<img src="'.$CFG->pixpath.'/t/edit.gif" alt="" border="0">';
echo '</a>';