. * */ // Init owncloud require_once('../../../lib/base.php'); $aid = $_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(); } $addressbook = OC_Contacts_Addressbook::findAddressbook( $aid ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your addressbook!')))); exit(); } $fn = $_POST['fn']; $vcard = new Sabre_VObject_Component('VCARD'); $vcard->add(new Sabre_VObject_Property('FN',$fn)); $vcard->add(new Sabre_VObject_Property('UID',OC_Contacts_Addressbook::createUID())); $id = OC_Contacts_Addressbook::addCard($aid,$vcard->serialize()); $details = OC_Contacts_Addressbook::structureContact($vcard); $tmpl = new OC_Template('contacts','part.details'); $tmpl->assign('details',$details); $tmpl->assign('id',$id); $page = $tmpl->fetchPage(); echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'page' => $page )));