diff --git a/course/editcategory.php b/course/editcategory.php index 4759f540367..1b03cf1c565 100644 --- a/course/editcategory.php +++ b/course/editcategory.php @@ -64,9 +64,7 @@ if ($mform->is_cancelled()) { $parent_cat = $DB->get_record('course_categories', array('id' => $newcategory->parent)); move_category($newcategory, $parent_cat); } - if (!$DB->update_record('course_categories', $newcategory)) { - print_error( "cannotupdatecategory", '', '', $newcategory->name); - } + $DB->update_record('course_categories', $newcategory); fix_course_sortorder(); } else { diff --git a/course/index.php b/course/index.php index e01fe6408c0..a1c1427aba7 100644 --- a/course/index.php +++ b/course/index.php @@ -156,9 +156,7 @@ if ($cattomove->parent != $moveto) { $newparent = $DB->get_record('course_categories', array('id'=>$moveto)); require_capability('moodle/category:manage', get_category_or_system_context($moveto)); - if (!move_category($cattomove, $newparent)) { - print_error('cannotupdatecategory', '', '', format_string($cattomove->name)); - } + move_category($cattomove, $newparent); } } } @@ -174,12 +172,8 @@ } require_capability('moodle/category:manage', get_category_or_system_context($tempcat->parent)); if ($tempcat) { - if (!$DB->set_field('course_categories', 'visible', $visible, array('id'=>$tempcat->id))) { - print_error('cannotupdatecategory', '', '', format_string($tempcat->name)); - } - if (!$DB->set_field('course', 'visible', $visible, array('category' => $tempcat->id))) { - print_error('cannotshowhidecoursesincategory', '', '', format_string($tempcat->name)); - } + $DB->set_field('course_categories', 'visible', $visible, array('id'=>$tempcat->id)); + $DB->set_field('course', 'visible', $visible, array('category' => $tempcat->id)); } } diff --git a/course/lib.php b/course/lib.php index ac095180175..af130914242 100644 --- a/course/lib.php +++ b/course/lib.php @@ -3281,10 +3281,7 @@ function category_delete_move($category, $newparentid, $showfeedback=true) { if ($children = $DB->get_records('course_categories', array('parent'=>$category->id), 'sortorder ASC')) { foreach ($children as $childcat) { - if (!move_category($childcat, $newparentcat)) { - notify("Error moving category $childcat->name"); - return false; - } + move_category($childcat, $newparentcat); } } @@ -3352,22 +3349,18 @@ function move_courses($courseids, $categoryid) { * Efficiently moves a category - NOTE that this can have * a huge impact access-control-wise... */ -function move_category ($category, $newparentcat) { +function move_category($category, $newparentcat) { global $CFG, $DB; $context = get_context_instance(CONTEXT_COURSECAT, $category->id); if (empty($newparentcat->id)) { - if (!$DB->set_field('course_categories', 'parent', 0, array('id'=>$category->id))) { - return false; - } + $DB->set_field('course_categories', 'parent', 0, array('id'=>$category->id)); $newparent = get_context_instance(CONTEXT_SYSTEM); } else { - if (!$DB->set_field('course_categories', 'parent', $newparentcat->id, array('id'=>$category->id))) { - return false; - } + $DB->set_field('course_categories', 'parent', $newparentcat->id, array('id'=>$category->id)); $newparent = get_context_instance(CONTEXT_COURSECAT, $newparentcat->id); } @@ -3378,8 +3371,6 @@ function move_category ($category, $newparentcat) { // and fix the sortorders fix_course_sortorder(); - - return true; } /** diff --git a/course/mod.php b/course/mod.php index 77044a02de0..a01b065eaf5 100644 --- a/course/mod.php +++ b/course/mod.php @@ -168,9 +168,7 @@ $cm->indent = 0; } - if (!$DB->set_field('course_modules', 'indent', $cm->indent, array('id'=>$cm->id))) { - print_error('cannotupdatelevel'); - } + $DB->set_field('course_modules', 'indent', $cm->indent, array('id'=>$cm->id)); rebuild_course_cache($cm->course); diff --git a/course/modedit.php b/course/modedit.php index eea05a9fa48..e12e7d639a0 100644 --- a/course/modedit.php +++ b/course/modedit.php @@ -298,9 +298,7 @@ condition_info::update_cm_from_form($cm,$fromform,true); } - if (!$DB->update_record('course_modules', $cm)) { - print_error('cannotupdatecoursemodule'); - } + $DB->update_record('course_modules', $cm); if (!$updateinstancefunction($fromform, $mform)) { print_error('cannotupdatemod', '', 'view.php?id=$course->id', $fromform->modulename); diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index c2e8dcb261a..f4625b2d979 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -129,14 +129,7 @@ $string['cannotsetupcapforplugin'] = 'Could not set up the capabilities for $a'; $string['cannotsetupcapformod'] = 'Could not set up the capabilities for $a'; $string['cannotshowhidecoursesincategory'] = 'Cannot show/hide the courses in category $a.'; $string['cannotunzipfile'] = 'Cannot unzip file'; -$string['cannotupgradeblock'] = 'Upgrade of blocks system failed! (Could not update version in config table.)'; -$string['cannotupgradecaps'] = 'Had difficulties upgrading the core capabilities for the Roles system'; -$string['cannotupdatecategory'] = 'Could not update the category ($a)'; -$string['cannotupdatecoursemodule'] = 'Could not update the course module'; -$string['cannotupdatecomment'] = 'Could not update this comment'; $string['cannotupdatecm'] = 'Could not update the course module with the correct section'; -$string['cannotupdatefield'] = 'Error updating field'; -$string['cannotupdatelevel'] = 'Could not update the indent level on that course module'; $string['cannotupdategroup'] = 'Error updating group'; $string['cannotupdaterate'] = 'Could not update an old rating ($a->id = $a->rating)'; $string['cannotupdaterecord'] = 'Could not update record ID $a'; diff --git a/mod/glossary/comment.php b/mod/glossary/comment.php index 014ae18ea86..c6b5dafe171 100644 --- a/mod/glossary/comment.php +++ b/mod/glossary/comment.php @@ -188,11 +188,9 @@ function glossary_comment_edit() { $updatedcomment->format = $data->format; $updatedcomment->timemodified = time(); - if (!$DB->update_record('glossary_comments', $updatedcomment)) { - print_error('cannotupdatecomment'); - } else { - add_to_log($course->id, 'glossary', 'update comment', "comments.php?id=$cm->id&eid=$entry->id", "$updatedcomment->id",$cm->id); - } + $DB->update_record('glossary_comments', $updatedcomment); + add_to_log($course->id, 'glossary', 'update comment', "comments.php?id=$cm->id&eid=$entry->id", "$updatedcomment->id",$cm->id); + redirect("comments.php?id=$cm->id&eid=$entry->id"); } else { diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index b37e837fa14..0213c0a0a5b 100644 --- a/mod/glossary/editcategories.php +++ b/mod/glossary/editcategories.php @@ -68,12 +68,9 @@ $cat->name = $name; $cat->usedynalink = $usedynalink; - if ( !$DB->update_record("glossary_categories", $cat) ) { - print_error('cannotupdatecategory'); - redirect("editcategories.php?id=$cm->id"); - } else { - add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook,$cm->id); - } + $DB->update_record("glossary_categories", $cat); + add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook,$cm->id); + } else { echo "

" . get_string("edit"). " " . get_string("category","glossary") . ""; diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php index f899b3d0f44..44d617a8398 100644 --- a/mod/hotpot/lib.php +++ b/mod/hotpot/lib.php @@ -584,9 +584,7 @@ function hotpot_add_chain(&$hotpot) { print_error('cannotaddcoursemoduletosection'); } - if (! $DB->set_field('course_modules', 'section', $sectionid, array("id"=>$hotpot->coursemodule))) { - print_error('cannotupdatecoursemodule'); - } + $DB->set_field('course_modules', 'section', $sectionid, array("id"=>$hotpot->coursemodule)); add_to_log($hotpot->course, "course", "add mod", "../mod/$hotpot->modulename/view.php?id=$hotpot->coursemodule", diff --git a/user/profile/definelib.php b/user/profile/definelib.php index c0a96ba06d8..ae744543d25 100644 --- a/user/profile/definelib.php +++ b/user/profile/definelib.php @@ -156,13 +156,9 @@ class profile_define_base { if (empty($data->id)) { unset($data->id); - if (!$data->id = $DB->insert_record('user_info_field', $data)) { - print_error('cannotcreatefield'); - } + $data->id = $DB->insert_record('user_info_field', $data); } else { - if (!$DB->update_record('user_info_field', $data)) { - print_error('cannotupdatefield'); - } + $DB->update_record('user_info_field', $data); } } @@ -427,13 +423,9 @@ function profile_edit_category($id, $redirect) { if (empty($data->id)) { unset($data->id); $data->sortorder = $DB->count_records('user_info_category') + 1; - if (!$DB->insert_record('user_info_category', $data, false)) { - print_error('cannotinsertcategory'); - } + $DB->insert_record('user_info_category', $data, false); } else { - if (!$DB->update_record('user_info_category', $data)) { - print_error('cannotupdatecategory'); - } + $DB->update_record('user_info_category', $data); } profile_reorder_categories(); redirect($redirect);