Skip to content

Commit

Permalink
MDL-18293 $DB->something is using exceptions, no need for ifs there, …
Browse files Browse the repository at this point in the history
…removing useless strings
  • Loading branch information
skodak committed Jun 3, 2009
1 parent a8d6ef8 commit 7826abc
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 47 deletions.
1 change: 0 additions & 1 deletion lang/en_utf8/assignment.php
Expand Up @@ -26,7 +26,6 @@
$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';
Expand Down
1 change: 0 additions & 1 deletion lang/en_utf8/chat.php
Expand Up @@ -5,7 +5,6 @@
$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';
Expand Down
2 changes: 0 additions & 2 deletions lang/en_utf8/choice.php
Expand Up @@ -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';
Expand Down
1 change: 0 additions & 1 deletion lang/en_utf8/data.php
Expand Up @@ -30,7 +30,6 @@
$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:';
Expand Down
2 changes: 0 additions & 2 deletions lang/en_utf8/feedback.php
Expand Up @@ -20,8 +20,6 @@
$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';
Expand Down
4 changes: 1 addition & 3 deletions mod/assignment/lib.php
Expand Up @@ -1571,9 +1571,7 @@ function get_submission($userid=0, $createnew=false, $teachermodified=false) {
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));
}
Expand Down
5 changes: 2 additions & 3 deletions mod/chat/gui_basic/index.php
Expand Up @@ -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));

Expand Down
5 changes: 2 additions & 3 deletions mod/chat/gui_header_js/insert.php
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions mod/chat/gui_header_js/users.php
Expand Up @@ -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 ;-)
}
Expand Down
13 changes: 4 additions & 9 deletions mod/chat/lib.php
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions mod/choice/lib.php
Expand Up @@ -355,19 +355,15 @@ function choice_user_submit_response($formanswer, $choice, $userid, $courseid, $
$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;
$newanswer->choiceid = $choice->id;
$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 {
Expand Down
4 changes: 1 addition & 3 deletions mod/data/field/file/field.class.php
Expand Up @@ -138,9 +138,7 @@ function update_content($recordid, $value, $name) {
$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));
}

Expand Down
4 changes: 1 addition & 3 deletions mod/data/field/picture/field.class.php
Expand Up @@ -180,9 +180,7 @@ function update_content($recordid, $value, $name) {
$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));
}

Expand Down
8 changes: 2 additions & 6 deletions mod/feedback/lib.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7826abc

Please sign in to comment.