source: pmb4.2/trunk/fuentes/pmb/admin/connecteurs/out/webdav/lib/Sabre/CalDAV/Principal/User.php @ 815

Last change on this file since 815 was 815, checked in by jrpelegrina, 4 years ago

Initial release of pmb 4.2

  • Property svn:executable set to *
File size: 3.8 KB
Line 
1<?php
2
3namespace Sabre\CalDAV\Principal;
4use Sabre\DAV;
5use Sabre\DAVACL;
6
7/**
8 * CalDAV principal
9 *
10 * This is a standard user-principal for CalDAV. This principal is also a
11 * collection and returns the caldav-proxy-read and caldav-proxy-write child
12 * principals.
13 *
14 * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved.
15 * @author Evert Pot (http://www.rooftopsolutions.nl/)
16 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
17 */
18class User extends DAVACL\Principal implements DAV\ICollection {
19
20    /**
21     * Creates a new file in the directory
22     *
23     * @param string $name Name of the file
24     * @param resource $data Initial payload, passed as a readable stream resource.
25     * @throws DAV\Exception\Forbidden
26     * @return void
27     */
28    public function createFile($name, $data = null) {
29
30        throw new DAV\Exception\Forbidden('Permission denied to create file (filename ' . $name . ')');
31
32    }
33
34    /**
35     * Creates a new subdirectory
36     *
37     * @param string $name
38     * @throws DAV\Exception\Forbidden
39     * @return void
40     */
41    public function createDirectory($name) {
42
43        throw new DAV\Exception\Forbidden('Permission denied to create directory');
44
45    }
46
47    /**
48     * Returns a specific child node, referenced by its name
49     *
50     * @param string $name
51     * @return DAV\INode
52     */
53    public function getChild($name) {
54
55        $principal = $this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/' . $name);
56        if (!$principal) {
57            throw new DAV\Exception\NotFound('Node with name ' . $name . ' was not found');
58        }
59        if ($name === 'calendar-proxy-read')
60            return new ProxyRead($this->principalBackend, $this->principalProperties);
61
62        if ($name === 'calendar-proxy-write')
63            return new ProxyWrite($this->principalBackend, $this->principalProperties);
64
65        throw new DAV\Exception\NotFound('Node with name ' . $name . ' was not found');
66
67    }
68
69    /**
70     * Returns an array with all the child nodes
71     *
72    * @return DAV\INode[]
73     */
74    public function getChildren() {
75
76        $r = array();
77        if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-read')) {
78            $r[] = new ProxyRead($this->principalBackend, $this->principalProperties);
79        }
80        if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-write')) {
81            $r[] = new ProxyWrite($this->principalBackend, $this->principalProperties);
82        }
83
84        return $r;
85
86    }
87
88    /**
89     * Returns whether or not the child node exists
90     *
91     * @param string $name
92     * @return bool
93     */
94    public function childExists($name) {
95
96        try {
97            $this->getChild($name);
98            return true;
99        } catch (DAV\Exception\NotFound $e) {
100            return false;
101        }
102
103    }
104
105    /**
106     * Returns a list of ACE's for this node.
107     *
108     * Each ACE has the following properties:
109     *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
110     *     currently the only supported privileges
111     *   * 'principal', a url to the principal who owns the node
112     *   * 'protected' (optional), indicating that this ACE is not allowed to
113     *      be updated.
114     *
115     * @return array
116     */
117    public function getACL() {
118
119        $acl = parent::getACL();
120        $acl[] = array(
121            'privilege' => '{DAV:}read',
122            'principal' => $this->principalProperties['uri'] . '/calendar-proxy-read',
123            'protected' => true,
124        );
125        $acl[] = array(
126            'privilege' => '{DAV:}read',
127            'principal' => $this->principalProperties['uri'] . '/calendar-proxy-write',
128            'protected' => true,
129        );
130        return $acl;
131
132    }
133
134}
Note: See TracBrowser for help on using the repository browser.