1<?php
2
3namespace Sabre\DAVACL\FS;
4
5use Sabre\DAV\FSExt\File as BaseFile;
6use Sabre\DAVACL\IACL;
7use Sabre\DAV\Exception\Forbidden;
8
9/**
10 * This is an ACL-enabled file node.
11 *
12 * @copyright Copyright (C) 2007-2015 fruux GmbH. (https://fruux.com/)
13 * @author Evert Pot (http://evertpot.com/)
14 * @license http://sabre.io/license/ Modified BSD License
15 */
16class File extends BaseFile implements IACL {
17
18    /**
19     * A list of ACL rules.
20     *
21     * @var array
22     */
23    protected $acl;
24
25    /**
26     * Owner uri, or null for no owner.
27     *
28     * @var string|null
29     */
30    protected $owner;
31
32    /**
33     * Constructor
34     *
35     * @param string $path on-disk path.
36     * @param array $acl ACL rules.
37     * @param string|null $owner principal owner string.
38     */
39    function __construct($path, array $acl, $owner = null) {
40
41        parent::__construct($path);
42        $this->acl = $acl;
43        $this->owner = $owner;
44
45    }
46
47    /**
48     * Returns the owner principal
49     *
50     * This must be a url to a principal, or null if there's no owner
51     *
52     * @return string|null
53     */
54    function getOwner() {
55
56        return $this->owner;
57
58    }
59
60    /**
61     * Returns a group principal
62     *
63     * This must be a url to a principal, or null if there's no owner
64     *
65     * @return string|null
66     */
67    function getGroup() {
68
69        return null;
70
71    }
72
73    /**
74     * Returns a list of ACE's for this node.
75     *
76     * Each ACE has the following properties:
77     *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
78     *     currently the only supported privileges
79     *   * 'principal', a url to the principal who owns the node
80     *   * 'protected' (optional), indicating that this ACE is not allowed to
81     *      be updated.
82     *
83     * @return array
84     */
85    function getACL() {
86
87        return $this->acl;
88
89    }
90
91    /**
92     * Updates the ACL
93     *
94     * This method will receive a list of new ACE's as an array argument.
95     *
96     * @param array $acl
97     * @return void
98     */
99    function setACL(array $acl) {
100
101        throw new Forbidden('Setting ACL is not allowed here');
102
103    }
104
105    /**
106     * Returns the list of supported privileges for this node.
107     *
108     * The returned data structure is a list of nested privileges.
109     * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
110     * standard structure.
111     *
112     * If null is returned from this method, the default privilege set is used,
113     * which is fine for most common usecases.
114     *
115     * @return array|null
116     */
117    function getSupportedPrivilegeSet() {
118
119        return null;
120
121    }
122
123}
124