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

The Card object represents a single Card from an addressbook. More...

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

Public Member Functions

 __construct (Backend\BackendInterface $carddavBackend, array $addressBookInfo, array $cardData)
 Constructor. More...
 
 getName ()
 Returns the uri for this object. More...
 
 get ()
 Returns the VCard-formatted object. More...
 
 put ($cardData)
 Updates the VCard-formatted object. More...
 
 delete ()
 Deletes the card. More...
 
 getContentType ()
 Returns the mime content-type. More...
 
 getETag ()
 Returns an ETag for this object. More...
 
 getLastModified ()
 Returns the last modification date as a unix timestamp. More...
 
 getSize ()
 Returns the size of this object in bytes. More...
 
 getOwner ()
 Returns the owner principal. More...
 
 getACL ()
 Returns a list of ACE's for this node. More...
 
- Public Member Functions inherited from Sabre\DAV\File
 put ($data)
 Replaces the contents of the file. More...
 
 get ()
 Returns the data. More...
 
 getSize ()
 Returns the size of the file, in bytes. More...
 
 getETag ()
 Returns the ETag for a file. More...
 
 getContentType ()
 Returns the mime-type for a file. More...
 
- Public Member Functions inherited from Sabre\DAV\Node
 getLastModified ()
 Returns the last modification time as a unix timestamp. More...
 
 delete ()
 Deletes the current node. More...
 
 setName ($name)
 Renames the node. More...
 
- Public Member Functions inherited from Sabre\DAVACL\IACL
 getGroup ()
 Returns a group principal. More...
 
 setACL (array $acl)
 Updates the ACL. More...
 
 getSupportedPrivilegeSet ()
 Returns the list of supported privileges for this node. More...
 

Protected Attributes

 $carddavBackend
 
 $cardData
 
 $addressBookInfo
 

Detailed Description

The Card object represents a single Card from an addressbook.

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

Definition at line 15 of file Card.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
Backend\BackendInterface$carddavBackend
array$addressBookInfo
array$cardData

Definition at line 47 of file Card.php.

References Sabre\CardDAV\Card\$addressBookInfo, Sabre\CardDAV\Card\$cardData, and Sabre\CardDAV\Card\$carddavBackend.

47  {
48 
49  $this->carddavBackend = $carddavBackend;
50  $this->addressBookInfo = $addressBookInfo;
51  $this->cardData = $cardData;
52 
53  }

Member Function Documentation

◆ delete()

Sabre\CardDAV\Card::delete ( )

Deletes the card.

Returns
void

Implements Sabre\DAV\INode.

Definition at line 109 of file Card.php.

109  {
110 
111  $this->carddavBackend->deleteCard($this->addressBookInfo['id'], $this->cardData['uri']);
112 
113  }

◆ get()

Sabre\CardDAV\Card::get ( )

Returns the VCard-formatted object.

Returns
string

Implements Sabre\DAV\IFile.

Definition at line 71 of file Card.php.

71  {
72 
73  // Pre-populating 'carddata' is optional. If we don't yet have it
74  // already, we fetch it from the backend.
75  if (!isset($this->cardData['carddata'])) {
76  $this->cardData = $this->carddavBackend->getCard($this->addressBookInfo['id'], $this->cardData['uri']);
77  }
78  return $this->cardData['carddata'];
79 
80  }

◆ getACL()

Sabre\CardDAV\Card::getACL ( )

Returns a list of ACE's for this node.

Each ACE has the following properties:

  • 'privilege', a string such as {DAV:}read or {DAV:}write. These are currently the only supported privileges
  • 'principal', a url to the principal who owns the node
  • 'protected' (optional), indicating that this ACE is not allowed to be updated.
Returns
array

Implements Sabre\DAVACL\IACL.

Definition at line 199 of file Card.php.

199  {
200 
201  // An alternative acl may be specified through the cardData array.
202  if (isset($this->cardData['acl'])) {
203  return $this->cardData['acl'];
204  }
205 
206  return [
207  [
208  'privilege' => '{DAV:}all',
209  'principal' => $this->addressBookInfo['principaluri'],
210  'protected' => true,
211  ],
212  ];
213 
214  }

◆ getContentType()

Sabre\CardDAV\Card::getContentType ( )

Returns the mime content-type.

Returns
string

Implements Sabre\DAV\IFile.

Definition at line 120 of file Card.php.

120  {
121 
122  return 'text/vcard; charset=utf-8';
123 
124  }

◆ getETag()

Sabre\CardDAV\Card::getETag ( )

Returns an ETag for this object.

Returns
string

Implements Sabre\DAV\IFile.

Definition at line 131 of file Card.php.

References $data.

131  {
132 
133  if (isset($this->cardData['etag'])) {
134  return $this->cardData['etag'];
135  } else {
136  $data = $this->get();
137  if (is_string($data)) {
138  return '"' . md5($data) . '"';
139  } else {
140  // We refuse to calculate the md5 if it's a stream.
141  return null;
142  }
143  }
144 
145  }
$data
Definition: bench.php:6

◆ getLastModified()

Sabre\CardDAV\Card::getLastModified ( )

Returns the last modification date as a unix timestamp.

Returns
int

Implements Sabre\DAV\INode.

Definition at line 152 of file Card.php.

152  {
153 
154  return isset($this->cardData['lastmodified']) ? $this->cardData['lastmodified'] : null;
155 
156  }

◆ getName()

Sabre\CardDAV\Card::getName ( )

Returns the uri for this object.

Returns
string

Implements Sabre\DAV\INode.

Definition at line 60 of file Card.php.

60  {
61 
62  return $this->cardData['uri'];
63 
64  }

◆ getOwner()

Sabre\CardDAV\Card::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 180 of file Card.php.

180  {
181 
182  return $this->addressBookInfo['principaluri'];
183 
184  }

◆ getSize()

Sabre\CardDAV\Card::getSize ( )

Returns the size of this object in bytes.

Returns
int

Implements Sabre\DAV\IFile.

Definition at line 163 of file Card.php.

163  {
164 
165  if (array_key_exists('size', $this->cardData)) {
166  return $this->cardData['size'];
167  } else {
168  return strlen($this->get());
169  }
170 
171  }

◆ put()

Sabre\CardDAV\Card::put (   $cardData)

Updates the VCard-formatted object.

Parameters
string$cardData
Returns
string|null

Implements Sabre\DAV\IFile.

Definition at line 88 of file Card.php.

References Sabre\CardDAV\Card\$cardData, and Sabre\DAV\StringUtil\ensureUTF8().

88  {
89 
90  if (is_resource($cardData))
91  $cardData = stream_get_contents($cardData);
92 
93  // Converting to UTF-8, if needed
95 
96  $etag = $this->carddavBackend->updateCard($this->addressBookInfo['id'], $this->cardData['uri'], $cardData);
97  $this->cardData['carddata'] = $cardData;
98  $this->cardData['etag'] = $etag;
99 
100  return $etag;
101 
102  }
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
+ Here is the call graph for this function:

Field Documentation

◆ $addressBookInfo

Sabre\CardDAV\Card::$addressBookInfo
protected

Definition at line 38 of file Card.php.

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

◆ $cardData

Sabre\CardDAV\Card::$cardData
protected

Definition at line 31 of file Card.php.

Referenced by Sabre\CardDAV\Card\__construct(), and Sabre\CardDAV\Card\put().

◆ $carddavBackend

Sabre\CardDAV\Card::$carddavBackend
protected

Definition at line 24 of file Card.php.

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


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