/** * Update and save the address book data to backend * NOTE: @see IPIMObject::update for consistency considerations. * * @param array $data * @return bool */ public function update(array $data) { if (!$this->hasPermission(\OCP\PERMISSION_UPDATE)) { throw new \Exception( self::$l10n->t('Access denied'), Http::STATUS_FORBIDDEN ); } if (!$this->getBackend()->hasContactMethodFor(\OCP\PERMISSION_UPDATE)) { throw new \Exception( self::$l10n->t('The backend for this address book does not support updating'), Http::STATUS_NOT_IMPLEMENTED ); } if (count($data) === 0) { return false; } foreach ($data as $key => $value) { switch ($key) { case 'displayname': $this->addressBookInfo['displayname'] = $value; break; case 'description': $this->addressBookInfo['description'] = $value; break; } } return $this->backend->updateAddressBook($this->getId(), $data); }
public function testUpdateAddressBookFail() { $this->assertFalse($this->backend->updateAddressBook('foo', array('description' => 'foo bar'))); }