/** * @NoAdminRequired */ public function newContactSave() { $postRequestAll = $this->getParams(); $pHiddenField = $this->params('hiddenfield'); $pAddressbook = (int) $this->params('addressbooks'); if (isset($pHiddenField) && $pHiddenField === 'newitContact') { $vcard = ContactsApp::createVCardFromRequest($postRequestAll); try { $id = VCard::add(intval($pAddressbook), $vcard, null, true); $addressBookPerm = Addressbook::find($pAddressbook); $aFavourites = array(); $carddata = VCard::find($id); $vcard = VObject\Reader::read($carddata['carddata']); $carddata['photo'] = ''; $fullname = strtoupper(substr($carddata['fullname'], 0, 1)); $newLetter = $fullname; $carddata['letter'] = $newLetter; $details = VCard::structureContact($vcard); $cardOutput = ContactsApp::renderSingleCard($details, $carddata, $addressBookPerm, $aFavourites); $params = ['status' => 'success', 'data' => ['id' => $id, 'card' => $cardOutput, 'letter' => $newLetter, 'addrBookId' => $pAddressbook]]; $response = new JSONResponse($params); return $response; $response = new JSONResponse($params); return $response; } catch (Exception $e) { $params = ['status' => 'error', 'message' => $e->getMessage()]; $response = new JSONResponse($params); return $response; } } }