]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14978 removed obsoleted get_course_users()
authorskodak <skodak>
Sun, 25 May 2008 14:27:33 +0000 (14:27 +0000)
committerskodak <skodak>
Sun, 25 May 2008 14:27:33 +0000 (14:27 +0000)
lib/deprecatedlib.php
mod/forum/lib.php
mod/survey/download.php
mod/survey/graph.php
mod/survey/report.php

index 6be85ee74a48019c5892aafd948e2b3c81b798c5..1221c48911159d13603eb98b48f64200f80e4c53 100644 (file)
@@ -203,60 +203,6 @@ function get_recent_enrolments($courseid, $timestart) {
                               ORDER BY l.time ASC");
 }
 
-/**
- * Returns all the users of a course: students and teachers
- *
- * @param int $courseid The course in question.
- * @param string $sort ?
- * @param string $exceptions ?
- * @param string $fields A comma separated list of fields to be returned from the chosen table.
- * @return object
- * @todo Finish documenting this function
- */
-function get_course_users($courseid, $sort='ul.timeaccess DESC', $exceptions='', $fields='u.*, ul.timeaccess as lastaccess') {
-    global $CFG;
-
-    $context = get_context_instance(CONTEXT_COURSE, $courseid);
-
-    /// If the course id is the SITEID, we need to return all the users if the "defaultuserroleid"
-    /// has the capbility of accessing the site course. $CFG->nodefaultuserrolelists set to true can
-    /// over-rule using this.
-    if (($courseid == SITEID) && !empty($CFG->defaultuserroleid) && empty($CFG->nodefaultuserrolelists)) {
-        if ($roles = get_roles_with_capability('moodle/course:view', CAP_ALLOW, $context)) {
-            $hascap = false;
-            foreach ($roles as $role) {
-                if ($role->id == $CFG->defaultuserroleid) {
-                    $hascap = true;
-                    break;
-                }
-            }
-            if ($hascap) {
-                if (empty($fields)) {
-                    $fields = '*';
-                }
-                return get_users(true, '', true, $exceptions, 'lastname ASC', '', '', '', '', $fields);
-            }
-        }
-    }
-    return get_users_by_capability($context, 'moodle/course:view', $fields, $sort, '','','',$exceptions, false);
-
-}
-
-/**
- * Returns a list of all site users
- * Obsolete, just calls get_course_users(SITEID)
- *
- * @uses SITEID
- * @deprecated Use {@link get_course_users()} instead.
- * @param string $fields A comma separated list of fields to be returned from the chosen table.
- * @return object|false  {@link $USER} records or false if error.
- */
-function get_site_users($sort='u.lastaccess DESC', $fields='*', $exceptions='') {
-
-    return get_course_users(SITEID, $sort, $exceptions, $fields);
-}
-
-
 ########### FROM weblib.php ##########################################################################
 
 /**
index 3d99f90ecec700d553c3e3f8499003e71d3d7708..3368e3e813256ad7c2daa7b13d27a310de9bf357 100644 (file)
@@ -70,8 +70,10 @@ function forum_add_instance($forum) {
         }
     }
 
-    if ($forum->forcesubscribe == FORUM_INITIALSUBSCRIBE) { // all users should be subscribed initially
-        $users = get_course_users($forum->course);
+    if ($forum->forcesubscribe == FORUM_INITIALSUBSCRIBE) {
+        // all users should be subscribed initially
+        $users = get_users_by_capability(get_context_instance(CONTEXT_COURSE, $forum->course),
+                                         'mod/forum:initialsubscriptions', 'u.id', '', '','','',null, false);
         foreach ($users as $user) {
             forum_subscribe($user->id, $forum->id);
         }
index eb966aae06aed416d55145ac7b08d9ff52cf104a..fab478824ab338a135c0a6913fb3876abedbef74 100644 (file)
         print_error("Course is misconfigured");
     }
 
+    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+
     require_login($course->id, false, $cm);
-    require_capability('mod/survey:download', get_context_instance(CONTEXT_MODULE, $cm->id)) ;
+    require_capability('mod/survey:download', $context) ;
 
     if (! $survey = get_record("survey", "id", $cm->instance)) {
         print_error("Survey ID was incorrect");
@@ -30,9 +32,9 @@
     $groupmode = groups_get_activity_groupmode($cm);   // Groups are being used
 
     if ($groupmode and $group) {
-        $users = groups_get_members($group);
+        $users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $group, null, false);
     } else {
-        $users = get_course_users($course->id);
+        $users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', '', null, false);
         $group = false;
     }
 
index 4d2e9c5edc7db729e3bb45b9b6d5c2bd2ed44da3..71f2bf01fa33c315f6530e16b30a0ca856706e74 100644 (file)
 
 /// Check to see if groups are being used in this survey
     if ($group) {
-        $users = groups_get_members($group);
+        $users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $group, null, false);
     } else if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) { 
-        $users = groups_get_grouping_members($cm->groupingid);
+        $groups = groups_get_all_groups($courseid, 0, $cm->groupingid);
+        $groups = array_keys($groups);
+        $users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $groups, null, false);
     } else {
-        $users = get_course_users($course->id);
+        $users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', '', null, false);
         $group = false;
     }
 
index ea1a154c56dd7f7c611b04b42e3e7abb8ddb2c97..b18ee4b8ccbd37c3dfc0690bf26b3757309872a9 100644 (file)
     }
 
     if ($currentgroup) {
-        $users = groups_get_members($currentgroup);
+        $users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $currentgroup, null, false);
     } else if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) { 
-        $users = groups_get_grouping_members($cm->groupingid);
+        $groups = groups_get_all_groups($courseid, 0, $cm->groupingid);
+        $groups = array_keys($groups);
+        $users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $groups, null, false);
     } else {
-        $users = get_course_users($course->id);
+        $users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', '', null, false);
+        $group = false;
     }
+
     $groupingid = $cm->groupingid;
     
     print_simple_box_start("center");