@@ -31,30 +31,30 @@ |
||
31 | 31 | |
32 | 32 | class LastUsedController extends Controller { |
33 | 33 | |
34 | - /** @var IConfig */ |
|
35 | - protected $config; |
|
34 | + /** @var IConfig */ |
|
35 | + protected $config; |
|
36 | 36 | |
37 | - /** @var IUserSession */ |
|
38 | - protected $userSession; |
|
37 | + /** @var IUserSession */ |
|
38 | + protected $userSession; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param string $appName |
|
42 | - * @param IRequest $request |
|
43 | - * @param IConfig $config |
|
44 | - * @param IUserSession $userSession |
|
45 | - */ |
|
46 | - public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) { |
|
47 | - parent::__construct($appName, $request); |
|
48 | - $this->config = $config; |
|
49 | - $this->userSession = $userSession; |
|
50 | - } |
|
40 | + /** |
|
41 | + * @param string $appName |
|
42 | + * @param IRequest $request |
|
43 | + * @param IConfig $config |
|
44 | + * @param IUserSession $userSession |
|
45 | + */ |
|
46 | + public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) { |
|
47 | + parent::__construct($appName, $request); |
|
48 | + $this->config = $config; |
|
49 | + $this->userSession = $userSession; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @NoAdminRequired |
|
54 | - */ |
|
55 | - public function getLastUsedTagIds() { |
|
56 | - $lastUsed = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'systemtags', 'last_used', '[]'); |
|
57 | - $tagIds = json_decode($lastUsed, true); |
|
58 | - return new DataResponse(array_map(function($id) { return (string) $id; }, $tagIds)); |
|
59 | - } |
|
52 | + /** |
|
53 | + * @NoAdminRequired |
|
54 | + */ |
|
55 | + public function getLastUsedTagIds() { |
|
56 | + $lastUsed = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'systemtags', 'last_used', '[]'); |
|
57 | + $tagIds = json_decode($lastUsed, true); |
|
58 | + return new DataResponse(array_map(function($id) { return (string) $id; }, $tagIds)); |
|
59 | + } |
|
60 | 60 | } |
@@ -42,304 +42,304 @@ |
||
42 | 42 | |
43 | 43 | class SyncService { |
44 | 44 | |
45 | - /** @var CardDavBackend */ |
|
46 | - private $backend; |
|
47 | - |
|
48 | - /** @var IUserManager */ |
|
49 | - private $userManager; |
|
50 | - |
|
51 | - /** @var ILogger */ |
|
52 | - private $logger; |
|
53 | - |
|
54 | - /** @var array */ |
|
55 | - private $localSystemAddressBook; |
|
56 | - |
|
57 | - /** @var AccountManager */ |
|
58 | - private $accountManager; |
|
59 | - |
|
60 | - /** @var string */ |
|
61 | - protected $certPath; |
|
62 | - |
|
63 | - /** |
|
64 | - * SyncService constructor. |
|
65 | - * |
|
66 | - * @param CardDavBackend $backend |
|
67 | - * @param IUserManager $userManager |
|
68 | - * @param ILogger $logger |
|
69 | - * @param AccountManager $accountManager |
|
70 | - */ |
|
71 | - public function __construct(CardDavBackend $backend, IUserManager $userManager, ILogger $logger, AccountManager $accountManager) { |
|
72 | - $this->backend = $backend; |
|
73 | - $this->userManager = $userManager; |
|
74 | - $this->logger = $logger; |
|
75 | - $this->accountManager = $accountManager; |
|
76 | - $this->certPath = ''; |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @param string $url |
|
81 | - * @param string $userName |
|
82 | - * @param string $addressBookUrl |
|
83 | - * @param string $sharedSecret |
|
84 | - * @param string $syncToken |
|
85 | - * @param int $targetBookId |
|
86 | - * @param string $targetPrincipal |
|
87 | - * @param array $targetProperties |
|
88 | - * @return string |
|
89 | - * @throws \Exception |
|
90 | - */ |
|
91 | - public function syncRemoteAddressBook($url, $userName, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties) { |
|
92 | - // 1. create addressbook |
|
93 | - $book = $this->ensureSystemAddressBookExists($targetPrincipal, $targetBookId, $targetProperties); |
|
94 | - $addressBookId = $book['id']; |
|
95 | - |
|
96 | - // 2. query changes |
|
97 | - try { |
|
98 | - $response = $this->requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken); |
|
99 | - } catch (ClientHttpException $ex) { |
|
100 | - if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) { |
|
101 | - // remote server revoked access to the address book, remove it |
|
102 | - $this->backend->deleteAddressBook($addressBookId); |
|
103 | - $this->logger->info('Authorization failed, remove address book: ' . $url, ['app' => 'dav']); |
|
104 | - throw $ex; |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - // 3. apply changes |
|
109 | - // TODO: use multi-get for download |
|
110 | - foreach ($response['response'] as $resource => $status) { |
|
111 | - $cardUri = basename($resource); |
|
112 | - if (isset($status[200])) { |
|
113 | - $vCard = $this->download($url, $userName, $sharedSecret, $resource); |
|
114 | - $existingCard = $this->backend->getCard($addressBookId, $cardUri); |
|
115 | - if ($existingCard === false) { |
|
116 | - $this->backend->createCard($addressBookId, $cardUri, $vCard['body']); |
|
117 | - } else { |
|
118 | - $this->backend->updateCard($addressBookId, $cardUri, $vCard['body']); |
|
119 | - } |
|
120 | - } else { |
|
121 | - $this->backend->deleteCard($addressBookId, $cardUri); |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - return $response['token']; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @param string $principal |
|
130 | - * @param string $id |
|
131 | - * @param array $properties |
|
132 | - * @return array|null |
|
133 | - * @throws \Sabre\DAV\Exception\BadRequest |
|
134 | - */ |
|
135 | - public function ensureSystemAddressBookExists($principal, $id, $properties) { |
|
136 | - $book = $this->backend->getAddressBooksByUri($principal, $id); |
|
137 | - if (!is_null($book)) { |
|
138 | - return $book; |
|
139 | - } |
|
140 | - $this->backend->createAddressBook($principal, $id, $properties); |
|
141 | - |
|
142 | - return $this->backend->getAddressBooksByUri($principal, $id); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Check if there is a valid certPath we should use |
|
147 | - * |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - protected function getCertPath() { |
|
151 | - |
|
152 | - // we already have a valid certPath |
|
153 | - if ($this->certPath !== '') { |
|
154 | - return $this->certPath; |
|
155 | - } |
|
156 | - |
|
157 | - /** @var ICertificateManager $certManager */ |
|
158 | - $certManager = \OC::$server->getCertificateManager(null); |
|
159 | - $certPath = $certManager->getAbsoluteBundlePath(); |
|
160 | - if (file_exists($certPath)) { |
|
161 | - $this->certPath = $certPath; |
|
162 | - } |
|
163 | - |
|
164 | - return $this->certPath; |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * @param string $url |
|
169 | - * @param string $userName |
|
170 | - * @param string $addressBookUrl |
|
171 | - * @param string $sharedSecret |
|
172 | - * @return Client |
|
173 | - */ |
|
174 | - protected function getClient($url, $userName, $sharedSecret) { |
|
175 | - $settings = [ |
|
176 | - 'baseUri' => $url . '/', |
|
177 | - 'userName' => $userName, |
|
178 | - 'password' => $sharedSecret, |
|
179 | - ]; |
|
180 | - $client = new Client($settings); |
|
181 | - $certPath = $this->getCertPath(); |
|
182 | - $client->setThrowExceptions(true); |
|
183 | - |
|
184 | - if ($certPath !== '' && strpos($url, 'http://') !== 0) { |
|
185 | - $client->addCurlSetting(CURLOPT_CAINFO, $this->certPath); |
|
186 | - } |
|
187 | - |
|
188 | - return $client; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * @param string $url |
|
193 | - * @param string $userName |
|
194 | - * @param string $addressBookUrl |
|
195 | - * @param string $sharedSecret |
|
196 | - * @param string $syncToken |
|
197 | - * @return array |
|
198 | - */ |
|
199 | - protected function requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken) { |
|
200 | - $client = $this->getClient($url, $userName, $sharedSecret); |
|
201 | - |
|
202 | - $body = $this->buildSyncCollectionRequestBody($syncToken); |
|
203 | - |
|
204 | - $response = $client->request('REPORT', $addressBookUrl, $body, [ |
|
205 | - 'Content-Type' => 'application/xml' |
|
206 | - ]); |
|
207 | - |
|
208 | - return $this->parseMultiStatus($response['body']); |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * @param string $url |
|
213 | - * @param string $userName |
|
214 | - * @param string $sharedSecret |
|
215 | - * @param string $resourcePath |
|
216 | - * @return array |
|
217 | - */ |
|
218 | - protected function download($url, $userName, $sharedSecret, $resourcePath) { |
|
219 | - $client = $this->getClient($url, $userName, $sharedSecret); |
|
220 | - return $client->request('GET', $resourcePath); |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * @param string|null $syncToken |
|
225 | - * @return string |
|
226 | - */ |
|
227 | - private function buildSyncCollectionRequestBody($syncToken) { |
|
228 | - |
|
229 | - $dom = new \DOMDocument('1.0', 'UTF-8'); |
|
230 | - $dom->formatOutput = true; |
|
231 | - $root = $dom->createElementNS('DAV:', 'd:sync-collection'); |
|
232 | - $sync = $dom->createElement('d:sync-token', $syncToken); |
|
233 | - $prop = $dom->createElement('d:prop'); |
|
234 | - $cont = $dom->createElement('d:getcontenttype'); |
|
235 | - $etag = $dom->createElement('d:getetag'); |
|
236 | - |
|
237 | - $prop->appendChild($cont); |
|
238 | - $prop->appendChild($etag); |
|
239 | - $root->appendChild($sync); |
|
240 | - $root->appendChild($prop); |
|
241 | - $dom->appendChild($root); |
|
242 | - return $dom->saveXML(); |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * @param string $body |
|
247 | - * @return array |
|
248 | - * @throws \Sabre\Xml\ParseException |
|
249 | - */ |
|
250 | - private function parseMultiStatus($body) { |
|
251 | - $xml = new Service(); |
|
252 | - |
|
253 | - /** @var MultiStatus $multiStatus */ |
|
254 | - $multiStatus = $xml->expect('{DAV:}multistatus', $body); |
|
255 | - |
|
256 | - $result = []; |
|
257 | - foreach ($multiStatus->getResponses() as $response) { |
|
258 | - $result[$response->getHref()] = $response->getResponseProperties(); |
|
259 | - } |
|
260 | - |
|
261 | - return ['response' => $result, 'token' => $multiStatus->getSyncToken()]; |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * @param IUser $user |
|
266 | - */ |
|
267 | - public function updateUser(IUser $user) { |
|
268 | - $systemAddressBook = $this->getLocalSystemAddressBook(); |
|
269 | - $addressBookId = $systemAddressBook['id']; |
|
270 | - $converter = new Converter($this->accountManager); |
|
271 | - $name = $user->getBackendClassName(); |
|
272 | - $userId = $user->getUID(); |
|
273 | - |
|
274 | - $cardId = "$name:$userId.vcf"; |
|
275 | - $card = $this->backend->getCard($addressBookId, $cardId); |
|
276 | - if ($user->isEnabled()) { |
|
277 | - if ($card === false) { |
|
278 | - $vCard = $converter->createCardFromUser($user); |
|
279 | - if ($vCard !== null) { |
|
280 | - $this->backend->createCard($addressBookId, $cardId, $vCard->serialize()); |
|
281 | - } |
|
282 | - } else { |
|
283 | - $vCard = $converter->createCardFromUser($user); |
|
284 | - if (is_null($vCard)) { |
|
285 | - $this->backend->deleteCard($addressBookId, $cardId); |
|
286 | - } else { |
|
287 | - $this->backend->updateCard($addressBookId, $cardId, $vCard->serialize()); |
|
288 | - } |
|
289 | - } |
|
290 | - } else { |
|
291 | - $this->backend->deleteCard($addressBookId, $cardId); |
|
292 | - } |
|
293 | - } |
|
294 | - |
|
295 | - /** |
|
296 | - * @param IUser|string $userOrCardId |
|
297 | - */ |
|
298 | - public function deleteUser($userOrCardId) { |
|
299 | - $systemAddressBook = $this->getLocalSystemAddressBook(); |
|
300 | - if ($userOrCardId instanceof IUser){ |
|
301 | - $name = $userOrCardId->getBackendClassName(); |
|
302 | - $userId = $userOrCardId->getUID(); |
|
303 | - |
|
304 | - $userOrCardId = "$name:$userId.vcf"; |
|
305 | - } |
|
306 | - $this->backend->deleteCard($systemAddressBook['id'], $userOrCardId); |
|
307 | - } |
|
308 | - |
|
309 | - /** |
|
310 | - * @return array|null |
|
311 | - */ |
|
312 | - public function getLocalSystemAddressBook() { |
|
313 | - if (is_null($this->localSystemAddressBook)) { |
|
314 | - $systemPrincipal = "principals/system/system"; |
|
315 | - $this->localSystemAddressBook = $this->ensureSystemAddressBookExists($systemPrincipal, 'system', [ |
|
316 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => 'System addressbook which holds all users of this instance' |
|
317 | - ]); |
|
318 | - } |
|
319 | - |
|
320 | - return $this->localSystemAddressBook; |
|
321 | - } |
|
322 | - |
|
323 | - public function syncInstance(\Closure $progressCallback = null) { |
|
324 | - $systemAddressBook = $this->getLocalSystemAddressBook(); |
|
325 | - $this->userManager->callForSeenUsers(function($user) use ($systemAddressBook, $progressCallback) { |
|
326 | - $this->updateUser($user); |
|
327 | - if (!is_null($progressCallback)) { |
|
328 | - $progressCallback(); |
|
329 | - } |
|
330 | - }); |
|
331 | - |
|
332 | - // remove no longer existing |
|
333 | - $allCards = $this->backend->getCards($systemAddressBook['id']); |
|
334 | - foreach($allCards as $card) { |
|
335 | - $vCard = Reader::read($card['carddata']); |
|
336 | - $uid = $vCard->UID->getValue(); |
|
337 | - // load backend and see if user exists |
|
338 | - if (!$this->userManager->userExists($uid)) { |
|
339 | - $this->deleteUser($card['uri']); |
|
340 | - } |
|
341 | - } |
|
342 | - } |
|
45 | + /** @var CardDavBackend */ |
|
46 | + private $backend; |
|
47 | + |
|
48 | + /** @var IUserManager */ |
|
49 | + private $userManager; |
|
50 | + |
|
51 | + /** @var ILogger */ |
|
52 | + private $logger; |
|
53 | + |
|
54 | + /** @var array */ |
|
55 | + private $localSystemAddressBook; |
|
56 | + |
|
57 | + /** @var AccountManager */ |
|
58 | + private $accountManager; |
|
59 | + |
|
60 | + /** @var string */ |
|
61 | + protected $certPath; |
|
62 | + |
|
63 | + /** |
|
64 | + * SyncService constructor. |
|
65 | + * |
|
66 | + * @param CardDavBackend $backend |
|
67 | + * @param IUserManager $userManager |
|
68 | + * @param ILogger $logger |
|
69 | + * @param AccountManager $accountManager |
|
70 | + */ |
|
71 | + public function __construct(CardDavBackend $backend, IUserManager $userManager, ILogger $logger, AccountManager $accountManager) { |
|
72 | + $this->backend = $backend; |
|
73 | + $this->userManager = $userManager; |
|
74 | + $this->logger = $logger; |
|
75 | + $this->accountManager = $accountManager; |
|
76 | + $this->certPath = ''; |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @param string $url |
|
81 | + * @param string $userName |
|
82 | + * @param string $addressBookUrl |
|
83 | + * @param string $sharedSecret |
|
84 | + * @param string $syncToken |
|
85 | + * @param int $targetBookId |
|
86 | + * @param string $targetPrincipal |
|
87 | + * @param array $targetProperties |
|
88 | + * @return string |
|
89 | + * @throws \Exception |
|
90 | + */ |
|
91 | + public function syncRemoteAddressBook($url, $userName, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties) { |
|
92 | + // 1. create addressbook |
|
93 | + $book = $this->ensureSystemAddressBookExists($targetPrincipal, $targetBookId, $targetProperties); |
|
94 | + $addressBookId = $book['id']; |
|
95 | + |
|
96 | + // 2. query changes |
|
97 | + try { |
|
98 | + $response = $this->requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken); |
|
99 | + } catch (ClientHttpException $ex) { |
|
100 | + if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) { |
|
101 | + // remote server revoked access to the address book, remove it |
|
102 | + $this->backend->deleteAddressBook($addressBookId); |
|
103 | + $this->logger->info('Authorization failed, remove address book: ' . $url, ['app' => 'dav']); |
|
104 | + throw $ex; |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + // 3. apply changes |
|
109 | + // TODO: use multi-get for download |
|
110 | + foreach ($response['response'] as $resource => $status) { |
|
111 | + $cardUri = basename($resource); |
|
112 | + if (isset($status[200])) { |
|
113 | + $vCard = $this->download($url, $userName, $sharedSecret, $resource); |
|
114 | + $existingCard = $this->backend->getCard($addressBookId, $cardUri); |
|
115 | + if ($existingCard === false) { |
|
116 | + $this->backend->createCard($addressBookId, $cardUri, $vCard['body']); |
|
117 | + } else { |
|
118 | + $this->backend->updateCard($addressBookId, $cardUri, $vCard['body']); |
|
119 | + } |
|
120 | + } else { |
|
121 | + $this->backend->deleteCard($addressBookId, $cardUri); |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + return $response['token']; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @param string $principal |
|
130 | + * @param string $id |
|
131 | + * @param array $properties |
|
132 | + * @return array|null |
|
133 | + * @throws \Sabre\DAV\Exception\BadRequest |
|
134 | + */ |
|
135 | + public function ensureSystemAddressBookExists($principal, $id, $properties) { |
|
136 | + $book = $this->backend->getAddressBooksByUri($principal, $id); |
|
137 | + if (!is_null($book)) { |
|
138 | + return $book; |
|
139 | + } |
|
140 | + $this->backend->createAddressBook($principal, $id, $properties); |
|
141 | + |
|
142 | + return $this->backend->getAddressBooksByUri($principal, $id); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Check if there is a valid certPath we should use |
|
147 | + * |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + protected function getCertPath() { |
|
151 | + |
|
152 | + // we already have a valid certPath |
|
153 | + if ($this->certPath !== '') { |
|
154 | + return $this->certPath; |
|
155 | + } |
|
156 | + |
|
157 | + /** @var ICertificateManager $certManager */ |
|
158 | + $certManager = \OC::$server->getCertificateManager(null); |
|
159 | + $certPath = $certManager->getAbsoluteBundlePath(); |
|
160 | + if (file_exists($certPath)) { |
|
161 | + $this->certPath = $certPath; |
|
162 | + } |
|
163 | + |
|
164 | + return $this->certPath; |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * @param string $url |
|
169 | + * @param string $userName |
|
170 | + * @param string $addressBookUrl |
|
171 | + * @param string $sharedSecret |
|
172 | + * @return Client |
|
173 | + */ |
|
174 | + protected function getClient($url, $userName, $sharedSecret) { |
|
175 | + $settings = [ |
|
176 | + 'baseUri' => $url . '/', |
|
177 | + 'userName' => $userName, |
|
178 | + 'password' => $sharedSecret, |
|
179 | + ]; |
|
180 | + $client = new Client($settings); |
|
181 | + $certPath = $this->getCertPath(); |
|
182 | + $client->setThrowExceptions(true); |
|
183 | + |
|
184 | + if ($certPath !== '' && strpos($url, 'http://') !== 0) { |
|
185 | + $client->addCurlSetting(CURLOPT_CAINFO, $this->certPath); |
|
186 | + } |
|
187 | + |
|
188 | + return $client; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * @param string $url |
|
193 | + * @param string $userName |
|
194 | + * @param string $addressBookUrl |
|
195 | + * @param string $sharedSecret |
|
196 | + * @param string $syncToken |
|
197 | + * @return array |
|
198 | + */ |
|
199 | + protected function requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken) { |
|
200 | + $client = $this->getClient($url, $userName, $sharedSecret); |
|
201 | + |
|
202 | + $body = $this->buildSyncCollectionRequestBody($syncToken); |
|
203 | + |
|
204 | + $response = $client->request('REPORT', $addressBookUrl, $body, [ |
|
205 | + 'Content-Type' => 'application/xml' |
|
206 | + ]); |
|
207 | + |
|
208 | + return $this->parseMultiStatus($response['body']); |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * @param string $url |
|
213 | + * @param string $userName |
|
214 | + * @param string $sharedSecret |
|
215 | + * @param string $resourcePath |
|
216 | + * @return array |
|
217 | + */ |
|
218 | + protected function download($url, $userName, $sharedSecret, $resourcePath) { |
|
219 | + $client = $this->getClient($url, $userName, $sharedSecret); |
|
220 | + return $client->request('GET', $resourcePath); |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * @param string|null $syncToken |
|
225 | + * @return string |
|
226 | + */ |
|
227 | + private function buildSyncCollectionRequestBody($syncToken) { |
|
228 | + |
|
229 | + $dom = new \DOMDocument('1.0', 'UTF-8'); |
|
230 | + $dom->formatOutput = true; |
|
231 | + $root = $dom->createElementNS('DAV:', 'd:sync-collection'); |
|
232 | + $sync = $dom->createElement('d:sync-token', $syncToken); |
|
233 | + $prop = $dom->createElement('d:prop'); |
|
234 | + $cont = $dom->createElement('d:getcontenttype'); |
|
235 | + $etag = $dom->createElement('d:getetag'); |
|
236 | + |
|
237 | + $prop->appendChild($cont); |
|
238 | + $prop->appendChild($etag); |
|
239 | + $root->appendChild($sync); |
|
240 | + $root->appendChild($prop); |
|
241 | + $dom->appendChild($root); |
|
242 | + return $dom->saveXML(); |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * @param string $body |
|
247 | + * @return array |
|
248 | + * @throws \Sabre\Xml\ParseException |
|
249 | + */ |
|
250 | + private function parseMultiStatus($body) { |
|
251 | + $xml = new Service(); |
|
252 | + |
|
253 | + /** @var MultiStatus $multiStatus */ |
|
254 | + $multiStatus = $xml->expect('{DAV:}multistatus', $body); |
|
255 | + |
|
256 | + $result = []; |
|
257 | + foreach ($multiStatus->getResponses() as $response) { |
|
258 | + $result[$response->getHref()] = $response->getResponseProperties(); |
|
259 | + } |
|
260 | + |
|
261 | + return ['response' => $result, 'token' => $multiStatus->getSyncToken()]; |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * @param IUser $user |
|
266 | + */ |
|
267 | + public function updateUser(IUser $user) { |
|
268 | + $systemAddressBook = $this->getLocalSystemAddressBook(); |
|
269 | + $addressBookId = $systemAddressBook['id']; |
|
270 | + $converter = new Converter($this->accountManager); |
|
271 | + $name = $user->getBackendClassName(); |
|
272 | + $userId = $user->getUID(); |
|
273 | + |
|
274 | + $cardId = "$name:$userId.vcf"; |
|
275 | + $card = $this->backend->getCard($addressBookId, $cardId); |
|
276 | + if ($user->isEnabled()) { |
|
277 | + if ($card === false) { |
|
278 | + $vCard = $converter->createCardFromUser($user); |
|
279 | + if ($vCard !== null) { |
|
280 | + $this->backend->createCard($addressBookId, $cardId, $vCard->serialize()); |
|
281 | + } |
|
282 | + } else { |
|
283 | + $vCard = $converter->createCardFromUser($user); |
|
284 | + if (is_null($vCard)) { |
|
285 | + $this->backend->deleteCard($addressBookId, $cardId); |
|
286 | + } else { |
|
287 | + $this->backend->updateCard($addressBookId, $cardId, $vCard->serialize()); |
|
288 | + } |
|
289 | + } |
|
290 | + } else { |
|
291 | + $this->backend->deleteCard($addressBookId, $cardId); |
|
292 | + } |
|
293 | + } |
|
294 | + |
|
295 | + /** |
|
296 | + * @param IUser|string $userOrCardId |
|
297 | + */ |
|
298 | + public function deleteUser($userOrCardId) { |
|
299 | + $systemAddressBook = $this->getLocalSystemAddressBook(); |
|
300 | + if ($userOrCardId instanceof IUser){ |
|
301 | + $name = $userOrCardId->getBackendClassName(); |
|
302 | + $userId = $userOrCardId->getUID(); |
|
303 | + |
|
304 | + $userOrCardId = "$name:$userId.vcf"; |
|
305 | + } |
|
306 | + $this->backend->deleteCard($systemAddressBook['id'], $userOrCardId); |
|
307 | + } |
|
308 | + |
|
309 | + /** |
|
310 | + * @return array|null |
|
311 | + */ |
|
312 | + public function getLocalSystemAddressBook() { |
|
313 | + if (is_null($this->localSystemAddressBook)) { |
|
314 | + $systemPrincipal = "principals/system/system"; |
|
315 | + $this->localSystemAddressBook = $this->ensureSystemAddressBookExists($systemPrincipal, 'system', [ |
|
316 | + '{' . Plugin::NS_CARDDAV . '}addressbook-description' => 'System addressbook which holds all users of this instance' |
|
317 | + ]); |
|
318 | + } |
|
319 | + |
|
320 | + return $this->localSystemAddressBook; |
|
321 | + } |
|
322 | + |
|
323 | + public function syncInstance(\Closure $progressCallback = null) { |
|
324 | + $systemAddressBook = $this->getLocalSystemAddressBook(); |
|
325 | + $this->userManager->callForSeenUsers(function($user) use ($systemAddressBook, $progressCallback) { |
|
326 | + $this->updateUser($user); |
|
327 | + if (!is_null($progressCallback)) { |
|
328 | + $progressCallback(); |
|
329 | + } |
|
330 | + }); |
|
331 | + |
|
332 | + // remove no longer existing |
|
333 | + $allCards = $this->backend->getCards($systemAddressBook['id']); |
|
334 | + foreach($allCards as $card) { |
|
335 | + $vCard = Reader::read($card['carddata']); |
|
336 | + $uid = $vCard->UID->getValue(); |
|
337 | + // load backend and see if user exists |
|
338 | + if (!$this->userManager->userExists($uid)) { |
|
339 | + $this->deleteUser($card['uri']); |
|
340 | + } |
|
341 | + } |
|
342 | + } |
|
343 | 343 | |
344 | 344 | |
345 | 345 | } |
@@ -24,14 +24,14 @@ |
||
24 | 24 | namespace OCA\User_LDAP; |
25 | 25 | |
26 | 26 | class ConnectionFactory { |
27 | - /** @var ILDAPWrapper */ |
|
28 | - private $ldap; |
|
27 | + /** @var ILDAPWrapper */ |
|
28 | + private $ldap; |
|
29 | 29 | |
30 | - public function __construct(ILDAPWrapper $ldap) { |
|
31 | - $this->ldap = $ldap; |
|
32 | - } |
|
30 | + public function __construct(ILDAPWrapper $ldap) { |
|
31 | + $this->ldap = $ldap; |
|
32 | + } |
|
33 | 33 | |
34 | - public function get($prefix) { |
|
35 | - return new Connection($this->ldap, $prefix, 'user_ldap'); |
|
36 | - } |
|
34 | + public function get($prefix) { |
|
35 | + return new Connection($this->ldap, $prefix, 'user_ldap'); |
|
36 | + } |
|
37 | 37 | } |
@@ -29,21 +29,21 @@ |
||
29 | 29 | namespace OCA\AdminAudit\Actions; |
30 | 30 | |
31 | 31 | class Console extends Action { |
32 | - /** |
|
33 | - * @param $arguments |
|
34 | - */ |
|
35 | - public function runCommand(array $arguments) { |
|
36 | - if (!isset($arguments[1]) || $arguments[1] === '_completion') { |
|
37 | - // Don't log autocompletion |
|
38 | - return; |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param $arguments |
|
34 | + */ |
|
35 | + public function runCommand(array $arguments) { |
|
36 | + if (!isset($arguments[1]) || $arguments[1] === '_completion') { |
|
37 | + // Don't log autocompletion |
|
38 | + return; |
|
39 | + } |
|
40 | 40 | |
41 | - // Remove `./occ` |
|
42 | - array_shift($arguments); |
|
41 | + // Remove `./occ` |
|
42 | + array_shift($arguments); |
|
43 | 43 | |
44 | - $this->log('Console command executed: %s', |
|
45 | - ['arguments' => implode(' ', $arguments)], |
|
46 | - ['arguments'] |
|
47 | - ); |
|
48 | - } |
|
44 | + $this->log('Console command executed: %s', |
|
45 | + ['arguments' => implode(' ', $arguments)], |
|
46 | + ['arguments'] |
|
47 | + ); |
|
48 | + } |
|
49 | 49 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | namespace OCA\Files_Trashbin\Sabre; |
29 | 29 | |
30 | 30 | class TrashFolderFile extends AbstractTrashFile { |
31 | - public function get() { |
|
32 | - return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb'); |
|
33 | - } |
|
31 | + public function get() { |
|
32 | + return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb'); |
|
33 | + } |
|
34 | 34 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | namespace OCA\Files_Trashbin\Sabre; |
29 | 29 | |
30 | 30 | class TrashFolder extends AbstractTrashFolder { |
31 | - public function getName(): string { |
|
32 | - return $this->data->getName() . '.d' . $this->getLastModified(); |
|
33 | - } |
|
31 | + public function getName(): string { |
|
32 | + return $this->data->getName() . '.d' . $this->getLastModified(); |
|
33 | + } |
|
34 | 34 | } |
@@ -37,220 +37,220 @@ |
||
37 | 37 | * @since 9.0.0 |
38 | 38 | */ |
39 | 39 | interface ICache { |
40 | - const NOT_FOUND = 0; |
|
41 | - const PARTIAL = 1; //only partial data available, file not cached in the database |
|
42 | - const SHALLOW = 2; //folder in cache, but not all child files are completely scanned |
|
43 | - const COMPLETE = 3; |
|
40 | + const NOT_FOUND = 0; |
|
41 | + const PARTIAL = 1; //only partial data available, file not cached in the database |
|
42 | + const SHALLOW = 2; //folder in cache, but not all child files are completely scanned |
|
43 | + const COMPLETE = 3; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Get the numeric storage id for this cache's storage |
|
47 | - * |
|
48 | - * @return int |
|
49 | - * @since 9.0.0 |
|
50 | - */ |
|
51 | - public function getNumericStorageId(); |
|
45 | + /** |
|
46 | + * Get the numeric storage id for this cache's storage |
|
47 | + * |
|
48 | + * @return int |
|
49 | + * @since 9.0.0 |
|
50 | + */ |
|
51 | + public function getNumericStorageId(); |
|
52 | 52 | |
53 | - /** |
|
54 | - * get the stored metadata of a file or folder |
|
55 | - * |
|
56 | - * @param string | int $file either the path of a file or folder or the file id for a file or folder |
|
57 | - * @return ICacheEntry|false the cache entry or false if the file is not found in the cache |
|
58 | - * @since 9.0.0 |
|
59 | - */ |
|
60 | - public function get($file); |
|
53 | + /** |
|
54 | + * get the stored metadata of a file or folder |
|
55 | + * |
|
56 | + * @param string | int $file either the path of a file or folder or the file id for a file or folder |
|
57 | + * @return ICacheEntry|false the cache entry or false if the file is not found in the cache |
|
58 | + * @since 9.0.0 |
|
59 | + */ |
|
60 | + public function get($file); |
|
61 | 61 | |
62 | - /** |
|
63 | - * get the metadata of all files stored in $folder |
|
64 | - * |
|
65 | - * Only returns files one level deep, no recursion |
|
66 | - * |
|
67 | - * @param string $folder |
|
68 | - * @return ICacheEntry[] |
|
69 | - * @since 9.0.0 |
|
70 | - */ |
|
71 | - public function getFolderContents($folder); |
|
62 | + /** |
|
63 | + * get the metadata of all files stored in $folder |
|
64 | + * |
|
65 | + * Only returns files one level deep, no recursion |
|
66 | + * |
|
67 | + * @param string $folder |
|
68 | + * @return ICacheEntry[] |
|
69 | + * @since 9.0.0 |
|
70 | + */ |
|
71 | + public function getFolderContents($folder); |
|
72 | 72 | |
73 | - /** |
|
74 | - * get the metadata of all files stored in $folder |
|
75 | - * |
|
76 | - * Only returns files one level deep, no recursion |
|
77 | - * |
|
78 | - * @param int $fileId the file id of the folder |
|
79 | - * @return ICacheEntry[] |
|
80 | - * @since 9.0.0 |
|
81 | - */ |
|
82 | - public function getFolderContentsById($fileId); |
|
73 | + /** |
|
74 | + * get the metadata of all files stored in $folder |
|
75 | + * |
|
76 | + * Only returns files one level deep, no recursion |
|
77 | + * |
|
78 | + * @param int $fileId the file id of the folder |
|
79 | + * @return ICacheEntry[] |
|
80 | + * @since 9.0.0 |
|
81 | + */ |
|
82 | + public function getFolderContentsById($fileId); |
|
83 | 83 | |
84 | - /** |
|
85 | - * store meta data for a file or folder |
|
86 | - * This will automatically call either insert or update depending on if the file exists |
|
87 | - * |
|
88 | - * @param string $file |
|
89 | - * @param array $data |
|
90 | - * |
|
91 | - * @return int file id |
|
92 | - * @throws \RuntimeException |
|
93 | - * @since 9.0.0 |
|
94 | - */ |
|
95 | - public function put($file, array $data); |
|
84 | + /** |
|
85 | + * store meta data for a file or folder |
|
86 | + * This will automatically call either insert or update depending on if the file exists |
|
87 | + * |
|
88 | + * @param string $file |
|
89 | + * @param array $data |
|
90 | + * |
|
91 | + * @return int file id |
|
92 | + * @throws \RuntimeException |
|
93 | + * @since 9.0.0 |
|
94 | + */ |
|
95 | + public function put($file, array $data); |
|
96 | 96 | |
97 | - /** |
|
98 | - * insert meta data for a new file or folder |
|
99 | - * |
|
100 | - * @param string $file |
|
101 | - * @param array $data |
|
102 | - * |
|
103 | - * @return int file id |
|
104 | - * @throws \RuntimeException |
|
105 | - * @since 9.0.0 |
|
106 | - */ |
|
107 | - public function insert($file, array $data); |
|
97 | + /** |
|
98 | + * insert meta data for a new file or folder |
|
99 | + * |
|
100 | + * @param string $file |
|
101 | + * @param array $data |
|
102 | + * |
|
103 | + * @return int file id |
|
104 | + * @throws \RuntimeException |
|
105 | + * @since 9.0.0 |
|
106 | + */ |
|
107 | + public function insert($file, array $data); |
|
108 | 108 | |
109 | - /** |
|
110 | - * update the metadata of an existing file or folder in the cache |
|
111 | - * |
|
112 | - * @param int $id the fileid of the existing file or folder |
|
113 | - * @param array $data [$key => $value] the metadata to update, only the fields provided in the array will be updated, non-provided values will remain unchanged |
|
114 | - * @since 9.0.0 |
|
115 | - */ |
|
116 | - public function update($id, array $data); |
|
109 | + /** |
|
110 | + * update the metadata of an existing file or folder in the cache |
|
111 | + * |
|
112 | + * @param int $id the fileid of the existing file or folder |
|
113 | + * @param array $data [$key => $value] the metadata to update, only the fields provided in the array will be updated, non-provided values will remain unchanged |
|
114 | + * @since 9.0.0 |
|
115 | + */ |
|
116 | + public function update($id, array $data); |
|
117 | 117 | |
118 | - /** |
|
119 | - * get the file id for a file |
|
120 | - * |
|
121 | - * A file id is a numeric id for a file or folder that's unique within an owncloud instance which stays the same for the lifetime of a file |
|
122 | - * |
|
123 | - * File ids are easiest way for apps to store references to a file since unlike paths they are not affected by renames or sharing |
|
124 | - * |
|
125 | - * @param string $file |
|
126 | - * @return int |
|
127 | - * @since 9.0.0 |
|
128 | - */ |
|
129 | - public function getId($file); |
|
118 | + /** |
|
119 | + * get the file id for a file |
|
120 | + * |
|
121 | + * A file id is a numeric id for a file or folder that's unique within an owncloud instance which stays the same for the lifetime of a file |
|
122 | + * |
|
123 | + * File ids are easiest way for apps to store references to a file since unlike paths they are not affected by renames or sharing |
|
124 | + * |
|
125 | + * @param string $file |
|
126 | + * @return int |
|
127 | + * @since 9.0.0 |
|
128 | + */ |
|
129 | + public function getId($file); |
|
130 | 130 | |
131 | - /** |
|
132 | - * get the id of the parent folder of a file |
|
133 | - * |
|
134 | - * @param string $file |
|
135 | - * @return int |
|
136 | - * @since 9.0.0 |
|
137 | - */ |
|
138 | - public function getParentId($file); |
|
131 | + /** |
|
132 | + * get the id of the parent folder of a file |
|
133 | + * |
|
134 | + * @param string $file |
|
135 | + * @return int |
|
136 | + * @since 9.0.0 |
|
137 | + */ |
|
138 | + public function getParentId($file); |
|
139 | 139 | |
140 | - /** |
|
141 | - * check if a file is available in the cache |
|
142 | - * |
|
143 | - * @param string $file |
|
144 | - * @return bool |
|
145 | - * @since 9.0.0 |
|
146 | - */ |
|
147 | - public function inCache($file); |
|
140 | + /** |
|
141 | + * check if a file is available in the cache |
|
142 | + * |
|
143 | + * @param string $file |
|
144 | + * @return bool |
|
145 | + * @since 9.0.0 |
|
146 | + */ |
|
147 | + public function inCache($file); |
|
148 | 148 | |
149 | - /** |
|
150 | - * remove a file or folder from the cache |
|
151 | - * |
|
152 | - * when removing a folder from the cache all files and folders inside the folder will be removed as well |
|
153 | - * |
|
154 | - * @param string $file |
|
155 | - * @since 9.0.0 |
|
156 | - */ |
|
157 | - public function remove($file); |
|
149 | + /** |
|
150 | + * remove a file or folder from the cache |
|
151 | + * |
|
152 | + * when removing a folder from the cache all files and folders inside the folder will be removed as well |
|
153 | + * |
|
154 | + * @param string $file |
|
155 | + * @since 9.0.0 |
|
156 | + */ |
|
157 | + public function remove($file); |
|
158 | 158 | |
159 | - /** |
|
160 | - * Move a file or folder in the cache |
|
161 | - * |
|
162 | - * @param string $source |
|
163 | - * @param string $target |
|
164 | - * @since 9.0.0 |
|
165 | - */ |
|
166 | - public function move($source, $target); |
|
159 | + /** |
|
160 | + * Move a file or folder in the cache |
|
161 | + * |
|
162 | + * @param string $source |
|
163 | + * @param string $target |
|
164 | + * @since 9.0.0 |
|
165 | + */ |
|
166 | + public function move($source, $target); |
|
167 | 167 | |
168 | - /** |
|
169 | - * Move a file or folder in the cache |
|
170 | - * |
|
171 | - * Note that this should make sure the entries are removed from the source cache |
|
172 | - * |
|
173 | - * @param \OCP\Files\Cache\ICache $sourceCache |
|
174 | - * @param string $sourcePath |
|
175 | - * @param string $targetPath |
|
176 | - * @throws \OC\DatabaseException |
|
177 | - * @since 9.0.0 |
|
178 | - */ |
|
179 | - public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath); |
|
168 | + /** |
|
169 | + * Move a file or folder in the cache |
|
170 | + * |
|
171 | + * Note that this should make sure the entries are removed from the source cache |
|
172 | + * |
|
173 | + * @param \OCP\Files\Cache\ICache $sourceCache |
|
174 | + * @param string $sourcePath |
|
175 | + * @param string $targetPath |
|
176 | + * @throws \OC\DatabaseException |
|
177 | + * @since 9.0.0 |
|
178 | + */ |
|
179 | + public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath); |
|
180 | 180 | |
181 | - /** |
|
182 | - * Get the scan status of a file |
|
183 | - * |
|
184 | - * - ICache::NOT_FOUND: File is not in the cache |
|
185 | - * - ICache::PARTIAL: File is not stored in the cache but some incomplete data is known |
|
186 | - * - ICache::SHALLOW: The folder and it's direct children are in the cache but not all sub folders are fully scanned |
|
187 | - * - ICache::COMPLETE: The file or folder, with all it's children) are fully scanned |
|
188 | - * |
|
189 | - * @param string $file |
|
190 | - * |
|
191 | - * @return int ICache::NOT_FOUND, ICache::PARTIAL, ICache::SHALLOW or ICache::COMPLETE |
|
192 | - * @since 9.0.0 |
|
193 | - */ |
|
194 | - public function getStatus($file); |
|
181 | + /** |
|
182 | + * Get the scan status of a file |
|
183 | + * |
|
184 | + * - ICache::NOT_FOUND: File is not in the cache |
|
185 | + * - ICache::PARTIAL: File is not stored in the cache but some incomplete data is known |
|
186 | + * - ICache::SHALLOW: The folder and it's direct children are in the cache but not all sub folders are fully scanned |
|
187 | + * - ICache::COMPLETE: The file or folder, with all it's children) are fully scanned |
|
188 | + * |
|
189 | + * @param string $file |
|
190 | + * |
|
191 | + * @return int ICache::NOT_FOUND, ICache::PARTIAL, ICache::SHALLOW or ICache::COMPLETE |
|
192 | + * @since 9.0.0 |
|
193 | + */ |
|
194 | + public function getStatus($file); |
|
195 | 195 | |
196 | - /** |
|
197 | - * search for files matching $pattern, files are matched if their filename matches the search pattern |
|
198 | - * |
|
199 | - * @param string $pattern the search pattern using SQL search syntax (e.g. '%searchstring%') |
|
200 | - * @return ICacheEntry[] an array of cache entries where the name matches the search pattern |
|
201 | - * @since 9.0.0 |
|
202 | - * @deprecated 9.0.0 due to lack of pagination, not all backends might implement this |
|
203 | - */ |
|
204 | - public function search($pattern); |
|
196 | + /** |
|
197 | + * search for files matching $pattern, files are matched if their filename matches the search pattern |
|
198 | + * |
|
199 | + * @param string $pattern the search pattern using SQL search syntax (e.g. '%searchstring%') |
|
200 | + * @return ICacheEntry[] an array of cache entries where the name matches the search pattern |
|
201 | + * @since 9.0.0 |
|
202 | + * @deprecated 9.0.0 due to lack of pagination, not all backends might implement this |
|
203 | + */ |
|
204 | + public function search($pattern); |
|
205 | 205 | |
206 | - /** |
|
207 | - * search for files by mimetype |
|
208 | - * |
|
209 | - * @param string $mimetype either a full mimetype to search ('text/plain') or only the first part of a mimetype ('image') |
|
210 | - * where it will search for all mimetypes in the group ('image/*') |
|
211 | - * @return ICacheEntry[] an array of cache entries where the mimetype matches the search |
|
212 | - * @since 9.0.0 |
|
213 | - * @deprecated 9.0.0 due to lack of pagination, not all backends might implement this |
|
214 | - */ |
|
215 | - public function searchByMime($mimetype); |
|
206 | + /** |
|
207 | + * search for files by mimetype |
|
208 | + * |
|
209 | + * @param string $mimetype either a full mimetype to search ('text/plain') or only the first part of a mimetype ('image') |
|
210 | + * where it will search for all mimetypes in the group ('image/*') |
|
211 | + * @return ICacheEntry[] an array of cache entries where the mimetype matches the search |
|
212 | + * @since 9.0.0 |
|
213 | + * @deprecated 9.0.0 due to lack of pagination, not all backends might implement this |
|
214 | + */ |
|
215 | + public function searchByMime($mimetype); |
|
216 | 216 | |
217 | - /** |
|
218 | - * Search for files with a flexible query |
|
219 | - * |
|
220 | - * @param ISearchQuery $query |
|
221 | - * @return ICacheEntry[] |
|
222 | - * @throw \InvalidArgumentException if the cache is unable to perform the query |
|
223 | - * @since 12.0.0 |
|
224 | - */ |
|
225 | - public function searchQuery(ISearchQuery $query); |
|
217 | + /** |
|
218 | + * Search for files with a flexible query |
|
219 | + * |
|
220 | + * @param ISearchQuery $query |
|
221 | + * @return ICacheEntry[] |
|
222 | + * @throw \InvalidArgumentException if the cache is unable to perform the query |
|
223 | + * @since 12.0.0 |
|
224 | + */ |
|
225 | + public function searchQuery(ISearchQuery $query); |
|
226 | 226 | |
227 | - /** |
|
228 | - * find a folder in the cache which has not been fully scanned |
|
229 | - * |
|
230 | - * If multiple incomplete folders are in the cache, the one with the highest id will be returned, |
|
231 | - * use the one with the highest id gives the best result with the background scanner, since that is most |
|
232 | - * likely the folder where we stopped scanning previously |
|
233 | - * |
|
234 | - * @return string|bool the path of the folder or false when no folder matched |
|
235 | - * @since 9.0.0 |
|
236 | - */ |
|
237 | - public function getIncomplete(); |
|
227 | + /** |
|
228 | + * find a folder in the cache which has not been fully scanned |
|
229 | + * |
|
230 | + * If multiple incomplete folders are in the cache, the one with the highest id will be returned, |
|
231 | + * use the one with the highest id gives the best result with the background scanner, since that is most |
|
232 | + * likely the folder where we stopped scanning previously |
|
233 | + * |
|
234 | + * @return string|bool the path of the folder or false when no folder matched |
|
235 | + * @since 9.0.0 |
|
236 | + */ |
|
237 | + public function getIncomplete(); |
|
238 | 238 | |
239 | - /** |
|
240 | - * get the path of a file on this storage by it's file id |
|
241 | - * |
|
242 | - * @param int $id the file id of the file or folder to search |
|
243 | - * @return string|null the path of the file (relative to the storage) or null if a file with the given id does not exists within this cache |
|
244 | - * @since 9.0.0 |
|
245 | - */ |
|
246 | - public function getPathById($id); |
|
239 | + /** |
|
240 | + * get the path of a file on this storage by it's file id |
|
241 | + * |
|
242 | + * @param int $id the file id of the file or folder to search |
|
243 | + * @return string|null the path of the file (relative to the storage) or null if a file with the given id does not exists within this cache |
|
244 | + * @since 9.0.0 |
|
245 | + */ |
|
246 | + public function getPathById($id); |
|
247 | 247 | |
248 | - /** |
|
249 | - * normalize the given path for usage in the cache |
|
250 | - * |
|
251 | - * @param string $path |
|
252 | - * @return string |
|
253 | - * @since 9.0.0 |
|
254 | - */ |
|
255 | - public function normalize($path); |
|
248 | + /** |
|
249 | + * normalize the given path for usage in the cache |
|
250 | + * |
|
251 | + * @param string $path |
|
252 | + * @return string |
|
253 | + * @since 9.0.0 |
|
254 | + */ |
|
255 | + public function normalize($path); |
|
256 | 256 | } |
@@ -36,24 +36,24 @@ |
||
36 | 36 | */ |
37 | 37 | class LoginFailedEvent extends Event { |
38 | 38 | |
39 | - /** @var string */ |
|
40 | - private $uid; |
|
41 | - |
|
42 | - /** |
|
43 | - * @since 19.0.0 |
|
44 | - */ |
|
45 | - public function __construct(string $uid) { |
|
46 | - parent::__construct(); |
|
47 | - |
|
48 | - $this->uid = $uid; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * returns the uid of the user that was tried to login against |
|
53 | - * |
|
54 | - * @since 19.0.0 |
|
55 | - */ |
|
56 | - public function getUid(): string { |
|
57 | - return $this->uid; |
|
58 | - } |
|
39 | + /** @var string */ |
|
40 | + private $uid; |
|
41 | + |
|
42 | + /** |
|
43 | + * @since 19.0.0 |
|
44 | + */ |
|
45 | + public function __construct(string $uid) { |
|
46 | + parent::__construct(); |
|
47 | + |
|
48 | + $this->uid = $uid; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * returns the uid of the user that was tried to login against |
|
53 | + * |
|
54 | + * @since 19.0.0 |
|
55 | + */ |
|
56 | + public function getUid(): string { |
|
57 | + return $this->uid; |
|
58 | + } |
|
59 | 59 | } |
@@ -53,52 +53,52 @@ |
||
53 | 53 | abstract class AFilesDocument extends IndexDocument { |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Returns the owner of the document/file. |
|
58 | - * |
|
59 | - * @since 15.0.0 |
|
60 | - * |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - abstract public function getOwnerId(): string; |
|
56 | + /** |
|
57 | + * Returns the owner of the document/file. |
|
58 | + * |
|
59 | + * @since 15.0.0 |
|
60 | + * |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + abstract public function getOwnerId(): string; |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * Returns the current viewer of the document/file. |
|
68 | - * |
|
69 | - * @since 15.0.0 |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - abstract public function getViewerId(): string; |
|
66 | + /** |
|
67 | + * Returns the current viewer of the document/file. |
|
68 | + * |
|
69 | + * @since 15.0.0 |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + abstract public function getViewerId(): string; |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * Returns the type of the document/file. |
|
78 | - * |
|
79 | - * @since 15.0.0 |
|
80 | - * |
|
81 | - * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER |
|
82 | - */ |
|
83 | - abstract public function getType(): string; |
|
76 | + /** |
|
77 | + * Returns the type of the document/file. |
|
78 | + * |
|
79 | + * @since 15.0.0 |
|
80 | + * |
|
81 | + * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER |
|
82 | + */ |
|
83 | + abstract public function getType(): string; |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * Returns the mimetype of the document/file. |
|
88 | - * |
|
89 | - * @since 15.0.0 |
|
90 | - * |
|
91 | - * @return string |
|
92 | - */ |
|
93 | - abstract public function getMimetype(): string; |
|
86 | + /** |
|
87 | + * Returns the mimetype of the document/file. |
|
88 | + * |
|
89 | + * @since 15.0.0 |
|
90 | + * |
|
91 | + * @return string |
|
92 | + */ |
|
93 | + abstract public function getMimetype(): string; |
|
94 | 94 | |
95 | - /** |
|
96 | - * Returns the path of the document/file. |
|
97 | - * |
|
98 | - * @since 15.0.0 |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - abstract public function getPath(): string; |
|
95 | + /** |
|
96 | + * Returns the path of the document/file. |
|
97 | + * |
|
98 | + * @since 15.0.0 |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + abstract public function getPath(): string; |
|
103 | 103 | |
104 | 104 | } |