@@ -22,8 +22,8 @@ |
||
22 | 22 | */ |
23 | 23 | |
24 | 24 | return [ |
25 | - 'routes' => [ |
|
26 | - ['name' => 'birthday_calendar#enable', 'url' => '/enableBirthdayCalendar', 'verb' => 'POST'], |
|
27 | - ['name' => 'birthday_calendar#disable', 'url' => '/disableBirthdayCalendar', 'verb' => 'POST'], |
|
28 | - ] |
|
25 | + 'routes' => [ |
|
26 | + ['name' => 'birthday_calendar#enable', 'url' => '/enableBirthdayCalendar', 'verb' => 'POST'], |
|
27 | + ['name' => 'birthday_calendar#disable', 'url' => '/disableBirthdayCalendar', 'verb' => 'POST'], |
|
28 | + ] |
|
29 | 29 | ]; |
@@ -32,50 +32,50 @@ |
||
32 | 32 | |
33 | 33 | class BirthdayCalendarController extends Controller { |
34 | 34 | |
35 | - /** |
|
36 | - * @var IDBConnection |
|
37 | - */ |
|
38 | - protected $db; |
|
35 | + /** |
|
36 | + * @var IDBConnection |
|
37 | + */ |
|
38 | + protected $db; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @var IConfig |
|
42 | - */ |
|
43 | - protected $config; |
|
40 | + /** |
|
41 | + * @var IConfig |
|
42 | + */ |
|
43 | + protected $config; |
|
44 | 44 | |
45 | - /** |
|
46 | - * BirthdayCalendar constructor. |
|
47 | - * |
|
48 | - * @param string $appName |
|
49 | - * @param IRequest $request |
|
50 | - * @param IDBConnection $db |
|
51 | - * @param IConfig $config |
|
52 | - */ |
|
53 | - public function __construct($appName, IRequest $request, |
|
54 | - IDBConnection $db, IConfig $config){ |
|
55 | - parent::__construct($appName, $request); |
|
56 | - $this->db = $db; |
|
57 | - $this->config = $config; |
|
58 | - } |
|
45 | + /** |
|
46 | + * BirthdayCalendar constructor. |
|
47 | + * |
|
48 | + * @param string $appName |
|
49 | + * @param IRequest $request |
|
50 | + * @param IDBConnection $db |
|
51 | + * @param IConfig $config |
|
52 | + */ |
|
53 | + public function __construct($appName, IRequest $request, |
|
54 | + IDBConnection $db, IConfig $config){ |
|
55 | + parent::__construct($appName, $request); |
|
56 | + $this->db = $db; |
|
57 | + $this->config = $config; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @return Response |
|
62 | - */ |
|
63 | - public function enable() { |
|
64 | - $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'yes'); |
|
60 | + /** |
|
61 | + * @return Response |
|
62 | + */ |
|
63 | + public function enable() { |
|
64 | + $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'yes'); |
|
65 | 65 | |
66 | - // TODO schedule background job to regenerate |
|
66 | + // TODO schedule background job to regenerate |
|
67 | 67 | |
68 | - return new JSONResponse([]); |
|
69 | - } |
|
68 | + return new JSONResponse([]); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return Response |
|
73 | - */ |
|
74 | - public function disable() { |
|
75 | - $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'no'); |
|
71 | + /** |
|
72 | + * @return Response |
|
73 | + */ |
|
74 | + public function disable() { |
|
75 | + $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'no'); |
|
76 | 76 | |
77 | - // TODO delete all birthday calendars |
|
77 | + // TODO delete all birthday calendars |
|
78 | 78 | |
79 | - return new JSONResponse([]); |
|
80 | - } |
|
79 | + return new JSONResponse([]); |
|
80 | + } |
|
81 | 81 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | * @param IConfig $config |
52 | 52 | */ |
53 | 53 | public function __construct($appName, IRequest $request, |
54 | - IDBConnection $db, IConfig $config){ |
|
54 | + IDBConnection $db, IConfig $config) { |
|
55 | 55 | parent::__construct($appName, $request); |
56 | 56 | $this->db = $db; |
57 | 57 | $this->config = $config; |
@@ -29,41 +29,41 @@ |
||
29 | 29 | |
30 | 30 | class CalDAVSettings implements ISettings { |
31 | 31 | |
32 | - /** @var IConfig */ |
|
33 | - private $config; |
|
32 | + /** @var IConfig */ |
|
33 | + private $config; |
|
34 | 34 | |
35 | - /** |
|
36 | - * CalDAVSettings constructor. |
|
37 | - * |
|
38 | - * @param IConfig $config |
|
39 | - */ |
|
40 | - public function __construct(IConfig $config) { |
|
41 | - $this->config = $config; |
|
42 | - } |
|
35 | + /** |
|
36 | + * CalDAVSettings constructor. |
|
37 | + * |
|
38 | + * @param IConfig $config |
|
39 | + */ |
|
40 | + public function __construct(IConfig $config) { |
|
41 | + $this->config = $config; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @return TemplateResponse |
|
46 | - */ |
|
47 | - public function getForm() { |
|
48 | - $parameters = [ |
|
49 | - 'send_invitations' => $this->config->getAppValue('dav', 'sendInvitations', 'yes'), |
|
50 | - 'generate_birthday_calendar' => $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'), |
|
51 | - ]; |
|
44 | + /** |
|
45 | + * @return TemplateResponse |
|
46 | + */ |
|
47 | + public function getForm() { |
|
48 | + $parameters = [ |
|
49 | + 'send_invitations' => $this->config->getAppValue('dav', 'sendInvitations', 'yes'), |
|
50 | + 'generate_birthday_calendar' => $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'), |
|
51 | + ]; |
|
52 | 52 | |
53 | - return new TemplateResponse('dav', 'settings-admin-caldav', $parameters); |
|
54 | - } |
|
53 | + return new TemplateResponse('dav', 'settings-admin-caldav', $parameters); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function getSection() { |
|
60 | - return 'additional'; |
|
61 | - } |
|
56 | + /** |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function getSection() { |
|
60 | + return 'additional'; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return int |
|
65 | - */ |
|
66 | - public function getPriority() { |
|
67 | - return 20; |
|
68 | - } |
|
63 | + /** |
|
64 | + * @return int |
|
65 | + */ |
|
66 | + public function getPriority() { |
|
67 | + return 20; |
|
68 | + } |
|
69 | 69 | } |
@@ -39,302 +39,302 @@ |
||
39 | 39 | */ |
40 | 40 | class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { |
41 | 41 | |
42 | - /** @var IConfig */ |
|
43 | - private $config; |
|
44 | - |
|
45 | - public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10N $l10n, IConfig $config) { |
|
46 | - parent::__construct($caldavBackend, $calendarInfo); |
|
47 | - |
|
48 | - if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
49 | - $this->calendarInfo['{DAV:}displayname'] = $l10n->t('Contact birthdays'); |
|
50 | - } |
|
51 | - if ($this->getName() === CalDavBackend::PERSONAL_CALENDAR_URI && |
|
52 | - $this->calendarInfo['{DAV:}displayname'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { |
|
53 | - $this->calendarInfo['{DAV:}displayname'] = $l10n->t('Personal'); |
|
54 | - } |
|
55 | - |
|
56 | - $this->config = $config; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * Updates the list of shares. |
|
61 | - * |
|
62 | - * The first array is a list of people that are to be added to the |
|
63 | - * resource. |
|
64 | - * |
|
65 | - * Every element in the add array has the following properties: |
|
66 | - * * href - A url. Usually a mailto: address |
|
67 | - * * commonName - Usually a first and last name, or false |
|
68 | - * * summary - A description of the share, can also be false |
|
69 | - * * readOnly - A boolean value |
|
70 | - * |
|
71 | - * Every element in the remove array is just the address string. |
|
72 | - * |
|
73 | - * @param array $add |
|
74 | - * @param array $remove |
|
75 | - * @return void |
|
76 | - * @throws Forbidden |
|
77 | - */ |
|
78 | - public function updateShares(array $add, array $remove) { |
|
79 | - if ($this->isShared()) { |
|
80 | - throw new Forbidden(); |
|
81 | - } |
|
82 | - $this->caldavBackend->updateShares($this, $add, $remove); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Returns the list of people whom this resource is shared with. |
|
87 | - * |
|
88 | - * Every element in this array should have the following properties: |
|
89 | - * * href - Often a mailto: address |
|
90 | - * * commonName - Optional, for example a first + last name |
|
91 | - * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. |
|
92 | - * * readOnly - boolean |
|
93 | - * * summary - Optional, a description for the share |
|
94 | - * |
|
95 | - * @return array |
|
96 | - */ |
|
97 | - public function getShares() { |
|
98 | - if ($this->isShared()) { |
|
99 | - return []; |
|
100 | - } |
|
101 | - return $this->caldavBackend->getShares($this->getResourceId()); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * @return int |
|
106 | - */ |
|
107 | - public function getResourceId() { |
|
108 | - return $this->calendarInfo['id']; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function getPrincipalURI() { |
|
115 | - return $this->calendarInfo['principaluri']; |
|
116 | - } |
|
117 | - |
|
118 | - public function getACL() { |
|
119 | - $acl = [ |
|
120 | - [ |
|
121 | - 'privilege' => '{DAV:}read', |
|
122 | - 'principal' => $this->getOwner(), |
|
123 | - 'protected' => true, |
|
124 | - ]]; |
|
125 | - if ($this->getName() !== BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
126 | - $acl[] = [ |
|
127 | - 'privilege' => '{DAV:}write', |
|
128 | - 'principal' => $this->getOwner(), |
|
129 | - 'protected' => true, |
|
130 | - ]; |
|
131 | - } else { |
|
132 | - $acl[] = [ |
|
133 | - 'privilege' => '{DAV:}write-properties', |
|
134 | - 'principal' => $this->getOwner(), |
|
135 | - 'protected' => true, |
|
136 | - ]; |
|
137 | - } |
|
138 | - |
|
139 | - if ($this->getOwner() !== parent::getOwner()) { |
|
140 | - $acl[] = [ |
|
141 | - 'privilege' => '{DAV:}read', |
|
142 | - 'principal' => parent::getOwner(), |
|
143 | - 'protected' => true, |
|
144 | - ]; |
|
145 | - if ($this->canWrite()) { |
|
146 | - $acl[] = [ |
|
147 | - 'privilege' => '{DAV:}write', |
|
148 | - 'principal' => parent::getOwner(), |
|
149 | - 'protected' => true, |
|
150 | - ]; |
|
151 | - } else { |
|
152 | - $acl[] = [ |
|
153 | - 'privilege' => '{DAV:}write-properties', |
|
154 | - 'principal' => parent::getOwner(), |
|
155 | - 'protected' => true, |
|
156 | - ]; |
|
157 | - } |
|
158 | - } |
|
159 | - if ($this->isPublic()) { |
|
160 | - $acl[] = [ |
|
161 | - 'privilege' => '{DAV:}read', |
|
162 | - 'principal' => 'principals/system/public', |
|
163 | - 'protected' => true, |
|
164 | - ]; |
|
165 | - } |
|
166 | - |
|
167 | - $acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl); |
|
168 | - |
|
169 | - if (!$this->isShared()) { |
|
170 | - return $acl; |
|
171 | - } |
|
172 | - |
|
173 | - $allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/public']; |
|
174 | - return array_filter($acl, function($rule) use ($allowedPrincipals) { |
|
175 | - return in_array($rule['principal'], $allowedPrincipals); |
|
176 | - }); |
|
177 | - } |
|
178 | - |
|
179 | - public function getChildACL() { |
|
180 | - return $this->getACL(); |
|
181 | - } |
|
182 | - |
|
183 | - public function getOwner() { |
|
184 | - if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
185 | - return $this->calendarInfo['{http://owncloud.org/ns}owner-principal']; |
|
186 | - } |
|
187 | - return parent::getOwner(); |
|
188 | - } |
|
189 | - |
|
190 | - public function delete() { |
|
191 | - if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal']) && |
|
192 | - $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']) { |
|
193 | - $principal = 'principal:' . parent::getOwner(); |
|
194 | - $shares = $this->caldavBackend->getShares($this->getResourceId()); |
|
195 | - $shares = array_filter($shares, function($share) use ($principal){ |
|
196 | - return $share['href'] === $principal; |
|
197 | - }); |
|
198 | - if (empty($shares)) { |
|
199 | - throw new Forbidden(); |
|
200 | - } |
|
201 | - |
|
202 | - $this->caldavBackend->updateShares($this, [], [ |
|
203 | - 'href' => $principal |
|
204 | - ]); |
|
205 | - return; |
|
206 | - } |
|
207 | - |
|
208 | - // Remember when a user deleted their birthday calendar |
|
209 | - // in order to not regenerate it on the next contacts change |
|
210 | - if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
211 | - $principalURI = $this->getPrincipalURI(); |
|
212 | - $userId = substr($principalURI, 17); |
|
213 | - |
|
214 | - $this->config->setUserValue($userId, 'dav', 'generateBirthdayCalendar', 'no'); |
|
215 | - } |
|
216 | - |
|
217 | - parent::delete(); |
|
218 | - } |
|
219 | - |
|
220 | - public function propPatch(PropPatch $propPatch) { |
|
221 | - // parent::propPatch will only update calendars table |
|
222 | - // if calendar is shared, changes have to be made to the properties table |
|
223 | - if (!$this->isShared()) { |
|
224 | - parent::propPatch($propPatch); |
|
225 | - } |
|
226 | - } |
|
227 | - |
|
228 | - public function getChild($name) { |
|
229 | - |
|
230 | - $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); |
|
231 | - |
|
232 | - if (!$obj) { |
|
233 | - throw new NotFound('Calendar object not found'); |
|
234 | - } |
|
235 | - |
|
236 | - if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
237 | - throw new NotFound('Calendar object not found'); |
|
238 | - } |
|
239 | - |
|
240 | - $obj['acl'] = $this->getChildACL(); |
|
241 | - |
|
242 | - return new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
243 | - |
|
244 | - } |
|
245 | - |
|
246 | - public function getChildren() { |
|
247 | - |
|
248 | - $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); |
|
249 | - $children = []; |
|
250 | - foreach ($objs as $obj) { |
|
251 | - if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
252 | - continue; |
|
253 | - } |
|
254 | - $obj['acl'] = $this->getChildACL(); |
|
255 | - $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
256 | - } |
|
257 | - return $children; |
|
258 | - |
|
259 | - } |
|
260 | - |
|
261 | - public function getMultipleChildren(array $paths) { |
|
262 | - |
|
263 | - $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths); |
|
264 | - $children = []; |
|
265 | - foreach ($objs as $obj) { |
|
266 | - if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
267 | - continue; |
|
268 | - } |
|
269 | - $obj['acl'] = $this->getChildACL(); |
|
270 | - $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
271 | - } |
|
272 | - return $children; |
|
273 | - |
|
274 | - } |
|
275 | - |
|
276 | - public function childExists($name) { |
|
277 | - $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); |
|
278 | - if (!$obj) { |
|
279 | - return false; |
|
280 | - } |
|
281 | - if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
282 | - return false; |
|
283 | - } |
|
284 | - |
|
285 | - return true; |
|
286 | - } |
|
287 | - |
|
288 | - public function calendarQuery(array $filters) { |
|
289 | - |
|
290 | - $uris = $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters); |
|
291 | - if ($this->isShared()) { |
|
292 | - return array_filter($uris, function ($uri) { |
|
293 | - return $this->childExists($uri); |
|
294 | - }); |
|
295 | - } |
|
296 | - |
|
297 | - return $uris; |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * @param boolean $value |
|
302 | - * @return string|null |
|
303 | - */ |
|
304 | - public function setPublishStatus($value) { |
|
305 | - $publicUri = $this->caldavBackend->setPublishStatus($value, $this); |
|
306 | - $this->calendarInfo['publicuri'] = $publicUri; |
|
307 | - return $publicUri; |
|
308 | - } |
|
309 | - |
|
310 | - /** |
|
311 | - * @return mixed $value |
|
312 | - */ |
|
313 | - public function getPublishStatus() { |
|
314 | - return $this->caldavBackend->getPublishStatus($this); |
|
315 | - } |
|
316 | - |
|
317 | - private function canWrite() { |
|
318 | - if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) { |
|
319 | - return !$this->calendarInfo['{http://owncloud.org/ns}read-only']; |
|
320 | - } |
|
321 | - return true; |
|
322 | - } |
|
323 | - |
|
324 | - private function isPublic() { |
|
325 | - return isset($this->calendarInfo['{http://owncloud.org/ns}public']); |
|
326 | - } |
|
327 | - |
|
328 | - protected function isShared() { |
|
329 | - if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
330 | - return false; |
|
331 | - } |
|
332 | - |
|
333 | - return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']; |
|
334 | - } |
|
335 | - |
|
336 | - public function isSubscription() { |
|
337 | - return isset($this->calendarInfo['{http://calendarserver.org/ns/}source']); |
|
338 | - } |
|
42 | + /** @var IConfig */ |
|
43 | + private $config; |
|
44 | + |
|
45 | + public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10N $l10n, IConfig $config) { |
|
46 | + parent::__construct($caldavBackend, $calendarInfo); |
|
47 | + |
|
48 | + if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
49 | + $this->calendarInfo['{DAV:}displayname'] = $l10n->t('Contact birthdays'); |
|
50 | + } |
|
51 | + if ($this->getName() === CalDavBackend::PERSONAL_CALENDAR_URI && |
|
52 | + $this->calendarInfo['{DAV:}displayname'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { |
|
53 | + $this->calendarInfo['{DAV:}displayname'] = $l10n->t('Personal'); |
|
54 | + } |
|
55 | + |
|
56 | + $this->config = $config; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * Updates the list of shares. |
|
61 | + * |
|
62 | + * The first array is a list of people that are to be added to the |
|
63 | + * resource. |
|
64 | + * |
|
65 | + * Every element in the add array has the following properties: |
|
66 | + * * href - A url. Usually a mailto: address |
|
67 | + * * commonName - Usually a first and last name, or false |
|
68 | + * * summary - A description of the share, can also be false |
|
69 | + * * readOnly - A boolean value |
|
70 | + * |
|
71 | + * Every element in the remove array is just the address string. |
|
72 | + * |
|
73 | + * @param array $add |
|
74 | + * @param array $remove |
|
75 | + * @return void |
|
76 | + * @throws Forbidden |
|
77 | + */ |
|
78 | + public function updateShares(array $add, array $remove) { |
|
79 | + if ($this->isShared()) { |
|
80 | + throw new Forbidden(); |
|
81 | + } |
|
82 | + $this->caldavBackend->updateShares($this, $add, $remove); |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Returns the list of people whom this resource is shared with. |
|
87 | + * |
|
88 | + * Every element in this array should have the following properties: |
|
89 | + * * href - Often a mailto: address |
|
90 | + * * commonName - Optional, for example a first + last name |
|
91 | + * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. |
|
92 | + * * readOnly - boolean |
|
93 | + * * summary - Optional, a description for the share |
|
94 | + * |
|
95 | + * @return array |
|
96 | + */ |
|
97 | + public function getShares() { |
|
98 | + if ($this->isShared()) { |
|
99 | + return []; |
|
100 | + } |
|
101 | + return $this->caldavBackend->getShares($this->getResourceId()); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * @return int |
|
106 | + */ |
|
107 | + public function getResourceId() { |
|
108 | + return $this->calendarInfo['id']; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function getPrincipalURI() { |
|
115 | + return $this->calendarInfo['principaluri']; |
|
116 | + } |
|
117 | + |
|
118 | + public function getACL() { |
|
119 | + $acl = [ |
|
120 | + [ |
|
121 | + 'privilege' => '{DAV:}read', |
|
122 | + 'principal' => $this->getOwner(), |
|
123 | + 'protected' => true, |
|
124 | + ]]; |
|
125 | + if ($this->getName() !== BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
126 | + $acl[] = [ |
|
127 | + 'privilege' => '{DAV:}write', |
|
128 | + 'principal' => $this->getOwner(), |
|
129 | + 'protected' => true, |
|
130 | + ]; |
|
131 | + } else { |
|
132 | + $acl[] = [ |
|
133 | + 'privilege' => '{DAV:}write-properties', |
|
134 | + 'principal' => $this->getOwner(), |
|
135 | + 'protected' => true, |
|
136 | + ]; |
|
137 | + } |
|
138 | + |
|
139 | + if ($this->getOwner() !== parent::getOwner()) { |
|
140 | + $acl[] = [ |
|
141 | + 'privilege' => '{DAV:}read', |
|
142 | + 'principal' => parent::getOwner(), |
|
143 | + 'protected' => true, |
|
144 | + ]; |
|
145 | + if ($this->canWrite()) { |
|
146 | + $acl[] = [ |
|
147 | + 'privilege' => '{DAV:}write', |
|
148 | + 'principal' => parent::getOwner(), |
|
149 | + 'protected' => true, |
|
150 | + ]; |
|
151 | + } else { |
|
152 | + $acl[] = [ |
|
153 | + 'privilege' => '{DAV:}write-properties', |
|
154 | + 'principal' => parent::getOwner(), |
|
155 | + 'protected' => true, |
|
156 | + ]; |
|
157 | + } |
|
158 | + } |
|
159 | + if ($this->isPublic()) { |
|
160 | + $acl[] = [ |
|
161 | + 'privilege' => '{DAV:}read', |
|
162 | + 'principal' => 'principals/system/public', |
|
163 | + 'protected' => true, |
|
164 | + ]; |
|
165 | + } |
|
166 | + |
|
167 | + $acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl); |
|
168 | + |
|
169 | + if (!$this->isShared()) { |
|
170 | + return $acl; |
|
171 | + } |
|
172 | + |
|
173 | + $allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/public']; |
|
174 | + return array_filter($acl, function($rule) use ($allowedPrincipals) { |
|
175 | + return in_array($rule['principal'], $allowedPrincipals); |
|
176 | + }); |
|
177 | + } |
|
178 | + |
|
179 | + public function getChildACL() { |
|
180 | + return $this->getACL(); |
|
181 | + } |
|
182 | + |
|
183 | + public function getOwner() { |
|
184 | + if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
185 | + return $this->calendarInfo['{http://owncloud.org/ns}owner-principal']; |
|
186 | + } |
|
187 | + return parent::getOwner(); |
|
188 | + } |
|
189 | + |
|
190 | + public function delete() { |
|
191 | + if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal']) && |
|
192 | + $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']) { |
|
193 | + $principal = 'principal:' . parent::getOwner(); |
|
194 | + $shares = $this->caldavBackend->getShares($this->getResourceId()); |
|
195 | + $shares = array_filter($shares, function($share) use ($principal){ |
|
196 | + return $share['href'] === $principal; |
|
197 | + }); |
|
198 | + if (empty($shares)) { |
|
199 | + throw new Forbidden(); |
|
200 | + } |
|
201 | + |
|
202 | + $this->caldavBackend->updateShares($this, [], [ |
|
203 | + 'href' => $principal |
|
204 | + ]); |
|
205 | + return; |
|
206 | + } |
|
207 | + |
|
208 | + // Remember when a user deleted their birthday calendar |
|
209 | + // in order to not regenerate it on the next contacts change |
|
210 | + if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
211 | + $principalURI = $this->getPrincipalURI(); |
|
212 | + $userId = substr($principalURI, 17); |
|
213 | + |
|
214 | + $this->config->setUserValue($userId, 'dav', 'generateBirthdayCalendar', 'no'); |
|
215 | + } |
|
216 | + |
|
217 | + parent::delete(); |
|
218 | + } |
|
219 | + |
|
220 | + public function propPatch(PropPatch $propPatch) { |
|
221 | + // parent::propPatch will only update calendars table |
|
222 | + // if calendar is shared, changes have to be made to the properties table |
|
223 | + if (!$this->isShared()) { |
|
224 | + parent::propPatch($propPatch); |
|
225 | + } |
|
226 | + } |
|
227 | + |
|
228 | + public function getChild($name) { |
|
229 | + |
|
230 | + $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); |
|
231 | + |
|
232 | + if (!$obj) { |
|
233 | + throw new NotFound('Calendar object not found'); |
|
234 | + } |
|
235 | + |
|
236 | + if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
237 | + throw new NotFound('Calendar object not found'); |
|
238 | + } |
|
239 | + |
|
240 | + $obj['acl'] = $this->getChildACL(); |
|
241 | + |
|
242 | + return new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
243 | + |
|
244 | + } |
|
245 | + |
|
246 | + public function getChildren() { |
|
247 | + |
|
248 | + $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); |
|
249 | + $children = []; |
|
250 | + foreach ($objs as $obj) { |
|
251 | + if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
252 | + continue; |
|
253 | + } |
|
254 | + $obj['acl'] = $this->getChildACL(); |
|
255 | + $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
256 | + } |
|
257 | + return $children; |
|
258 | + |
|
259 | + } |
|
260 | + |
|
261 | + public function getMultipleChildren(array $paths) { |
|
262 | + |
|
263 | + $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths); |
|
264 | + $children = []; |
|
265 | + foreach ($objs as $obj) { |
|
266 | + if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
267 | + continue; |
|
268 | + } |
|
269 | + $obj['acl'] = $this->getChildACL(); |
|
270 | + $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
271 | + } |
|
272 | + return $children; |
|
273 | + |
|
274 | + } |
|
275 | + |
|
276 | + public function childExists($name) { |
|
277 | + $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); |
|
278 | + if (!$obj) { |
|
279 | + return false; |
|
280 | + } |
|
281 | + if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
282 | + return false; |
|
283 | + } |
|
284 | + |
|
285 | + return true; |
|
286 | + } |
|
287 | + |
|
288 | + public function calendarQuery(array $filters) { |
|
289 | + |
|
290 | + $uris = $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters); |
|
291 | + if ($this->isShared()) { |
|
292 | + return array_filter($uris, function ($uri) { |
|
293 | + return $this->childExists($uri); |
|
294 | + }); |
|
295 | + } |
|
296 | + |
|
297 | + return $uris; |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * @param boolean $value |
|
302 | + * @return string|null |
|
303 | + */ |
|
304 | + public function setPublishStatus($value) { |
|
305 | + $publicUri = $this->caldavBackend->setPublishStatus($value, $this); |
|
306 | + $this->calendarInfo['publicuri'] = $publicUri; |
|
307 | + return $publicUri; |
|
308 | + } |
|
309 | + |
|
310 | + /** |
|
311 | + * @return mixed $value |
|
312 | + */ |
|
313 | + public function getPublishStatus() { |
|
314 | + return $this->caldavBackend->getPublishStatus($this); |
|
315 | + } |
|
316 | + |
|
317 | + private function canWrite() { |
|
318 | + if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) { |
|
319 | + return !$this->calendarInfo['{http://owncloud.org/ns}read-only']; |
|
320 | + } |
|
321 | + return true; |
|
322 | + } |
|
323 | + |
|
324 | + private function isPublic() { |
|
325 | + return isset($this->calendarInfo['{http://owncloud.org/ns}public']); |
|
326 | + } |
|
327 | + |
|
328 | + protected function isShared() { |
|
329 | + if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
330 | + return false; |
|
331 | + } |
|
332 | + |
|
333 | + return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']; |
|
334 | + } |
|
335 | + |
|
336 | + public function isSubscription() { |
|
337 | + return isset($this->calendarInfo['{http://calendarserver.org/ns/}source']); |
|
338 | + } |
|
339 | 339 | |
340 | 340 | } |
@@ -33,96 +33,96 @@ |
||
33 | 33 | |
34 | 34 | class CalendarHome extends \Sabre\CalDAV\CalendarHome { |
35 | 35 | |
36 | - /** @var \OCP\IL10N */ |
|
37 | - private $l10n; |
|
38 | - |
|
39 | - /** @var \OCP\IConfig */ |
|
40 | - private $config; |
|
41 | - |
|
42 | - public function __construct(BackendInterface $caldavBackend, $principalInfo) { |
|
43 | - parent::__construct($caldavBackend, $principalInfo); |
|
44 | - $this->l10n = \OC::$server->getL10N('dav'); |
|
45 | - $this->config = \OC::$server->getConfig(); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * @return BackendInterface |
|
50 | - */ |
|
51 | - public function getCalDAVBackend() { |
|
52 | - return $this->caldavBackend; |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * @inheritdoc |
|
57 | - */ |
|
58 | - function getChildren() { |
|
59 | - $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); |
|
60 | - $objects = []; |
|
61 | - foreach ($calendars as $calendar) { |
|
62 | - $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
63 | - } |
|
64 | - |
|
65 | - if ($this->caldavBackend instanceof SchedulingSupport) { |
|
66 | - $objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
67 | - $objects[] = new Outbox($this->principalInfo['uri']); |
|
68 | - } |
|
69 | - |
|
70 | - // We're adding a notifications node, if it's supported by the backend. |
|
71 | - if ($this->caldavBackend instanceof NotificationSupport) { |
|
72 | - $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
73 | - } |
|
74 | - |
|
75 | - // If the backend supports subscriptions, we'll add those as well, |
|
76 | - if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
77 | - foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
78 | - $objects[] = new Subscription($this->caldavBackend, $subscription); |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - return $objects; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @inheritdoc |
|
87 | - */ |
|
88 | - function getChild($name) { |
|
89 | - // Special nodes |
|
90 | - if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
91 | - return new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
92 | - } |
|
93 | - if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
94 | - return new Outbox($this->principalInfo['uri']); |
|
95 | - } |
|
96 | - if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) { |
|
97 | - return new \Sabre\CalDAv\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
98 | - } |
|
99 | - |
|
100 | - // Calendars |
|
101 | - foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) { |
|
102 | - if ($calendar['uri'] === $name) { |
|
103 | - return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
108 | - foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
109 | - if ($subscription['uri'] === $name) { |
|
110 | - return new Subscription($this->caldavBackend, $subscription); |
|
111 | - } |
|
112 | - } |
|
113 | - |
|
114 | - } |
|
115 | - |
|
116 | - throw new NotFound('Node with name \'' . $name . '\' could not be found'); |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * @param array $filters |
|
121 | - * @param integer|null $limit |
|
122 | - * @param integer|null $offset |
|
123 | - */ |
|
124 | - function calendarSearch(array $filters, $limit=null, $offset=null) { |
|
125 | - $principalUri = $this->principalInfo['uri']; |
|
126 | - return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset); |
|
127 | - } |
|
36 | + /** @var \OCP\IL10N */ |
|
37 | + private $l10n; |
|
38 | + |
|
39 | + /** @var \OCP\IConfig */ |
|
40 | + private $config; |
|
41 | + |
|
42 | + public function __construct(BackendInterface $caldavBackend, $principalInfo) { |
|
43 | + parent::__construct($caldavBackend, $principalInfo); |
|
44 | + $this->l10n = \OC::$server->getL10N('dav'); |
|
45 | + $this->config = \OC::$server->getConfig(); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * @return BackendInterface |
|
50 | + */ |
|
51 | + public function getCalDAVBackend() { |
|
52 | + return $this->caldavBackend; |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * @inheritdoc |
|
57 | + */ |
|
58 | + function getChildren() { |
|
59 | + $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); |
|
60 | + $objects = []; |
|
61 | + foreach ($calendars as $calendar) { |
|
62 | + $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
63 | + } |
|
64 | + |
|
65 | + if ($this->caldavBackend instanceof SchedulingSupport) { |
|
66 | + $objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
67 | + $objects[] = new Outbox($this->principalInfo['uri']); |
|
68 | + } |
|
69 | + |
|
70 | + // We're adding a notifications node, if it's supported by the backend. |
|
71 | + if ($this->caldavBackend instanceof NotificationSupport) { |
|
72 | + $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
73 | + } |
|
74 | + |
|
75 | + // If the backend supports subscriptions, we'll add those as well, |
|
76 | + if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
77 | + foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
78 | + $objects[] = new Subscription($this->caldavBackend, $subscription); |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + return $objects; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * @inheritdoc |
|
87 | + */ |
|
88 | + function getChild($name) { |
|
89 | + // Special nodes |
|
90 | + if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
91 | + return new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
92 | + } |
|
93 | + if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
94 | + return new Outbox($this->principalInfo['uri']); |
|
95 | + } |
|
96 | + if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) { |
|
97 | + return new \Sabre\CalDAv\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
98 | + } |
|
99 | + |
|
100 | + // Calendars |
|
101 | + foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) { |
|
102 | + if ($calendar['uri'] === $name) { |
|
103 | + return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
108 | + foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
109 | + if ($subscription['uri'] === $name) { |
|
110 | + return new Subscription($this->caldavBackend, $subscription); |
|
111 | + } |
|
112 | + } |
|
113 | + |
|
114 | + } |
|
115 | + |
|
116 | + throw new NotFound('Node with name \'' . $name . '\' could not be found'); |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * @param array $filters |
|
121 | + * @param integer|null $limit |
|
122 | + * @param integer|null $offset |
|
123 | + */ |
|
124 | + function calendarSearch(array $filters, $limit=null, $offset=null) { |
|
125 | + $principalUri = $this->principalInfo['uri']; |
|
126 | + return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset); |
|
127 | + } |
|
128 | 128 | } |
@@ -24,41 +24,41 @@ |
||
24 | 24 | |
25 | 25 | class PublicCalendarRoot extends Collection { |
26 | 26 | |
27 | - /** @var CalDavBackend */ |
|
28 | - protected $caldavBackend; |
|
27 | + /** @var CalDavBackend */ |
|
28 | + protected $caldavBackend; |
|
29 | 29 | |
30 | - /** @var \OCP\IL10N */ |
|
31 | - protected $l10n; |
|
30 | + /** @var \OCP\IL10N */ |
|
31 | + protected $l10n; |
|
32 | 32 | |
33 | - /** @var \OCP\IConfig */ |
|
34 | - protected $config; |
|
33 | + /** @var \OCP\IConfig */ |
|
34 | + protected $config; |
|
35 | 35 | |
36 | - function __construct(CalDavBackend $caldavBackend) { |
|
37 | - $this->caldavBackend = $caldavBackend; |
|
38 | - $this->l10n = \OC::$server->getL10N('dav'); |
|
39 | - $this->config = \OC::$server->getConfig(); |
|
36 | + function __construct(CalDavBackend $caldavBackend) { |
|
37 | + $this->caldavBackend = $caldavBackend; |
|
38 | + $this->l10n = \OC::$server->getL10N('dav'); |
|
39 | + $this->config = \OC::$server->getConfig(); |
|
40 | 40 | |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @inheritdoc |
|
45 | - */ |
|
46 | - function getName() { |
|
47 | - return 'public-calendars'; |
|
48 | - } |
|
43 | + /** |
|
44 | + * @inheritdoc |
|
45 | + */ |
|
46 | + function getName() { |
|
47 | + return 'public-calendars'; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @inheritdoc |
|
52 | - */ |
|
53 | - function getChild($name) { |
|
54 | - $calendar = $this->caldavBackend->getPublicCalendar($name); |
|
55 | - return new PublicCalendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
56 | - } |
|
50 | + /** |
|
51 | + * @inheritdoc |
|
52 | + */ |
|
53 | + function getChild($name) { |
|
54 | + $calendar = $this->caldavBackend->getPublicCalendar($name); |
|
55 | + return new PublicCalendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @inheritdoc |
|
60 | - */ |
|
61 | - function getChildren() { |
|
62 | - return []; |
|
63 | - } |
|
58 | + /** |
|
59 | + * @inheritdoc |
|
60 | + */ |
|
61 | + function getChildren() { |
|
62 | + return []; |
|
63 | + } |
|
64 | 64 | } |
@@ -104,7 +104,7 @@ |
||
104 | 104 | * @param RequestInterface $request |
105 | 105 | * @param ResponseInterface $response |
106 | 106 | * |
107 | - * @return bool|void |
|
107 | + * @return null|false |
|
108 | 108 | */ |
109 | 109 | public function httpPost(RequestInterface $request, ResponseInterface $response) { |
110 | 110 | $node = $this->server->tree->getNodeForPath($this->server->getRequestUri()); |
@@ -37,94 +37,94 @@ |
||
37 | 37 | * @package OCA\DAV\CalDAV\BirthdayCalendar |
38 | 38 | */ |
39 | 39 | class EnablePlugin extends ServerPlugin { |
40 | - const NS_Nextcloud = 'http://nextcloud.com/ns'; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var IConfig |
|
44 | - */ |
|
45 | - protected $config; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var Server |
|
49 | - */ |
|
50 | - protected $server; |
|
51 | - |
|
52 | - /** |
|
53 | - * PublishPlugin constructor. |
|
54 | - * |
|
55 | - * @param IConfig $config |
|
56 | - */ |
|
57 | - public function __construct(IConfig $config) { |
|
58 | - $this->config = $config; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * This method should return a list of server-features. |
|
63 | - * |
|
64 | - * This is for example 'versioning' and is added to the DAV: header |
|
65 | - * in an OPTIONS response. |
|
66 | - * |
|
67 | - * @return string[] |
|
68 | - */ |
|
69 | - public function getFeatures() { |
|
70 | - return ['nc-enable-birthday-calendar']; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Returns a plugin name. |
|
75 | - * |
|
76 | - * Using this name other plugins will be able to access other plugins |
|
77 | - * using Sabre\DAV\Server::getPlugin |
|
78 | - * |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function getPluginName() { |
|
82 | - return 'nc-enable-birthday-calendar'; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * This initializes the plugin. |
|
87 | - * |
|
88 | - * This function is called by Sabre\DAV\Server, after |
|
89 | - * addPlugin is called. |
|
90 | - * |
|
91 | - * This method should set up the required event subscriptions. |
|
92 | - * |
|
93 | - * @param Server $server |
|
94 | - */ |
|
95 | - public function initialize(Server $server) { |
|
96 | - $this->server = $server; |
|
97 | - |
|
98 | - $this->server->on('method:POST', [$this, 'httpPost']); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * We intercept this to handle POST requests on calendar homes. |
|
103 | - * |
|
104 | - * @param RequestInterface $request |
|
105 | - * @param ResponseInterface $response |
|
106 | - * |
|
107 | - * @return bool|void |
|
108 | - */ |
|
109 | - public function httpPost(RequestInterface $request, ResponseInterface $response) { |
|
110 | - $node = $this->server->tree->getNodeForPath($this->server->getRequestUri()); |
|
111 | - if (!($node instanceof CalendarHome)) { |
|
112 | - return; |
|
113 | - } |
|
114 | - |
|
115 | - $requestBody = $request->getBodyAsString(); |
|
116 | - $this->server->xml->parse($requestBody, $request->getUrl(), $documentType); |
|
117 | - if ($documentType !== '{'.self::NS_Nextcloud.'}enable-birthday-calendar') { |
|
118 | - return; |
|
119 | - } |
|
120 | - |
|
121 | - $principalUri = $node->getOwner(); |
|
122 | - $userId = substr($principalUri, 17); |
|
123 | - |
|
124 | - $this->config->setUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
125 | - |
|
126 | - $this->server->httpResponse->setStatus(204); |
|
127 | - |
|
128 | - return false; |
|
129 | - } |
|
40 | + const NS_Nextcloud = 'http://nextcloud.com/ns'; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var IConfig |
|
44 | + */ |
|
45 | + protected $config; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var Server |
|
49 | + */ |
|
50 | + protected $server; |
|
51 | + |
|
52 | + /** |
|
53 | + * PublishPlugin constructor. |
|
54 | + * |
|
55 | + * @param IConfig $config |
|
56 | + */ |
|
57 | + public function __construct(IConfig $config) { |
|
58 | + $this->config = $config; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * This method should return a list of server-features. |
|
63 | + * |
|
64 | + * This is for example 'versioning' and is added to the DAV: header |
|
65 | + * in an OPTIONS response. |
|
66 | + * |
|
67 | + * @return string[] |
|
68 | + */ |
|
69 | + public function getFeatures() { |
|
70 | + return ['nc-enable-birthday-calendar']; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Returns a plugin name. |
|
75 | + * |
|
76 | + * Using this name other plugins will be able to access other plugins |
|
77 | + * using Sabre\DAV\Server::getPlugin |
|
78 | + * |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function getPluginName() { |
|
82 | + return 'nc-enable-birthday-calendar'; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * This initializes the plugin. |
|
87 | + * |
|
88 | + * This function is called by Sabre\DAV\Server, after |
|
89 | + * addPlugin is called. |
|
90 | + * |
|
91 | + * This method should set up the required event subscriptions. |
|
92 | + * |
|
93 | + * @param Server $server |
|
94 | + */ |
|
95 | + public function initialize(Server $server) { |
|
96 | + $this->server = $server; |
|
97 | + |
|
98 | + $this->server->on('method:POST', [$this, 'httpPost']); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * We intercept this to handle POST requests on calendar homes. |
|
103 | + * |
|
104 | + * @param RequestInterface $request |
|
105 | + * @param ResponseInterface $response |
|
106 | + * |
|
107 | + * @return bool|void |
|
108 | + */ |
|
109 | + public function httpPost(RequestInterface $request, ResponseInterface $response) { |
|
110 | + $node = $this->server->tree->getNodeForPath($this->server->getRequestUri()); |
|
111 | + if (!($node instanceof CalendarHome)) { |
|
112 | + return; |
|
113 | + } |
|
114 | + |
|
115 | + $requestBody = $request->getBodyAsString(); |
|
116 | + $this->server->xml->parse($requestBody, $request->getUrl(), $documentType); |
|
117 | + if ($documentType !== '{'.self::NS_Nextcloud.'}enable-birthday-calendar') { |
|
118 | + return; |
|
119 | + } |
|
120 | + |
|
121 | + $principalUri = $node->getOwner(); |
|
122 | + $userId = substr($principalUri, 17); |
|
123 | + |
|
124 | + $this->config->setUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
125 | + |
|
126 | + $this->server->httpResponse->setStatus(204); |
|
127 | + |
|
128 | + return false; |
|
129 | + } |
|
130 | 130 | } |
@@ -78,7 +78,7 @@ |
||
78 | 78 | * |
79 | 79 | * @return string |
80 | 80 | */ |
81 | - public function getPluginName() { |
|
81 | + public function getPluginName() { |
|
82 | 82 | return 'nc-enable-birthday-calendar'; |
83 | 83 | } |
84 | 84 |
@@ -60,220 +60,220 @@ |
||
60 | 60 | |
61 | 61 | class Server { |
62 | 62 | |
63 | - /** @var IRequest */ |
|
64 | - private $request; |
|
63 | + /** @var IRequest */ |
|
64 | + private $request; |
|
65 | 65 | |
66 | - /** @var string */ |
|
67 | - private $baseUri; |
|
66 | + /** @var string */ |
|
67 | + private $baseUri; |
|
68 | 68 | |
69 | - /** @var Connector\Sabre\Server */ |
|
70 | - private $server; |
|
69 | + /** @var Connector\Sabre\Server */ |
|
70 | + private $server; |
|
71 | 71 | |
72 | - public function __construct(IRequest $request, $baseUri) { |
|
73 | - $this->request = $request; |
|
74 | - $this->baseUri = $baseUri; |
|
75 | - $logger = \OC::$server->getLogger(); |
|
76 | - $mailer = \OC::$server->getMailer(); |
|
77 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
78 | - $timezone = new TimeFactory(); |
|
79 | - $sendInvitations = \OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes'; |
|
72 | + public function __construct(IRequest $request, $baseUri) { |
|
73 | + $this->request = $request; |
|
74 | + $this->baseUri = $baseUri; |
|
75 | + $logger = \OC::$server->getLogger(); |
|
76 | + $mailer = \OC::$server->getMailer(); |
|
77 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
78 | + $timezone = new TimeFactory(); |
|
79 | + $sendInvitations = \OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes'; |
|
80 | 80 | |
81 | - $root = new RootCollection(); |
|
82 | - $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
81 | + $root = new RootCollection(); |
|
82 | + $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
83 | 83 | |
84 | - // Add maintenance plugin |
|
85 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
84 | + // Add maintenance plugin |
|
85 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
86 | 86 | |
87 | - // Backends |
|
88 | - $authBackend = new Auth( |
|
89 | - \OC::$server->getSession(), |
|
90 | - \OC::$server->getUserSession(), |
|
91 | - \OC::$server->getRequest(), |
|
92 | - \OC::$server->getTwoFactorAuthManager(), |
|
93 | - \OC::$server->getBruteForceThrottler() |
|
94 | - ); |
|
87 | + // Backends |
|
88 | + $authBackend = new Auth( |
|
89 | + \OC::$server->getSession(), |
|
90 | + \OC::$server->getUserSession(), |
|
91 | + \OC::$server->getRequest(), |
|
92 | + \OC::$server->getTwoFactorAuthManager(), |
|
93 | + \OC::$server->getBruteForceThrottler() |
|
94 | + ); |
|
95 | 95 | |
96 | - // Set URL explicitly due to reverse-proxy situations |
|
97 | - $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
98 | - $this->server->setBaseUri($this->baseUri); |
|
96 | + // Set URL explicitly due to reverse-proxy situations |
|
97 | + $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
98 | + $this->server->setBaseUri($this->baseUri); |
|
99 | 99 | |
100 | - $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
101 | - $authPlugin = new Plugin(); |
|
102 | - $authPlugin->addBackend(new PublicAuth()); |
|
103 | - $this->server->addPlugin($authPlugin); |
|
100 | + $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
101 | + $authPlugin = new Plugin(); |
|
102 | + $authPlugin->addBackend(new PublicAuth()); |
|
103 | + $this->server->addPlugin($authPlugin); |
|
104 | 104 | |
105 | - // allow setup of additional auth backends |
|
106 | - $event = new SabrePluginEvent($this->server); |
|
107 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
105 | + // allow setup of additional auth backends |
|
106 | + $event = new SabrePluginEvent($this->server); |
|
107 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
108 | 108 | |
109 | - $bearerAuthBackend = new BearerAuth( |
|
110 | - \OC::$server->getUserSession(), |
|
111 | - \OC::$server->getSession(), |
|
112 | - \OC::$server->getRequest() |
|
113 | - ); |
|
114 | - $authPlugin->addBackend($bearerAuthBackend); |
|
115 | - // because we are throwing exceptions this plugin has to be the last one |
|
116 | - $authPlugin->addBackend($authBackend); |
|
109 | + $bearerAuthBackend = new BearerAuth( |
|
110 | + \OC::$server->getUserSession(), |
|
111 | + \OC::$server->getSession(), |
|
112 | + \OC::$server->getRequest() |
|
113 | + ); |
|
114 | + $authPlugin->addBackend($bearerAuthBackend); |
|
115 | + // because we are throwing exceptions this plugin has to be the last one |
|
116 | + $authPlugin->addBackend($authBackend); |
|
117 | 117 | |
118 | - // debugging |
|
119 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
120 | - $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
121 | - } else { |
|
122 | - $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
123 | - } |
|
118 | + // debugging |
|
119 | + if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
120 | + $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
121 | + } else { |
|
122 | + $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
123 | + } |
|
124 | 124 | |
125 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
126 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
127 | - $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
125 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
126 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
127 | + $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
128 | 128 | |
129 | - // acl |
|
130 | - $acl = new DavAclPlugin(); |
|
131 | - $acl->principalCollectionSet = [ |
|
132 | - 'principals/users', 'principals/groups' |
|
133 | - ]; |
|
134 | - $acl->defaultUsernamePath = 'principals/users'; |
|
135 | - $this->server->addPlugin($acl); |
|
129 | + // acl |
|
130 | + $acl = new DavAclPlugin(); |
|
131 | + $acl->principalCollectionSet = [ |
|
132 | + 'principals/users', 'principals/groups' |
|
133 | + ]; |
|
134 | + $acl->defaultUsernamePath = 'principals/users'; |
|
135 | + $this->server->addPlugin($acl); |
|
136 | 136 | |
137 | - // calendar plugins |
|
138 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
139 | - $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
140 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
141 | - if ($sendInvitations) { |
|
142 | - $this->server->addPlugin(new IMipPlugin($mailer, $logger, $timezone)); |
|
143 | - } |
|
144 | - $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
145 | - $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
146 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
147 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
148 | - \OC::$server->getConfig(), |
|
149 | - \OC::$server->getURLGenerator() |
|
150 | - )); |
|
137 | + // calendar plugins |
|
138 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
139 | + $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
140 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
141 | + if ($sendInvitations) { |
|
142 | + $this->server->addPlugin(new IMipPlugin($mailer, $logger, $timezone)); |
|
143 | + } |
|
144 | + $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
145 | + $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
146 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
147 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
148 | + \OC::$server->getConfig(), |
|
149 | + \OC::$server->getURLGenerator() |
|
150 | + )); |
|
151 | 151 | |
152 | - // addressbook plugins |
|
153 | - $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
154 | - $this->server->addPlugin(new VCFExportPlugin()); |
|
155 | - $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
152 | + // addressbook plugins |
|
153 | + $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
154 | + $this->server->addPlugin(new VCFExportPlugin()); |
|
155 | + $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
156 | 156 | |
157 | - // system tags plugins |
|
158 | - $this->server->addPlugin(new SystemTagPlugin( |
|
159 | - \OC::$server->getSystemTagManager(), |
|
160 | - \OC::$server->getGroupManager(), |
|
161 | - \OC::$server->getUserSession() |
|
162 | - )); |
|
157 | + // system tags plugins |
|
158 | + $this->server->addPlugin(new SystemTagPlugin( |
|
159 | + \OC::$server->getSystemTagManager(), |
|
160 | + \OC::$server->getGroupManager(), |
|
161 | + \OC::$server->getUserSession() |
|
162 | + )); |
|
163 | 163 | |
164 | - // comments plugin |
|
165 | - $this->server->addPlugin(new CommentsPlugin( |
|
166 | - \OC::$server->getCommentsManager(), |
|
167 | - \OC::$server->getUserSession() |
|
168 | - )); |
|
164 | + // comments plugin |
|
165 | + $this->server->addPlugin(new CommentsPlugin( |
|
166 | + \OC::$server->getCommentsManager(), |
|
167 | + \OC::$server->getUserSession() |
|
168 | + )); |
|
169 | 169 | |
170 | - $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
170 | + $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
171 | 171 | |
172 | - // allow setup of additional plugins |
|
173 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
172 | + // allow setup of additional plugins |
|
173 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
174 | 174 | |
175 | - // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
176 | - // we do not provide locking we emulate it using a fake locking plugin. |
|
177 | - if($request->isUserAgent([ |
|
178 | - '/WebDAVFS/', |
|
179 | - '/Microsoft Office OneNote 2013/', |
|
180 | - '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
181 | - ])) { |
|
182 | - $this->server->addPlugin(new FakeLockerPlugin()); |
|
183 | - } |
|
175 | + // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
176 | + // we do not provide locking we emulate it using a fake locking plugin. |
|
177 | + if($request->isUserAgent([ |
|
178 | + '/WebDAVFS/', |
|
179 | + '/Microsoft Office OneNote 2013/', |
|
180 | + '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
181 | + ])) { |
|
182 | + $this->server->addPlugin(new FakeLockerPlugin()); |
|
183 | + } |
|
184 | 184 | |
185 | - if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
186 | - $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
187 | - } |
|
185 | + if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
186 | + $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
187 | + } |
|
188 | 188 | |
189 | - // wait with registering these until auth is handled and the filesystem is setup |
|
190 | - $this->server->on('beforeMethod', function () use ($root) { |
|
191 | - // custom properties plugin must be the last one |
|
192 | - $userSession = \OC::$server->getUserSession(); |
|
193 | - $user = $userSession->getUser(); |
|
194 | - if ($user !== null) { |
|
195 | - $view = \OC\Files\Filesystem::getView(); |
|
196 | - $this->server->addPlugin( |
|
197 | - new FilesPlugin( |
|
198 | - $this->server->tree, |
|
199 | - \OC::$server->getConfig(), |
|
200 | - $this->request, |
|
201 | - \OC::$server->getPreviewManager(), |
|
202 | - false, |
|
203 | - !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
204 | - ) |
|
205 | - ); |
|
189 | + // wait with registering these until auth is handled and the filesystem is setup |
|
190 | + $this->server->on('beforeMethod', function () use ($root) { |
|
191 | + // custom properties plugin must be the last one |
|
192 | + $userSession = \OC::$server->getUserSession(); |
|
193 | + $user = $userSession->getUser(); |
|
194 | + if ($user !== null) { |
|
195 | + $view = \OC\Files\Filesystem::getView(); |
|
196 | + $this->server->addPlugin( |
|
197 | + new FilesPlugin( |
|
198 | + $this->server->tree, |
|
199 | + \OC::$server->getConfig(), |
|
200 | + $this->request, |
|
201 | + \OC::$server->getPreviewManager(), |
|
202 | + false, |
|
203 | + !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
204 | + ) |
|
205 | + ); |
|
206 | 206 | |
207 | - $this->server->addPlugin( |
|
208 | - new \Sabre\DAV\PropertyStorage\Plugin( |
|
209 | - new CustomPropertiesBackend( |
|
210 | - $this->server->tree, |
|
211 | - \OC::$server->getDatabaseConnection(), |
|
212 | - \OC::$server->getUserSession()->getUser() |
|
213 | - ) |
|
214 | - ) |
|
215 | - ); |
|
216 | - if ($view !== null) { |
|
217 | - $this->server->addPlugin( |
|
218 | - new QuotaPlugin($view, false)); |
|
219 | - } |
|
220 | - $this->server->addPlugin( |
|
221 | - new TagsPlugin( |
|
222 | - $this->server->tree, \OC::$server->getTagManager() |
|
223 | - ) |
|
224 | - ); |
|
225 | - // TODO: switch to LazyUserFolder |
|
226 | - $userFolder = \OC::$server->getUserFolder(); |
|
227 | - $this->server->addPlugin(new SharesPlugin( |
|
228 | - $this->server->tree, |
|
229 | - $userSession, |
|
230 | - $userFolder, |
|
231 | - \OC::$server->getShareManager() |
|
232 | - )); |
|
233 | - $this->server->addPlugin(new CommentPropertiesPlugin( |
|
234 | - \OC::$server->getCommentsManager(), |
|
235 | - $userSession |
|
236 | - )); |
|
237 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
238 | - if ($view !== null) { |
|
239 | - $this->server->addPlugin(new FilesReportPlugin( |
|
240 | - $this->server->tree, |
|
241 | - $view, |
|
242 | - \OC::$server->getSystemTagManager(), |
|
243 | - \OC::$server->getSystemTagObjectMapper(), |
|
244 | - \OC::$server->getTagManager(), |
|
245 | - $userSession, |
|
246 | - \OC::$server->getGroupManager(), |
|
247 | - $userFolder |
|
248 | - )); |
|
249 | - $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
250 | - $this->server->tree, |
|
251 | - $user, |
|
252 | - \OC::$server->getRootFolder(), |
|
253 | - \OC::$server->getShareManager(), |
|
254 | - $view |
|
255 | - ))); |
|
256 | - } |
|
257 | - $this->server->addPlugin(new \OCA\Dav\CalDAV\BirthdayCalendar\EnablePlugin( |
|
258 | - \OC::$server->getConfig() |
|
259 | - )); |
|
260 | - } |
|
207 | + $this->server->addPlugin( |
|
208 | + new \Sabre\DAV\PropertyStorage\Plugin( |
|
209 | + new CustomPropertiesBackend( |
|
210 | + $this->server->tree, |
|
211 | + \OC::$server->getDatabaseConnection(), |
|
212 | + \OC::$server->getUserSession()->getUser() |
|
213 | + ) |
|
214 | + ) |
|
215 | + ); |
|
216 | + if ($view !== null) { |
|
217 | + $this->server->addPlugin( |
|
218 | + new QuotaPlugin($view, false)); |
|
219 | + } |
|
220 | + $this->server->addPlugin( |
|
221 | + new TagsPlugin( |
|
222 | + $this->server->tree, \OC::$server->getTagManager() |
|
223 | + ) |
|
224 | + ); |
|
225 | + // TODO: switch to LazyUserFolder |
|
226 | + $userFolder = \OC::$server->getUserFolder(); |
|
227 | + $this->server->addPlugin(new SharesPlugin( |
|
228 | + $this->server->tree, |
|
229 | + $userSession, |
|
230 | + $userFolder, |
|
231 | + \OC::$server->getShareManager() |
|
232 | + )); |
|
233 | + $this->server->addPlugin(new CommentPropertiesPlugin( |
|
234 | + \OC::$server->getCommentsManager(), |
|
235 | + $userSession |
|
236 | + )); |
|
237 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
238 | + if ($view !== null) { |
|
239 | + $this->server->addPlugin(new FilesReportPlugin( |
|
240 | + $this->server->tree, |
|
241 | + $view, |
|
242 | + \OC::$server->getSystemTagManager(), |
|
243 | + \OC::$server->getSystemTagObjectMapper(), |
|
244 | + \OC::$server->getTagManager(), |
|
245 | + $userSession, |
|
246 | + \OC::$server->getGroupManager(), |
|
247 | + $userFolder |
|
248 | + )); |
|
249 | + $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
250 | + $this->server->tree, |
|
251 | + $user, |
|
252 | + \OC::$server->getRootFolder(), |
|
253 | + \OC::$server->getShareManager(), |
|
254 | + $view |
|
255 | + ))); |
|
256 | + } |
|
257 | + $this->server->addPlugin(new \OCA\Dav\CalDAV\BirthdayCalendar\EnablePlugin( |
|
258 | + \OC::$server->getConfig() |
|
259 | + )); |
|
260 | + } |
|
261 | 261 | |
262 | - // register plugins from apps |
|
263 | - $pluginManager = new PluginManager( |
|
264 | - \OC::$server, |
|
265 | - \OC::$server->getAppManager() |
|
266 | - ); |
|
267 | - foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
268 | - $this->server->addPlugin($appPlugin); |
|
269 | - } |
|
270 | - foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
271 | - $root->addChild($appCollection); |
|
272 | - } |
|
273 | - }); |
|
274 | - } |
|
262 | + // register plugins from apps |
|
263 | + $pluginManager = new PluginManager( |
|
264 | + \OC::$server, |
|
265 | + \OC::$server->getAppManager() |
|
266 | + ); |
|
267 | + foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
268 | + $this->server->addPlugin($appPlugin); |
|
269 | + } |
|
270 | + foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
271 | + $root->addChild($appCollection); |
|
272 | + } |
|
273 | + }); |
|
274 | + } |
|
275 | 275 | |
276 | - public function exec() { |
|
277 | - $this->server->exec(); |
|
278 | - } |
|
276 | + public function exec() { |
|
277 | + $this->server->exec(); |
|
278 | + } |
|
279 | 279 | } |