MDL-18293 $DB->something is using exceptions, no need for ifs there, removing useless strings

This commit is contained in:
skodak
2009-06-03 20:25:27 +00:00
parent a8d6ef8c6c
commit 7826abc79f
14 changed files with 17 additions and 47 deletions
-1
View 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';
-1
View 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';
-2
View 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';
-1
View 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:';
-2
View 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';
+1 -3
View 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));
}
+2 -3
View 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));
+2 -3
View 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);
+2 -4
View File
@@ -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 ;-)
}
+4 -9
View 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);
}
}
}
+2 -6
View 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 {
+1 -3
View File
@@ -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));
}
+1 -3
View File
@@ -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));
}
+2 -6
View 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;