6 * This is a standard user-principal for CalDAV. This principal is also a
7 * collection and returns the caldav-proxy-read and caldav-proxy-write child
12 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
13 * @author Evert Pot (http://www.rooftopsolutions.nl/)
14 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
16 class Sabre_CalDAV_Principal_User extends Sabre_DAVACL_Principal implements Sabre_DAV_ICollection {
19 * Creates a new file in the directory
21 * @param string $name Name of the file
22 * @param resource $data Initial payload, passed as a readable stream resource.
23 * @throws Sabre_DAV_Exception_Forbidden
26 public function createFile($name, $data = null) {
28 throw new Sabre_DAV_Exception_Forbidden('Permission denied to create file (filename ' . $name . ')');
33 * Creates a new subdirectory
36 * @throws Sabre_DAV_Exception_Forbidden
39 public function createDirectory($name) {
41 throw new Sabre_DAV_Exception_Forbidden('Permission denied to create directory');
46 * Returns a specific child node, referenced by its name
49 * @return Sabre_DAV_INode
51 public function getChild($name) {
53 $principal = $this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/' . $name);
55 throw new Sabre_DAV_Exception_NotFound('Node with name ' . $name . ' was not found');
57 if ($name === 'calendar-proxy-read')
58 return new Sabre_CalDAV_Principal_ProxyRead($this->principalBackend, $this->principalProperties);
60 if ($name === 'calendar-proxy-write')
61 return new Sabre_CalDAV_Principal_ProxyWrite($this->principalBackend, $this->principalProperties);
63 throw new Sabre_DAV_Exception_NotFound('Node with name ' . $name . ' was not found');
68 * Returns an array with all the child nodes
70 * @return Sabre_DAV_INode[]
72 public function getChildren() {
75 if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-read')) {
76 $r[] = new Sabre_CalDAV_Principal_ProxyRead($this->principalBackend, $this->principalProperties);
78 if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-write')) {
79 $r[] = new Sabre_CalDAV_Principal_ProxyWrite($this->principalBackend, $this->principalProperties);
87 * Returns whether or not the child node exists
92 public function childExists($name) {
95 $this->getChild($name);
97 } catch (Sabre_DAV_Exception_NotFound $e) {
104 * Returns a list of ACE's for this node.
106 * Each ACE has the following properties:
107 * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
108 * currently the only supported privileges
109 * * 'principal', a url to the principal who owns the node
110 * * 'protected' (optional), indicating that this ACE is not allowed to
115 public function getACL() {
117 $acl = parent::getACL();
119 'privilege' => '{DAV:}read',
120 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-read',
124 'privilege' => '{DAV:}read',
125 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-write',