]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18637 fix Moodle 1.9-style {$CFG->prefix}tablename in HEAD, and a few missing...
authortjhunt <tjhunt>
Mon, 23 Mar 2009 05:19:53 +0000 (05:19 +0000)
committertjhunt <tjhunt>
Mon, 23 Mar 2009 05:19:53 +0000 (05:19 +0000)
I did not fix all the DB problems in search, there are too many there for me to be prepared to clean up other people's mess.

(For once, it was not me making this mistake ;-))

12 files changed:
admin/replace.php
auth/shibboleth/logout.php
grade/report/stats/lib.php
grade/report/visual/lib.php
lib/accesslib.php
mod/feedback/lib.php
search/add.php
search/delete.php
search/documents/data_document.php
search/documents/forum_document.php
search/documents/resource_document.php
search/update.php

index 67fd9da523933b30228da4a880309e5dd16beb03..bf54affd65509b2fe1c75ea4ae3677760b6592eb 100644 (file)
@@ -43,8 +43,8 @@ print_simple_box_end();
 /// Try to replace some well-known serialised contents (html blocks)
 notify('Replacing in html blocks...');
 $sql = "SELECT bi.*
-          FROM {$CFG->prefix}block_instance bi
-          JOIN {$CFG->prefix}block b ON b.id = bi.blockid
+          FROM {block_instance} bi
+          JOIN {block} b ON b.id = bi.blockid
          WHERE b.name = 'html'";
 if ($instances = $DB->get_records_sql($sql)) {
     foreach ($instances as $instance) {
index 24ab73a7b796be743ca5edca9a021f2beb3408cf..783419b28d72477adc68dca279041ca16ee28f61 100644 (file)
@@ -126,7 +126,7 @@ WSDL;
 
 function LogoutNotification($SessionID){
     
-    global $CFG, $SESSION;
+    global $CFG, $SESSION, $DB;
     
     // Delete session of user using $SessionID
     if(empty($CFG->dbsessions)) {
@@ -169,7 +169,7 @@ function LogoutNotification($SessionID){
             $ADODB_SESS_LIFE   = $CFG->sessiontimeout;
         }
         
-            if ($user_session_data = get_records_sql('SELECT sesskey, sessdata FROM '. $CFG->prefix .'sessions2 WHERE expiry > NOW()')) {
+            if ($user_session_data = $DB->get_records_sql('SELECT sesskey, sessdata FROM {sessions2} WHERE expiry > NOW()')) {
             foreach ($user_session_data as $session_data) {
                 
                 // Get user session
index 976a714c989dbc382093a00c8cf92dfd93cd6182..a67b58ca4da584a06c11fac0fca74cdce626937f 100755 (executable)
@@ -247,11 +247,11 @@ class grade_report_stats extends grade_report {
         } else {
             /// please note that we must fetch all grade_grades fields if we want to contruct grade_grade object from it!
             $sql = "SELECT g.*
-                  FROM {$CFG->prefix}grade_items gi,
-                       {$CFG->prefix}grade_grades g
+                  FROM {grade_items} gi,
+                       {grade_grades} g
                  WHERE g.itemid = gi.id AND gi.courseid = {$this->courseid} {$this->userselect}";
 
-            $grades = get_records_sql($sql);
+            $grades = $DB->get_records_sql($sql);
         }
 
         $userids = array_keys($this->users);
index 8ead22c790fde507ba5d6357bd1ee52692db0864..2875a94322d26c87558bf4943c000cecefb2878a 100755 (executable)
@@ -240,14 +240,14 @@ class grade_report_visual extends grade_report {
             $this->users = $DB->get_records_sql($sql, $params);
         } else {
             $sql = "SELECT u.id, u.firstname, u.lastname, u.imagealt, u.picture, u.idnumber
-                      FROM {$CFG->prefix}user u
-                           JOIN {$CFG->prefix}role_assignments ra ON u.id = ra.userid
+                      FROM {user) u
+                           JOIN {role_assignments} ra ON u.id = ra.userid
                            $this->groupsql
                      WHERE ra.roleid in ($this->gradebookroles)
                            $this->groupwheresql
                            AND ra.contextid ".get_related_contexts_string($this->context);
 
-            $this->users = get_records_sql($sql);
+            $this->users = $DB->get_records_sql($sql);
         }
 
         if (empty($this->users)) {
@@ -290,8 +290,8 @@ class grade_report_visual extends grade_report {
         } else {
             /// please note that we must fetch all grade_grades fields if we want to contruct grade_grade object from it!
             $sql = "SELECT g.*
-                  FROM {$CFG->prefix}grade_items gi,
-                       {$CFG->prefix}grade_grades g
+                  FROM {grade_items} gi,
+                       {grade_grades} g
                  WHERE g.itemid = gi.id AND gi.courseid = {$this->courseid} {$this->userselect}";
 
             $grades = get_records_sql($sql);
index 122bea7bf74ea7b24a752c46a00aa1b1c7eaf863..0e84f05d29b9925355cb292e694698b03b0ed9a4 100755 (executable)
@@ -1135,24 +1135,24 @@ function get_user_courses_bycap($userid, $cap, $accessdata, $doanything, $sort='
                            ctx.id AS ctxid, ctx.path AS ctxpath,
                            ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel,
                            cc.path AS categorypath
-                    FROM {$CFG->prefix}course c
-                    JOIN {$CFG->prefix}course_categories cc
+                    FROM {course} c
+                    JOIN {course_categories} cc
                       ON c.category=cc.id
-                    JOIN {$CFG->prefix}context ctx
+                    JOIN {context} ctx
                       ON (c.id=ctx.instanceid AND ctx.contextlevel=".CONTEXT_COURSE.")
-                    JOIN {$CFG->prefix}role_assignments ra
+                    JOIN {role_assignments} ra
                       ON (ra.contextid=ctx.id AND ra.userid=:userid)
                     UNION
                     SELECT c.id,
                            ctx.id AS ctxid, ctx.path AS ctxpath,
                            ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel,
                            cc.path AS categorypath
-                    FROM {$CFG->prefix}course c
-                    JOIN {$CFG->prefix}course_categories cc
+                    FROM {course} c
+                    JOIN {course_categories} cc
                       ON c.category=cc.id
-                    JOIN {$CFG->prefix}context ctx
+                    JOIN {context} ctx
                       ON (c.id=ctx.instanceid AND ctx.contextlevel=".CONTEXT_COURSE.")
-                    JOIN {$CFG->prefix}role_capabilities rc
+                    JOIN {role_capabilities} rc
                       ON (rc.contextid=ctx.id AND (rc.capability=:cap $capany)) ";
 
         if (!empty($catclause)) { /// If we have found the right in categories, add child courses here too
@@ -1162,10 +1162,10 @@ function get_user_courses_bycap($userid, $cap, $accessdata, $doanything, $sort='
                            ctx.id AS ctxid, ctx.path AS ctxpath,
                            ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel,
                            cc.path AS categorypath
-                    FROM {$CFG->prefix}course c
-                    JOIN {$CFG->prefix}course_categories cc
+                    FROM {course} c
+                    JOIN {course_categories} cc
                       ON c.category=cc.id
-                    JOIN {$CFG->prefix}context ctx
+                    JOIN {context} ctx
                       ON (c.id=ctx.instanceid AND ctx.contextlevel=".CONTEXT_COURSE.")
                     $catclause";
         }
@@ -1173,7 +1173,7 @@ function get_user_courses_bycap($userid, $cap, $accessdata, $doanything, $sort='
     /// Close the inline_view and join with courses table to get requested $coursefields
         $sql .= "
                 ) inline_view
-                INNER JOIN {$CFG->prefix}course c
+                INNER JOIN {course} c
                     ON inline_view.id = c.id";
 
     /// To keep cross-db we need to strip any prefix in the ORDER BY clause for queries using UNION
index 0a2c7be728f0cba3bc155f321a07fee69bcc61ed..ffa869d316744da4e729433939cb4e99a525a3b6 100644 (file)
@@ -197,7 +197,7 @@ function feedback_get_recent_mod_activity(&$activities, &$index, $timemodified,
 
     if ($groupid) {
         $groupselect = "AND gm.groupid = $groupid";
-        $groupjoin   = "JOIN {$CFG->prefix}groups_members gm ON  gm.userid=u.id";
+        $groupjoin   = "JOIN {groups_members} gm ON  gm.userid=u.id";
     } else {
         $groupselect = "";
         $groupjoin   = "";
index 26eb4159d94a0eac0a09d8854f9aa84b0124bb6c..42c80bb719b21c01e7a7e9e9eac6293bf410a5b6 100644 (file)
@@ -88,7 +88,7 @@
                                     docid,
                                     itemtype
                                 FROM
-                                    {$CFG->prefix}{$table}
+                                    {" . $table . "}
                                 WHERE
                                     doctype = ?
                                     $itemtypes
                                 SELECT id,
                                     {$values[0]} as docid
                                 FROM
-                                    {$CFG->prefix}{$values[1]}
+                                    {" . $values[1] . "
                                 WHERE
                                     id NOT IN ('{$docIdList}') and
                                     {$values[2]} > {$indexdate}
index 5ab8d5e3bb2a0e4f1b592b32e8fc83ff905639aa..b6b4bc56b675b799784ff2d0976e803323bc2e77 100644 (file)
@@ -75,7 +75,7 @@
                                     id,
                                     {$values[0]}
                                 FROM
-                                    {$CFG->prefix}{$values[1]}
+                                    {" . $values[1] . "}
                                     $where
                             ";
                             $docIds = get_records_sql($query);
@@ -87,7 +87,7 @@
                                     id,
                                     docid
                                 FROM
-                                    {$CFG->prefix}{$table}
+                                    {" . $table . "}
                                 WHERE
                                     doctype = '{$mod->name}' AND
                                     $itemtypes
index 3462c123bd07467cca2d622ff6e3dc9ddf48e2cb..510b8b66dc86a5bdd68ba3796993d1b113925ccd 100644 (file)
@@ -117,8 +117,8 @@ function data_get_records($database_id, $typematch = '*') {
         SELECT
            c.*
         FROM 
-            {$CFG->prefix}data_content as c,
-            {$CFG->prefix}data_records as r
+            {data_content} as c,
+            {data_records} as r
         WHERE
             c.recordid = r.id AND
             r.dataid = {$database_id} 
@@ -161,8 +161,8 @@ function data_get_comments($database_id) {
           c.modified,
           r.dataid
        FROM
-          {$CFG->prefix}data_comments as c,
-          {$CFG->prefix}data_records as r 
+          {data_comments} as c,
+          {data_records} as r 
        WHERE
           c.recordid = r.id
     ";
index 5393752841992d416a686652c0aa1b9b39019f48..832142bb48c0bf27ab701c6b833e7e8398afb80a 100644 (file)
@@ -193,13 +193,13 @@ function forum_get_discussions_fast($forum_id) {
             u.firstname, 
             u.lastname
         FROM 
-            {$CFG->prefix}forum_discussions d
+            {forum_discussions} d
         JOIN 
-            {$CFG->prefix}forum_posts p 
+            {forum_posts} p 
         ON 
             p.discussion = d.id
         JOIN 
-            {$CFG->prefix}user u 
+            {user} u 
         ON 
             p.userid = u.id
         WHERE 
@@ -235,13 +235,13 @@ function forum_get_child_posts_fast($parent, $forum_id) {
             u.firstname, 
             u.lastname
         FROM 
-            {$CFG->prefix}forum_discussions d
+            {forum_discussions} d
         JOIN 
-            {$CFG->prefix}forum_posts p 
+            {forum_posts} p 
         ON 
             p.discussion = d.id
         JOIN 
-            {$CFG->prefix}user u 
+            {user} u 
         ON 
             p.userid = u.id
         WHERE 
index bc73bf89d719f16d985f7bad287bd478426df402..3c2ee64887a0d4e9926a911105861ff49d5fea26 100644 (file)
@@ -88,7 +88,7 @@ function resource_get_content_for_index(&$notneeded) {
             id as trueid,
             r.*
         FROM 
-            {$CFG->prefix}resource as r
+            {resource} as r
         WHERE 
             alltext != '' AND 
             alltext != ' ' AND 
@@ -125,9 +125,9 @@ function resource_get_content_for_index(&$notneeded) {
                r.type as type,
                r.timemodified as timemodified
             FROM 
-                {$CFG->prefix}resource as r,
-                {$CFG->prefix}course_modules as cm,
-                {$CFG->prefix}modules as m
+                {resource} as r,
+                {course_modules} as cm,
+                {modules} as m
             WHERE 
                r.type = 'file' AND
                cm.instance = r.id AND
@@ -237,9 +237,9 @@ function resource_single_document($id, $itemtype) {
            r.type as type,
            r.timemodified as timemodified
         FROM 
-            {$CFG->prefix}resource as r,
-            {$CFG->prefix}course_modules as cm,
-            {$CFG->prefix}modules as m
+            {resource} as r,
+            {course_modules} as cm,
+            {modules} as m
         WHERE 
             cm.instance = r.id AND
             cm.course = r.course AND
index ab5d56d95ef2b29461ebc82256d36624797aac8c..ec081a6df49e9f3ed1140da958519a28f633d724 100644 (file)
@@ -83,7 +83,7 @@
                                     docid,
                                     itemtype
                                 FROM
-                                    {$CFG->prefix}{$table}
+                                    {" . $table . "}
                                 WHERE
                                     doctype = ?
                                     $itemtypes
@@ -96,7 +96,7 @@
                                     id,
                                     {$values[0]} as docid
                                 FROM
-                                    {$CFG->prefix}{$values[1]}
+                                    {" . $values[1] . "}
                                 WHERE
                                     {$values[3]} > {$indexdate} AND
                                     id IN ('{$docIdList}')