]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-7380 converted various places to use new groups API
authorskodak <skodak>
Sat, 8 Sep 2007 20:53:05 +0000 (20:53 +0000)
committerskodak <skodak>
Sat, 8 Sep 2007 20:53:05 +0000 (20:53 +0000)
12 files changed:
blocks/blog_tags/block_blog_tags.php
blocks/online_users/block_online_users.php
blog/index.php
blog/lib.php
calendar/event.php
course/lib.php
course/modedit.php
course/recent.php
lib/grouplib.php
user/index.php
user/tabs.php
user/view.php

index fd012bd5472120efc922e4d33710a3881aef7e70..c92a863e6b2e9f343b9bfe5636b125c44dfe4bde 100644 (file)
@@ -134,7 +134,7 @@ class block_blog_tags extends block_base {
 
                     case BLOG_GROUP_LEVEL:
                         $filtertype = 'group';
-                        $filterselect = get_and_set_current_group($COURSE, groupmode($COURSE));
+                        $filterselect = groups_get_course_group($COURSE);
                     break;
 
                     case BLOG_COURSE_LEVEL:
index 8029c2c54114cfcea71bd90023693545644582dc..06bec16b732e8b4db1f10da717e55666e3d94708 100644 (file)
@@ -43,7 +43,7 @@ class block_online_users extends block_base {
                              && !has_capability('moodle/site:accessallgroups', $context));
 
         //Get the user current group
-        $currentgroup = $isseparategroups ? get_and_set_current_group($COURSE, groupmode($COURSE)) : NULL;
+        $currentgroup = $isseparategroups ? groups_get_course_group($COURSE) : NULL;
 
         $groupmembers = "";
         $groupselect = "";
index 946e8b7a24f488b29bfd48b55ec250b8b49feb87..2e977f4717b905ceffbd00ca33d4a27ebf09f124 100755 (executable)
@@ -98,7 +98,7 @@ switch ($filtertype) {
         if (!has_capability('moodle/blog:view', $coursecontext)) {
             error('You do not have the required permissions to view blogs in this course/group');
         }
-        if (groupmode($course) == SEPARATEGROUPS
+        if (groups_get_course_groupmode($course) == SEPARATEGROUPS
           and !has_capability('moodle/site:accessallgroups', $coursecontext)) {
             if (!groups_is_member($filterselect)) {
                 error ('You are not a member of this course group');
index 25dd3aa71894d4cec618b71d5a85976299a7eea4..6069f429f3cc2ed97053af700af26190c23fc27a 100755 (executable)
                 $usercourses = array_keys(get_my_courses($targetuserid));
                 $shared = array_intersect($mycourses, $usercourses);
                 foreach ($shared as $courseid) {
+                    $course = get_record('course', 'id', $courseid);
                     $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
                     if (has_capability('moodle/site:accessallgroups', $coursecontext)
-                      or groupmode($courseid) != SEPARATEGROUPS) {
+                      or groups_get_course_groupmode($course) != SEPARATEGROUPS) {
                         return true;
                     } else {
                         if ($usergroups = groups_get_all_groups($courseid, $targetuserid)) {
index bf995650cb8a5a0ef043aaf13a93ca40816f6097..7d9aab24adb9d08b71e933a06646bb98aa58f4cb 100644 (file)
                 if (!$course = get_record('course', 'id', $courseid)) {
                     error('Incorrect course ID');
                 }
-                if ($groupmode = groupmode($course)) {   // Groups are being used
-                    $changegroup = optional_param('group', -1, PARAM_INT);
-                    $groupid = get_and_set_current_group($course, $groupmode, $changegroup);
-                } else {
-                    $groupid = 0;
-                }
+                
+                $groupid = groups_get_course_group($course);
 
                 echo '<h2>'.get_string('eventkind', 'calendar').':</h2>';
                 echo '<div id="selecteventtype">';
index 24b34cc537def73c686a51dda61596c726ab356e..6f28aeffa5b317cac44bc8c981b2d6ef4377fd6b 100644 (file)
@@ -178,7 +178,7 @@ function print_recent_selector_form($course, $advancedfilter=0, $selecteduser=0,
 
         echo '<tr>';
 
-        $groupmode =  groupmode($course);
+        $groupmode =  groups_get_course_groupmode($course);
 
         if ($groupmode == VISIBLEGROUPS or ($groupmode and has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id)))) {
             if ($groups = groups_get_all_groups($course->id)) {
@@ -1412,9 +1412,9 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
                          $typestring.$instancename.'</a>';
                 }
                 if ($usetracking && $mod->modname == 'forum') {
-                    $groupmode = groupmode($course, $mod);
+                    $groupmode = groups_get_course_groupmode($course, $mod);
                     $groupid = ($groupmode == SEPARATEGROUPS && !has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) ?
-                               get_current_group($course->id) : false;
+                               groups_get_course_group($course, true) : false;
 
                     if (forum_tp_can_track_forums() && !isset($untracked[$mod->instance])) {
                         $unread = forum_tp_count_forum_unread_posts($USER->id, $mod->instance, $groupid);
@@ -2455,15 +2455,16 @@ function print_groupmode_setting($form, $course=NULL) {
         if (! $cm = get_record('course_modules', 'id', $form->coursemodule)) {
             error("This course module doesn't exist");
         }
+        $groupmode = groups_get_activity_groupmode($cm);
     } else {
         $cm = null;
+        $groupmode = groups_get_course_groupmode($course);
     }
-    $groupmode = groupmode($course, $cm);
     if ($course->groupmode or (!$course->groupmodeforce)) {
         echo '<tr valign="top">';
         echo '<td align="right"><b>'.get_string('groupmode').':</b></td>';
         echo '<td align="left">';
-        unset($choices);
+        $choices = array();
         $choices[NOGROUPS] = get_string('groupsnone');
         $choices[SEPARATEGROUPS] = get_string('groupsseparate');
         $choices[VISIBLEGROUPS] = get_string('groupsvisible');
index 0b9e9d40c60a8f81a6ed972bafe874898c1ab6fc..3f9cee3fa8868e0f1592cbf349fe642368b99618 100644 (file)
         $form->section          = $cw->section;  // The section number itself - relative!!! (section column in course_sections)
         $form->visible          = $cm->visible; //??  $cw->visible ? $cm->visible : 0; // section hiding overrides
         $form->cmidnumber       = $cm->idnumber;          // The cm IDnumber
-        $form->groupmode        = groupmode($COURSE,$cm); // locked later if forced
+        $form->groupmode        = groups_get_activity_groupmode($cm); // locked later if forced
         $form->groupingid       = $cm->groupingid;
         $form->groupmembersonly = $cm->groupmembersonly;
         $form->course           = $course->id;
index b909b0af650286ba3af7c1d60540855cb669c7f4..b84172cc314aa65e791c1d4109dda045ac9c9d4a 100644 (file)
                 $mod = $mods[$sectionmod];
                 $instance = get_record("$mod->modname", "id", "$mod->instance");
 
-                $coursemod = get_record_sql("SELECT m.id, m.name, cm.groupmode, cm.visible
+                $coursemod = get_record_sql("SELECT m.id, m.name, cm.groupmode, cm.visible, cm.course, cm.groupingid
                                                FROM {$CFG->prefix}course_modules cm,
                                                     {$CFG->prefix}modules m
                                               WHERE course = '$course->id' $hiddenfilter
                                                 AND m.id = cm.module $activityfilter
                                                 AND cm.id = '$sectionmod'");
-
-                $groupmode = groupmode($course, $coursemod);
+                $groupmode = groups_get_activity_groupmode($coursemod);
                 switch ($groupmode) {
-                    case SEPARATEGROUPS :  $groupid = mygroupid($course->id); break;
+                    case SEPARATEGROUPS :
+                        $groupid = 0;
+                        if ($mygroups = groups_get_all_groups($course->id, $USER->id, $coursemode->groupingid)) {
+                            if (array_key_exists($selectedgroup, $mygroups)) {
+                                $groupid = $selectedgroup;
+                            }
+                        }
+                        break;
+
                     case VISIBLEGROUPS  :  $groupid = $selectedgroup; break;
                     case NOGROUPS       :
                     default             :  $groupid = 0;
index af2aab37777961017d3f7c90669a266e82befb9b..745b50ca94484272ffa571d362a911f4a3c0bca9 100644 (file)
@@ -1,17 +1,17 @@
 <?php  //$Id$
 
 /**
- * No groups used?
+ * Groups not used in course or activity
  */
 define('NOGROUPS', 0);
 
 /**
- * Groups used?
+ * Groups used, users do not see other groups
  */
 define('SEPARATEGROUPS', 1);
 
 /**
- * Groups visible?
+ * Groups used, students see other groups
  */
 define('VISIBLEGROUPS', 2);
 
index b7af2906aee9c1554e78e66cfe87961d06713c54..944560af54f4794b4a1795ae062ec8471dd4b151 100644 (file)
@@ -10,7 +10,6 @@
     define('DEFAULT_PAGE_SIZE', 20);
     define('SHOW_ALL_PAGE_SIZE', 5000);
 
-    $group        = optional_param('group', -1, PARAM_INT);                   // Group to show
     $page         = optional_param('page', 0, PARAM_INT);                     // which page to show
     $perpage      = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT);  // how many per page
     $mode         = optional_param('mode', NULL);                             // '0' for less details, '1' for more
 /// Check to see if groups are being used in this forum
 /// and if so, set $currentgroup to reflect the current group
 
-    $groupmode    = groupmode($course);   // Groups are being used
-    $currentgroup = get_and_set_current_group($course, $groupmode, $group);
+    $groupmode    = groups_get_course_groupmode($course);   // Groups are being used
+    $currentgroup = groups_get_course_group($course, true);
 
     if (!$currentgroup) {      // To make some other functions work better later
         $currentgroup  = NULL;
     }
 
     // Should use this variable so that we don't break stuff every time a variable is added or changed.
-    $baseurl = $CFG->wwwroot.'/user/index.php?contextid='.$context->id.'&amp;roleid='.$roleid.'&amp;id='.$course->id.'&amp;group='.$currentgroup.'&amp;perpage='.$perpage.'&amp;accesssince='.$accesssince.'&amp;search='.s($search);
+    $baseurl = $CFG->wwwroot.'/user/index.php?contextid='.$context->id.'&amp;roleid='.$roleid.'&amp;id='.$course->id.'&amp;perpage='.$perpage.'&amp;accesssince='.$accesssince.'&amp;search='.s($search);
 
 /// Print headers
 
     }
 
     echo '<td class="left">';
-    setup_and_print_groups($course, $groupmode, $baseurl);
+    groups_print_course_menu($course, $baseurl);
     echo '</td>';
 
     // get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
     echo '</td></tr></table>';
 
     if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', $context))) {    /// Display info about the group
-        if ($group = groups_get_group($currentgroup)) { //TODO:
+        if ($group = groups_get_group($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);
index 71c4103cb9acb169bf8fc109c2d9a9123899ac17..814a6fff55f7cb7e03147d37bb47309b86c573fe 100644 (file)
@@ -52,8 +52,8 @@
         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
         print_heading(format_string($course->fullname));
 
-        $toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.$filterselect.'&amp;group=0',
-            get_string('participants'));    //the groupid hack is necessary, otherwise the group in the session willbe used
+        $toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.$filterselect,
+            get_string('participants'));
         
         if ($CFG->bloglevel >= 3) {
             $toprow[] = new tabobject('blogs', $CFG->wwwroot.'/blog/index.php?filtertype=course&amp;filterselect='.$filterselect, get_string('blogs','blog'));
@@ -68,7 +68,7 @@
      **************************************/
     } else if ($filtertype == 'group' && $filterselect) {
 
-        $group_name = groups_get_group_name($filterselect); //TODO:
+        $group_name = groups_get_group_name($filterselect);
         print_heading($group_name);
 
         if ($CFG->bloglevel >= 2) {
index b80fbb3ed4e2a138e87efd3590b5b0345551f7d1..00491b285d6679be3ed386b816307cd6e6546caf 100644 (file)
 
 
         // If groups are in use, make sure we can see that group
-        if (groupmode($course) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $coursecontext)) {
+        if (groups_get_course_groupmode($course) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $coursecontext)) {
             require_login();
 
             ///this is changed because of mygroupid
         if ($usergroups = groups_get_all_groups($course->id, $user->id)){
             $groupstr = '';
             foreach ($usergroups as $group){
-                $groupstr .= ' <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$group->id.'">'.$group->name.'</a>,';
+                $groupstr .= ' <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$group->id.'">'.format_string($group->name).'</a>,';
             }
             print_row(get_string("group").":", rtrim($groupstr, ', '));
         }