From 90ee78e21ca64d464ed522447b6185aa24b90259 Mon Sep 17 00:00:00 2001
From: skodak <skodak>
Date: Tue, 17 Feb 2009 16:33:32 +0000
Subject: [PATCH] MDL-18293 removing unused error strings (now replaced by
 exceptions)

---
 course/editcategory.php         |  4 +---
 course/index.php                | 12 +++---------
 course/lib.php                  | 17 ++++-------------
 course/mod.php                  |  4 +---
 course/modedit.php              |  4 +---
 lang/en_utf8/error.php          |  7 -------
 mod/glossary/comment.php        |  8 +++-----
 mod/glossary/editcategories.php |  9 +++------
 mod/hotpot/lib.php              |  4 +---
 user/profile/definelib.php      | 16 ++++------------
 10 files changed, 21 insertions(+), 64 deletions(-)

diff --git a/course/editcategory.php b/course/editcategory.php
index 4759f54036..1b03cf1c56 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 e01fe6408c..a1c1427aba 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 ac09518017..af13091424 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 77044a02de..a01b065eaf 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 eea05a9fa4..e12e7d639a 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 c2e8dcb261..f4625b2d97 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 014ae18ea8..c6b5dafe17 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&amp;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&amp;eid=$entry->id", "$updatedcomment->id",$cm->id);
+
         redirect("comments.php?id=$cm->id&amp;eid=$entry->id");
 
     } else {
diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php
index b37e837fa1..0213c0a0a5 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 "<p style=\"text-align:center\">" . get_string("edit"). " " . get_string("category","glossary") . "<span style=\"font-size:1.5em\">";
 
diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php
index f899b3d0f4..44d617a839 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 c0a96ba06d..ae744543d2 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);
-- 
2.39.5