From: skodak Date: Wed, 3 Jun 2009 20:25:27 +0000 (+0000) Subject: MDL-18293 $DB->something is using exceptions, no need for ifs there, removing useless... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7826abc79f64292dab4ef37bc12a6672389157c8;p=moodle.git MDL-18293 $DB->something is using exceptions, no need for ifs there, removing useless strings --- diff --git a/lang/en_utf8/assignment.php b/lang/en_utf8/assignment.php index 685b2f8ca6..7834ed1426 100644 --- a/lang/en_utf8/assignment.php +++ b/lang/en_utf8/assignment.php @@ -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'; diff --git a/lang/en_utf8/chat.php b/lang/en_utf8/chat.php index f80b8d4cca..5e5b932ca1 100644 --- a/lang/en_utf8/chat.php +++ b/lang/en_utf8/chat.php @@ -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'; diff --git a/lang/en_utf8/choice.php b/lang/en_utf8/choice.php index c443c3ba0e..d7dafc8064 100644 --- a/lang/en_utf8/choice.php +++ b/lang/en_utf8/choice.php @@ -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'; diff --git a/lang/en_utf8/data.php b/lang/en_utf8/data.php index cd9aa96407..24d578a52e 100644 --- a/lang/en_utf8/data.php +++ b/lang/en_utf8/data.php @@ -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:'; diff --git a/lang/en_utf8/feedback.php b/lang/en_utf8/feedback.php index 1dddeefae3..f3d5dbc631 100644 --- a/lang/en_utf8/feedback.php +++ b/lang/en_utf8/feedback.php @@ -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'; diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 60299f48b4..c729ddec61 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -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)); } diff --git a/mod/chat/gui_basic/index.php b/mod/chat/gui_basic/index.php index 14d70c2b6f..b896c43366 100644 --- a/mod/chat/gui_basic/index.php +++ b/mod/chat/gui_basic/index.php @@ -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)); diff --git a/mod/chat/gui_header_js/insert.php b/mod/chat/gui_header_js/insert.php index 269ad81cd6..08cc3d5eba 100644 --- a/mod/chat/gui_header_js/insert.php +++ b/mod/chat/gui_header_js/insert.php @@ -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); diff --git a/mod/chat/gui_header_js/users.php b/mod/chat/gui_header_js/users.php index aaac235355..a8f976b695 100644 --- a/mod/chat/gui_header_js/users.php +++ b/mod/chat/gui_header_js/users.php @@ -40,10 +40,8 @@ $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 ;-) } diff --git a/mod/chat/lib.php b/mod/chat/lib.php index 9eac825aeb..883ab4b87c 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -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); } } } diff --git a/mod/choice/lib.php b/mod/choice/lib.php index f918c2c224..3e570c6182 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -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 { diff --git a/mod/data/field/file/field.class.php b/mod/data/field/file/field.class.php index 3e49966121..261753f4d6 100755 --- a/mod/data/field/file/field.class.php +++ b/mod/data/field/file/field.class.php @@ -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)); } diff --git a/mod/data/field/picture/field.class.php b/mod/data/field/picture/field.class.php index 6e81556289..962230f5b8 100755 --- a/mod/data/field/picture/field.class.php +++ b/mod/data/field/picture/field.class.php @@ -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)); } diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index ea195cf813..38c41bf800 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -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;