1<?php
2
3namespace Sabre\DAVACL;
4
5/**
6 * This trait is a default implementation of the IACL interface.
7 *
8 * In many cases you only want to implement 1 or to of the IACL functions,
9 * this trait allows you to be a bit lazier.
10 *
11 * By default this trait grants all privileges to the owner of the resource.
12 *
13 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
14 * @author Evert Pot (https://evertpot.com/)
15 * @license http://sabre.io/license/ Modified BSD License
16 */
17trait ACLTrait {
18
19    /**
20     * Returns the owner principal
21     *
22     * This must be a url to a principal, or null if there's no owner
23     *
24     * @return string|null
25     */
26    function getOwner() {
27
28        return null;
29
30    }
31
32    /**
33     * Returns a group principal
34     *
35     * This must be a url to a principal, or null if there's no owner
36     *
37     * @return string|null
38     */
39    function getGroup() {
40
41        return null;
42
43    }
44
45    /**
46     * Returns a list of ACE's for this node.
47     *
48     * Each ACE has the following properties:
49     *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
50     *     currently the only supported privileges
51     *   * 'principal', a url to the principal who owns the node
52     *   * 'protected' (optional), indicating that this ACE is not allowed to
53     *      be updated.
54     *
55     * @return array
56     */
57    function getACL() {
58
59        return [
60            [
61                'privilege' => '{DAV:}all',
62                'principal' => '{DAV:}owner',
63                'protected' => true,
64            ]
65        ];
66
67    }
68
69    /**
70     * Updates the ACL
71     *
72     * This method will receive a list of new ACE's as an array argument.
73     *
74     * @param array $acl
75     * @return void
76     */
77    function setACL(array $acl) {
78
79        throw new \Sabre\DAV\Exception\Forbidden('Setting ACL is not supported on this node');
80    }
81
82    /**
83     * Returns the list of supported privileges for this node.
84     *
85     * The returned data structure is a list of nested privileges.
86     * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
87     * standard structure.
88     *
89     * If null is returned from this method, the default privilege set is used,
90     * which is fine for most common usecases.
91     *
92     * @return array|null
93     */
94    function getSupportedPrivilegeSet() {
95
96        return null;
97
98    }
99
100}
101