4 class Sabre_CalDAV_AnimexxUserCalendars implements Sabre_DAV_IExtendedCollection, Sabre_DAVACL_IACL {
9 * @var Sabre_DAVACL_IPrincipalBackend
11 protected $principalBackend;
16 * @var array|Sabre_CalDAV_Backend_Common[]
18 protected $caldavBackends;
21 * Principal information
25 protected $principalInfo;
30 * @param Sabre_DAVACL_IPrincipalBackend $principalBackend
31 * @param array|Sabre_CalDAV_Backend_Common[] $caldavBackends
32 * @param mixed $userUri
34 public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend, $caldavBackends, $userUri) {
36 $this->principalBackend = $principalBackend;
37 $this->caldavBackends = $caldavBackends;
38 $this->principalInfo = $principalBackend->getPrincipalByPath($userUri);
43 * Returns the name of this object
47 public function getName() {
49 list(,$name) = Sabre_DAV_URLUtil::splitPath($this->principalInfo['uri']);
55 * Updates the name of this object
58 * @throws Sabre_DAV_Exception_Forbidden
61 public function setName($name) {
63 throw new Sabre_DAV_Exception_Forbidden();
70 * @throws Sabre_DAV_Exception_Forbidden
73 public function delete() {
75 throw new Sabre_DAV_Exception_Forbidden();
80 * Returns the last modification date
84 public function getLastModified() {
91 * Creates a new file under this object.
93 * This is currently not allowed
95 * @param string $filename
96 * @param resource $data
97 * @throws Sabre_DAV_Exception_MethodNotAllowed
98 * @return null|string|void
100 public function createFile($filename, $data=null) {
102 throw new Sabre_DAV_Exception_MethodNotAllowed('Creating new files in this collection is not supported');
107 * Creates a new directory under this object.
109 * This is currently not allowed.
111 * @param string $filename
112 * @throws Sabre_DAV_Exception_MethodNotAllowed
115 public function createDirectory($filename) {
117 throw new Sabre_DAV_Exception_MethodNotAllowed('Creating new collections in this collection is not supported');
122 * Returns a single calendar, by name
124 * @param string $name
125 * @throws Sabre_DAV_Exception_NotFound
126 * @todo needs optimizing
127 * @return \Sabre_CalDAV_Calendar|\Sabre_DAV_INode
129 public function getChild($name) {
131 foreach($this->getChildren() as $child) {
132 if ($name==$child->getName())
136 throw new Sabre_DAV_Exception_NotFound('Calendar with name \'' . $name . '\' could not be found');
141 * Checks if a calendar exists.
143 * @param string $name
144 * @todo needs optimizing
147 public function childExists($name) {
149 foreach($this->getChildren() as $child) {
150 if ($name==$child->getName())
159 * Returns a list of calendars
161 * @return array|\Sabre_DAV_INode[]
164 public function getChildren() {
166 foreach ($this->caldavBackends as $backend) {
167 $calendars = $backend->getCalendarsForUser($this->principalInfo["uri"]);
168 foreach($calendars as $calendar) {
169 $objs[] = new $calendar["calendar_class"]($this->principalBackend, $backend, $calendar);
177 * Creates a new calendar
179 * @param string $name
180 * @param array $resourceType
181 * @param array $properties
182 * @throws Sabre_DAV_Exception_InvalidResourceType
185 public function createExtendedCollection($name, array $resourceType, array $properties) {
187 if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar',$resourceType) || count($resourceType)!==2) {
188 throw new Sabre_DAV_Exception_InvalidResourceType('Unknown resourceType for this collection');
190 $this->caldavBackends[0]->createCalendar($this->principalInfo['uri'], $name, $properties);
195 * Returns the owner principal
197 * This must be a url to a principal, or null if there's no owner
199 * @return string|null
201 public function getOwner() {
203 return $this->principalInfo['uri'];
208 * Returns a group principal
210 * This must be a url to a principal, or null if there's no owner
212 * @return string|null
214 public function getGroup() {
221 * Returns a list of ACE's for this node.
223 * Each ACE has the following properties:
224 * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
225 * currently the only supported privileges
226 * * 'principal', a url to the principal who owns the node
227 * * 'protected' (optional), indicating that this ACE is not allowed to
232 public function getACL() {
235 'privilege' => '{DAV:}read',
236 'principal' => $this->principalInfo['uri'],
240 'privilege' => '{DAV:}write',
241 'principal' => $this->principalInfo['uri'],
245 'privilege' => '{DAV:}read',
246 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write',
250 'privilege' => '{DAV:}write',
251 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write',
255 'privilege' => '{DAV:}read',
256 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-read',
267 * This method will receive a list of new ACE's.
270 * @throws Sabre_DAV_Exception_MethodNotAllowed
273 public function setACL(array $acl) {
275 throw new Sabre_DAV_Exception_MethodNotAllowed('Changing ACL is not yet supported');
281 * Returns the list of supported privileges for this node.
283 * The returned data structure is a list of nested privileges.
284 * See Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet for a simple
285 * standard structure.
287 * If null is returned from this method, the default privilege set is used,
288 * which is fine for most common usecases.
292 function getSupportedPrivilegeSet()