]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15094 fixed stats regression and prefix cleanup
authorskodak <skodak>
Thu, 5 Jun 2008 20:35:28 +0000 (20:35 +0000)
committerskodak <skodak>
Thu, 5 Jun 2008 20:35:28 +0000 (20:35 +0000)
course/editcategory.php
course/report/participation/index.php
course/report/stats/graph.php
course/report/stats/lib.php
course/report/stats/report.php
enrol/database/enrol.php
lib/adminlib.php
lib/moodlelib.php
tag/lib.php
user/filters/globalrole.php

index dfe7d2bb1ce9ad9f15697a1bfa66a4f68c468d6a..269eb6f2410b0c4a1c8fa82610016d35f693a02b 100644 (file)
@@ -129,7 +129,7 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
         if ($courses = get_courses($id, "fullname ASC", 'c.id,c.fullname,c.sortorder')) {
             // move it off the range
             $count = $DB->get_record_sql('SELECT MAX(sortorder) AS max, 1
-                                     FROM ' . $CFG->prefix . 'course WHERE category=' . $category->id);
+                                     FROM {course} WHERE category=' . $category->id);
             $count = $count->max + 100;
             begin_sql();
             foreach ($courses as $course) {
@@ -242,7 +242,7 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
             // TODO something like fix_course_sortorder() ?
 
             // we are going to need to know the range
-            $max = $DB->get_record_sql('SELECT MAX(sortorder) AS max, 1 FROM ' . $CFG->prefix . 'course_categories WHERE id=' . $category->id);
+            $max = $DB->get_record_sql('SELECT MAX(sortorder) AS max, 1 FROM {course_categories} WHERE id=' . $category->id);
             $max = $max->max + 100;
 
             if (!empty($moveup)) {
index 54fc6dc938cc69c295209d82916c0bc58dfeb611..5e59d69a4dd702b3f95b9f057c0acebec5c170e4 100644 (file)
         }
 
         $countsql = "SELECT COUNT(DISTINCT(ra.userid))
-                       FROM {$CFG->prefix}role_assignments ra
-                            JOIN {$CFG->prefix}user u           ON u.id = ra.userid
-                            LEFT OUTER JOIN {$CFG->prefix}log l ON l.userid = ra.userid
+                       FROM {role_assignments} ra
+                            JOIN {user} u           ON u.id = ra.userid
+                            LEFT OUTER JOIN {log} l ON l.userid = ra.userid
                       WHERE ra.contextid $relatedcontexts AND ra.roleid = :roleid AND
                             (l.id IS NULL OR
                                (l.cmid = :instanceid AND l.time > :timefrom AND $actionsql)
index f3a402fb38d9cd99c7c8443677f7bc19ff279ba7..aa45cb5bb33212f08ce045cfc0f5b59fbc55d490 100644 (file)
@@ -38,7 +38,7 @@
 
     // TODO: cleanup this ugly mess!
     $sql = 'SELECT '.((empty($param->fieldscomplete)) ? 'id,roleid,timeend,' : '').$param->fields
-    .' FROM '.$CFG->prefix.'stats_'.$param->table.' WHERE '
+    .' FROM {stats_'.$param->table.'} WHERE '
     .(($course->id == SITEID) ? '' : ' courseid = '.$course->id.' AND ')
      .((!empty($userid)) ? ' userid = '.$userid.' AND ' : '')
      .((!empty($roleid)) ? ' roleid = '.$roleid.' AND ' : '')
index a3fc32ad42a2b4bef3dc096ba6b3cecc0f0cecfd..9cee9848e36d14efaaf3962746ec5866277fa361 100644 (file)
     function report_stats_timeoptions($mode) {
         global $CFG, $DB;
         
-        $tableprefix = $CFG->prefix.'stats_';
-
         if ($mode == STATS_MODE_DETAILED) {
-            $tableprefix = $CFG->prefix.'stats_user_';
+            $earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_user_daily} ORDER BY timeend');
+            $earliestweek = $DB->get_field_sql('SELECT timeend FROM {stats_user_weekly} ORDER BY timeend');
+            $earliestmonth = $DB->get_field_sql('SELECT timeend FROM {stats_user_monthly} ORDER BY timeend');
+        } else {
+            $earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_daily} ORDER BY timeend');
+            $earliestweek = $DB->get_field_sql('SELECT timeend FROM {stats_weekly} ORDER BY timeend');
+            $earliestmonth = $DB->get_field_sql('SELECT timeend FROM {stats_monthly} ORDER BY timeend');
         }
 
-        $earliestday = $DB->get_field_sql('SELECT timeend FROM {daily} ORDER BY timeend');
-        $earliestweek = $DB->get_field_sql('SELECT timeend FROM {weekly} ORDER BY timeend');
-        $earliestmonth = $DB->get_field_sql('SELECT timeend FROM {monthly} ORDER BY timeend');
 
         if (empty($earliestday)) $earliestday = time();
         if (empty($earliestweek)) $earliestweek = time();
index 69fe80e52d82d04098befe96c6ee7350c0fae39a..184d2c946305a50bbe774448ad6ca781a6626719 100644 (file)
@@ -24,8 +24,8 @@
 
         //TODO: lceanup this ugly mess
         $sql = 'SELECT DISTINCT s.userid, u.firstname, u.lastname, u.idnumber
-                     FROM '.$CFG->prefix.'stats_user_'.$param->table.' s
-                     JOIN '.$CFG->prefix.'user u ON u.id = s.userid
+                     FROM {stats_user_'.$param->table.'} s
+                     JOIN {user} u ON u.id = s.userid
                      WHERE courseid = '.$course->id
             . ((!empty($param->stattype)) ? ' AND stattype = \''.$param->stattype.'\'' : '')
             . ((!empty($time)) ? ' AND timeend >= '.$param->timeafter : '')
index 1c5086e04e57b8350a6ae2743accb21bf6705907..aa5a3c141d7bdba3dbb8d397eb37fc4f55f5dc22 100644 (file)
@@ -15,7 +15,7 @@ function setup_enrolments(&$user) {
     global $CFG, $DB;
 
     // NOTE: if $this->enrol_connect() succeeds you MUST remember to call
-    // $this->enrol_disconnect() as it is doing some nasty vodoo with $CFG->prefix
+    // $this->enrol_disconnect() as it is doing some nasty vodoo with table prefix
     $enroldb = $this->enrol_connect();
     if (!$enroldb) {
         error_log('[ENROL_DB] Could not make a connection');
@@ -632,7 +632,7 @@ function create_course ($course,$skip_fix_course_sortorder=0){
 /// DB Connect
 /// NOTE: You MUST remember to disconnect
 /// when you stop using it -- as this call will
-/// sometimes modify $CFG->prefix for the whole of Moodle!
+/// sometimes modify table prefix for the whole of Moodle!
 function enrol_connect() {
     global $CFG;
 
index 3a9db94b8dd3e5e568bb7b3fd457bdeb9c1e578d..f99daf0c1bb2231eaf8431769c95071b21c91f50 100644 (file)
@@ -4522,7 +4522,7 @@ function db_replace($search, $replace) {
             $DB->set_debug(true);
             foreach ($columns as $column => $data) {
                 if (in_array($data->meta_type, array('C', 'X'))) {  // Text stuff only
-                    $DB->execute("UPDATE {$CFG->prefix}$table SET $column = REPLACE($column, ?, ?)", array($search, $replace));
+                    $DB->execute("UPDATE {".$table."} SET $column = REPLACE($column, ?, ?)", array($search, $replace));
                 }
             }
             $DB->set_debug(false);
index 6d0e8c9146cb63888a219fe753f4113ac9f4600e..38f45727d236df5a238240ec6cb39d1fbb9c1ed4 100644 (file)
@@ -3691,7 +3691,7 @@ function reset_course_userdata($data) {
         // change course start data
         $DB->set_field('course', 'startdate', $data->reset_start_date, array('id'=>$data->courseid));
         // update all course and group events - do not move activity events
-        $updatesql = "UPDATE {$CFG->prefix}event
+        $updatesql = "UPDATE {event}
                          SET timestart = timestart + ?
                        WHERE courseid=? AND instance=0";
         $DB->execute($updatesql, array($data->timeshift, $data->courseid));
@@ -6321,7 +6321,7 @@ function notify_login_failures() {
 /// Get all the INFOs with more than notifyloginthreshold failures since lastnotifyfailure
 /// and insert them into the cache_flags temp table
     $sql = "SELECT info, count(*)
-              FROM {$CFG->prefix}log
+              FROM {log}
              WHERE module = 'login' AND action = 'error'
                    AND time > ?
           GROUP BY info
index 3f92316c0640e7f091a02c437f4e7007fa9fd2d8..46c117a53d46dcc2b44f0ff9f84f99bb68e1eaf7 100644 (file)
@@ -267,7 +267,7 @@ function tag_get_tags($record_type, $record_id, $type=null) {
     // the tag has been deleted.  This shouldn't happen, but if it did, using 
     // this query could help "clean it up".  This causes bugs at this time.
     //$tags = $DB->get_records_sql("SELECT ti.tagid, tg.tagtype, tg.name, tg.rawname, tg.flag, ti.ordering ".
-    //    "FROM {$CFG->prefix}tag_instance ti LEFT JOIN {$CFG->prefix}tag tg ON ti.tagid = tg.id ".
+    //    "FROM {tag_instance} ti LEFT JOIN {tag} tg ON ti.tagid = tg.id ".
     //    "WHERE ti.itemtype = '{$record_type}' AND ti.itemid = '{$record_id}' {$type} ".
     //    "ORDER BY ti.ordering ASC");
 }
index c959790c32732a5ddacca93fa0866451a779c052..e802339ea36c80f6d53c95c09b4f7322bfb95329 100644 (file)
@@ -66,7 +66,7 @@ class user_filter_globalrole extends user_filter_type {
         $timenow = round(time(), 100);
 
         $sql = "id IN (SELECT userid
-                         FROM {$CFG->prefix}role_assignments a
+                         FROM {role_assignments} a
                         WHERE a.contextid=".SYSCONTEXTID." AND a.roleid=$value AND a.timestart<$timenow
                               AND (a.timeend=0 OR a.timeend>$timenow))";
         return array($sql, array());