]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10383 - some more refactoring and new grouping related functions for modules
authorskodak <skodak>
Mon, 20 Aug 2007 13:56:39 +0000 (13:56 +0000)
committerskodak <skodak>
Mon, 20 Aug 2007 13:56:39 +0000 (13:56 +0000)
lib/grouplib.php
lib/weblib.php

index c12a4848698db5bf89434ab4e8421d543a440a1d..bf106b5679b653cef746c8203539da95c8cad34f 100644 (file)
@@ -83,11 +83,6 @@ function groups_get_group($groupid) {
 function groups_get_all_groups($courseid, $userid=0, $groupingid=0) {
     global $CFG;
 
-    // groupings are ignored when not enabled
-    if (empty($CFG->enablegroupings)) {
-        $groupingid = 0;
-    }
-
     if (!empty($userid)) {
         $userfrom  = ", {$CFG->prefix}groups_members gm";
         $userwhere = "AND g.id = gm.groupid AND gm.userid = '$userid'";
@@ -137,11 +132,6 @@ function groups_is_member($groupid, $userid=null) {
 function groups_has_membership($cm, $userid=null) {
     global $CFG, $USER;
 
-    // groupings are ignored when not enabled
-    if (empty($CFG->enablegroupings)) {
-        $cm->groupingid = 0;
-    }
-
     if (empty($userid)) {
         $userid = $USER->id;
     }
@@ -206,12 +196,7 @@ function groups_get_activity_groupmode($cm) {
  * @return mixed void or string depending on $return param
  */
 function groups_print_activity_menu($cm, $urlroot, $return=false) {
-    global $CFG, $USER;
-
-    // groupings are ignored when not enabled
-    if (empty($CFG->enablegroupings)) {
-        $cm->groupingid = 0;
-    }
+    global $USER;
 
     if (!$groupmode = groups_get_activity_groupmode($cm)) {
         if ($return) {
@@ -271,12 +256,7 @@ function groups_print_activity_menu($cm, $urlroot, $return=false) {
  * @return mixed false if groups not used, int if groups used, 0 means all groups (access must be verified in SEPARATE mode)
  */
 function groups_get_activity_group($cm, $update=false) {
-    global $CFG, $USER, $SESSION;
-
-    // groupings are ignored when not enabled
-    if (empty($CFG->enablegroupings)) {
-        $cm->groupingid = 0;
-    }
+    global $USER, $SESSION;
 
     if (!$groupmode = groups_get_activity_groupmode($cm)) {
         // NOGROUPS used
@@ -331,32 +311,4 @@ function groups_get_activity_group($cm, $update=false) {
     return $SESSION->activegroup[$cm->course][$groupmode][$cm->groupingid];
 }
 
-/**
- * Determine if a course module is currently visible to a user
- * @uses $USER If $userid is null, use the global object.
- * @param int $cm The course module
- * @param int $userid The user to check against the group.
- * @return boolean True if the user can view the course module, false otherwise.
- */
-function groups_course_module_visible($cm, $userid=null) {
-    global $CFG, $USER;
-    
-    if (empty($userid)) {
-        $userid = $USER->id;
-    }
-    if (empty($CFG->enablegroupings)) {
-        return(true);
-    }
-    if (empty($cm->groupmembersonly)) {
-        return(true);
-    }
-    if (has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id), $userid)) {
-        return(true);
-    }
-    if (groups_has_membership($cm, $userid)) {
-        return(true);
-    }
-    return(false);
-}
-
 ?>
index 824e9ea5509f1692bb3a26ca49a28cf75c56970a..70cb08a8039dae8a4f02ea18698466450be8da59 100644 (file)
@@ -4673,10 +4673,6 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
         if ($mod->section > $course->numsections) {   /// Don't show excess hidden sections
             break;
         }
-        $mod->id = $mod->cm;
-        if (!groups_course_module_visible($mod)) {
-            continue;
-        }
 
         if ($mod->section > 0 and $section <> $mod->section) {
             $thissection = $sections[$mod->section];