4 class Sabre_DAVACL_PrincipalBackend_Friendica implements Sabre_DAVACL_IPrincipalBackend
12 public $prefix = 'principals/users';
15 * @var Sabre_DAV_Auth_Backend_AbstractBasic $authBackend;
17 protected $authBackend;
19 public function __construct(&$authBackend)
22 $this->authBackend = &$authBackend;
28 * Returns a list of principals based on a prefix.
30 * This prefix will often contain something like 'principals'. You are only
31 * expected to return principals that are in this base path.
33 * You are expected to return at least a 'uri' for every user, you can
34 * return any additional properties if you wish so. Common properties are:
36 * {http://sabredav.org/ns}email-address - This is a custom SabreDAV
37 * field that's actualy injected in a number of other properties. If
38 * you have an email address, use this property.
40 * @param string $prefixPath
43 public function getPrincipalsByPrefix($prefixPath)
46 // This backend only support principals in one collection
47 if ($prefixPath !== $this->prefix) return array();
51 $r = q("SELECT `nickname` FROM `user` WHERE `nickname` = '%s'", escape_tags($this->authBackend->getCurrentUser()) );
54 'uri' => $this->prefix . '/' . strtolower($t['nickname']),
55 '{DAV:}displayname' => $t['nickname'],
64 * Returns a specific principal, specified by it's path.
65 * The returned structure should be the exact same as from
66 * getPrincipalsByPrefix.
71 public function getPrincipalByPath($path)
74 list($prefixPath, $userName) = Sabre_DAV_URLUtil::splitPath($path);
76 // This backend only support principals in one collection
77 if ($prefixPath !== $this->prefix) return null;
79 $r = q("SELECT `nickname` FROM `user` WHERE `nickname` = '%s'", escape_tags($userName) );
80 if (count($r) == 0) return array();
83 'uri' => $this->prefix . '/' . strtolower($r[0]['nickname']),
84 '{DAV:}displayname' => $r[0]['nickname'],
90 function getGroupMemberSet($principal)
95 function getGroupMembership($principal)
102 * Updates the list of group members for a group principal.
104 * The principals should be passed as a list of uri's.
106 * @param string $principal
107 * @param array $members
108 * @throws Sabre_DAV_Exception
111 public function setGroupMemberSet($principal, array $members)
113 throw new Sabre_DAV_Exception('Operation not supported');
117 * Updates one ore more webdav properties on a principal.
119 * The list of mutations is supplied as an array. Each key in the array is
120 * a propertyname, such as {DAV:}displayname.
122 * Each value is the actual value to be updated. If a value is null, it
125 * This method should be atomic. It must either completely succeed, or
126 * completely fail. Success and failure can simply be returned as 'true' or
129 * It is also possible to return detailed failure information. In that case
130 * an array such as this should be returned:
134 * '{DAV:}prop1' => null,
137 * '{DAV:}prop2' => null,
140 * '{DAV:}prop3' => null,
143 * '{DAV:}prop4' => null,
147 * In this previous example prop1 was successfully updated or deleted, and
148 * prop2 was succesfully created.
150 * prop3 failed to update due to '403 Forbidden' and because of this prop4
151 * also could not be updated with '424 Failed dependency'.
153 * This last example was actually incorrect. While 200 and 201 could appear
154 * in 1 response, if there's any error (403) the other properties should
155 * always fail with 423 (failed dependency).
157 * But anyway, if you don't want to scratch your head over this, just
158 * return true or false.
160 * @param string $path
161 * @param array $mutations
164 function updatePrincipal($path, $mutations)
166 // TODO: Implement updatePrincipal() method.
170 * This method is used to search for principals matching a set of
173 * This search is specifically used by RFC3744's principal-property-search
174 * REPORT. You should at least allow searching on
175 * http://sabredav.org/ns}email-address.
177 * The actual search should be a unicode-non-case-sensitive search. The
178 * keys in searchProperties are the WebDAV property names, while the values
179 * are the property values to search on.
181 * If multiple properties are being searched on, the search should be
184 * This method should simply return an array with full principal uri's.
186 * If somebody attempted to search on a property the backend does not
187 * support, you should simply return 0 results.
189 * You can also just return 0 results if you choose to not support
190 * searching at all, but keep in mind that this may stop certain features
193 * @param string $prefixPath
194 * @param array $searchProperties
197 function searchPrincipals($prefixPath, array $searchProperties)
199 // TODO: Implement searchPrincipals() method.