summaryrefslogtreecommitdiffstats
path: root/apps/contacts/ajax/addproperty.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/contacts/ajax/addproperty.php')
-rw-r--r--apps/contacts/ajax/addproperty.php13
1 files changed, 5 insertions, 8 deletions
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index a311bba6e26..5a37f77f858 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -27,27 +27,24 @@ $id = $_POST['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();
}
$vcard = OC_Contacts_VCard::parse($card['carddata']);
// Check if the card is valid
if(is_null($vcard)){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('vCard could not be read.'))));
+ OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.'))));
exit();
}
@@ -75,4 +72,4 @@ $tmpl = new OC_Template('contacts','part.property');
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($property,$line));
$page = $tmpl->fetchPage();
-echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page )));
+OC_JSON::success(array('data' => array( 'page' => $page )));