[collection-edit] Handle duplicate key error properly. Avoid SQL error on new.

This commit is contained in:
Andrew McMillan 2010-09-20 12:55:41 +12:00
parent c5c97ad5d2
commit a46f8bf613

View File

@ -89,8 +89,11 @@ if ( $can_write_collection && $editor->IsSubmit() ) {
else {
$c->messages[] = i18n("Updating Collection record.");
}
$editor->Write();
if ( isset($_FILES['ics_file']['tmp_name']) && $_FILES['ics_file']['tmp_name'] != '' ) {
if ( !$editor->Write() ) {
$c->messages[] = i18n("Failed to write collection.");
if ( $id > 0 ) $editor->GetRecord();
}
else if ( isset($_FILES['ics_file']['tmp_name']) && $_FILES['ics_file']['tmp_name'] != '' ) {
/**
* If the user has uploaded a .ics file as a calendar, we fake this out
* as if it were a "PUT" request against a collection. This is something
@ -116,7 +119,7 @@ if ( $can_write_collection && $editor->IsSubmit() ) {
}
}
else {
$editor->GetRecord();
if ( $id > 0 ) $editor->GetRecord();
if ( $editor->IsSubmit() ) {
$c->messages[] = i18n('You do not have permission to modify this record.');
}