summaryrefslogtreecommitdiffstats
path: root/3rdparty/Sabre/CalDAV/Principal/User.php
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/Sabre/CalDAV/Principal/User.php')
-rwxr-xr-x[-rw-r--r--]3rdparty/Sabre/CalDAV/Principal/User.php108
1 files changed, 59 insertions, 49 deletions
diff --git a/3rdparty/Sabre/CalDAV/Principal/User.php b/3rdparty/Sabre/CalDAV/Principal/User.php
index 034629b89b3..8453b877a73 100644..100755
--- a/3rdparty/Sabre/CalDAV/Principal/User.php
+++ b/3rdparty/Sabre/CalDAV/Principal/User.php
@@ -1,25 +1,25 @@
<?php
/**
- * CalDAV principal
+ * CalDAV principal
*
- * This is a standard user-principal for CalDAV. This principal is also a
- * collection and returns the caldav-proxy-read and caldav-proxy-write child
+ * This is a standard user-principal for CalDAV. This principal is also a
+ * collection and returns the caldav-proxy-read and caldav-proxy-write child
* principals.
- *
+ *
* @package Sabre
* @subpackage CalDAV
- * @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
*/
class Sabre_CalDAV_Principal_User extends Sabre_DAVACL_Principal implements Sabre_DAV_ICollection {
/**
- * Creates a new file in the directory
- *
- * @param string $name Name of the file
- * @param resource $data Initial payload, passed as a readable stream resource.
+ * Creates a new file in the directory
+ *
+ * @param string $name Name of the file
+ * @param resource $data Initial payload, passed as a readable stream resource.
* @throws Sabre_DAV_Exception_Forbidden
* @return void
*/
@@ -30,9 +30,9 @@ class Sabre_CalDAV_Principal_User extends Sabre_DAVACL_Principal implements Sabr
}
/**
- * Creates a new subdirectory
- *
- * @param string $name
+ * Creates a new subdirectory
+ *
+ * @param string $name
* @throws Sabre_DAV_Exception_Forbidden
* @return void
*/
@@ -43,45 +43,60 @@ class Sabre_CalDAV_Principal_User extends Sabre_DAVACL_Principal implements Sabr
}
/**
- * Returns a specific child node, referenced by its name
- *
- * @param string $name
- * @return Sabre_DAV_INode
+ * Returns a specific child node, referenced by its name
+ *
+ * @param string $name
+ * @return Sabre_DAV_INode
*/
public function getChild($name) {
+ $principal = $this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/' . $name);
+ if (!$principal) {
+ throw new Sabre_DAV_Exception_NotFound('Node with name ' . $name . ' was not found');
+ }
if ($name === 'calendar-proxy-read')
return new Sabre_CalDAV_Principal_ProxyRead($this->principalBackend, $this->principalProperties);
if ($name === 'calendar-proxy-write')
return new Sabre_CalDAV_Principal_ProxyWrite($this->principalBackend, $this->principalProperties);
- throw new Sabre_DAV_Exception_FileNotFound('Node with name ' . $name . ' was not found');
+ throw new Sabre_DAV_Exception_NotFound('Node with name ' . $name . ' was not found');
}
/**
- * Returns an array with all the child nodes
- *
- * @return Sabre_DAV_INode[]
+ * Returns an array with all the child nodes
+ *
+ * @return Sabre_DAV_INode[]
*/
public function getChildren() {
- return array(
- new Sabre_CalDAV_Principal_ProxyRead($this->principalBackend, $this->principalProperties),
- new Sabre_CalDAV_Principal_ProxyWrite($this->principalBackend, $this->principalProperties),
- );
+ $r = array();
+ if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-read')) {
+ $r[] = new Sabre_CalDAV_Principal_ProxyRead($this->principalBackend, $this->principalProperties);
+ }
+ if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-write')) {
+ $r[] = new Sabre_CalDAV_Principal_ProxyWrite($this->principalBackend, $this->principalProperties);
+ }
+
+ return $r;
}
/**
- * Checks if a child-node with the specified name exists
- *
- * @return bool
+ * Returns whether or not the child node exists
+ *
+ * @param string $name
+ * @return bool
*/
public function childExists($name) {
- return $name === 'calendar-proxy-read' || $name === 'calendar-proxy-write';
+ try {
+ $this->getChild($name);
+ return true;
+ } catch (Sabre_DAV_Exception_NotFound $e) {
+ return false;
+ }
}
@@ -89,33 +104,28 @@ class Sabre_CalDAV_Principal_User extends Sabre_DAVACL_Principal implements Sabr
* 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() {
- return array(
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => $this->principalProperties['uri'],
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-read',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-write',
- 'protected' => true,
- ),
+ $acl = parent::getACL();
+ $acl[] = array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-read',
+ 'protected' => true,
+ );
+ $acl[] = array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-write',
+ 'protected' => true,
);
+ return $acl;
}