diff options
author | Mario <mario@mariovavti.com> | 2019-11-10 12:49:51 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-11-10 14:10:03 +0100 |
commit | 580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch) | |
tree | 82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/lib/CardDAV/AddressBook.php | |
parent | d22766f458a8539a40a57f3946459a9be1f21cd6 (diff) | |
download | volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2 volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip |
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/lib/CardDAV/AddressBook.php')
-rw-r--r-- | vendor/sabre/dav/lib/CardDAV/AddressBook.php | 141 |
1 files changed, 62 insertions, 79 deletions
diff --git a/vendor/sabre/dav/lib/CardDAV/AddressBook.php b/vendor/sabre/dav/lib/CardDAV/AddressBook.php index c9d28a091..434801554 100644 --- a/vendor/sabre/dav/lib/CardDAV/AddressBook.php +++ b/vendor/sabre/dav/lib/CardDAV/AddressBook.php @@ -1,12 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\CardDAV; use Sabre\DAV; use Sabre\DAVACL; /** - * The AddressBook class represents a CardDAV addressbook, owned by a specific user + * The AddressBook class represents a CardDAV addressbook, owned by a specific user. * * The AddressBook can contain multiple vcards * @@ -14,77 +16,78 @@ use Sabre\DAVACL; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class AddressBook extends DAV\Collection implements IAddressBook, DAV\IProperties, DAVACL\IACL, DAV\Sync\ISyncCollection, DAV\IMultiGet { - +class AddressBook extends DAV\Collection implements IAddressBook, DAV\IProperties, DAVACL\IACL, DAV\Sync\ISyncCollection, DAV\IMultiGet +{ use DAVACL\ACLTrait; /** - * This is an array with addressbook information + * This is an array with addressbook information. * * @var array */ protected $addressBookInfo; /** - * CardDAV backend + * CardDAV backend. * * @var Backend\BackendInterface */ protected $carddavBackend; /** - * Constructor + * Constructor. * * @param Backend\BackendInterface $carddavBackend - * @param array $addressBookInfo + * @param array $addressBookInfo */ - function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo) { - + public function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo) + { $this->carddavBackend = $carddavBackend; $this->addressBookInfo = $addressBookInfo; - } /** - * Returns the name of the addressbook + * Returns the name of the addressbook. * * @return string */ - function getName() { - + public function getName() + { return $this->addressBookInfo['uri']; - } /** - * Returns a card + * Returns a card. * * @param string $name + * * @return Card */ - function getChild($name) { - + public function getChild($name) + { $obj = $this->carddavBackend->getCard($this->addressBookInfo['id'], $name); - if (!$obj) throw new DAV\Exception\NotFound('Card not found'); - return new Card($this->carddavBackend, $this->addressBookInfo, $obj); + if (!$obj) { + throw new DAV\Exception\NotFound('Card not found'); + } + return new Card($this->carddavBackend, $this->addressBookInfo, $obj); } /** - * Returns the full list of cards + * Returns the full list of cards. * * @return array */ - function getChildren() { - + public function getChildren() + { $objs = $this->carddavBackend->getCards($this->addressBookInfo['id']); $children = []; foreach ($objs as $obj) { $obj['acl'] = $this->getChildACL(); $children[] = new Card($this->carddavBackend, $this->addressBookInfo, $obj); } - return $children; + return $children; } /** @@ -94,47 +97,47 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * If any children are not found, you do not have to return them. * * @param string[] $paths + * * @return array */ - function getMultipleChildren(array $paths) { - + public function getMultipleChildren(array $paths) + { $objs = $this->carddavBackend->getMultipleCards($this->addressBookInfo['id'], $paths); $children = []; foreach ($objs as $obj) { $obj['acl'] = $this->getChildACL(); $children[] = new Card($this->carddavBackend, $this->addressBookInfo, $obj); } - return $children; + return $children; } /** - * Creates a new directory + * Creates a new directory. * * We actually block this, as subdirectories are not allowed in addressbooks. * * @param string $name - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { throw new DAV\Exception\MethodNotAllowed('Creating collections in addressbooks is not allowed'); - } /** - * Creates a new file + * Creates a new file. * * The contents of the new file must be a valid VCARD. * * This method may return an ETag. * - * @param string $name + * @param string $name * @param resource $vcardData + * * @return string|null */ - function createFile($name, $vcardData = null) { - + public function createFile($name, $vcardData = null) + { if (is_resource($vcardData)) { $vcardData = stream_get_contents($vcardData); } @@ -142,41 +145,32 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie $vcardData = DAV\StringUtil::ensureUTF8($vcardData); return $this->carddavBackend->createCard($this->addressBookInfo['id'], $name, $vcardData); - } /** * Deletes the entire addressbook. - * - * @return void */ - function delete() { - + public function delete() + { $this->carddavBackend->deleteAddressBook($this->addressBookInfo['id']); - } /** - * Renames the addressbook + * Renames the addressbook. * * @param string $newName - * @return void */ - function setName($newName) { - + public function setName($newName) + { throw new DAV\Exception\MethodNotAllowed('Renaming addressbooks is not yet supported'); - } /** * Returns the last modification date as a unix timestamp. - * - * @return void */ - function getLastModified() { - + public function getLastModified() + { return null; - } /** @@ -189,12 +183,10 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * Read the PropPatch documentation for more information. * * @param DAV\PropPatch $propPatch - * @return void */ - function propPatch(DAV\PropPatch $propPatch) { - + public function propPatch(DAV\PropPatch $propPatch) + { return $this->carddavBackend->updateAddressBook($this->addressBookInfo['id'], $propPatch); - } /** @@ -206,39 +198,33 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * If the array is empty, it means 'all properties' were requested. * * @param array $properties + * * @return array */ - function getProperties($properties) { - + public function getProperties($properties) + { $response = []; foreach ($properties as $propertyName) { - if (isset($this->addressBookInfo[$propertyName])) { - $response[$propertyName] = $this->addressBookInfo[$propertyName]; - } - } return $response; - } /** - * Returns the owner principal + * Returns the owner principal. * * This must be a url to a principal, or null if there's no owner * * @return string|null */ - function getOwner() { - + public function getOwner() + { return $this->addressBookInfo['principaluri']; - } - /** * This method returns the ACL's for card nodes in this address book. * The result of this method automatically gets passed to the @@ -246,8 +232,8 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * * @return array */ - function getChildACL() { - + public function getChildACL() + { return [ [ 'privilege' => '{DAV:}all', @@ -255,10 +241,8 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie 'protected' => true, ], ]; - } - /** * This method returns the current sync-token for this collection. * This can be any string. @@ -268,8 +252,8 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * * @return string|null */ - function getSyncToken() { - + public function getSyncToken() + { if ( $this->carddavBackend instanceof Backend\SyncSupport && isset($this->addressBookInfo['{DAV:}sync-token']) @@ -282,7 +266,6 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie ) { return $this->addressBookInfo['{http://sabredav.org/ns}sync-token']; } - } /** @@ -336,12 +319,13 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * The limit is 'suggestive'. You are free to ignore it. * * @param string $syncToken - * @param int $syncLevel - * @param int $limit + * @param int $syncLevel + * @param int $limit + * * @return array */ - function getChanges($syncToken, $syncLevel, $limit = null) { - + public function getChanges($syncToken, $syncLevel, $limit = null) + { if (!$this->carddavBackend instanceof Backend\SyncSupport) { return null; } @@ -352,6 +336,5 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie $syncLevel, $limit ); - } } |