diff --git a/admin/health.php b/admin/health.php
index ac6aa744db2..14db41b608f 100644
--- a/admin/health.php
+++ b/admin/health.php
@@ -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.';
diff --git a/admin/index.php b/admin/index.php
index 6b3e2ff4db5..62b79c93b5e 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -590,7 +590,7 @@
}
/// 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);
diff --git a/admin/mnet/enr_hosts.php b/admin/mnet/enr_hosts.php
index 085539bc74b..546f3cef19e 100644
--- a/admin/mnet/enr_hosts.php
+++ b/admin/mnet/enr_hosts.php
@@ -38,11 +38,11 @@
$hosts = $enrolment->list_remote_servers();
foreach ($hosts as $host) {
$coursesurl = "$CFG->wwwroot/$CFG->admin/mnet/enr_courses.php?host={$host->id}&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 '
'
. "| {$host->name} | "
diff --git a/admin/mnet/peers.php b/admin/mnet/peers.php
index 584e0c260ab..5dcefbcd9f2 100644
--- a/admin/mnet/peers.php
+++ b/admin/mnet/peers.php
@@ -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);
}
diff --git a/admin/report/backups/index.php b/admin/report/backups/index.php
index a4f52946d50..612501c4ddd 100644
--- a/admin/report/backups/index.php
+++ b/admin/report/backups/index.php
@@ -63,7 +63,7 @@
echo "$strnext |
";
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 "";
echo "| courseid\">".$coursename." | ";
@@ -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');
diff --git a/admin/report/courseoverview/index.php b/admin/report/courseoverview/index.php
index fbb922b588c..f4e122719e8 100644
--- a/admin/report/courseoverview/index.php
+++ b/admin/report/courseoverview/index.php
@@ -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();
@@ -101,7 +101,7 @@
foreach ($courses as $c) {
$a = array();
- $a[] = ''.get_field('course','shortname','id',$c->courseid).'';
+ $a[] = ''.$DB->get_field('course', 'shortname', array('id'=>$c->courseid)).'';
$a[] = $c->line1;
if (isset($c->line2)) {
diff --git a/admin/report/courseoverview/reportsgraph.php b/admin/report/courseoverview/reportsgraph.php
index c81bb190685..715e68d8487 100644
--- a/admin/report/courseoverview/reportsgraph.php
+++ b/admin/report/courseoverview/reportsgraph.php
@@ -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');
diff --git a/admin/roles/assign.php b/admin/roles/assign.php
index 523b8a36e40..2c816eb13c3 100755
--- a/admin/roles/assign.php
+++ b/admin/roles/assign.php
@@ -454,7 +454,7 @@
}
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(''.$rolename.'',$description, $rolehodlercount[$roleid]);
if ($showroleholders) {
$row[] = $rolehodlernames[$roleid];
diff --git a/admin/roles/manage.php b/admin/roles/manage.php
index 3e2259dea4e..e52236290cb 100755
--- a/admin/roles/manage.php
+++ b/admin/roles/manage.php
@@ -386,7 +386,7 @@
// 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&roleid='.$roleid);
diff --git a/admin/roles/override.php b/admin/roles/override.php
index a2e3641b175..72359f73d6e 100755
--- a/admin/roles/override.php
+++ b/admin/roles/override.php
@@ -200,7 +200,7 @@
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(''.$rolename.'', $description, $overridecount);
}
diff --git a/admin/uploadpicture.php b/admin/uploadpicture.php
index be1102ed72b..e9e82d96820 100644
--- a/admin/uploadpicture.php
+++ b/admin/uploadpicture.php
@@ -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 {
diff --git a/admin/xmldb/actions/test/test.class.php b/admin/xmldb/actions/test/test.class.php
index 0705ad81660..0d5bf440e73 100644
--- a/admin/xmldb/actions/test/test.class.php
+++ b/admin/xmldb/actions/test/test.class.php
@@ -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;
diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php
index 3dd4df8f384..da71a863f5e 100644
--- a/auth/mnet/auth.php
+++ b/auth/mnet/auth.php
@@ -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]);
diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php
index d8ea5fe50db..9a1b144234d 100644
--- a/blocks/moodleblock.class.php
+++ b/blocks/moodleblock.class.php
@@ -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));
}
/**
diff --git a/blocks/section_links/block_section_links.php b/blocks/section_links/block_section_links.php
index 36870a89fcc..7201d946c5c 100644
--- a/blocks/section_links/block_section_links.php
+++ b/blocks/section_links/block_section_links.php
@@ -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.'&'.$sectionname.'=';
diff --git a/blog/rsslib.php b/blog/rsslib.php
index 0b078f3cb01..0b2119b4874 100755
--- a/blog/rsslib.php
+++ b/blog/rsslib.php
@@ -100,7 +100,7 @@
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 = '';
diff --git a/course/editcategory.php b/course/editcategory.php
index e699ea9b3d7..57a6538bbd8 100644
--- a/course/editcategory.php
+++ b/course/editcategory.php
@@ -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!");
}
diff --git a/course/index.php b/course/index.php
index d4fc19785ee..2715c853487 100644
--- a/course/index.php
+++ b/course/index.php
@@ -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)) {
@@ -292,7 +292,7 @@
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');
}
}
diff --git a/course/lib.php b/course/lib.php
index 8756df8f737..f89dd714217 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -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
diff --git a/course/report/outline/index.php b/course/report/outline/index.php
index b05a990ab9b..a7de0e59786 100644
--- a/course/report/outline/index.php
+++ b/course/report/outline/index.php
@@ -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');
}
diff --git a/course/report/stats/lib.php b/course/report/stats/lib.php
index be81872fc4b..a3fc32ad42a 100644
--- a/course/report/stats/lib.php
+++ b/course/report/stats/lib.php
@@ -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();
diff --git a/course/report/stats/report.php b/course/report/stats/report.php
index c2255bc8e38..69fe80e52d8 100644
--- a/course/report/stats/report.php
+++ b/course/report/stats/report.php
@@ -104,7 +104,7 @@
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)) {
diff --git a/enrol/imsenterprise/enrol.php b/enrol/imsenterprise/enrol.php
index eb50e86a27e..4132f4edd97 100644
--- a/enrol/imsenterprise/enrol.php
+++ b/enrol/imsenterprise/enrol.php
@@ -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));
}
diff --git a/lib/statslib.php b/lib/statslib.php
index acded270e60..3d96f3ccac2 100644
--- a/lib/statslib.php
+++ b/lib/statslib.php
@@ -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) {
diff --git a/login/forgot_password.php b/login/forgot_password.php
index 904cef44fe8..fe62cf98478 100644
--- a/login/forgot_password.php
+++ b/login/forgot_password.php
@@ -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');
}
diff --git a/mnet/environment.php b/mnet/environment.php
index 982579b87f7..1ceb68d2276 100644
--- a/mnet/environment.php
+++ b/mnet/environment.php
@@ -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;
diff --git a/mnet/lib.php b/mnet/lib.php
index 99a55843f57..650abc53c19 100644
--- a/mnet/lib.php
+++ b/mnet/lib.php
@@ -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']);
diff --git a/user/editlib.php b/user/editlib.php
index 58b2e7dfb26..575c11e6457 100644
--- a/user/editlib.php
+++ b/user/editlib.php
@@ -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));
}
}
diff --git a/user/filters/globalrole.php b/user/filters/globalrole.php
index 82b4691e5c0..c959790c327 100644
--- a/user/filters/globalrole.php
+++ b/user/filters/globalrole.php
@@ -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;
diff --git a/user/policy.php b/user/policy.php
index f9b24a9beb7..0545455f1ed 100644
--- a/user/policy.php
+++ b/user/policy.php
@@ -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');
}
}
diff --git a/user/view.php b/user/view.php
index 875efa786de..b7bbbbd94a2 100644
--- a/user/view.php
+++ b/user/view.php
@@ -246,11 +246,11 @@
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;
}
}