summaryrefslogtreecommitdiffstats
path: root/3rdparty/Sabre/CardDAV/Card.php
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/Sabre/CardDAV/Card.php')
-rwxr-xr-x[-rw-r--r--]3rdparty/Sabre/CardDAV/Card.php136
1 files changed, 83 insertions, 53 deletions
diff --git a/3rdparty/Sabre/CardDAV/Card.php b/3rdparty/Sabre/CardDAV/Card.php
index 2844eaf7ed6..d7c66333837 100644..100755
--- a/3rdparty/Sabre/CardDAV/Card.php
+++ b/3rdparty/Sabre/CardDAV/Card.php
@@ -2,10 +2,10 @@
/**
* The Card object represents a single Card from an addressbook
- *
+ *
* @package Sabre
* @subpackage CardDAV
- * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
+ * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
@@ -13,29 +13,29 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
/**
* CardDAV backend
- *
- * @var Sabre_CardDAV_Backend_Abstract
+ *
+ * @var Sabre_CardDAV_Backend_Abstract
*/
private $carddavBackend;
/**
* Array with information about this Card
- *
- * @var array
+ *
+ * @var array
*/
private $cardData;
/**
- * Array with information about the containing addressbook
- *
- * @var array
+ * Array with information about the containing addressbook
+ *
+ * @var array
*/
private $addressBookInfo;
/**
- * Constructor
- *
- * @param Sabre_CardDAV_Backend_Abstract $carddavBackend
+ * Constructor
+ *
+ * @param Sabre_CardDAV_Backend_Abstract $carddavBackend
* @param array $addressBookInfo
* @param array $cardData
*/
@@ -48,9 +48,9 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
}
/**
- * Returns the uri for this object
- *
- * @return string
+ * Returns the uri for this object
+ *
+ * @return string
*/
public function getName() {
@@ -59,25 +59,26 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
}
/**
- * Returns the VCard-formatted object
- *
- * @return string
+ * Returns the VCard-formatted object
+ *
+ * @return string
*/
public function get() {
- $cardData = $this->cardData['carddata'];
- $s = fopen('php://temp','r+');
- fwrite($s, $cardData);
- rewind($s);
- return $s;
+ // Pre-populating 'carddata' is optional. If we don't yet have it
+ // already, we fetch it from the backend.
+ if (!isset($this->cardData['carddata'])) {
+ $this->cardData = $this->carddavBackend->getCard($this->addressBookInfo['id'], $this->cardData['uri']);
+ }
+ return $this->cardData['carddata'];
}
/**
- * Updates the VCard-formatted object
- *
- * @param string $cardData
- * @return void
+ * Updates the VCard-formatted object
+ *
+ * @param string $cardData
+ * @return void
*/
public function put($cardData) {
@@ -87,14 +88,17 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
// Converting to UTF-8, if needed
$cardData = Sabre_DAV_StringUtil::ensureUTF8($cardData);
- $this->carddavBackend->updateCard($this->addressBookInfo['id'],$this->cardData['uri'],$cardData);
+ $etag = $this->carddavBackend->updateCard($this->addressBookInfo['id'],$this->cardData['uri'],$cardData);
$this->cardData['carddata'] = $cardData;
+ $this->cardData['etag'] = $etag;
+
+ return $etag;
}
/**
* Deletes the card
- *
+ *
* @return void
*/
public function delete() {
@@ -104,9 +108,9 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
}
/**
- * Returns the mime content-type
- *
- * @return string
+ * Returns the mime content-type
+ *
+ * @return string
*/
public function getContentType() {
@@ -115,20 +119,24 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
}
/**
- * Returns an ETag for this object
- *
- * @return string
+ * Returns an ETag for this object
+ *
+ * @return string
*/
public function getETag() {
- return '"' . md5($this->cardData['carddata']) . '"';
+ if (isset($this->cardData['etag'])) {
+ return $this->cardData['etag'];
+ } else {
+ return '"' . md5($this->get()) . '"';
+ }
}
/**
* Returns the last modification date as a unix timestamp
- *
- * @return time
+ *
+ * @return time
*/
public function getLastModified() {
@@ -137,21 +145,25 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
}
/**
- * Returns the size of this object in bytes
- *
+ * Returns the size of this object in bytes
+ *
* @return int
*/
public function getSize() {
- return strlen($this->cardData['carddata']);
+ if (array_key_exists('size', $this->cardData)) {
+ return $this->cardData['size'];
+ } else {
+ return strlen($this->get());
+ }
}
/**
* Returns the owner principal
*
- * This must be a url to a principal, or null if there's no owner
- *
+ * This must be a url to a principal, or null if there's no owner
+ *
* @return string|null
*/
public function getOwner() {
@@ -164,8 +176,8 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
* Returns a group principal
*
* This must be a url to a principal, or null if there's no owner
- *
- * @return string|null
+ *
+ * @return string|null
*/
public function getGroup() {
@@ -177,13 +189,13 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
* 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
+ * * '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.
- *
- * @return array
+ * * 'protected' (optional), indicating that this ACE is not allowed to
+ * be updated.
+ *
+ * @return array
*/
public function getACL() {
@@ -205,9 +217,9 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
/**
* Updates the ACL
*
- * This method will receive a list of new ACE's.
- *
- * @param array $acl
+ * This method will receive a list of new ACE's.
+ *
+ * @param array $acl
* @return void
*/
public function setACL(array $acl) {
@@ -216,5 +228,23 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
}
+ /**
+ * Returns the list of supported privileges for this node.
+ *
+ * The returned data structure is a list of nested privileges.
+ * See Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet for a simple
+ * standard structure.
+ *
+ * If null is returned from this method, the default privilege set is used,
+ * which is fine for most common usecases.
+ *
+ * @return array|null
+ */
+ public function getSupportedPrivilegeSet() {
+
+ return null;
+
+ }
+
}