diff --git a/admin/xmldb/actions/test/test.class.php b/admin/xmldb/actions/test/test.class.php
index c507c695c2c7c..ba7590f32f432 100644
--- a/admin/xmldb/actions/test/test.class.php
+++ b/admin/xmldb/actions/test/test.class.php
@@ -968,23 +968,20 @@ function invoke() {
$rec->name = 'texttest';
/// Calculate its length
$textlen = $textlib->strlen($fulltext);
- if ($rec->id = $DB->insert_record('newnameforthetable', $rec)) {
- if ($new = $DB->get_record('newnameforthetable', array('id'=>$rec->id))) {
- $DB->delete_records('newnameforthetable', array('id'=>$new->id));
- $newtextlen = $textlib->strlen($new->intro);
- if ($fulltext === $new->intro) {
- $test->sql = array($newtextlen . ' cc. (text) sent and received ok');
- $test->status = true;
- } else {
- $test->error = $DB->get_last_error();
- $test->sql = array($newtextlen . ' cc. (text) transfer failed. Data changed!');
- $test->status = false;
- }
+ $rec->id = $DB->insert_record('newnameforthetable', $rec);
+ if ($new = $DB->get_record('newnameforthetable', array('id'=>$rec->id))) {
+ $DB->delete_records('newnameforthetable', array('id'=>$new->id));
+ $newtextlen = $textlib->strlen($new->intro);
+ if ($fulltext === $new->intro) {
+ $test->sql = array($newtextlen . ' cc. (text) sent and received ok');
+ $test->status = true;
} else {
- $test->error = $DB->get_last_error().'xx';
+ $test->error = $DB->get_last_error();
+ $test->sql = array($newtextlen . ' cc. (text) transfer failed. Data changed!');
+ $test->status = false;
}
} else {
- $test->error = $DB->get_last_error().'yy'.var_export($rec->id, true);
+ $test->error = $DB->get_last_error().'xx';
}
$tests['insert record '. $textlen . ' cc. (text)'] = $test;
}
@@ -998,19 +995,16 @@ function invoke() {
$rec->name = 'binarytest';
/// Calculate its length
$textlen = strlen($rec->avatar);
- if ($rec->id = $DB->insert_record('newnameforthetable', $rec)) {
- if ($new = $DB->get_record('newnameforthetable', array('id'=>$rec->id))) {
- $newtextlen = strlen($new->avatar);
- if ($rec->avatar === $new->avatar) {
- $test->sql = array($newtextlen . ' bytes (binary) sent and received ok');
- $test->status = true;
- } else {
- $test->error = $DB->get_last_error();
- $test->sql = array($newtextlen . ' bytes (binary) transfer failed. Data changed!');
- $test->status = false;
- }
+ $rec->id = $DB->insert_record('newnameforthetable', $rec);
+ if ($new = $DB->get_record('newnameforthetable', array('id'=>$rec->id))) {
+ $newtextlen = strlen($new->avatar);
+ if ($rec->avatar === $new->avatar) {
+ $test->sql = array($newtextlen . ' bytes (binary) sent and received ok');
+ $test->status = true;
} else {
$test->error = $DB->get_last_error();
+ $test->sql = array($newtextlen . ' bytes (binary) transfer failed. Data changed!');
+ $test->status = false;
}
} else {
$test->error = $DB->get_last_error();
diff --git a/auth/db/auth.php b/auth/db/auth.php
index 7682da1ebb158..ada6406411632 100644
--- a/auth/db/auth.php
+++ b/auth/db/auth.php
@@ -365,15 +365,14 @@ function sync_users($do_updates=false) {
$DB->set_field('user', 'deleted', 0, array('username'=>$user->username));
echo "\t"; print_string('auth_dbreviveduser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id)); echo "\n";
- } elseif ($id = $DB->insert_record ('user',$user)) { // it is truly a new user
+ } else {
+ $id = $DB->insert_record ('user',$user); // it is truly a new user
echo "\t"; print_string('auth_dbinsertuser','auth_db',array('name'=>$user->username, 'id'=>$id)); echo "\n";
// if relevant, tag for password generation
if ($this->config->passtype === 'internal') {
set_user_preference('auth_forcepasswordchange', 1, $id);
set_user_preference('create_password', 1, $id);
}
- } else {
- echo "\t"; print_string('auth_dbinsertusererror', 'auth_db', $user->username); echo "\n";
}
}
$transaction->allow_commit();
diff --git a/auth/email/auth.php b/auth/email/auth.php
index d57f11e602e9f..01612b6d3c57a 100644
--- a/auth/email/auth.php
+++ b/auth/email/auth.php
@@ -79,9 +79,7 @@ function user_signup($user, $notify=true) {
$user->password = hash_internal_user_password($user->password);
- if (! ($user->id = $DB->insert_record('user', $user)) ) {
- print_error('auth_emailnoinsert','auth_email');
- }
+ $user->id = $DB->insert_record('user', $user);
/// Save any custom profile field information
profile_save_data($user);
diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php
index f114d1dcafa83..ce5ca113c1f8a 100644
--- a/auth/ldap/auth.php
+++ b/auth/ldap/auth.php
@@ -490,9 +490,7 @@ function user_signup($user, $notify=true) {
print_error('auth_ldap_create_error', 'auth_ldap');
}
- if (! ($user->id = $DB->insert_record('user', $user)) ) {
- print_error('auth_emailnoinsert', 'auth_email');
- }
+ $user->id = $DB->insert_record('user', $user);
// Save any custom profile field information
profile_save_data($user);
@@ -861,18 +859,15 @@ function sync_users($do_updates=true) {
$user->lang = $CFG->lang;
}
- if ($id = $DB->insert_record('user', $user)) {
- echo "\t"; print_string('auth_dbinsertuser', 'auth_db', array('name'=>$user->username, 'id'=>$id)); echo "\n";
- if (!empty($this->config->forcechangepassword)) {
- set_user_preference('auth_forcepasswordchange', 1, $id);
- }
+ $id = $DB->insert_record('user', $user);
+ echo "\t"; print_string('auth_dbinsertuser', 'auth_db', array('name'=>$user->username, 'id'=>$id)); echo "\n";
+ if (!empty($this->config->forcechangepassword)) {
+ set_user_preference('auth_forcepasswordchange', 1, $id);
+ }
- // Add course creators if needed
- if ($creatorrole !== false and $this->iscreator($user->username)) {
- role_assign($creatorrole->id, $id, $sitecontext->id, $this->roleauth);
- }
- } else {
- echo "\t"; print_string('auth_dbinsertusererror', 'auth_db', $user->username); echo "\n";
+ // Add course creators if needed
+ if ($creatorrole !== false and $this->iscreator($user->username)) {
+ role_assign($creatorrole->id, $id, $sitecontext->id, $this->roleauth);
}
}
diff --git a/blog/external_blog_edit.php b/blog/external_blog_edit.php
index 517dde20815bf..42cb3ed246bd8 100644
--- a/blog/external_blog_edit.php
+++ b/blog/external_blog_edit.php
@@ -82,10 +82,9 @@
$newexternal->filtertags = $data->filtertags;
$newexternal->timemodified = mktime();
- if ($newexternal->id = $DB->insert_record('blog_external', $newexternal)) {
- blog_sync_external_entries($newexternal);
- tag_set('blog_external', $newexternal->id, $data->autotags);
- }
+ $newexternal->id = $DB->insert_record('blog_external', $newexternal);
+ blog_sync_external_entries($newexternal);
+ tag_set('blog_external', $newexternal->id, $data->autotags);
break;
diff --git a/enrol/mnet/enrol.php b/enrol/mnet/enrol.php
index 4efcf95166b5f..230aee1eb1e15 100644
--- a/enrol/mnet/enrol.php
+++ b/enrol/mnet/enrol.php
@@ -145,7 +145,9 @@ public function enrol_user(array $userdata, $courseid) {
// users {@link http://tracker.moodle.org/browse/MDL-21327}
$user = mnet_strip_user((object)$userdata, mnet_fields_to_import($client));
$user->mnethostid = $client->id;
- if (!$user->id = $DB->insert_record('user', $user)) {
+ try {
+ $user->id = $DB->insert_record('user', $user);
+ } catch (Exception $e) {
throw new mnet_server_exception(5011, 'couldnotcreateuser', 'enrol_mnet');
}
}
diff --git a/lib/datalib.php b/lib/datalib.php
index 48bb742b1851c..7ebb845de6cb7 100644
--- a/lib/datalib.php
+++ b/lib/datalib.php
@@ -1234,9 +1234,8 @@ function make_default_scale() {
get_string('postrating3', 'forum');
$defaultscale->timemodified = time();
- if ($defaultscale->id = $DB->insert_record('scale', $defaultscale)) {
- $DB->execute("UPDATE {forum} SET scale = ?", array($defaultscale->id));
- }
+ $defaultscale->id = $DB->insert_record('scale', $defaultscale);
+ $DB->execute("UPDATE {forum} SET scale = ?", array($defaultscale->id));
}
diff --git a/lib/simpletest/fixtures/gradetest.php b/lib/simpletest/fixtures/gradetest.php
index fc7d9ef0ca3f3..f7748ac50400c 100644
--- a/lib/simpletest/fixtures/gradetest.php
+++ b/lib/simpletest/fixtures/gradetest.php
@@ -106,11 +106,10 @@ function load_scale() {
$scale->description = 'This scale defines some of qualities that make posts helpful within the Moodle help forums.\n Your feedback will help others see how their posts are being received.';
$scale->timemodified = mktime();
- if ($scale->id = $DB->insert_record('scale', $scale)) {
- $this->scale[0] = $scale;
- $temp = explode(',', $scale->scale);
- $this->scalemax[0] = count($temp) -1;
- }
+ $scale->id = $DB->insert_record('scale', $scale);
+ $this->scale[0] = $scale;
+ $temp = explode(',', $scale->scale);
+ $this->scalemax[0] = count($temp) -1;
$scale = new stdClass();
@@ -121,11 +120,10 @@ function load_scale() {
$scale->description = 'This scale is used to mark standard assignments.';
$scale->timemodified = mktime();
- if ($scale->id = $DB->insert_record('scale', $scale)) {
- $this->scale[1] = $scale;
- $temp = explode(',', $scale->scale);
- $this->scalemax[1] = count($temp) -1;
- }
+ $scale->id = $DB->insert_record('scale', $scale);
+ $this->scale[1] = $scale;
+ $temp = explode(',', $scale->scale);
+ $this->scalemax[1] = count($temp) -1;
$scale = new stdClass();
@@ -138,11 +136,10 @@ function load_scale() {
$temp = explode(',', $scale->scale);
$scale->max = count($temp) -1;
- if ($scale->id = $DB->insert_record('scale', $scale)) {
- $this->scale[2] = $scale;
- $temp = explode(',', $scale->scale);
- $this->scalemax[2] = count($temp) -1;
- }
+ $scale->id = $DB->insert_record('scale', $scale);
+ $this->scale[2] = $scale;
+ $temp = explode(',', $scale->scale);
+ $this->scalemax[2] = count($temp) -1;
$scale->name = 'unittestscale4';
$scale->courseid = $this->courseid;
@@ -153,11 +150,10 @@ function load_scale() {
$temp = explode(',', $scale->scale);
$scale->max = count($temp) -1;
- if ($scale->id = $DB->insert_record('scale', $scale)) {
- $this->scale[3] = $scale;
- $temp = explode(',', $scale->scale);
- $this->scalemax[3] = count($temp) -1;
- }
+ $scale->id = $DB->insert_record('scale', $scale);
+ $this->scale[3] = $scale;
+ $temp = explode(',', $scale->scale);
+ $this->scalemax[3] = count($temp) -1;
$scale->name = 'unittestscale5';
$scale->courseid = $this->courseid;
@@ -168,11 +164,10 @@ function load_scale() {
$temp = explode(',', $scale->scale);
$scale->max = count($temp) -1;
- if ($scale->id = $DB->insert_record('scale', $scale)) {
- $this->scale[4] = $scale;
- $temp = explode(',', $scale->scale);
- $this->scalemax[4] = count($temp) -1;
- }
+ $scale->id = $DB->insert_record('scale', $scale);
+ $this->scale[4] = $scale;
+ $temp = explode(',', $scale->scale);
+ $this->scalemax[4] = count($temp) -1;
}
/**
@@ -196,11 +191,10 @@ function load_grade_categories() {
$grade_category->timemodified = mktime();
$grade_category->depth = 2;
- if ($grade_category->id = $DB->insert_record('grade_categories', $grade_category)) {
- $grade_category->path = '/'.$course_category->id.'/'.$grade_category->id.'/';
- $DB->update_record('grade_categories', $grade_category);
- $this->grade_categories[0] = $grade_category;
- }
+ $grade_category->id = $DB->insert_record('grade_categories', $grade_category);
+ $grade_category->path = '/'.$course_category->id.'/'.$grade_category->id.'/';
+ $DB->update_record('grade_categories', $grade_category);
+ $this->grade_categories[0] = $grade_category;
$grade_category = new stdClass();
@@ -215,11 +209,10 @@ function load_grade_categories() {
$grade_category->timemodified = mktime();
$grade_category->depth = 3;
- if ($grade_category->id = $DB->insert_record('grade_categories', $grade_category)) {
- $grade_category->path = $this->grade_categories[0]->path.$grade_category->id.'/';
- $DB->update_record('grade_categories', $grade_category);
- $this->grade_categories[1] = $grade_category;
- }
+ $grade_category->id = $DB->insert_record('grade_categories', $grade_category);
+ $grade_category->path = $this->grade_categories[0]->path.$grade_category->id.'/';
+ $DB->update_record('grade_categories', $grade_category);
+ $this->grade_categories[1] = $grade_category;
$grade_category = new stdClass();
@@ -234,11 +227,10 @@ function load_grade_categories() {
$grade_category->timemodified = mktime();
$grade_category->depth = 3;
- if ($grade_category->id = $DB->insert_record('grade_categories', $grade_category)) {
- $grade_category->path = $this->grade_categories[0]->path.$grade_category->id.'/';
- $DB->update_record('grade_categories', $grade_category);
- $this->grade_categories[2] = $grade_category;
- }
+ $grade_category->id = $DB->insert_record('grade_categories', $grade_category);
+ $grade_category->path = $this->grade_categories[0]->path.$grade_category->id.'/';
+ $DB->update_record('grade_categories', $grade_category);
+ $this->grade_categories[2] = $grade_category;
// A category with no parent, but grade_items as children
@@ -255,11 +247,10 @@ function load_grade_categories() {
$grade_category->timemodified = mktime();
$grade_category->depth = 2;
- if ($grade_category->id = $DB->insert_record('grade_categories', $grade_category)) {
- $grade_category->path = '/'.$course_category->id.'/'.$grade_category->id.'/';
- $DB->update_record('grade_categories', $grade_category);
- $this->grade_categories[3] = $grade_category;
- }
+ $grade_category->id = $DB->insert_record('grade_categories', $grade_category);
+ $grade_category->path = '/'.$course_category->id.'/'.$grade_category->id.'/';
+ $DB->update_record('grade_categories', $grade_category);
+ $this->grade_categories[3] = $grade_category;
}
/**
@@ -269,21 +260,18 @@ function load_modules() {
global $DB;
$module = new stdClass();
$module->name = 'assignment';
- if ($module->id = $DB->insert_record('modules', $module)) {
- $this->modules[0] = $module;
- }
+ $module->id = $DB->insert_record('modules', $module);
+ $this->modules[0] = $module;
$module = new stdClass();
$module->name = 'quiz';
- if ($module->id = $DB->insert_record('modules', $module)) {
- $this->modules[1] = $module;
- }
+ $module->id = $DB->insert_record('modules', $module);
+ $this->modules[1] = $module;
$module = new stdClass();
$module->name = 'forum';
- if ($module->id = $DB->insert_record('modules', $module)) {
- $this->modules[2] = $module;
- }
+ $module->id = $DB->insert_record('modules', $module);
+ $this->modules[2] = $module;
}
/**
@@ -295,49 +283,43 @@ function load_course_modules() {
$course_module->course = $this->courseid;
$quiz->module = 1;
$quiz->instance = 2;
- if ($course_module->id = $DB->insert_record('course_modules', $course_module)) {
- $this->course_module[0] = $course_module;
- }
+ $course_module->id = $DB->insert_record('course_modules', $course_module);
+ $this->course_module[0] = $course_module;
$course_module = new stdClass();
$course_module->course = $this->courseid;
$quiz->module = 2;
$quiz->instance = 1;
- if ($course_module->id = $DB->insert_record('course_modules', $course_module)) {
- $this->course_module[0] = $course_module;
- }
+ $course_module->id = $DB->insert_record('course_modules', $course_module);
+ $this->course_module[0] = $course_module;
$course_module = new stdClass();
$course_module->course = $this->courseid;
$quiz->module = 2;
$quiz->instance = 5;
- if ($course_module->id = $DB->insert_record('course_modules', $course_module)) {
- $this->course_module[0] = $course_module;
- }
+ $course_module->id = $DB->insert_record('course_modules', $course_module);
+ $this->course_module[0] = $course_module;
$course_module = new stdClass();
$course_module->course = $this->courseid;
$quiz->module = 3;
$quiz->instance = 3;
- if ($course_module->id = $DB->insert_record('course_modules', $course_module)) {
- $this->course_module[0] = $course_module;
- }
+ $course_module->id = $DB->insert_record('course_modules', $course_module);
+ $this->course_module[0] = $course_module;
$course_module = new stdClass();
$course_module->course = $this->courseid;
$quiz->module = 3;
$quiz->instance = 7;
- if ($course_module->id = $DB->insert_record('course_modules', $course_module)) {
- $this->course_module[0] = $course_module;
- }
+ $course_module->id = $DB->insert_record('course_modules', $course_module);
+ $this->course_module[0] = $course_module;
$course_module = new stdClass();
$course_module->course = $this->courseid;
$quiz->module = 3;
$quiz->instance = 9;
- if ($course_module->id = $DB->insert_record('course_modules', $course_module)) {
- $this->course_module[0] = $course_module;
- }
+ $course_module->id = $DB->insert_record('course_modules', $course_module);
+ $this->course_module[0] = $course_module;
}
/**
@@ -350,19 +332,16 @@ function load_quiz_activities() {
$quiz->name = 'test quiz';
$quiz->intro = 'let us quiz you!';
$quiz->questions = '1,2';
- if ($quiz->id = $DB->insert_record('quiz', $quiz)) {
- $this->activities[0] = $quiz;
- }
+ $quiz->id = $DB->insert_record('quiz', $quiz);
+ $this->activities[0] = $quiz;
$quiz = new stdClass();
$quiz->course = $this->courseid;
$quiz->name = 'test quiz 2';
$quiz->intro = 'let us quiz you again!';
$quiz->questions = '1,3';
- if ($quiz->id = $DB->insert_record('quiz', $quiz)) {
- $this->activities[1] = $quiz;
- }
-
+ $quiz->id = $DB->insert_record('quiz', $quiz);
+ $this->activities[1] = $quiz;
}
/**
@@ -392,9 +371,8 @@ function load_grade_items() {
$grade_item->timemodified = mktime();
$grade_item->sortorder = 3;
- if ($grade_item->id = $DB->insert_record('grade_items', $grade_item)) {
- $this->grade_items[0] = $grade_item;
- }
+ $grade_item->id = $DB->insert_record('grade_items', $grade_item);
+ $this->grade_items[0] = $grade_item;
// id = 1
$grade_item = new stdClass();
@@ -415,9 +393,8 @@ function load_grade_items() {
$grade_item->timemodified = mktime();
$grade_item->sortorder = 4;
- if ($grade_item->id = $DB->insert_record('grade_items', $grade_item)) {
- $this->grade_items[1] = $grade_item;
- }
+ $grade_item->id = $DB->insert_record('grade_items', $grade_item);
+ $this->grade_items[1] = $grade_item;
// id = 2
$grade_item = new stdClass();
@@ -437,9 +414,8 @@ function load_grade_items() {
$grade_item->timemodified = mktime();
$grade_item->sortorder = 6;
- if ($grade_item->id = $DB->insert_record('grade_items', $grade_item)) {
- $this->grade_items[2] = $grade_item;
- }
+ $grade_item->id = $DB->insert_record('grade_items', $grade_item);
+ $this->grade_items[2] = $grade_item;
// Load grade_items associated with the 3 categories
// id = 3
@@ -458,9 +434,8 @@ function load_grade_items() {
$grade_item->timemodified = mktime();
$grade_item->sortorder = 1;
- if ($grade_item->id = $DB->insert_record('grade_items', $grade_item)) {
- $this->grade_items[3] = $grade_item;
- }
+ $grade_item->id = $DB->insert_record('grade_items', $grade_item);
+ $this->grade_items[3] = $grade_item;
// id = 4
$grade_item = new stdClass();
@@ -478,9 +453,8 @@ function load_grade_items() {
$grade_item->timemodified = mktime();
$grade_item->sortorder = 2;
- if ($grade_item->id = $DB->insert_record('grade_items', $grade_item)) {
- $this->grade_items[4] = $grade_item;
- }
+ $grade_item->id = $DB->insert_record('grade_items', $grade_item);
+ $this->grade_items[4] = $grade_item;
// id = 5
$grade_item = new stdClass();
@@ -498,9 +472,8 @@ function load_grade_items() {
$grade_item->timemodified = mktime();
$grade_item->sortorder = 5;
- if ($grade_item->id = $DB->insert_record('grade_items', $grade_item)) {
- $this->grade_items[5] = $grade_item;
- }
+ $grade_item->id = $DB->insert_record('grade_items', $grade_item);
+ $this->grade_items[5] = $grade_item;
// Orphan grade_item
// id = 6
@@ -522,9 +495,8 @@ function load_grade_items() {
$grade_item->timemodified = mktime();
$grade_item->sortorder = 7;
- if ($grade_item->id = $DB->insert_record('grade_items', $grade_item)) {
- $this->grade_items[6] = $grade_item;
- }
+ $grade_item->id = $DB->insert_record('grade_items', $grade_item);
+ $this->grade_items[6] = $grade_item;
// 2 grade items under level1category
// id = 7
@@ -545,9 +517,8 @@ function load_grade_items() {
$grade_item->timemodified = mktime();
$grade_item->sortorder = 9;
- if ($grade_item->id = $DB->insert_record('grade_items', $grade_item)) {
- $this->grade_items[7] = $grade_item;
- }
+ $grade_item->id = $DB->insert_record('grade_items', $grade_item);
+ $this->grade_items[7] = $grade_item;
// id = 8
$grade_item = new stdClass();
@@ -566,9 +537,8 @@ function load_grade_items() {
$grade_item->timemodified = mktime();
$grade_item->sortorder = 10;
- if ($grade_item->id = $DB->insert_record('grade_items', $grade_item)) {
- $this->grade_items[8] = $grade_item;
- }
+ $grade_item->id = $DB->insert_record('grade_items', $grade_item);
+ $this->grade_items[8] = $grade_item;
// Grade_item for level1category
// id = 9
@@ -588,9 +558,8 @@ function load_grade_items() {
$grade_item->timemodified = mktime();
$grade_item->sortorder = 8;
- if ($grade_item->id = $DB->insert_record('grade_items', $grade_item)) {
- $this->grade_items[9] = $grade_item;
- }
+ $grade_item->id = $DB->insert_record('grade_items', $grade_item);
+ $this->grade_items[9] = $grade_item;
// Manual grade_item
// id = 10
@@ -609,10 +578,8 @@ function load_grade_items() {
$grade_item->timecreated = mktime();
$grade_item->timemodified = mktime();
- if ($grade_item->id = $DB->insert_record('grade_items', $grade_item)) {
- $this->grade_items[10] = $grade_item;
- }
-
+ $grade_item->id = $DB->insert_record('grade_items', $grade_item);
+ $this->grade_items[10] = $grade_item;
}
/**
@@ -623,7 +590,7 @@ function load_grade_grades() {
//this method is called once for each test method. Avoid adding things to $this->grade_grades multiple times
$this->grade_grades = array();
-
+
// Grades for grade_item 1
$grade = new stdClass();
$grade->itemid = $this->grade_items[0]->id;
@@ -637,9 +604,8 @@ function load_grade_grades() {
$grade->feedback = 'Good, but not good enough..';
$grade->feedbackformat = FORMAT_PLAIN;
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[0] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[0] = $grade;
$grade = new stdClass();
$grade->itemid = $this->grade_items[0]->id;
@@ -650,9 +616,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '2 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[1] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[1] = $grade;
$grade = new stdClass();
$grade->itemid = $this->grade_items[0]->id;
@@ -663,9 +628,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '3 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[2] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[2] = $grade;
// No raw grades for grade_item 2 - it is calculated
@@ -678,9 +642,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '4 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[3] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[3] = $grade;
$grade = new stdClass();
$grade->itemid = $this->grade_items[1]->id;
@@ -690,9 +653,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '5 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[4] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[4] = $grade;
$grade = new stdClass();
$grade->itemid = $this->grade_items[1]->id;
@@ -702,9 +664,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '6 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[5] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[5] = $grade;
// Grades for grade_item 3
@@ -719,9 +680,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '7 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[6] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[6] = $grade;
$grade = new stdClass();
$grade->itemid = $this->grade_items[2]->id;
@@ -733,9 +693,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '8 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[] = $grade;
$grade = new stdClass();
$grade->itemid = $this->grade_items[2]->id;
@@ -747,9 +706,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '9 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[] = $grade;
// Grades for grade_item 7
@@ -762,9 +720,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '10 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[] = $grade;
$grade = new stdClass();
$grade->itemid = $this->grade_items[6]->id;
@@ -775,9 +732,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '11 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[] = $grade;
$grade = new stdClass();
$grade->itemid = $this->grade_items[6]->id;
@@ -788,9 +744,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '12 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[] = $grade;
// Grades for grade_item 8
@@ -803,9 +758,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '13 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[] = $grade;
$grade = new stdClass();
$grade->itemid = $this->grade_items[7]->id;
@@ -816,9 +770,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '14 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[] = $grade;
// Grades for grade_item 9
@@ -831,9 +784,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '15 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[] = $grade;
$grade = new stdClass();
$grade->itemid = $this->grade_items[8]->id;
@@ -844,9 +796,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '16 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[] = $grade;
$grade = new stdClass();
$grade->itemid = $this->grade_items[8]->id;
@@ -857,9 +808,8 @@ function load_grade_grades() {
$grade->timemodified = mktime();
$grade->information = '17 of 17 grade_grades';
- if ($grade->id = $DB->insert_record('grade_grades', $grade)) {
- $this->grade_grades[] = $grade;
- }
+ $grade->id = $DB->insert_record('grade_grades', $grade);
+ $this->grade_grades[] = $grade;
}
/**
@@ -880,9 +830,8 @@ function load_grade_outcomes() {
$grade_outcome->timemodified = mktime();
$grade_outcome->scaleid = $this->scale[2]->id;
- if ($grade_outcome->id = $DB->insert_record('grade_outcomes', $grade_outcome)) {
- $this->grade_outcomes[] = $grade_outcome;
- }
+ $grade_outcome->id = $DB->insert_record('grade_outcomes', $grade_outcome);
+ $this->grade_outcomes[] = $grade_outcome;
// Calculation for grade_item 2
$grade_outcome = new stdClass();
@@ -893,9 +842,8 @@ function load_grade_outcomes() {
$grade_outcome->timemodified = mktime();
$grade_outcome->scaleid = $this->scale[3]->id;
- if ($grade_outcome->id = $DB->insert_record('grade_outcomes', $grade_outcome)) {
- $this->grade_outcomes[] = $grade_outcome;
- }
+ $grade_outcome->id = $DB->insert_record('grade_outcomes', $grade_outcome);
+ $this->grade_outcomes[] = $grade_outcome;
// Calculation for grade_item 3
$grade_outcome = new stdClass();
@@ -906,9 +854,8 @@ function load_grade_outcomes() {
$grade_outcome->timemodified = mktime();
$grade_outcome->scaleid = $this->scale[4]->id;
- if ($grade_outcome->id = $DB->insert_record('grade_outcomes', $grade_outcome)) {
- $this->grade_outcomes[] = $grade_outcome;
- }
+ $grade_outcome->id = $DB->insert_record('grade_outcomes', $grade_outcome);
+ $this->grade_outcomes[] = $grade_outcome;
}
/**
diff --git a/mnet/lib.php b/mnet/lib.php
index a18f72c4ecec6..8905ac65057c1 100644
--- a/mnet/lib.php
+++ b/mnet/lib.php
@@ -442,25 +442,17 @@ function mnet_update_sso_access_control($username, $mnet_host_id, $accessctrl) {
if ($aclrecord = $DB->get_record('mnet_sso_access_control', array('username'=>$username, 'mnet_host_id'=>$mnet_host_id))) {
// update
$aclrecord->accessctrl = $accessctrl;
- if ($DB->update_record('mnet_sso_access_control', $aclrecord)) {
- add_to_log(SITEID, 'admin/mnet', 'update', 'admin/mnet/access_control.php',
- "SSO ACL: $accessctrl user '$username' from {$mnethost->name}");
- } else {
- print_error('failedaclwrite', 'mnet', '', $username);
- return false;
- }
+ $DB->update_record('mnet_sso_access_control', $aclrecord);
+ add_to_log(SITEID, 'admin/mnet', 'update', 'admin/mnet/access_control.php',
+ "SSO ACL: $accessctrl user '$username' from {$mnethost->name}");
} else {
// insert
$aclrecord->username = $username;
$aclrecord->accessctrl = $accessctrl;
$aclrecord->mnet_host_id = $mnet_host_id;
- if ($id = $DB->insert_record('mnet_sso_access_control', $aclrecord)) {
- add_to_log(SITEID, 'admin/mnet', 'add', 'admin/mnet/access_control.php',
- "SSO ACL: $accessctrl user '$username' from {$mnethost->name}");
- } else {
- print_error('failedaclwrite', 'mnet', '', $username);
- return false;
- }
+ $id = $DB->insert_record('mnet_sso_access_control', $aclrecord);
+ add_to_log(SITEID, 'admin/mnet', 'add', 'admin/mnet/access_control.php',
+ "SSO ACL: $accessctrl user '$username' from {$mnethost->name}");
}
return true;
}
diff --git a/mod/chat/chat_ajax.php b/mod/chat/chat_ajax.php
index 1a8ea6629ecc3..ad91a1bad1f5a 100644
--- a/mod/chat/chat_ajax.php
+++ b/mod/chat/chat_ajax.php
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see