ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\CardDAV\AddressBook Class Reference

The AddressBook class represents a CardDAV addressbook, owned by a specific user. More...

+ Inheritance diagram for Sabre\CardDAV\AddressBook:
+ Collaboration diagram for Sabre\CardDAV\AddressBook:

Public Member Functions

 __construct (Backend\BackendInterface $carddavBackend, array $addressBookInfo)
 Constructor. More...
 
 getName ()
 Returns the name of the addressbook. More...
 
 getChild ($name)
 Returns a card. More...
 
 getChildren ()
 Returns the full list of cards. More...
 
 getMultipleChildren (array $paths)
 This method receives a list of paths in it's first argument. More...
 
 createDirectory ($name)
 Creates a new directory. More...
 
 createFile ($name, $vcardData=null)
 Creates a new file. More...
 
 delete ()
 Deletes the entire addressbook. More...
 
 setName ($newName)
 Renames the addressbook. More...
 
 getLastModified ()
 Returns the last modification date as a unix timestamp. More...
 
 propPatch (DAV\PropPatch $propPatch)
 Updates properties on this node. More...
 
 getProperties ($properties)
 Returns a list of properties for this nodes. More...
 
 getOwner ()
 Returns the owner principal. More...
 
 getChildACL ()
 This method returns the ACL's for card nodes in this address book. More...
 
 getSyncToken ()
 This method returns the current sync-token for this collection. More...
 
 getChanges ($syncToken, $syncLevel, $limit=null)
 The getChanges method returns all the changes that have happened, since the specified syncToken and the current collection. More...
 
- Public Member Functions inherited from Sabre\DAV\Collection
 getChild ($name)
 Returns a child object, by its name. More...
 
 childExists ($name)
 Checks is a child-node exists. More...
 
 createFile ($name, $data=null)
 Creates a new file in the directory. More...
 
 createDirectory ($name)
 Creates a new subdirectory. More...
 
 getLastModified ()
 Returns the last modification time as a unix timestamp. More...
 
 delete ()
 Deletes the current node. More...
 
 setName ($name)
 Renames the node. More...
 
 delete ()
 Deleted the current node. More...
 
 getName ()
 Returns the name of the node. More...
 
 setName ($name)
 Renames the node. More...
 
 getLastModified ()
 Returns the last modification time, as a unix timestamp. More...
 
 createFile ($name, $data=null)
 Creates a new file in the directory. More...
 
 createDirectory ($name)
 Creates a new subdirectory. More...
 
 getChild ($name)
 Returns a specific child node, referenced by its name. More...
 
 getChildren ()
 Returns an array with all the child nodes. More...
 
 childExists ($name)
 Checks if a child-node with the specified name exists. More...
 
- Public Member Functions inherited from Sabre\DAV\IProperties
 propPatch (PropPatch $propPatch)
 Updates properties on this node. More...
 
 getProperties ($properties)
 Returns a list of properties for this nodes. More...
 
- Public Member Functions inherited from Sabre\DAVACL\IACL
 getOwner ()
 Returns the owner principal. More...
 
 getGroup ()
 Returns a group principal. More...
 
 getACL ()
 Returns a list of ACE's for this node. More...
 
 setACL (array $acl)
 Updates the ACL. More...
 
 getSupportedPrivilegeSet ()
 Returns the list of supported privileges for this node. More...
 
 getSyncToken ()
 This method returns the current sync-token for this collection. More...
 
 getChanges ($syncToken, $syncLevel, $limit=null)
 The getChanges method returns all the changes that have happened, since the specified syncToken and the current collection. More...
 
 getMultipleChildren (array $paths)
 This method receives a list of paths in it's first argument. More...
 

Protected Attributes

 $addressBookInfo
 
 $carddavBackend
 

Detailed Description

The AddressBook class represents a CardDAV addressbook, owned by a specific user.

The AddressBook can contain multiple vcards

Author
Evert Pot (http://evertpot.com/) @license http://sabre.io/license/ Modified BSD License

Definition at line 17 of file AddressBook.php.

Constructor & Destructor Documentation

◆ __construct()

Sabre\CardDAV\AddressBook::__construct ( Backend\BackendInterface  $carddavBackend,
array  $addressBookInfo 
)

Constructor.

Parameters
Backend\BackendInterface$carddavBackend
array$addressBookInfo

Definition at line 41 of file AddressBook.php.

41 {
42
43 $this->carddavBackend = $carddavBackend;
44 $this->addressBookInfo = $addressBookInfo;
45
46 }

References Sabre\CardDAV\AddressBook\$addressBookInfo, and Sabre\CardDAV\AddressBook\$carddavBackend.

Member Function Documentation

◆ createDirectory()

Sabre\CardDAV\AddressBook::createDirectory (   $name)

Creates a new directory.

We actually block this, as subdirectories are not allowed in addressbooks.

Parameters
string$name
Returns
void

Reimplemented from Sabre\DAV\Collection.

Definition at line 119 of file AddressBook.php.

119 {
120
121 throw new DAV\Exception\MethodNotAllowed('Creating collections in addressbooks is not allowed');
122
123 }

◆ createFile()

Sabre\CardDAV\AddressBook::createFile (   $name,
  $vcardData = null 
)

Creates a new file.

The contents of the new file must be a valid VCARD.

This method may return an ETag.

Parameters
string$name
resource$vcardData
Returns
string|null

Reimplemented from Sabre\DAV\Collection.

Definition at line 136 of file AddressBook.php.

136 {
137
138 if (is_resource($vcardData)) {
139 $vcardData = stream_get_contents($vcardData);
140 }
141 // Converting to UTF-8, if needed
142 $vcardData = DAV\StringUtil::ensureUTF8($vcardData);
143
144 return $this->carddavBackend->createCard($this->addressBookInfo['id'], $name, $vcardData);
145
146 }
static ensureUTF8($input)
This method takes an input string, checks if it's not valid UTF-8 and attempts to convert it to UTF-8...
Definition: StringUtil.php:79

References $name, and Sabre\DAV\StringUtil\ensureUTF8().

+ Here is the call graph for this function:

◆ delete()

Sabre\CardDAV\AddressBook::delete ( )

Deletes the entire addressbook.

Returns
void

Implements Sabre\DAV\INode.

Definition at line 153 of file AddressBook.php.

153 {
154
155 $this->carddavBackend->deleteAddressBook($this->addressBookInfo['id']);
156
157 }

◆ getChanges()

Sabre\CardDAV\AddressBook::getChanges (   $syncToken,
  $syncLevel,
  $limit = null 
)

The getChanges method returns all the changes that have happened, since the specified syncToken and the current collection.

This function should return an array, such as the following:

[ 'syncToken' => 'The current synctoken', 'added' => [ 'new.txt', ], 'modified' => [ 'modified.txt', ], 'deleted' => [ 'foo.php.bak', 'old.txt' ] ];

The syncToken property should reflect the current syncToken of the collection, as reported getSyncToken(). This is needed here too, to ensure the operation is atomic.

If the syncToken is specified as null, this is an initial sync, and all members should be reported.

The modified property is an array of nodenames that have changed since the last token.

The deleted property is an array with nodenames, that have been deleted from collection.

The second argument is basically the 'depth' of the report. If it's 1, you only have to report changes that happened only directly in immediate descendants. If it's 2, it should also include changes from the nodes below the child collections. (grandchildren)

The third (optional) argument allows a client to specify how many results should be returned at most. If the limit is not specified, it should be treated as infinite.

If the limit (infinite or not) is higher than you're willing to return, you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.

If the syncToken is expired (due to data cleanup) or unknown, you must return null.

The limit is 'suggestive'. You are free to ignore it.

Parameters
string$syncToken
int$syncLevel
int$limit
Returns
array

Implements Sabre\DAV\Sync\ISyncCollection.

Definition at line 343 of file AddressBook.php.

343 {
344
345 if (!$this->carddavBackend instanceof Backend\SyncSupport) {
346 return null;
347 }
348
349 return $this->carddavBackend->getChangesForAddressBook(
350 $this->addressBookInfo['id'],
351 $syncToken,
352 $syncLevel,
353 $limit
354 );
355
356 }

◆ getChild()

Sabre\CardDAV\AddressBook::getChild (   $name)

Returns a card.

Parameters
string$name
Returns
Card

Reimplemented from Sabre\DAV\Collection.

Definition at line 65 of file AddressBook.php.

65 {
66
67 $obj = $this->carddavBackend->getCard($this->addressBookInfo['id'], $name);
68 if (!$obj) throw new DAV\Exception\NotFound('Card not found');
69 return new Card($this->carddavBackend, $this->addressBookInfo, $obj);
70
71 }

References $name.

◆ getChildACL()

Sabre\CardDAV\AddressBook::getChildACL ( )

This method returns the ACL's for card nodes in this address book.

The result of this method automatically gets passed to the card nodes in this address book.

Returns
array

Definition at line 249 of file AddressBook.php.

249 {
250
251 return [
252 [
253 'privilege' => '{DAV:}all',
254 'principal' => $this->getOwner(),
255 'protected' => true,
256 ],
257 ];
258
259 }
getOwner()
Returns the owner principal.

References Sabre\CardDAV\AddressBook\getOwner().

Referenced by Sabre\CardDAV\AddressBook\getChildren(), and Sabre\CardDAV\AddressBook\getMultipleChildren().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getChildren()

Sabre\CardDAV\AddressBook::getChildren ( )

Returns the full list of cards.

Returns
array

Implements Sabre\DAV\ICollection.

Definition at line 78 of file AddressBook.php.

78 {
79
80 $objs = $this->carddavBackend->getCards($this->addressBookInfo['id']);
81 $children = [];
82 foreach ($objs as $obj) {
83 $obj['acl'] = $this->getChildACL();
84 $children[] = new Card($this->carddavBackend, $this->addressBookInfo, $obj);
85 }
86 return $children;
87
88 }
getChildACL()
This method returns the ACL's for card nodes in this address book.

References Sabre\CardDAV\AddressBook\getChildACL().

+ Here is the call graph for this function:

◆ getLastModified()

Sabre\CardDAV\AddressBook::getLastModified ( )

Returns the last modification date as a unix timestamp.

Returns
void

Implements Sabre\DAV\INode.

Definition at line 176 of file AddressBook.php.

176 {
177
178 return null;
179
180 }

◆ getMultipleChildren()

Sabre\CardDAV\AddressBook::getMultipleChildren ( array  $paths)

This method receives a list of paths in it's first argument.

It must return an array with Node objects.

If any children are not found, you do not have to return them.

Parameters
string[]$paths
Returns
array

Implements Sabre\DAV\IMultiGet.

Definition at line 99 of file AddressBook.php.

99 {
100
101 $objs = $this->carddavBackend->getMultipleCards($this->addressBookInfo['id'], $paths);
102 $children = [];
103 foreach ($objs as $obj) {
104 $obj['acl'] = $this->getChildACL();
105 $children[] = new Card($this->carddavBackend, $this->addressBookInfo, $obj);
106 }
107 return $children;
108
109 }
if($argc< 2) $paths
Definition: migrateto20.php:44

References $paths, and Sabre\CardDAV\AddressBook\getChildACL().

+ Here is the call graph for this function:

◆ getName()

Sabre\CardDAV\AddressBook::getName ( )

Returns the name of the addressbook.

Returns
string

Implements Sabre\DAV\INode.

Definition at line 53 of file AddressBook.php.

53 {
54
55 return $this->addressBookInfo['uri'];
56
57 }

◆ getOwner()

Sabre\CardDAV\AddressBook::getOwner ( )

Returns the owner principal.

This must be a url to a principal, or null if there's no owner

Returns
string|null

Implements Sabre\DAVACL\IACL.

Definition at line 235 of file AddressBook.php.

235 {
236
237 return $this->addressBookInfo['principaluri'];
238
239 }

Referenced by Sabre\CardDAV\AddressBook\getChildACL().

+ Here is the caller graph for this function:

◆ getProperties()

Sabre\CardDAV\AddressBook::getProperties (   $properties)

Returns a list of properties for this nodes.

The properties list is a list of propertynames the client requested, encoded in clark-notation {xmlnamespace}tagname

If the array is empty, it means 'all properties' were requested.

Parameters
array$properties
Returns
array

Implements Sabre\DAV\IProperties.

Definition at line 211 of file AddressBook.php.

211 {
212
213 $response = [];
214 foreach ($properties as $propertyName) {
215
216 if (isset($this->addressBookInfo[$propertyName])) {
217
218 $response[$propertyName] = $this->addressBookInfo[$propertyName];
219
220 }
221
222 }
223
224 return $response;
225
226 }
$response

References $response.

◆ getSyncToken()

Sabre\CardDAV\AddressBook::getSyncToken ( )

This method returns the current sync-token for this collection.

This can be any string.

If null is returned from this function, the plugin assumes there's no sync information available.

Returns
string|null

Implements Sabre\DAV\Sync\ISyncCollection.

Definition at line 271 of file AddressBook.php.

271 {
272
273 if (
274 $this->carddavBackend instanceof Backend\SyncSupport &&
275 isset($this->addressBookInfo['{DAV:}sync-token'])
276 ) {
277 return $this->addressBookInfo['{DAV:}sync-token'];
278 }
279 if (
280 $this->carddavBackend instanceof Backend\SyncSupport &&
281 isset($this->addressBookInfo['{http://sabredav.org/ns}sync-token'])
282 ) {
283 return $this->addressBookInfo['{http://sabredav.org/ns}sync-token'];
284 }
285
286 }

◆ propPatch()

Sabre\CardDAV\AddressBook::propPatch ( DAV\PropPatch  $propPatch)

Updates properties on this node.

This method received a PropPatch object, which contains all the information about the update.

To update specific properties, call the 'handle' method on this object. Read the PropPatch documentation for more information.

Parameters
DAV\PropPatch$propPatch
Returns
void

Definition at line 194 of file AddressBook.php.

194 {
195
196 return $this->carddavBackend->updateAddressBook($this->addressBookInfo['id'], $propPatch);
197
198 }

◆ setName()

Sabre\CardDAV\AddressBook::setName (   $newName)

Renames the addressbook.

Parameters
string$newName
Returns
void

Implements Sabre\DAV\INode.

Definition at line 165 of file AddressBook.php.

165 {
166
167 throw new DAV\Exception\MethodNotAllowed('Renaming addressbooks is not yet supported');
168
169 }

Field Documentation

◆ $addressBookInfo

Sabre\CardDAV\AddressBook::$addressBookInfo
protected

Definition at line 26 of file AddressBook.php.

Referenced by Sabre\CardDAV\AddressBook\__construct().

◆ $carddavBackend

Sabre\CardDAV\AddressBook::$carddavBackend
protected

Definition at line 33 of file AddressBook.php.

Referenced by Sabre\CardDAV\AddressBook\__construct().


The documentation for this class was generated from the following file: