mirror of
https://github.com/moodle/moodle.git
synced 2025-04-25 10:26:17 +02:00
MDL-18293 $DB->something is using exceptions, no need for ifs there, removing useless strings
This commit is contained in:
parent
7826abc79f
commit
2a7eff41ad
blog
lang/en_utf8
lib/grade
mod/glossary
user
@ -155,10 +155,6 @@ function do_delete($post) {
|
||||
tag_set('post', $post->id, array());
|
||||
|
||||
add_to_log(SITEID, 'blog', 'delete', 'index.php?userid='. $post->userid, 'deleted blog entry with entry id# '. $post->id);
|
||||
|
||||
if (!$status) {
|
||||
print_error('deleteposterror', 'blog', $returnurl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,23 +169,18 @@ function do_add($post, $blogeditform) {
|
||||
$post->created = time();
|
||||
|
||||
// Insert the new blog entry.
|
||||
if ($post->id = $DB->insert_record('post', $post)) {
|
||||
// Add blog attachment
|
||||
if ($blogeditform->get_new_filename('attachment')) {
|
||||
if ($blogeditform->save_stored_file('attachment', SYSCONTEXTID, 'blog', $post->id, '/', false, $USER->id)) {
|
||||
$DB->set_field("post", "attachment", 1, array("id"=>$post->id));
|
||||
}
|
||||
$post->id = $DB->insert_record('post', $post);
|
||||
// Add blog attachment
|
||||
if ($blogeditform->get_new_filename('attachment')) {
|
||||
if ($blogeditform->save_stored_file('attachment', SYSCONTEXTID, 'blog', $post->id, '/', false, $USER->id)) {
|
||||
$DB->set_field("post", "attachment", 1, array("id"=>$post->id));
|
||||
}
|
||||
|
||||
// Update tags.
|
||||
tag_set('post', $post->id, $post->tags);
|
||||
|
||||
add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$post->userid.'&postid='.$post->id, $post->subject);
|
||||
|
||||
} else {
|
||||
print_error('deleteposterror', 'blog', $returnurl);
|
||||
}
|
||||
|
||||
// Update tags.
|
||||
tag_set('post', $post->id, $post->tags);
|
||||
|
||||
add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$post->userid.'&postid='.$post->id, $post->subject);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,14 +203,10 @@ function do_edit($post, $blogeditform) {
|
||||
}
|
||||
|
||||
// Update record
|
||||
if ($DB->update_record('post', $post)) {
|
||||
tag_set('post', $post->id, $post->tags);
|
||||
$DB->update_record('post', $post);
|
||||
tag_set('post', $post->id, $post->tags);
|
||||
|
||||
add_to_log(SITEID, 'blog', 'update', 'index.php?userid='.$USER->id.'&postid='.$post->id, $post->subject);
|
||||
|
||||
} else {
|
||||
print_error('deleteposterror', 'blog', $returnurl);
|
||||
}
|
||||
add_to_log(SITEID, 'blog', 'update', 'index.php?userid='.$USER->id.'&postid='.$post->id, $post->subject);
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -22,7 +22,6 @@ $string['courseblogdisable'] = 'Course blogs is not enabled';
|
||||
$string['courseblogs'] = 'Users can only see blogs for people who share a course';
|
||||
$string['donothaveblog'] = 'You do not have your own blog, sorry.';
|
||||
$string['deleteotagswarn'] = 'Are you sure you want to remove this / these tags <br />from all blog posts and remove it from the system?';
|
||||
$string['deleteposterror'] = 'Error occured while deleting post';
|
||||
$string['disableblogs'] = 'Disable blog system completely';
|
||||
$string['emptybody'] = 'Blog entry body can not be empty';
|
||||
$string['emptytitle'] = 'Blog entry title can not be empty';
|
||||
|
@ -33,7 +33,6 @@ $string['cannotcreatelangbase'] = 'Error: Could not create base lang directory';
|
||||
$string['cannotcreatetempdir'] = 'Cannot create temp directory';
|
||||
$string['cannotcreatesitedir'] = 'Cannot create site folder. The site administrator needs to fix the file permissions.';
|
||||
$string['cannotcreateuploaddir'] = 'Cannot create upload folder. The site administrator needs to fix the file permissions.';
|
||||
$string['cannotcreateuser'] = 'Error creating user record';
|
||||
$string['cannotcreateorfindstructs'] = 'Error finding or creating section structures for this course';
|
||||
$string['cannotcreatepopupwin'] = 'Undefined element - cannot create pop-up window';
|
||||
$string['cannotcustomisefiltersblockuser'] = 'You cannot customise filters settings in user or block contexts.';
|
||||
|
@ -203,9 +203,7 @@ abstract class grade_object {
|
||||
|
||||
$data = $this->get_record_data();
|
||||
|
||||
if (!$DB->update_record($this->table, $data)) {
|
||||
return false;
|
||||
}
|
||||
$DB->update_record($this->table, $data);
|
||||
|
||||
if (empty($CFG->disablegradehistory)) {
|
||||
unset($data->timecreated);
|
||||
@ -290,10 +288,7 @@ abstract class grade_object {
|
||||
|
||||
$data = $this->get_record_data();
|
||||
|
||||
if (!$this->id = $DB->insert_record($this->table, $data)) {
|
||||
debugging("Could not insert object into db");
|
||||
return false;
|
||||
}
|
||||
$this->id = $DB->insert_record($this->table, $data);
|
||||
|
||||
// set all object properties from real db data
|
||||
$this->update_from_db();
|
||||
|
@ -152,7 +152,7 @@ class grade_outcome extends grade_object {
|
||||
$goc = new object();
|
||||
$goc->courseid = $courseid;
|
||||
$goc->outcomeid = $this->id;
|
||||
return (bool)$DB->insert_record('grade_outcomes_courses', $goc);
|
||||
$DB->insert_record('grade_outcomes_courses', $goc);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -79,10 +79,9 @@ function glossary_add_instance($glossary) {
|
||||
print_error('unknowformat', '', '', $glossary->displayformat);
|
||||
}
|
||||
|
||||
if ($returnid = $DB->insert_record("glossary", $glossary)) {
|
||||
$glossary->id = $returnid;
|
||||
glossary_grade_item_update($glossary);
|
||||
}
|
||||
$returnid = $DB->insert_record("glossary", $glossary);
|
||||
$glossary->id = $returnid;
|
||||
glossary_grade_item_update($glossary);
|
||||
|
||||
return $returnid;
|
||||
}
|
||||
@ -127,12 +126,11 @@ function glossary_update_instance($glossary) {
|
||||
print_error('unknowformat', '', '', $glossary->displayformat);
|
||||
}
|
||||
|
||||
if ($return = $DB->update_record("glossary", $glossary)) {
|
||||
if ($glossary->defaultapproval) {
|
||||
$DB->execute("UPDATE {glossary_entries} SET approved = 1 where approved <> 1 and glossaryid = ?", array($glossary->id));
|
||||
}
|
||||
glossary_grade_item_update($glossary);
|
||||
$return = $DB->update_record("glossary", $glossary);
|
||||
if ($glossary->defaultapproval) {
|
||||
$DB->execute("UPDATE {glossary_entries} SET approved = 1 where approved <> 1 and glossaryid = ?", array($glossary->id));
|
||||
}
|
||||
glossary_grade_item_update($glossary);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -97,15 +97,11 @@
|
||||
$usernew->mnethostid = $CFG->mnet_localhost_id; // always local user
|
||||
$usernew->confirmed = 1;
|
||||
$usernew->password = hash_internal_user_password($usernew->newpassword);
|
||||
if (!$usernew->id = $DB->insert_record('user', $usernew)) {
|
||||
print_error('cannotcreateuser');
|
||||
}
|
||||
$usernew->id = $DB->insert_record('user', $usernew);
|
||||
$usercreated = true;
|
||||
|
||||
} else {
|
||||
if (!$DB->update_record('user', $usernew)) {
|
||||
print_error('cannotupdateuser', 'message');
|
||||
}
|
||||
$DB->update_record('user', $usernew);
|
||||
// pass a true $userold here
|
||||
if (! $authplugin->user_update($user, $userform->get_data())) {
|
||||
// auth update failed, rollback for moodle
|
||||
|
@ -36,15 +36,12 @@ if (empty($preferences['newemailattemptsleft'])) {
|
||||
print_continue("$CFG->wwwroot/user/view.php?id=$user->id");
|
||||
} else {
|
||||
// update user email
|
||||
if (!$DB->set_field('user', 'email', $user->email, array('id' => $user->id))) {
|
||||
print_error('cannotupdateuser');
|
||||
} else {
|
||||
events_trigger('user_updated', $user);
|
||||
$a->email = $user->email;
|
||||
$stremailupdatesuccess = get_string('auth_emailupdatesuccess', 'auth', $a);
|
||||
print_box($stremailupdatesuccess, 'center');
|
||||
print_continue("$CFG->wwwroot/user/view.php?id=$user->id");
|
||||
}
|
||||
$DB->set_field('user', 'email', $user->email, array('id' => $user->id));
|
||||
events_trigger('user_updated', $user);
|
||||
$a->email = $user->email;
|
||||
$stremailupdatesuccess = get_string('auth_emailupdatesuccess', 'auth', $a);
|
||||
print_box($stremailupdatesuccess, 'center');
|
||||
print_continue("$CFG->wwwroot/user/view.php?id=$user->id");
|
||||
}
|
||||
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user