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