]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18293 $DB->somethiong is using exceptions, no need for ifs there, removing useles...
authorskodak <skodak>
Wed, 3 Jun 2009 20:16:20 +0000 (20:16 +0000)
committerskodak <skodak>
Wed, 3 Jun 2009 20:16:20 +0000 (20:16 +0000)
course/index.php
course/request.php
lang/en_utf8/error.php
lang/en_utf8/forum.php
lib/datalib.php
lib/moodlelib.php
lib/questionlib.php
mod/forum/lib.php
mod/forum/post.php

index df064a7253bb66e9c295739b6feb2f8912eb6dfa..e8de6cac0a056072d1b5acb729008af42d5bdfba 100644 (file)
         // Try and make one
         $tempcat = new object();
         $tempcat->name = get_string('miscellaneous');
-        if (!$tempcat->id = $DB->insert_record('course_categories', $tempcat)) {
-            print_error('cannotsetupcategory');
-        }
+        $tempcat->id = $DB->insert_record('course_categories', $tempcat);
         $tempcat->context = get_context_instance(CONTEXT_COURSECAT, $tempcat->id);
         mark_context_dirty('/'.SYSCONTEXTID);
         fix_course_sortorder(); // Required to build course_categories.depth and .path.
index aaa8050954d79a07882c436886d636c3d679a933..73eb6a28c6909cb0a4c615361c3cea90b6c0f54d 100644 (file)
@@ -62,9 +62,7 @@
 
     /// Record the request.
         $data->requester = $USER->id;
-        if (!$DB->insert_record('course_request', $data)) {
-            print_error('errorsavingrequest', '', $returnurl);
-        }
+        $DB->insert_record('course_request', $data);
 
     /// Notify the admin if required.
         if ($CFG->courserequestnotify) {
index d62a59071e3c3dd6754b1c4c8bb6b881dd2eb21f..1a1a58730ad478173ada7b8d6744f61ec44b9e2e 100644 (file)
@@ -80,7 +80,6 @@ $string['cannotimportformat'] = 'Sorry, importing this format is not yet impleme
 $string['cannotinsertgrade'] = 'Cannot insert grade item without course id!';
 $string['cannotinsertrate'] = 'Could not insert a new rating ($a->id = $a->rating)';
 $string['cannotinsertrecord'] = 'Could not insert new record ID $a';
-$string['cannotinsertkey'] = 'Cannot insert new key';
 $string['cannotmailconfirm'] = 'Error sending password change confirmation email';
 $string['cannotmanualctrack'] = 'Activity does not provide manual completion tracking';
 $string['cannotmapfield'] = 'Mapping collision detected - two fields maps to the same grade item $a';
@@ -120,7 +119,6 @@ $string['cannotsetpassword'] = 'Could not set user password!';
 $string['cannotsetprefgrade'] = 'Could not set preference aggregationview to $a for this grade category';
 $string['cannotsettheme'] = 'Could not set the theme!';
 $string['cannotsetupblock'] = 'Blocks tables could NOT be set up successfully!';
-$string['cannotsetupcategory'] = 'Serious error! Could not set up a default course category!';
 $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.';
index f5284e75ee46d6957239d9266797a6c5541132f1..e1c4875396acd5459ee7446fc764f739ab10ddf1 100644 (file)
@@ -46,9 +46,6 @@ $string['cannotsubscribe'] = 'Sorry, but you must be a group member to subscribe
 $string['cannotsplit'] = 'Discussions from this forum cannot be split';
 $string['cannotunsubscribe'] = 'Could not unsubscribe you from that forum';
 $string['cannotupdatecoursemoudle'] = 'Could not update course module with section id';
-$string['cannotupdatediscussion'] = 'Could not update the discussion';
-$string['cannotupdateforum'] = 'Can not update forum';
-$string['cannotupdatefirstpost'] = 'Could not update the first post';
 $string['cannotupdatepost'] = 'You can not update this post';
 $string['cannotremovesubscriber'] = 'Could not remove subscriber with id $a from this forum!';
 $string['cannotreply'] = 'You cannot reply to this post';
index 5ae2fcb272eeb1351c3e9ee4033ea295efc96663..1b7177b560c6e40ccefe78aa2d6e566369246ffd 100644 (file)
@@ -1313,9 +1313,7 @@ function get_course_category($catid=0) {
             $cat->depth        = 1;
             $cat->sortorder    = MAX_COURSES_IN_CATEGORY;
             $cat->timemodified = time();
-            if (!$catid = $DB->insert_record('course_categories', $cat)) {
-                print_error('cannotsetupcategory', 'error');
-            }
+            $catid = $DB->insert_record('course_categories', $cat);
             // make sure category context exists
             get_context_instance(CONTEXT_COURSECAT, $catid);
             mark_context_dirty('/'.SYSCONTEXTID);
index c48e438f444f41baafe10a3dde29d9409c8c32e4..756748ee1f0c663132b15ace2855c2531194c5b0 100644 (file)
@@ -2378,11 +2378,7 @@ function create_user_key($script, $userid, $instance=null, $iprestriction=null,
         // must be unique
         $key->value     = md5($userid.'_'.time().random_string(40));
     }
-
-    if (!$DB->insert_record('user_private_key', $key)) {
-        print_error('cannotinsertkey');
-    }
-
+    $DB->insert_record('user_private_key', $key);
     return $key->value;
 }
 
index 32a4849ec8a207a57c3c6092d48425ed62065864..d93bba5a0991286021289545d1e34fb5113d5166 100644 (file)
@@ -2062,9 +2062,7 @@ function question_new_attempt_uniqueid($modulename='quiz') {
 
     $attempt = new stdClass;
     $attempt->modulename = $modulename;
-    if (!$id = $DB->insert_record('question_attempts', $attempt)) {
-        print_error('cannotcreate', 'question');
-    }
+    $id = $DB->insert_record('question_attempts', $attempt);
     return $id;
 }
 
index 7c9b3f8393029f91cd68c9c86f722b786b5396e4..d617fd9431a8981c299cb46f930e2c5efc142d09 100644 (file)
@@ -184,20 +184,12 @@ function forum_update_instance($forum) {
         $post->message  = $forum->intro;
         $post->modified = $forum->timemodified;
 
-        if (! $DB->update_record('forum_posts', ($post))) {
-            print_error('cannotupdatefirstpost', 'forum');
-        }
-
+        $DB->update_record('forum_posts', $post);
         $discussion->name = $forum->name;
-
-        if (! $DB->update_record('forum_discussions', ($discussion))) {
-            print_error('cannotupdatediscussion', 'forum');
-        }
+        $DB->update_record('forum_discussions', $discussion);
     }
 
-    if (!$DB->update_record('forum', $forum)) {
-        print_error('cannotupdateforum', 'forum');
-    }
+    $DB->update_record('forum', $forum);
 
     forum_grade_item_update($forum);
 
index 1951b3cec0fbdb471d7f9b83091437d894861c41..6118a3fcead06543d9d1444bf637cfb9d833cf06 100644 (file)
             $newpost->parent  = 0;
             $newpost->subject = $name;
 
-            if (!$DB->update_record("forum_posts", $newpost)) {
-                print_error('cannotupdatediscussion', 'forum');
-            }
+            $DB->update_record("forum_posts", $newpost);
 
             forum_change_discussionid($post->id, $newid);