summaryrefslogtreecommitdiffstats
path: root/apps/contacts/ajax/addproperty.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2011-12-06 22:31:04 +0100
committerBart Visscher <bartv@thisnet.nl>2011-12-07 20:40:59 +0100
commit7e990a8e5c5bf266bd3fe36cd5bb99e49c6adb1e (patch)
tree01b639d59265fa14a359409c0617bfe8e65c0090 /apps/contacts/ajax/addproperty.php
parent247146f7036984e0ae7a6719e8adfca6c2251079 (diff)
downloadnextcloud-server-7e990a8e5c5bf266bd3fe36cd5bb99e49c6adb1e.tar.gz
nextcloud-server-7e990a8e5c5bf266bd3fe36cd5bb99e49c6adb1e.zip
Contacts: refactor common ajax functions to OC_Contacts_App
Diffstat (limited to 'apps/contacts/ajax/addproperty.php')
-rw-r--r--apps/contacts/ajax/addproperty.php24
1 files changed, 2 insertions, 22 deletions
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index e59a91e4a58..1ca4a85515b 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -23,31 +23,12 @@
// Init owncloud
require_once('../../../lib/base.php');
-$id = $_POST['id'];
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$card = OC_Contacts_VCard::find( $id );
-if( $card === false ){
- 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()){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.'))));
- exit();
-}
-
-$vcard = OC_VObject::parse($card['carddata']);
-// Check if the card is valid
-if(is_null($vcard)){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.'))));
- exit();
-}
+$id = $_POST['id'];
+$vcard = OC_Contacts_App::getContactVCard( $id );
$name = $_POST['name'];
$value = $_POST['value'];
@@ -56,7 +37,6 @@ $parameters = isset($_POST['parameteres'])?$_POST['parameters']:array();
$property = $vcard->addProperty($name, $value, $parameters);
$line = count($vcard->children) - 1;
-$checksum = md5($property->serialize());
OC_Contacts_VCard::edit($id,$vcard->serialize());