1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00

Return error messages in correct format.

This commit is contained in:
Thomas Tanghus 2012-07-08 14:11:48 +02:00
parent 2028f4d3e0
commit 1bff3df170

View File

@ -35,20 +35,20 @@ if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
$file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']); $file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']);
} }
if(!$file) { if(!$file) {
OCP\JSON::error(array('message' => 'Import file was empty.')); OCP\JSON::error(array('data' => array('message' => 'Import file was empty.')));
exit(); exit();
} }
if(isset($_POST['method']) && $_POST['method'] == 'new'){ if(isset($_POST['method']) && $_POST['method'] == 'new'){
$id = OC_Contacts_Addressbook::add(OCP\USER::getUser(), $_POST['addressbookname']); $id = OC_Contacts_Addressbook::add(OCP\USER::getUser(), $_POST['addressbookname']);
if(!$id) { if(!$id) {
OCP\JSON::error(array('message' => 'Error creating address book.')); OCP\JSON::error(array('data' => array('message' => 'Error creating address book.')));
exit(); exit();
} }
OC_Contacts_Addressbook::setActive($id, 1); OC_Contacts_Addressbook::setActive($id, 1);
}else{ }else{
$id = $_POST['id']; $id = $_POST['id'];
if(!$id) { if(!$id) {
OCP\JSON::error(array('message' => 'Error getting the ID of the address book.')); OCP\JSON::error(array('data' => array('message' => 'Error getting the ID of the address book.')));
exit(); exit();
} }
OC_Contacts_App::getAddressbook($id); // is owner access check OC_Contacts_App::getAddressbook($id); // is owner access check
@ -77,7 +77,7 @@ writeProgress('70');
$imported = 0; $imported = 0;
$failed = 0; $failed = 0;
if(!count($parts) > 0) { if(!count($parts) > 0) {
OCP\JSON::error(array('message' => 'No contacts to import in .'.$_POST['file'].' Please check if the file is corrupted.')); OCP\JSON::error(array('data' => array('message' => 'No contacts to import in .'.$_POST['file'].' Please check if the file is corrupted.')));
exit(); exit();
} }
foreach($parts as $part){ foreach($parts as $part){