4 * The UserCalenders class contains all calendars associated to one user
8 * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
9 * @author Evert Pot (http://www.rooftopsolutions.nl/)
10 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
12 class Sabre_CalDAV_AnimexxUserCalendars implements Sabre_DAV_IExtendedCollection, Sabre_DAVACL_IACL {
17 * @var Sabre_DAVACL_IPrincipalBackend
19 protected $principalBackend;
24 * @var array|Sabre_CalDAV_Backend_Abstract[]
26 protected $caldavBackends;
29 * Principal information
33 protected $principalInfo;
38 * @param Sabre_DAVACL_IPrincipalBackend $principalBackend
39 * @param array|Sabre_CalDAV_Backend_Abstract $caldavBackends
40 * @param mixed $userUri
42 public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend, $caldavBackends, $userUri) {
44 $this->principalBackend = $principalBackend;
45 $this->caldavBackends = $caldavBackends;
46 $this->principalInfo = $principalBackend->getPrincipalByPath($userUri);
51 * Returns the name of this object
55 public function getName() {
57 list(,$name) = Sabre_DAV_URLUtil::splitPath($this->principalInfo['uri']);
63 * Updates the name of this object
66 * @throws Sabre_DAV_Exception_Forbidden
69 public function setName($name) {
71 throw new Sabre_DAV_Exception_Forbidden();
78 * @throws Sabre_DAV_Exception_Forbidden
81 public function delete() {
83 throw new Sabre_DAV_Exception_Forbidden();
88 * Returns the last modification date
92 public function getLastModified() {
99 * Creates a new file under this object.
101 * This is currently not allowed
103 * @param string $filename
104 * @param resource $data
105 * @throws Sabre_DAV_Exception_MethodNotAllowed
106 * @return null|string|void
108 public function createFile($filename, $data=null) {
110 throw new Sabre_DAV_Exception_MethodNotAllowed('Creating new files in this collection is not supported');
115 * Creates a new directory under this object.
117 * This is currently not allowed.
119 * @param string $filename
120 * @throws Sabre_DAV_Exception_MethodNotAllowed
123 public function createDirectory($filename) {
125 throw new Sabre_DAV_Exception_MethodNotAllowed('Creating new collections in this collection is not supported');
130 * Returns a single calendar, by name
132 * @param string $name
133 * @throws Sabre_DAV_Exception_FileNotFound
134 * @todo needs optimizing
135 * @return \Sabre_CalDAV_Calendar|\Sabre_DAV_INode
137 public function getChild($name) {
139 foreach($this->getChildren() as $child) {
140 if ($name==$child->getName())
144 throw new Sabre_DAV_Exception_FileNotFound('Calendar with name \'' . $name . '\' could not be found');
149 * Checks if a calendar exists.
151 * @param string $name
152 * @todo needs optimizing
155 public function childExists($name) {
157 foreach($this->getChildren() as $child) {
158 if ($name==$child->getName())
167 * Returns a list of calendars
169 * @return array|\Sabre_DAV_INode[]
172 public function getChildren() {
174 foreach ($this->caldavBackends as $backend) {
175 $calendars = $backend->getCalendarsForUser($this->principalInfo["uri"]);
176 foreach($calendars as $calendar) {
177 $objs[] = new $calendar["calendar_class"]($this->principalBackend, $backend, $calendar);
180 //$objs[] = new Sabre_CalDAV_AnimexxUserZirkelCalendars($this->principalBackend, $this->caldavBackend, $this->username);
186 * Creates a new calendar
188 * @param string $name
189 * @param array $resourceType
190 * @param array $properties
191 * @throws Sabre_DAV_Exception_InvalidResourceType
194 public function createExtendedCollection($name, array $resourceType, array $properties) {
196 if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar',$resourceType) || count($resourceType)!==2) {
197 throw new Sabre_DAV_Exception_InvalidResourceType('Unknown resourceType for this collection');
199 $this->caldavBackends[0]->createCalendar($this->principalInfo['uri'], $name, $properties);
204 * Returns the owner principal
206 * This must be a url to a principal, or null if there's no owner
208 * @return string|null
210 public function getOwner() {
212 return $this->principalInfo['uri'];
217 * Returns a group principal
219 * This must be a url to a principal, or null if there's no owner
221 * @return string|null
223 public function getGroup() {
230 * Returns a list of ACE's for this node.
232 * Each ACE has the following properties:
233 * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
234 * currently the only supported privileges
235 * * 'principal', a url to the principal who owns the node
236 * * 'protected' (optional), indicating that this ACE is not allowed to
241 public function getACL() {
244 'privilege' => '{DAV:}read',
245 'principal' => $this->principalInfo['uri'],
249 'privilege' => '{DAV:}write',
250 'principal' => $this->principalInfo['uri'],
254 'privilege' => '{DAV:}read',
255 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write',
259 'privilege' => '{DAV:}write',
260 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write',
264 'privilege' => '{DAV:}read',
265 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-read',
276 * This method will receive a list of new ACE's.
279 * @throws Sabre_DAV_Exception_MethodNotAllowed
282 public function setACL(array $acl) {
284 throw new Sabre_DAV_Exception_MethodNotAllowed('Changing ACL is not yet supported');
290 * Returns the list of supported privileges for this node.
292 * The returned data structure is a list of nested privileges.
293 * See Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet for a simple
294 * standard structure.
296 * If null is returned from this method, the default privilege set is used,
297 * which is fine for most common usecases.
301 function getSupportedPrivilegeSet()