/** * Updates an addressbook's properties * * See Sabre_DAV_IProperties for a description of the mutations array, as * well as the return value. * * @param mixed $addressbookid * @param array $mutations * @see Sabre_DAV_IProperties::updateProperties * @return bool|array */ public function updateAddressBook($addressbookid, \Sabre\DAV\PropPatch $mutations) { $supportedProperties = ['{DAV:}displayname', '{' . \Sabre\CardDAV\Plugin::NS_CARDDAV . '}addressbook-description']; $propPatch->handle($supportedProperties, function ($mutations) use($addressbookid) { $updates = []; foreach ($mutations as $property => $newValue) { switch ($property) { case '{DAV:}displayname': $updates['displayname'] = $newValue; break; case '{' . \Sabre\CardDAV\Plugin::NS_CARDDAV . '}addressbook-description': $updates['description'] = $newValue; break; } } AddrBook::edit($addressbookid, $updates['displayname'], $updates['description']); return true; }); }
/** * @NoAdminRequired */ public function update() { $pId = $this->params('id'); $pActive = $this->params('active'); $pName = $this->params('name'); $pDescription = $this->params('description'); $pName = isset($pName) ? trim(strip_tags($pName)) : null; $description = isset($pDescription) ? trim(strip_tags($pDescription)) : null; if (!$pId) { $msg = (string) $this->l10n->t('id is not set.'); } if (!$pName) { $msg = (string) $this->l10n->t('Cannot update addressbook with an empty name.'); } try { Addressbook::edit($pId, $pName, $pDescription); } catch (Exception $e) { //bailOut($e->getMessage()); } if (!Addressbook::setActive($pId, $pActive)) { $msg = (string) $this->l10n->t('Error (de)activating addressbook.'); } $addressbook = Addressbook::find($pId); $params = ['status' => 'success', 'data' => ['addressbook' => $addressbook]]; $response = new JSONResponse($params); return $response; }