summaryrefslogtreecommitdiffstats
path: root/apps/contacts/ajax/deletecard.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2011-09-23 22:22:59 +0200
committerBart Visscher <bartv@thisnet.nl>2011-09-25 22:19:28 +0200
commit17e631bc5e327514596ce8761fe7f93d414a8717 (patch)
treea2e6bed923a493988028adafaaebcab5b9bfbd39 /apps/contacts/ajax/deletecard.php
parentdbddec9160338818009ec7020cec5a2b298aae7e (diff)
downloadnextcloud-server-17e631bc5e327514596ce8761fe7f93d414a8717.tar.gz
nextcloud-server-17e631bc5e327514596ce8761fe7f93d414a8717.zip
Use OC_JSON for json responses
Create OC_JSON class, for single point of creating json responses. No real logic change, this just cleans up the code a bit.
Diffstat (limited to 'apps/contacts/ajax/deletecard.php')
-rw-r--r--apps/contacts/ajax/deletecard.php12
1 files changed, 4 insertions, 8 deletions
diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php
index 7dde7d30a52..c69638320ed 100644
--- a/apps/contacts/ajax/deletecard.php
+++ b/apps/contacts/ajax/deletecard.php
@@ -28,23 +28,19 @@ $id = $_GET['id'];
$l10n = new OC_L10N('contacts');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in.'))));
- exit();
-}
-
+OC_JSON::checkLoggedIn();
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Contact could not be found.'))));
+ OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.'))));
exit();
}
$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact.'))));
+ OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.'))));
exit();
}
OC_Contacts_VCard::delete($id);
-echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id )));
+OC_JSON::success(array('data' => array( 'id' => $id )));