]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13550 deprecated primary role concept; merged from MOODLE_19_STABLE
authorskodak <skodak>
Thu, 21 Feb 2008 09:30:13 +0000 (09:30 +0000)
committerskodak <skodak>
Thu, 21 Feb 2008 09:30:13 +0000 (09:30 +0000)
lib/deprecatedlib.php
lib/dmllib.php

index 89679a90f9c8eab574a0ad409d7c75a3202713a3..d35c42f6e2879040e64cb67dfb0891a88794f7a4 100644 (file)
@@ -1541,4 +1541,40 @@ function get_users_not_fully_set_up($cutofftime=2000000000) {
                                AND (lastname = '' OR firstname = '' OR email = '')");
 }
 
+/**
+ * Returns SQL to be used as a subselect to find the primary role of users.
+ * Geoff Cant <geoff@catalyst.net.nz> (the author) is very keen for this to
+ * be implemented as a view in future versions.
+ *
+ * eg if this function returns a string called $primaryroles, then you could:
+ * $sql = 'SELECT COUNT(DISTINCT prs.userid) FROM ('.$primary_roles.') prs
+ *          WHERE prs.primary_roleid='.$role->id.' AND prs.courseid='.$course->id.
+ *          ' AND prs.contextlevel = '.CONTEXT_COURSE;
+ *
+ * @return string the piece of SQL code to be used in your FROM( ) statement.
+ */
+function sql_primary_role_subselect() {
+    global $CFG;
+    return 'SELECT ra.userid,
+                ra.roleid AS primary_roleid,
+                ra.contextid,
+                r.sortorder,
+                r.name,
+                r.description,
+                r.shortname,
+                c.instanceid AS courseid,
+                c.contextlevel
+            FROM '.$CFG->prefix.'role_assignments ra
+            INNER JOIN '.$CFG->prefix.'role r ON ra.roleid = r.id
+            INNER JOIN '.$CFG->prefix.'context c ON ra.contextid = c.id
+            WHERE NOT EXISTS (
+                              SELECT 1
+                              FROM '.$CFG->prefix.'role_assignments i_ra
+                              INNER JOIN '.$CFG->prefix.'role i_r ON i_ra.roleid = i_r.id
+                              WHERE ra.userid = i_ra.userid AND
+                                     ra.contextid = i_ra.contextid AND
+                                     i_r.sortorder < r.sortorder
+                              ) ';
+}
+
 ?>
index e756a6299d31b0e5e632448d23f43440a47566b5..9f5e236ac8fc1e31fb5fa4d1314b4d28778a6d91 100644 (file)
@@ -2123,42 +2123,6 @@ function sql_bitnot($int1) {
     }
 }
 
-/**
- * Returns SQL to be used as a subselect to find the primary role of users.
- * Geoff Cant <geoff@catalyst.net.nz> (the author) is very keen for this to
- * be implemented as a view in future versions.
- *
- * eg if this function returns a string called $primaryroles, then you could:
- * $sql = 'SELECT COUNT(DISTINCT prs.userid) FROM ('.$primary_roles.') prs
- *          WHERE prs.primary_roleid='.$role->id.' AND prs.courseid='.$course->id.
- *          ' AND prs.contextlevel = '.CONTEXT_COURSE;
- *
- * @return string the piece of SQL code to be used in your FROM( ) statement.
- */
-function sql_primary_role_subselect() {
-    global $CFG;
-    return 'SELECT ra.userid,
-                ra.roleid AS primary_roleid,
-                ra.contextid,
-                r.sortorder,
-                r.name,
-                r.description,
-                r.shortname,
-                c.instanceid AS courseid,
-                c.contextlevel
-            FROM '.$CFG->prefix.'role_assignments ra
-            INNER JOIN '.$CFG->prefix.'role r ON ra.roleid = r.id
-            INNER JOIN '.$CFG->prefix.'context c ON ra.contextid = c.id
-            WHERE NOT EXISTS (
-                              SELECT 1
-                              FROM '.$CFG->prefix.'role_assignments i_ra
-                              INNER JOIN '.$CFG->prefix.'role i_r ON i_ra.roleid = i_r.id
-                              WHERE ra.userid = i_ra.userid AND
-                                     ra.contextid = i_ra.contextid AND
-                                     i_r.sortorder < r.sortorder
-                              ) ';
-}
-
 /**
  * Prepare a SQL WHERE clause to select records where the given fields match the given values.
  *