xref: /plugin/davcal/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab) !
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\DAVACL\PrincipalBackend;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehler/**
6*a1a3b679SAndreas Boehler * Implement this interface to create your own principal backends.
7*a1a3b679SAndreas Boehler *
8*a1a3b679SAndreas Boehler * Creating backends for principals is entirely optional. You can also
9*a1a3b679SAndreas Boehler * implement Sabre\DAVACL\IPrincipal directly. This interface is used solely by
10*a1a3b679SAndreas Boehler * Sabre\DAVACL\AbstractPrincipalCollection.
11*a1a3b679SAndreas Boehler *
12*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
13*a1a3b679SAndreas Boehler * @author Evert Pot (http://evertpot.com/)
14*a1a3b679SAndreas Boehler * @license http://sabre.io/license/ Modified BSD License
15*a1a3b679SAndreas Boehler */
16*a1a3b679SAndreas Boehlerinterface BackendInterface {
17*a1a3b679SAndreas Boehler
18*a1a3b679SAndreas Boehler    /**
19*a1a3b679SAndreas Boehler     * Returns a list of principals based on a prefix.
20*a1a3b679SAndreas Boehler     *
21*a1a3b679SAndreas Boehler     * This prefix will often contain something like 'principals'. You are only
22*a1a3b679SAndreas Boehler     * expected to return principals that are in this base path.
23*a1a3b679SAndreas Boehler     *
24*a1a3b679SAndreas Boehler     * You are expected to return at least a 'uri' for every user, you can
25*a1a3b679SAndreas Boehler     * return any additional properties if you wish so. Common properties are:
26*a1a3b679SAndreas Boehler     *   {DAV:}displayname
27*a1a3b679SAndreas Boehler     *   {http://sabredav.org/ns}email-address - This is a custom SabreDAV
28*a1a3b679SAndreas Boehler     *     field that's actually injected in a number of other properties. If
29*a1a3b679SAndreas Boehler     *     you have an email address, use this property.
30*a1a3b679SAndreas Boehler     *
31*a1a3b679SAndreas Boehler     * @param string $prefixPath
32*a1a3b679SAndreas Boehler     * @return array
33*a1a3b679SAndreas Boehler     */
34*a1a3b679SAndreas Boehler    function getPrincipalsByPrefix($prefixPath);
35*a1a3b679SAndreas Boehler
36*a1a3b679SAndreas Boehler    /**
37*a1a3b679SAndreas Boehler     * Returns a specific principal, specified by it's path.
38*a1a3b679SAndreas Boehler     * The returned structure should be the exact same as from
39*a1a3b679SAndreas Boehler     * getPrincipalsByPrefix.
40*a1a3b679SAndreas Boehler     *
41*a1a3b679SAndreas Boehler     * @param string $path
42*a1a3b679SAndreas Boehler     * @return array
43*a1a3b679SAndreas Boehler     */
44*a1a3b679SAndreas Boehler    function getPrincipalByPath($path);
45*a1a3b679SAndreas Boehler
46*a1a3b679SAndreas Boehler    /**
47*a1a3b679SAndreas Boehler     * Updates one ore more webdav properties on a principal.
48*a1a3b679SAndreas Boehler     *
49*a1a3b679SAndreas Boehler     * The list of mutations is stored in a Sabre\DAV\PropPatch object.
50*a1a3b679SAndreas Boehler     * To do the actual updates, you must tell this object which properties
51*a1a3b679SAndreas Boehler     * you're going to process with the handle() method.
52*a1a3b679SAndreas Boehler     *
53*a1a3b679SAndreas Boehler     * Calling the handle method is like telling the PropPatch object "I
54*a1a3b679SAndreas Boehler     * promise I can handle updating this property".
55*a1a3b679SAndreas Boehler     *
56*a1a3b679SAndreas Boehler     * Read the PropPatch documenation for more info and examples.
57*a1a3b679SAndreas Boehler     *
58*a1a3b679SAndreas Boehler     * @param string $path
59*a1a3b679SAndreas Boehler     * @param \Sabre\DAV\PropPatch $propPatch
60*a1a3b679SAndreas Boehler     * @return void
61*a1a3b679SAndreas Boehler     */
62*a1a3b679SAndreas Boehler    function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch);
63*a1a3b679SAndreas Boehler
64*a1a3b679SAndreas Boehler    /**
65*a1a3b679SAndreas Boehler     * This method is used to search for principals matching a set of
66*a1a3b679SAndreas Boehler     * properties.
67*a1a3b679SAndreas Boehler     *
68*a1a3b679SAndreas Boehler     * This search is specifically used by RFC3744's principal-property-search
69*a1a3b679SAndreas Boehler     * REPORT.
70*a1a3b679SAndreas Boehler     *
71*a1a3b679SAndreas Boehler     * The actual search should be a unicode-non-case-sensitive search. The
72*a1a3b679SAndreas Boehler     * keys in searchProperties are the WebDAV property names, while the values
73*a1a3b679SAndreas Boehler     * are the property values to search on.
74*a1a3b679SAndreas Boehler     *
75*a1a3b679SAndreas Boehler     * By default, if multiple properties are submitted to this method, the
76*a1a3b679SAndreas Boehler     * various properties should be combined with 'AND'. If $test is set to
77*a1a3b679SAndreas Boehler     * 'anyof', it should be combined using 'OR'.
78*a1a3b679SAndreas Boehler     *
79*a1a3b679SAndreas Boehler     * This method should simply return an array with full principal uri's.
80*a1a3b679SAndreas Boehler     *
81*a1a3b679SAndreas Boehler     * If somebody attempted to search on a property the backend does not
82*a1a3b679SAndreas Boehler     * support, you should simply return 0 results.
83*a1a3b679SAndreas Boehler     *
84*a1a3b679SAndreas Boehler     * You can also just return 0 results if you choose to not support
85*a1a3b679SAndreas Boehler     * searching at all, but keep in mind that this may stop certain features
86*a1a3b679SAndreas Boehler     * from working.
87*a1a3b679SAndreas Boehler     *
88*a1a3b679SAndreas Boehler     * @param string $prefixPath
89*a1a3b679SAndreas Boehler     * @param array $searchProperties
90*a1a3b679SAndreas Boehler     * @param string $test
91*a1a3b679SAndreas Boehler     * @return array
92*a1a3b679SAndreas Boehler     */
93*a1a3b679SAndreas Boehler    function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof');
94*a1a3b679SAndreas Boehler
95*a1a3b679SAndreas Boehler    /**
96*a1a3b679SAndreas Boehler     * Finds a principal by its URI.
97*a1a3b679SAndreas Boehler     *
98*a1a3b679SAndreas Boehler     * This method may receive any type of uri, but mailto: addresses will be
99*a1a3b679SAndreas Boehler     * the most common.
100*a1a3b679SAndreas Boehler     *
101*a1a3b679SAndreas Boehler     * Implementation of this API is optional. It is currently used by the
102*a1a3b679SAndreas Boehler     * CalDAV system to find principals based on their email addresses. If this
103*a1a3b679SAndreas Boehler     * API is not implemented, some features may not work correctly.
104*a1a3b679SAndreas Boehler     *
105*a1a3b679SAndreas Boehler     * This method must return a relative principal path, or null, if the
106*a1a3b679SAndreas Boehler     * principal was not found or you refuse to find it.
107*a1a3b679SAndreas Boehler     *
108*a1a3b679SAndreas Boehler     * @param string $uri
109*a1a3b679SAndreas Boehler     * @param string $principalPrefix
110*a1a3b679SAndreas Boehler     * @return string
111*a1a3b679SAndreas Boehler     */
112*a1a3b679SAndreas Boehler    function findByUri($uri, $principalPrefix);
113*a1a3b679SAndreas Boehler
114*a1a3b679SAndreas Boehler    /**
115*a1a3b679SAndreas Boehler     * Returns the list of members for a group-principal
116*a1a3b679SAndreas Boehler     *
117*a1a3b679SAndreas Boehler     * @param string $principal
118*a1a3b679SAndreas Boehler     * @return array
119*a1a3b679SAndreas Boehler     */
120*a1a3b679SAndreas Boehler    function getGroupMemberSet($principal);
121*a1a3b679SAndreas Boehler
122*a1a3b679SAndreas Boehler    /**
123*a1a3b679SAndreas Boehler     * Returns the list of groups a principal is a member of
124*a1a3b679SAndreas Boehler     *
125*a1a3b679SAndreas Boehler     * @param string $principal
126*a1a3b679SAndreas Boehler     * @return array
127*a1a3b679SAndreas Boehler     */
128*a1a3b679SAndreas Boehler    function getGroupMembership($principal);
129*a1a3b679SAndreas Boehler
130*a1a3b679SAndreas Boehler    /**
131*a1a3b679SAndreas Boehler     * Updates the list of group members for a group principal.
132*a1a3b679SAndreas Boehler     *
133*a1a3b679SAndreas Boehler     * The principals should be passed as a list of uri's.
134*a1a3b679SAndreas Boehler     *
135*a1a3b679SAndreas Boehler     * @param string $principal
136*a1a3b679SAndreas Boehler     * @param array $members
137*a1a3b679SAndreas Boehler     * @return void
138*a1a3b679SAndreas Boehler     */
139*a1a3b679SAndreas Boehler    function setGroupMemberSet($principal, array $members);
140*a1a3b679SAndreas Boehler
141*a1a3b679SAndreas Boehler}
142