]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14679 converted some get/set_field()
authorskodak <skodak>
Mon, 2 Jun 2008 21:39:23 +0000 (21:39 +0000)
committerskodak <skodak>
Mon, 2 Jun 2008 21:39:23 +0000 (21:39 +0000)
31 files changed:
admin/health.php
admin/index.php
admin/mnet/enr_hosts.php
admin/mnet/peers.php
admin/report/backups/index.php
admin/report/courseoverview/index.php
admin/report/courseoverview/reportsgraph.php
admin/roles/assign.php
admin/roles/manage.php
admin/roles/override.php
admin/uploadpicture.php
admin/xmldb/actions/test/test.class.php
auth/mnet/auth.php
blocks/moodleblock.class.php
blocks/section_links/block_section_links.php
blog/rsslib.php
course/editcategory.php
course/index.php
course/lib.php
course/report/outline/index.php
course/report/stats/lib.php
course/report/stats/report.php
enrol/imsenterprise/enrol.php
lib/statslib.php
login/forgot_password.php
mnet/environment.php
mnet/lib.php
user/editlib.php
user/filters/globalrole.php
user/policy.php
user/view.php

index ac6aa744db2ae3c6282967911e36a2fd94b39031..14db41b608f62e65327e7bfdc65944c1f8f29ac5 100644 (file)
@@ -520,7 +520,7 @@ class problem_000011 extends problem_base {
     function solution() {
         global $CFG;
         if (optional_param('resetsesserrorcounter', 0, PARAM_BOOL)) {
-            if (get_field('config', 'name', 'name', 'session_error_counter')) {
+            if ($DB->get_field('config', 'name', array('name'=>'session_error_counter'))) {
                 delete_records('config', 'name', 'session_error_counter');
             }
             return 'Error counter was cleared.';
index 6b3e2ff4db5e294eba7a4fbc85f45886a3f29acd..62b79c93b5e937b4ef148d879d0ae7a107a970fc 100644 (file)
     }
 
 /// If no recently cron run
-    $lastcron = get_field_sql('SELECT max(lastcron) FROM ' . $CFG->prefix . 'modules');
+    $lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}');
     if (time() - $lastcron > 3600 * 24) {
         $strinstallation = get_string('installation', 'install');
         $helpbutton = helpbutton('install', $strinstallation, 'moodle', true, false, '', true);
index 085539bc74b031bccbeeaa54151b6144b75a38a3..546f3cef19ef4a7dbcdfc6b6e4c72f7fd7dc22d9 100644 (file)
     $hosts = $enrolment->list_remote_servers();
     foreach ($hosts as $host) {
         $coursesurl = "$CFG->wwwroot/$CFG->admin/mnet/enr_courses.php?host={$host->id}&amp;sesskey={$USER->sesskey}";
-        $coursecount = get_field_sql("SELECT count(id) FROM {$CFG->prefix}mnet_enrol_course WHERE hostid={$host->id}");
+        $coursecount = $DB->get_field_sql("SELECT COUNT(id) FROM {mnet_enrol_course} WHERE hostid=?", array($host->id));
         if (empty($coursecount)) {
             $coursecount = '?';
         }
-        $enrolcount = get_field_sql("SELECT count(id) FROM {$CFG->prefix}mnet_enrol_assignments WHERE hostid={$host->id}");
+        $enrolcount = $DB->get_field_sql("SELECT COUNT(id) FROM {mnet_enrol_assignments} WHERE hostid=?", array($host->id));
 
         echo '<tr>'
                . "<td><a href=\"{$coursesurl}\">{$host->name}</a></td>"
index 584e0c260ab1434f2a98f4176d738683b765aca3..5dcefbcd9f2b52f35282f9ad4b2858c2aabe3003 100644 (file)
@@ -87,7 +87,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
             }
             unset($temp_wwwroot);
             $mnet_peer->set_applicationid($form->applicationid);
-            $application = get_field('mnet_application', 'name', 'id', $form->applicationid);
+            $application = $DB->get_field('mnet_application', 'name', array('id'=>$form->applicationid));
             $mnet_peer->bootstrap($form->wwwroot, null, $application);
         }
 
index a4f52946d50c26f03f2901016b468790ed51d97f..612501c4ddd85509b5f5233f1d033345b8d5a45f 100644 (file)
@@ -63,7 +63,7 @@
             echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strnext</font></td></tr>";
             foreach ($courses as $course) {
             /// Get the course shortname
-                $coursename = get_field ("course","fullname","id",$course->courseid);
+                $coursename = $DB->get_field ("course", "fullname", array("id"=>$course->courseid));
                 if ($coursename) {
                     echo "<tr>";
                     echo "<td nowrap=\"nowrap\"><font size=\"2\"><a href=\"index.php?courseid=$course->courseid\">".$coursename."</a></font></td>";
@@ -90,7 +90,7 @@
     } else {
         print_heading($backuplogdetailed);
 
-        $coursename = get_field("course","fullname","id","$courseid");
+        $coursename = $DB->get_field("course", "fullname", array("id"=>"$courseid"));
         print_heading("$strcourse: $coursename");
 
         print_simple_box_start('center');
index fbb922b588cc0c19a8db9ea2b9c32ca14d6a784b..f4e122719e8e75b34b219a57d0f744defbb897f0 100644 (file)
@@ -28,9 +28,9 @@
 
     $tableprefix = $CFG->prefix.'stats_';
 
-    $earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend');
-    $earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend');
-    $earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'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();
 
             foreach  ($courses as $c) {
                 $a = array();
-                $a[] = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$c->courseid.'">'.get_field('course','shortname','id',$c->courseid).'</a>';
+                $a[] = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$c->courseid.'">'.$DB->get_field('course', 'shortname', array('id'=>$c->courseid)).'</a>';
 
                 $a[] = $c->line1;
                 if (isset($c->line2)) {
index c81bb1906851a39f97c209fe60f71b986d484102..715e68d84874a389d321aaf398a87c5893550b0a 100644 (file)
@@ -47,7 +47,7 @@
     }
 
     foreach ($courses as $c) {
-        $graph->x_data[] = get_field('course','shortname','id',$c->courseid);
+        $graph->x_data[] = $DB->get_field('course', 'shortname', array('id'=>$c->courseid));
         $graph->y_data['bar1'][] = $c->{$param->graphline};
     }
     $graph->y_order = array('bar1');
index 523b8a36e40e44ea35cf774ef7079e7b3f946e17..2c816eb13c3dcd359edd1a314d0f55e9089485cf 100755 (executable)
         }
 
         foreach ($assignableroles as $roleid => $rolename) {
-            $description = format_string(get_field('role', 'description', 'id', $roleid));
+            $description = format_string($DB->get_field('role', 'description', array('id'=>$roleid)));
             $row = array('<a href="'.$baseurl.'&amp;roleid='.$roleid.'">'.$rolename.'</a>',$description, $rolehodlercount[$roleid]);
             if ($showroleholders) {
                 $row[] = $rolehodlernames[$roleid];
index 3e2259dea4e5d85c2cbdfaed96f2101f21679fa6..e52236290cb7761e3bd5f7cb4358771b535b0171 100755 (executable)
                 // reset a role sitewide...
                 mark_context_dirty($sitecontext->path);
 
-                $rolename = get_field('role', 'name', 'id', $roleid);
+                $rolename = $DB->get_field('role', 'name', array('id'=>$roleid));
                 add_to_log(SITEID, 'role', 'reset', 'admin/roles/manage.php?roleid='.$roleid.'&action=reset', $rolename, '', $USER->id);
 
                 redirect('manage.php?action=view&amp;roleid='.$roleid);
index a2e3641b17578503cc642bd7d164e943f6ed29a7..72359f73d6e3026c6645dd7189fa1af0413a0c42 100755 (executable)
         foreach ($overridableroles as $roleid => $rolename) {
             $countusers = 0;
             $overridecount = $DB->count_records_select('role_capabilities', "roleid = ? AND contextid = ?", array($roleid, $context->id));
-            $description = format_string(get_field('role', 'description', 'id', $roleid));
+            $description = format_string($DB->get_field('role', 'description', array('id'=>$roleid)));
             $table->data[] = array('<a href="'.$baseurl.'&amp;roleid='.$roleid.'">'.$rolename.'</a>', $description, $overridecount);
         }
 
index be1102ed72b99242e43388cea09a4212aa50db1e..e9e82d9682043d29c178b94dbd32cb9c190c2f6f 100644 (file)
@@ -129,7 +129,7 @@ if ($formdata = $mform->get_data(false)) {
                                 continue;
                             }
                             if (my_save_profile_image($user->id, $zipdir.'/'.$item)) {
-                                set_field('user', 'picture', 1, 'id', $user->id);
+                                $DB->set_field('user', 'picture', 1, array('id'=>$user->id));
                                 $usersupdated++;
                                 notify(get_string('uploadpicture_userupdated', 'admin', $user->username));
                             } else {
index 0705ad81660eef87c5c3c6421fe1669ae523a845..0d5bf440e739eadc98fdf0d031b1d164ecfa05b2 100644 (file)
@@ -936,7 +936,7 @@ class test extends XMLDBAction {
             $tests['update record '. $textlen . ' cc. (text) and ' . $imglen . ' bytes (binary)'] = $test;
         }
 
-    /// 50th test. set_field with TEXT contents
+    /// 50th test. $DB->set_field with TEXT contents
         if ($test->status) {
             $test = new stdClass;
             $test->status = false;
index 3dd4df8f3848a89619d98b24e1b04dd9f940eea4..da71a863f5e0cda3f44b472d33e4d9c5e5b2c47e 100644 (file)
@@ -240,7 +240,7 @@ class auth_plugin_mnet extends auth_plugin_base {
      *   @return array The local user record.
      */
     function confirm_mnet_session($token, $remotewwwroot) {
-        global $CFG, $MNET, $SESSION;
+        global $CFG, $MNET, $SESSION, $DB;
         require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
 
         // verify the remote host is configured locally before attempting RPC call
@@ -425,7 +425,7 @@ class auth_plugin_mnet extends auth_plugin_base {
                 $extra = get_records_sql($sql);
 
                 $keys = array_keys($courses);
-                $defaultrolename = get_field('role', 'shortname', 'id', $CFG->defaultcourseroleid);
+                $defaultrolename = $DB->get_field('role', 'shortname', array('id'=>$CFG->defaultcourseroleid));
                 foreach ($keys AS $id) {
                     if ($courses[$id]->visible == 0) {
                         unset($courses[$id]);
index d8ea5fe50dbcbfbbac647040ae1b9b8c1ea353fa..9a1b144234d850c2a857312d21b395f955bb0d8d 100644 (file)
@@ -728,13 +728,15 @@ class block_base {
      * @todo finish documenting this function
      */
     function instance_config_save($data,$pinned=false) {
-        $data = stripslashes_recursive($data);
+        global $DB;
+
+        $data = $data;
         $this->config = $data;
         $table = 'block_instance';
         if (!empty($pinned)) {
             $table = 'block_pinned';
         }
-        return set_field($table, 'configdata', base64_encode(serialize($data)), 'id', $this->instance->id);
+        return $DB->set_field($table, 'configdata', base64_encode(serialize($data)), array('id'=>$this->instance->id));
     }
 
     /**
@@ -743,11 +745,13 @@ class block_base {
      * @todo finish documenting this function
      */
     function instance_config_commit($pinned=false) {
+        global $DB;
+
         $table = 'block_instance';
         if (!empty($pinned)) {
             $table = 'block_pinned';
         }
-        return set_field($table, 'configdata', base64_encode(serialize($this->config)), 'id', $this->instance->id);
+        return $DB->set_field($table, 'configdata', base64_encode(serialize($this->config)), array('id'=>$this->instance->id));
     }
 
      /**
index 36870a89fcced350af42bec334cb42f6e63ecc3f..7201d946c5cf9f11304cb6d0e206bce6daa0f6ee 100644 (file)
@@ -70,7 +70,7 @@ class block_section_links extends block_base {
         }
 
         if (!empty($USER->id)) {
-            $display = get_field('course_display', 'display', 'course', $this->instance->pageid, 'userid', $USER->id);
+            $display = $DB->get_field('course_display', 'display', array('course'=>$this->instance->pageid, 'userid'=>$USER->id));
         }
         if (!empty($display)) {
             $link = $CFG->wwwroot.'/course/view.php?id='.$this->instance->pageid.'&amp;'.$sectionname.'=';
index 0b078f3cb01d7d3ffa5ecd215fd0429b3388ce05..0b2119b4874626a55e23bf7a9871b44906bdaadc 100755 (executable)
                 break;
             case 'group':
                 $group = groups_get_group($id, false);
-                $info = $group->name; //TODO: get_field('groups', 'name', 'id', $id)
+                $info = $group->name; //TODO: $DB->get_field('groups', 'name', array('id'=>$id))
                 break;
             default:
                 $info = '';
index e699ea9b3d780aa61d62f49c5e5cdec5c74f820b..57a6538bbd8eaff874ae2bc6b1d6d9796e1a2b30 100644 (file)
@@ -133,7 +133,7 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
             $count = $count->max + 100;
             begin_sql();
             foreach ($courses as $course) {
-                set_field('course', 'sortorder', $count, 'id', $course->id);
+                $DB->set_field('course', 'sortorder', $count, array('id'=>$course->id));
                 $count++;
             }
             commit_sql();
@@ -226,7 +226,7 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
                 $visible = 1;
             }
             if ($category) {
-                if (! set_field("course_categories", "visible", $visible, "id", $category->id)) {
+                if (! $DB->set_field("course_categories", "visible", $visible, array("id"=>$category->id))) {
                     notify("Could not update that category!");
                 }
             }
@@ -259,9 +259,9 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
 
             if ($swapcourse and $movecourse) {        // Renumber everything for robustness
                 begin_sql();
-                if (!(    set_field("course", "sortorder", $max, "id", $swapcourse->id)
-                       && set_field("course", "sortorder", $swapcourse->sortorder, "id", $movecourse->id)
-                       && set_field("course", "sortorder", $movecourse->sortorder, "id", $swapcourse->id)
+                if (!(    $DB->set_field("course", "sortorder", $max, aray("id"=>$swapcourse->id))
+                       && $DB->set_field("course", "sortorder", $swapcourse->sortorder, array("id"=>$movecourse->id))
+                       && $DB->set_field("course", "sortorder", $movecourse->sortorder, array("id"=>$swapcourse->id))
                     )) {
                     notify("Could not update that course!");
                 }
index d4fc19785ee9de0accc2b31a50e2dd5a859956ff..2715c8534873853b5994f075a9ad313933a9ce42 100644 (file)
@@ -82,7 +82,7 @@
         }
         if (has_capability('moodle/course:create', $sysctx)) {       // Print link to create a new course
         /// Get the 1st available category
-            $options = array('category' => get_field('course_categories', 'id', 'parent', '0'));
+            $options = array('category' => $DB->get_field('course_categories', 'id', array('parent'=>'0')));
             print_single_button('edit.php', $options, get_string('addnewcourse'), 'get');
         }
         if (has_capability('moodle/site:approvecourse', $sysctx)  and !empty($CFG->enablecourserequests)) {
         if (has_capability('moodle/course:create', $sysctx)) {
             // print create course link to first category
             $options = array();
-            $options = array('category' => get_field('course_categories', 'id', 'parent', '0'));
+            $options = array('category' => $DB->get_field('course_categories', 'id', array('parent'=>'0')));
             print_single_button('edit.php', $options, get_string('addnewcourse'), 'get');
         }
     }
index 8756df8f73748b2915b316d26835114f3d9a6454..f89dd714217d2722801817bc0034e409c2595247 100644 (file)
@@ -1026,7 +1026,7 @@ function get_array_of_activities($courseid) {
                        }
                    }
                    if (!isset($mod[$seq]->name)) {
-                       $mod[$seq]->name = urlencode(get_field($rawmods[$seq]->modname, "name", "id", $rawmods[$seq]->instance));
+                       $mod[$seq]->name = urlencode($DB->get_field($rawmods[$seq]->modname, "name", array("id"=>$rawmods[$seq]->instance)));
                    }
                }
             }
@@ -2205,22 +2205,22 @@ function add_mod_to_section($mod, $beforemod=NULL) {
 
 function set_coursemodule_groupmode($id, $groupmode) {
     global $DB;
-    return set_field("course_modules", "groupmode", $groupmode, array("id"=>$id));
+    return $DB->set_field("course_modules", "groupmode", $groupmode, array("id"=>$id));
 }
 
 function set_coursemodule_groupingid($id, $groupingid) {
     global $DB;
-    return set_field("course_modules", "groupingid", $groupingid, array("id"=>$id));
+    return $DB->set_field("course_modules", "groupingid", $groupingid, array("id"=>$id));
 }
 
 function set_coursemodule_groupmembersonly($id, $groupmembersonly) {
     global $DB;
-    return set_field("course_modules", "groupmembersonly", $groupmembersonly, array("id"=>$id));
+    return $DB->set_field("course_modules", "groupmembersonly", $groupmembersonly, array("id"=>$id));
 }
 
 function set_coursemodule_idnumber($id, $idnumber) {
     global $DB;
-    return set_field("course_modules", "idnumber", $idnumber, array("id"=>$id));  
+    return $DB->set_field("course_modules", "idnumber", $idnumber, array("id"=>$id));  
 }
 /**
 * $prevstateoverrides = true will set the visibility of the course module
index b05a990ab9bab4ffad9dab9e3bfee601b14e6d50..a7de0e597860498333db64426249d1360134a259 100644 (file)
@@ -31,7 +31,7 @@
 
     print_heading(format_string($course->fullname));
 
-    if (!$logstart = get_field_sql("SELECT MIN(time) FROM {$CFG->prefix}log")) {
+    if (!$logstart = $DB->get_field_sql("SELECT MIN(time) FROM {log}")) {
         print_error('logfilenotavailable');
     }
 
index be81872fc4be50b27f24015ad3d8b0bd553df5d7..a3fc32ad42a2b4bef3dc096ba6b3cecc0f0cecfd 100644 (file)
@@ -30,7 +30,7 @@
 
 
     function report_stats_timeoptions($mode) {
-        global $CFG;
+        global $CFG, $DB;
         
         $tableprefix = $CFG->prefix.'stats_';
 
@@ -38,9 +38,9 @@
             $tableprefix = $CFG->prefix.'stats_user_';
         }
 
-        $earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend');
-        $earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend');
-        $earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'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 c2255bc8e38d579d8fe05144b73113e03507fd81..69fe80e52d82d04098befe96c6ee7350c0fae39a 100644 (file)
 
             print_heading(format_string($course->shortname).' - '.get_string('statsreport'.$report)
                     .((!empty($user)) ? ' '.get_string('statsreportforuser').' ' .fullname($user,true) : '')
-                    .((!empty($roleid)) ? ' '.get_field('role','name','id',$roleid) : ''));
+                    .((!empty($roleid)) ? ' '.$DB->get_field('role','name', array('id'=>$roleid)) : ''));
 
 
             if (empty($CFG->gdversion)) {
index eb50e86a27ecc035b1a1ba1b89995c6ddfb9f6b6..4132f4edd97d1b72d007e78be883e5d520273162 100644 (file)
@@ -69,6 +69,8 @@ var $imsroles = array(
 * For example, IMS role '01' is 'Learner', so may map to 'student' in Moodle.
 */
 function determine_default_rolemapping($imscode) {
+    global $DB;
+
     switch($imscode) {
         case '01':
         case '04':
@@ -89,7 +91,7 @@ function determine_default_rolemapping($imscode) {
         default:
             return 0; // Zero for no match
     }
-    return get_field('role', 'id', 'shortname', $shortname);
+    return $DB->get_field('role', 'id', array('shortname'=>$shortname));
 }
 
 
@@ -469,7 +471,7 @@ function process_group_tag($tagcontents){
         /* -----------Course aliasing is DEACTIVATED until a more general method is in place---------------
 
        // Second, look in the course alias table to see if the code should be translated to something else
-        if($aliases = get_field('enrol_coursealias', 'toids', 'fromid', $group->coursecode)){
+        if($aliases = $DB->get_field('enrol_coursealias', 'toids', array('fromid'=>$group->coursecode))){
             $this->log_line("Found alias of course code: Translated $group->coursecode to $aliases");
             // Alias is allowed to be a comma-separated list, so let's split it
             $group->coursecode = explode(',', $aliases);
@@ -561,7 +563,7 @@ function process_group_tag($tagcontents){
                     $this->log_line('Failed to create course '.$coursecode.' in Moodle');
                 }
               }
-            }elseif($recstatus==3 && ($courseid = get_field('course', 'id', 'idnumber', $coursecode))){
+            }elseif($recstatus==3 && ($courseid = $DB->get_field('course', 'id', array('idnumber'=>$coursecode)))){
                 // If course does exist, but recstatus==3 (delete), then set the course as hidden
                 $DB->set_field('course', 'visible', '0', array('id'=>$courseid));
             }
index acded270e60bd1a68110071099775b61770dde91..3d96f3ccac2b5e22c0e4b6b80e3e0d92fdc3efda 100644 (file)
@@ -1055,7 +1055,7 @@ function stats_get_parameters($time,$report,$courseid,$mode,$roleid=0) {
     case STATS_REPORT_ACTIVITYBYROLE;
         $param->fields = 'stat1 AS line1, stat2 AS line2';
         $param->stattype = 'activity';
-        $rolename = get_field('role','name','id',$roleid);
+        $rolename = $DB->get_field('role','name', array('id'=>$roleid));
         $param->line1 = $rolename . get_string('statsreads');
         $param->line2 = $rolename . get_string('statswrites');
         if ($courseid == SITEID) {
index 904cef44fe80ad097d745c2eed9eb10c1055de96..fe62cf984782f8248f3e947992081f3f8b1354ea 100644 (file)
@@ -62,7 +62,7 @@ if ($p_secret !== false) {
 
         // Clear secret so that it can not be used again
         $user->secret = '';
-        if (!set_field('user', 'secret', $user->secret, 'id', $user->id)) {
+        if (!$DB->set_field('user', 'secret', $user->secret, array('id'=>$user->id))) {
             print_error('Error resetting user secret string');
         }
 
@@ -114,7 +114,7 @@ if ($mform->is_cancelled()) {
 
             // set 'secret' string
             $user->secret = random_string(15);
-            if (!set_field('user', 'secret', $user->secret, 'id', $user->id)) {
+            if (!$DB->set_field('user', 'secret', $user->secret, array('id'=>$user->id))) {
                 print_error('error setting user secret string');
             }
 
index 982579b87f7800c38ac433d3ecf3d497b171ecba..1ceb68d2276a5696d73559b4ff4bf454d4784d2a 100644 (file)
@@ -93,6 +93,8 @@ class mnet_environment {
     }
 
     function get_keypair() {
+        global $DB;
+
         // We don't generate keys on install/upgrade because we want the USER
         // record to have an email address, city and country already.
         if (!empty($_SESSION['upgraderunning'])) return true;
@@ -100,7 +102,7 @@ class mnet_environment {
         if (!empty($this->keypair)) return true;
 
         $this->keypair = array();
-        $keypair = get_field('config_plugins', 'value', 'plugin', 'mnet', 'name', 'openssl');
+        $keypair = $DB->get_field('config_plugins', 'value', array('plugin'=>'mnet', 'name'=>'openssl'));
 
         if (!empty($keypair)) {
             // Explode/Implode is faster than Unserialize/Serialize
@@ -114,7 +116,7 @@ class mnet_environment {
             // Key generation/rotation
 
             // 1. Archive the current key (if there is one).
-            $result = get_field('config_plugins', 'value', 'plugin', 'mnet', 'name', 'openssl_history');
+            $result = $DB->get_field('config_plugins', 'value', array('plugin'=>'mnet', 'name'=>'openssl_history'));
             if(empty($result)) {
                 set_config('openssl_history', serialize(array()), 'mnet');
                 $openssl_history = array();
@@ -129,7 +131,7 @@ class mnet_environment {
 
             // 2. How many old keys do we want to keep? Use array_slice to get 
             // rid of any we don't want
-            $openssl_generations = get_field('config_plugins', 'value', 'plugin', 'mnet', 'name', 'openssl_generations');
+            $openssl_generations = $DB->get_field('config_plugins', 'value', array('plugin'=>'mnet', 'name'=>'openssl_generations'));
             if(empty($openssl_generations)) {
                 set_config('openssl_generations', 3, 'mnet');
                 $openssl_generations = 3;
index 99a55843f57304d55c510fee8c2bb3448bb1150d..650abc53c191fc59ec74f8930d8cd61436abeaa4 100644 (file)
@@ -289,10 +289,10 @@ function mnet_encrypt_message($message, $remote_certificate) {
  * @return  string              The signature over that text
  */
 function mnet_get_keypair() {
-    global $CFG;
+    global $CFG, $DB;;
     static $keypair = null;
     if (!is_null($keypair)) return $keypair;
-    if ($result = get_field('config_plugins', 'value', 'plugin', 'mnet', 'name', 'openssl')) {
+    if ($result = $DB->get_field('config_plugins', 'value', array('plugin'=>'mnet', 'name'=>'openssl'))) {
         list($keypair['certificate'], $keypair['keypair_PEM']) = explode('@@@@@@@@', $result);
         $keypair['privatekey'] = openssl_pkey_get_private($keypair['keypair_PEM']);
         $keypair['publickey']  = openssl_pkey_get_public($keypair['certificate']);
index 58b2e7dfb26f08667d15ec73f4db3d5c4934b632..575c11e6457842a5f4441c21355908cdb62db947 100644 (file)
@@ -20,14 +20,14 @@ function useredit_update_user_preference($usernew) {
 }
 
 function useredit_update_picture(&$usernew, &$userform) {
-    global $CFG;
+    global $CFG, $DB;
 
     if (isset($usernew->deletepicture) and $usernew->deletepicture) {
         $location = make_user_directory($usernew->id, true);
         @remove_dir($location);
-        set_field('user', 'picture', 0, 'id', $usernew->id);
+        $DB->set_field('user', 'picture', 0, array('id'=>$usernew->id));
     } else if ($usernew->picture = save_profile_image($usernew->id, $userform->get_um(), 'user')) {
-        set_field('user', 'picture', 1, 'id', $usernew->id);
+        $DB->set_field('user', 'picture', 1, array('id'=>$usernew->id));
     }
 }
 
index 82b4691e5c09fa88c73df531be35cd31f8c060e3..c959790c32732a5ddacca93fa0866451a779c052 100644 (file)
@@ -78,7 +78,9 @@ class user_filter_globalrole extends user_filter_type {
      * @return string active filter label
      */
     function get_label($data) {
-        $rolename = get_field('role', 'name', 'id', $data['value']);
+        global $DB;
+
+        $rolename = $DB->get_field('role', 'name', array('id'=>$data['value']));
 
         $a = new object();
         $a->label = $this->_label;
index f9b24a9beb7e303713557530931f8f2d3c735d06..0545455f1ede82096ee9b3cc72ee7b46aeca37bf 100644 (file)
@@ -13,7 +13,7 @@
 
     if ($agree and confirm_sesskey()) {    // User has agreed
         if (!isguestuser()) {              // Don't remember guests
-            if (!set_field('user', 'policyagreed', 1, 'id', $USER->id)) {
+            if (!$DB->set_field('user', 'policyagreed', 1, array('id'=>$USER->id))) {
                 print_error('Could not save your agreement');
             }
         }
index 875efa786de9ba91a3d468dae07607cd8cb46637..b7bbbbd94a2cd37894edcf3caf34ee3cbafcc275 100644 (file)
 
         if (has_capability('moodle/course:useremail', $coursecontext) or $currentuser) {   /// Can use the enable/disable email stuff
             if (!empty($enable)) {     /// Recieved a parameter to enable the email address
-                set_field('user', 'emailstop', 0, 'id', $user->id);
+                $DB->set_field('user', 'emailstop', 0, array('id'=>$user->id));
                 $user->emailstop = 0;
             }
             if (!empty($disable)) {     /// Recieved a parameter to disable the email address
-                set_field('user', 'emailstop', 1, 'id', $user->id);
+                $DB->set_field('user', 'emailstop', 1, array('id'=>$user->id));
                 $user->emailstop = 1;
             }
         }