]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18293 $DB->something is using exceptions, no need for ifs there, removing useless...
authorskodak <skodak>
Wed, 3 Jun 2009 20:25:27 +0000 (20:25 +0000)
committerskodak <skodak>
Wed, 3 Jun 2009 20:25:27 +0000 (20:25 +0000)
14 files changed:
lang/en_utf8/assignment.php
lang/en_utf8/chat.php
lang/en_utf8/choice.php
lang/en_utf8/data.php
lang/en_utf8/feedback.php
mod/assignment/lib.php
mod/chat/gui_basic/index.php
mod/chat/gui_header_js/insert.php
mod/chat/gui_header_js/users.php
mod/chat/lib.php
mod/choice/lib.php
mod/data/field/file/field.class.php
mod/data/field/picture/field.class.php
mod/feedback/lib.php

index 685b2f8ca647a10c58bf525e60cc5e66711757ee..7834ed14267b6b1a57093581208a58f0438f7922 100644 (file)
@@ -26,7 +26,6 @@ $string['assignmentname'] = 'Assignment name';
 $string['assignmenttype'] = 'Assignment type';
 $string['availabledate'] = 'Available from';
 $string['cannotdeletefiles'] = 'An error occurred and files could not be deleted';
-$string['cannotinsertempty'] = 'Could not insert a new empty submission';
 $string['cannotviewassignment'] = 'You can not view this assignment';
 $string['comment'] = 'Comment';
 $string['commentinline'] = 'Comment inline';
index f80b8d4cca075aa947d4409123cdc54c41beeb0f..5e5b932ca1bc890096059e0f263c06c81ad05825 100644 (file)
@@ -5,7 +5,6 @@ $string['ajax'] = 'Version using Ajax';
 $string['autoscroll'] = 'Auto Scroll';
 $string['beep'] = 'beep';
 $string['cantlogin'] = 'Could not log in to chat room!!';
-$string['cantinsert'] = 'Could not insert a chat message!';
 $string['chat:chat'] = 'Access a chat room';
 $string['chat:deletelog'] = 'Delete chat logs';
 $string['chat:exportsession'] = 'Export chat session';
index c443c3ba0ec2b33665250caeec7def89c69a7a45..d7dafc8064d4c9039d62251864a7e905d5133f18 100644 (file)
@@ -5,8 +5,6 @@
 $string['addmorechoices'] = 'Add more choices';
 $string['allowupdate'] = 'Allow choice to be updated';
 $string['answered'] = 'Answered';
-$string['cannotupdatechoice'] = 'Could not update your choice because of a database error';
-$string['cannotsavechoice'] = 'Could not save your choice';
 $string['choice'] = 'Choice';
 $string['choice:choose'] = 'Record a choice';
 $string['choice:deleteresponses'] = 'Delete responses';
index cd9aa964076bfc26395eaff66d0ea266b9bd43b5..24d578a52e8a6135db0dc4a813ee7a19bbd33b17 100644 (file)
@@ -30,7 +30,6 @@ $string['cannotadd'] = 'Can not add entries!';
 $string['cannotdeletepreset'] = 'Error deleting a preset!';
 $string['cannotrate'] = 'Rating of items not allowed!';
 $string['cannotunziptopreset'] = 'Cannot unzip to the preset directory';
-$string['cannotinsertempty'] = 'Could not make an empty record!';
 $string['cancel'] = 'Cancel';
 $string['checkbox'] = 'Checkbox';
 $string['chooseexportfields'] = 'Choose the fields you wish to export:';
index 1dddeefae3557e7c2f27b847f2f8f864ce25f45c..f3d5dbc631b7e8bc52472272f87237537a053602 100644 (file)
@@ -20,8 +20,6 @@ $string['confirmdeletetemplate'] = 'Are you sure you want to delete this templat
 $string['confirmusetemplate'] = 'Are you sure you want to use this template?';
 $string['average'] = 'Average';
 $string['bold'] = 'Bold';
-$string['cannotcreatetmpfeedback'] = 'Cannot create temporary feedback'; 
-$string['cannotcreatecompletedfeedback'] = 'Cannot create completed feedback'; 
 $stirng['cannotloadxml'] = 'failed to loading xml';
 $string['cannotunmap'] = 'Database problem, unable to unmap';
 $string['cannotmapfeedback'] = 'Database problem, unable to map feedback to course';
index 60299f48b4b3300d54db103b322824a5fd958ce4..c729ddec61b7940834844d0caa6267289a55759d 100644 (file)
@@ -1571,9 +1571,7 @@ class assignment_base {
             return $submission;
         }
         $newsubmission = $this->prepare_new_submission($userid, $teachermodified);
-        if (!$DB->insert_record("assignment_submissions", $newsubmission)) {
-            print_error('cannotinsertempty', 'assignment');
-        }
+        $DB->insert_record("assignment_submissions", $newsubmission);
 
         return $DB->get_record('assignment_submissions', array('assignment'=>$this->assignment->id, 'userid'=>$userid));
     }
index 14d70c2b6f03bf9aa104029ad54f7ab074b3e5e1..b896c4336671eb8a8d3906181b7093698be0a262 100644 (file)
@@ -80,9 +80,8 @@
             $newmessage->systrem = 0;
             $newmessage->message = $message;
             $newmessage->timestamp = time();
-            if (!$DB->insert_record('chat_messages', $newmessage) || !$DB->insert_record('chat_messages_current', $newmessage)) {
-                print_error('cantinsert', 'chat');
-            }
+            $DB->insert_record('chat_messages', $newmessage);
+            $DB->insert_record('chat_messages_current', $newmessage);
 
             $DB->set_field('chat_users', 'lastmessageping', time(), array('sid'=>$chat_sid));
 
index 269ad81cd62a50f7e9790ddca86d3dd694d8fcdb..08cc3d5ebab93b4c3696e132fdd65dc3d84d02df 100644 (file)
@@ -49,9 +49,8 @@
         $message->message = $chat_message;
         $message->timestamp = time();
 
-        if (!$DB->insert_record('chat_messages', $message) || !$DB->insert_record('chat_messages_current', $message)) {
-            print_error('cantinsert', 'chat');
-        }
+        $DB->insert_record('chat_messages', $message);
+        $DB->insert_record('chat_messages_current', $message);
 
         $chatuser->lastmessageping = time() - 2;
         $DB->update_record('chat_users', $chatuser);
index aaac235355bf8f91f1f0cd259490c68acba786ba..a8f976b695ddc1320dc53134d7d21edad3217b52 100644 (file)
         $message->system    = 0;
         $message->timestamp = time();
 
-        if (!$DB->insert_record('chat_messages', $message) ||
-            !$DB->insert_record('chat_messages_current', $message)) {
-            print_error('cantinsert', 'chat');
-        }
+        $DB->insert_record('chat_messages', $message);
+        $DB->insert_record('chat_messages_current', $message);
 
         $chatuser->lastmessageping = time();          // A beep is a ping  ;-)
     }
index 9eac825aebdfb75844c770b1956a78a171db1671..883ab4b87cc5fb54c0671af1baa30a74be3d5580 100644 (file)
@@ -646,10 +646,8 @@ function chat_login_user($chatid, $version, $groupid, $course) {
             $message->system    = 1;
             $message->timestamp = time();
 
-            if (!$DB->insert_record('chat_messages', $message) || !$DB->insert_record('chat_messages_current', $message))
-            {
-                print_error('cantinsert', 'chat');
-            }
+            $DB->insert_record('chat_messages', $message);
+            $DB->insert_record('chat_messages_current', $message);
         }
     }
 
@@ -683,11 +681,8 @@ function chat_delete_old_users() {
             $message->system    = 1;
             $message->timestamp = time();
 
-            if (!$DB->insert_record('chat_messages', $message)
-                || !$DB->insert_record('chat_messages_current', $message) )
-            {
-                print_error('cantinsert', 'chat');
-            }
+            $DB->insert_record('chat_messages', $message);
+            $DB->insert_record('chat_messages_current', $message);
         }
     }
 }
index f918c2c224302b5a38202bb022fddf36c355ce93..3e570c6182947930eac5f1093e2113a32a2abb80 100644 (file)
@@ -355,9 +355,7 @@ WHERE
             $newanswer = $current;
             $newanswer->optionid = $formanswer;
             $newanswer->timemodified = time();
-            if (! $DB->update_record("choice_answers", $newanswer)) {
-                print_error('cannotupdatechoice', 'choice');
-            }
+            $DB->update_record("choice_answers", $newanswer);
             add_to_log($courseid, "choice", "choose again", "view.php?id=$cm->id", $choice->id, $cm->id);
         } else {
             $newanswer = NULL;
@@ -365,9 +363,7 @@ WHERE
             $newanswer->userid = $userid;
             $newanswer->optionid = $formanswer;
             $newanswer->timemodified = time();
-            if (! $DB->insert_record("choice_answers", $newanswer)) {
-                print_error('cannotsavechoice', 'choice');
-            }
+            $DB->insert_record("choice_answers", $newanswer);
             add_to_log($courseid, "choice", "choose", "view.php?id=$cm->id", $choice->id, $cm->id);
         }
     } else {
index 3e49966121e0df2d5abaf0a66a886a8f82eea5b3..261753f4d6eae10dbd202122fb49029312b81e05 100755 (executable)
@@ -138,9 +138,7 @@ class data_field_file extends data_field_base {
             $content = new object();
             $content->fieldid  = $this->field->id;
             $content->recordid = $recordid;
-            if ($id = $DB->insert_record('data_content', $content)) {
-                print_error('cannotinsertempty', 'data');
-            }
+            $id = $DB->insert_record('data_content', $content);
             $content = $DB->get_record('data_content', array('id'=>$id));
         }
 
index 6e815562897910dff70b63087e3c8d64496ef823..962230f5b8813742388914cf94a47f99773e1ba2 100755 (executable)
@@ -180,9 +180,7 @@ class data_field_picture extends data_field_base {
             $content = new object();
             $content->fieldid  = $this->field->id;
             $content->recordid = $recordid;
-            if ($id = $DB->insert_record('data_content', $content)) {
-                print_error('cannotinsertempty', 'data');
-            }
+            $id = $DB->insert_record('data_content', $content);
             $content = $DB->get_record('data_content', array('id'=>$id));
         }
 
index ea195cf8133b23dd39a4aea8a1b9f10d3cc2ff38..38c41bf8009bb9b2ba78de9a80126e6a4ae041d3 100644 (file)
@@ -1244,9 +1244,7 @@ function feedback_set_tmp_values($feedbackcompleted) {
     // $tmpcpl = $feedbackcompleted;
     unset($tmpcpl->id);
     $tmpcpl->timemodified = time();
-    if(!$tmpcpl->id = $DB->insert_record('feedback_completedtmp', $tmpcpl)) {
-        print_error('cannotcreatetmpfeedback', 'feedback');
-    }
+    $tmpcpl->id = $DB->insert_record('feedback_completedtmp', $tmpcpl);
     //get all values of original-completed
     if(!$values = $DB->get_records('feedback_value', array('completed'=>$feedbackcompleted->id))) {
         return;
@@ -1283,9 +1281,7 @@ function feedback_save_tmp_values($feedbackcompletedtmp, $feedbackcompleted, $us
         unset($newcpl->id);
         $newcpl->userid = $userid;
         $newcpl->timemodified = time();
-        if(!$newcpl->id = $DB->insert_record('feedback_completed', $newcpl)) {
-            print_error('cannotcreatecompletedfeedback', 'feedback');
-        }
+        $newcpl->id = $DB->insert_record('feedback_completed', $newcpl);
         //get all values of tmp-completed
         if(!$values = $DB->get_records('feedback_valuetmp', array('completed'=>$feedbackcompletedtmp->id))) {
             return false;