@@ -29,14 +29,14 @@ |
||
29 | 29 | |
30 | 30 | class Errorlog implements IWriter { |
31 | 31 | |
32 | - /** |
|
33 | - * write a message in the log |
|
34 | - * @param string $app |
|
35 | - * @param string $message |
|
36 | - * @param int $level |
|
37 | - */ |
|
38 | - public function write(string $app, $message, int $level) { |
|
39 | - error_log('[owncloud]['.$app.']['.$level.'] '.$message); |
|
40 | - } |
|
32 | + /** |
|
33 | + * write a message in the log |
|
34 | + * @param string $app |
|
35 | + * @param string $message |
|
36 | + * @param int $level |
|
37 | + */ |
|
38 | + public function write(string $app, $message, int $level) { |
|
39 | + error_log('[owncloud]['.$app.']['.$level.'] '.$message); |
|
40 | + } |
|
41 | 41 | } |
42 | 42 |
@@ -32,17 +32,17 @@ |
||
32 | 32 | * @since 14.0.0 |
33 | 33 | */ |
34 | 34 | interface ILogFactory { |
35 | - /** |
|
36 | - * @param string $type - one of: file, errorlog, syslog |
|
37 | - * @return IWriter |
|
38 | - * @since 14.0.0 |
|
39 | - */ |
|
40 | - public function get(string $type): IWriter; |
|
35 | + /** |
|
36 | + * @param string $type - one of: file, errorlog, syslog |
|
37 | + * @return IWriter |
|
38 | + * @since 14.0.0 |
|
39 | + */ |
|
40 | + public function get(string $type): IWriter; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param string $path |
|
44 | - * @return ILogger |
|
45 | - * @since 14.0.0 |
|
46 | - */ |
|
47 | - public function getCustomLogger(string $path): ILogger; |
|
42 | + /** |
|
43 | + * @param string $path |
|
44 | + * @return ILogger |
|
45 | + * @since 14.0.0 |
|
46 | + */ |
|
47 | + public function getCustomLogger(string $path): ILogger; |
|
48 | 48 | } |
@@ -30,8 +30,8 @@ |
||
30 | 30 | * @since 14.0.0 |
31 | 31 | */ |
32 | 32 | interface IWriter { |
33 | - /** |
|
34 | - * @since 14.0.0 |
|
35 | - */ |
|
36 | - public function write(string $app, $message, int $level); |
|
33 | + /** |
|
34 | + * @since 14.0.0 |
|
35 | + */ |
|
36 | + public function write(string $app, $message, int $level); |
|
37 | 37 | } |
@@ -58,492 +58,492 @@ |
||
58 | 58 | */ |
59 | 59 | interface IServerContainer extends IContainer { |
60 | 60 | |
61 | - /** |
|
62 | - * The calendar manager will act as a broker between consumers for calendar information and |
|
63 | - * providers which actual deliver the calendar information. |
|
64 | - * |
|
65 | - * @return \OCP\Calendar\IManager |
|
66 | - * @since 13.0.0 |
|
67 | - */ |
|
68 | - public function getCalendarManager(); |
|
69 | - |
|
70 | - /** |
|
71 | - * The contacts manager will act as a broker between consumers for contacts information and |
|
72 | - * providers which actual deliver the contact information. |
|
73 | - * |
|
74 | - * @return \OCP\Contacts\IManager |
|
75 | - * @since 6.0.0 |
|
76 | - */ |
|
77 | - public function getContactsManager(); |
|
78 | - |
|
79 | - /** |
|
80 | - * The current request object holding all information about the request currently being processed |
|
81 | - * is returned from this method. |
|
82 | - * In case the current execution was not initiated by a web request null is returned |
|
83 | - * |
|
84 | - * @return \OCP\IRequest |
|
85 | - * @since 6.0.0 |
|
86 | - */ |
|
87 | - public function getRequest(); |
|
88 | - |
|
89 | - /** |
|
90 | - * Returns the preview manager which can create preview images for a given file |
|
91 | - * |
|
92 | - * @return \OCP\IPreview |
|
93 | - * @since 6.0.0 |
|
94 | - */ |
|
95 | - public function getPreviewManager(); |
|
96 | - |
|
97 | - /** |
|
98 | - * Returns the tag manager which can get and set tags for different object types |
|
99 | - * |
|
100 | - * @see \OCP\ITagManager::load() |
|
101 | - * @return \OCP\ITagManager |
|
102 | - * @since 6.0.0 |
|
103 | - */ |
|
104 | - public function getTagManager(); |
|
105 | - |
|
106 | - /** |
|
107 | - * Returns the root folder of ownCloud's data directory |
|
108 | - * |
|
109 | - * @return \OCP\Files\IRootFolder |
|
110 | - * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
111 | - */ |
|
112 | - public function getRootFolder(); |
|
113 | - |
|
114 | - /** |
|
115 | - * Returns a view to ownCloud's files folder |
|
116 | - * |
|
117 | - * @param string $userId user ID |
|
118 | - * @return \OCP\Files\Folder |
|
119 | - * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
120 | - * @see getUserFolder in \OCP\Files\IRootFolder |
|
121 | - */ |
|
122 | - public function getUserFolder($userId = null); |
|
123 | - |
|
124 | - /** |
|
125 | - * Returns an app-specific view in ownClouds data directory |
|
126 | - * |
|
127 | - * @return \OCP\Files\Folder |
|
128 | - * @since 6.0.0 |
|
129 | - * @deprecated 9.2.0 use IAppData |
|
130 | - */ |
|
131 | - public function getAppFolder(); |
|
132 | - |
|
133 | - /** |
|
134 | - * Returns a user manager |
|
135 | - * |
|
136 | - * @return \OCP\IUserManager |
|
137 | - * @since 8.0.0 |
|
138 | - */ |
|
139 | - public function getUserManager(); |
|
140 | - |
|
141 | - /** |
|
142 | - * Returns a group manager |
|
143 | - * |
|
144 | - * @return \OCP\IGroupManager |
|
145 | - * @since 8.0.0 |
|
146 | - */ |
|
147 | - public function getGroupManager(); |
|
148 | - |
|
149 | - /** |
|
150 | - * Returns the user session |
|
151 | - * |
|
152 | - * @return \OCP\IUserSession |
|
153 | - * @since 6.0.0 |
|
154 | - */ |
|
155 | - public function getUserSession(); |
|
156 | - |
|
157 | - /** |
|
158 | - * Returns the navigation manager |
|
159 | - * |
|
160 | - * @return \OCP\INavigationManager |
|
161 | - * @since 6.0.0 |
|
162 | - */ |
|
163 | - public function getNavigationManager(); |
|
164 | - |
|
165 | - /** |
|
166 | - * Returns the config manager |
|
167 | - * |
|
168 | - * @return \OCP\IConfig |
|
169 | - * @since 6.0.0 |
|
170 | - */ |
|
171 | - public function getConfig(); |
|
172 | - |
|
173 | - /** |
|
174 | - * Returns a Crypto instance |
|
175 | - * |
|
176 | - * @return \OCP\Security\ICrypto |
|
177 | - * @since 8.0.0 |
|
178 | - */ |
|
179 | - public function getCrypto(); |
|
180 | - |
|
181 | - /** |
|
182 | - * Returns a Hasher instance |
|
183 | - * |
|
184 | - * @return \OCP\Security\IHasher |
|
185 | - * @since 8.0.0 |
|
186 | - */ |
|
187 | - public function getHasher(); |
|
188 | - |
|
189 | - /** |
|
190 | - * Returns a SecureRandom instance |
|
191 | - * |
|
192 | - * @return \OCP\Security\ISecureRandom |
|
193 | - * @since 8.1.0 |
|
194 | - */ |
|
195 | - public function getSecureRandom(); |
|
196 | - |
|
197 | - /** |
|
198 | - * Returns a CredentialsManager instance |
|
199 | - * |
|
200 | - * @return \OCP\Security\ICredentialsManager |
|
201 | - * @since 9.0.0 |
|
202 | - */ |
|
203 | - public function getCredentialsManager(); |
|
204 | - |
|
205 | - /** |
|
206 | - * Returns the app config manager |
|
207 | - * |
|
208 | - * @return \OCP\IAppConfig |
|
209 | - * @since 7.0.0 |
|
210 | - */ |
|
211 | - public function getAppConfig(); |
|
212 | - |
|
213 | - /** |
|
214 | - * @return \OCP\L10N\IFactory |
|
215 | - * @since 8.2.0 |
|
216 | - */ |
|
217 | - public function getL10NFactory(); |
|
218 | - |
|
219 | - /** |
|
220 | - * get an L10N instance |
|
221 | - * @param string $app appid |
|
222 | - * @param string $lang |
|
223 | - * @return \OCP\IL10N |
|
224 | - * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
225 | - */ |
|
226 | - public function getL10N($app, $lang = null); |
|
227 | - |
|
228 | - /** |
|
229 | - * @return \OC\Encryption\Manager |
|
230 | - * @since 8.1.0 |
|
231 | - */ |
|
232 | - public function getEncryptionManager(); |
|
233 | - |
|
234 | - /** |
|
235 | - * @return \OC\Encryption\File |
|
236 | - * @since 8.1.0 |
|
237 | - */ |
|
238 | - public function getEncryptionFilesHelper(); |
|
239 | - |
|
240 | - /** |
|
241 | - * @return \OCP\Encryption\Keys\IStorage |
|
242 | - * @since 8.1.0 |
|
243 | - */ |
|
244 | - public function getEncryptionKeyStorage(); |
|
245 | - |
|
246 | - /** |
|
247 | - * Returns the URL generator |
|
248 | - * |
|
249 | - * @return \OCP\IURLGenerator |
|
250 | - * @since 6.0.0 |
|
251 | - */ |
|
252 | - public function getURLGenerator(); |
|
253 | - |
|
254 | - /** |
|
255 | - * Returns an ICache instance |
|
256 | - * |
|
257 | - * @return \OCP\ICache |
|
258 | - * @since 6.0.0 |
|
259 | - */ |
|
260 | - public function getCache(); |
|
261 | - |
|
262 | - /** |
|
263 | - * Returns an \OCP\CacheFactory instance |
|
264 | - * |
|
265 | - * @return \OCP\ICacheFactory |
|
266 | - * @since 7.0.0 |
|
267 | - */ |
|
268 | - public function getMemCacheFactory(); |
|
269 | - |
|
270 | - /** |
|
271 | - * Returns the current session |
|
272 | - * |
|
273 | - * @return \OCP\ISession |
|
274 | - * @since 6.0.0 |
|
275 | - */ |
|
276 | - public function getSession(); |
|
277 | - |
|
278 | - /** |
|
279 | - * Returns the activity manager |
|
280 | - * |
|
281 | - * @return \OCP\Activity\IManager |
|
282 | - * @since 6.0.0 |
|
283 | - */ |
|
284 | - public function getActivityManager(); |
|
285 | - |
|
286 | - /** |
|
287 | - * Returns the current session |
|
288 | - * |
|
289 | - * @return \OCP\IDBConnection |
|
290 | - * @since 6.0.0 |
|
291 | - */ |
|
292 | - public function getDatabaseConnection(); |
|
293 | - |
|
294 | - /** |
|
295 | - * Returns an avatar manager, used for avatar functionality |
|
296 | - * |
|
297 | - * @return \OCP\IAvatarManager |
|
298 | - * @since 6.0.0 |
|
299 | - */ |
|
300 | - public function getAvatarManager(); |
|
301 | - |
|
302 | - /** |
|
303 | - * Returns an job list for controlling background jobs |
|
304 | - * |
|
305 | - * @return \OCP\BackgroundJob\IJobList |
|
306 | - * @since 7.0.0 |
|
307 | - */ |
|
308 | - public function getJobList(); |
|
309 | - |
|
310 | - /** |
|
311 | - * Returns a logger instance |
|
312 | - * |
|
313 | - * @return \OCP\ILogger |
|
314 | - * @since 8.0.0 |
|
315 | - */ |
|
316 | - public function getLogger(); |
|
317 | - |
|
318 | - /** |
|
319 | - * returns a log factory instance |
|
320 | - * |
|
321 | - * @return ILogFactory |
|
322 | - * @since 14.0.0 |
|
323 | - */ |
|
324 | - public function getLogFactory(); |
|
325 | - |
|
326 | - /** |
|
327 | - * Returns a router for generating and matching urls |
|
328 | - * |
|
329 | - * @return \OCP\Route\IRouter |
|
330 | - * @since 7.0.0 |
|
331 | - */ |
|
332 | - public function getRouter(); |
|
333 | - |
|
334 | - /** |
|
335 | - * Returns a search instance |
|
336 | - * |
|
337 | - * @return \OCP\ISearch |
|
338 | - * @since 7.0.0 |
|
339 | - */ |
|
340 | - public function getSearch(); |
|
341 | - |
|
342 | - /** |
|
343 | - * Get the certificate manager for the user |
|
344 | - * |
|
345 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
346 | - * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
347 | - * @since 8.0.0 |
|
348 | - */ |
|
349 | - public function getCertificateManager($userId = null); |
|
350 | - |
|
351 | - /** |
|
352 | - * Create a new event source |
|
353 | - * |
|
354 | - * @return \OCP\IEventSource |
|
355 | - * @since 8.0.0 |
|
356 | - */ |
|
357 | - public function createEventSource(); |
|
358 | - |
|
359 | - /** |
|
360 | - * Returns an instance of the HTTP client service |
|
361 | - * |
|
362 | - * @return \OCP\Http\Client\IClientService |
|
363 | - * @since 8.1.0 |
|
364 | - */ |
|
365 | - public function getHTTPClientService(); |
|
366 | - |
|
367 | - /** |
|
368 | - * Get the active event logger |
|
369 | - * |
|
370 | - * @return \OCP\Diagnostics\IEventLogger |
|
371 | - * @since 8.0.0 |
|
372 | - */ |
|
373 | - public function getEventLogger(); |
|
374 | - |
|
375 | - /** |
|
376 | - * Get the active query logger |
|
377 | - * |
|
378 | - * The returned logger only logs data when debug mode is enabled |
|
379 | - * |
|
380 | - * @return \OCP\Diagnostics\IQueryLogger |
|
381 | - * @since 8.0.0 |
|
382 | - */ |
|
383 | - public function getQueryLogger(); |
|
384 | - |
|
385 | - /** |
|
386 | - * Get the manager for temporary files and folders |
|
387 | - * |
|
388 | - * @return \OCP\ITempManager |
|
389 | - * @since 8.0.0 |
|
390 | - */ |
|
391 | - public function getTempManager(); |
|
392 | - |
|
393 | - /** |
|
394 | - * Get the app manager |
|
395 | - * |
|
396 | - * @return \OCP\App\IAppManager |
|
397 | - * @since 8.0.0 |
|
398 | - */ |
|
399 | - public function getAppManager(); |
|
400 | - |
|
401 | - /** |
|
402 | - * Get the webroot |
|
403 | - * |
|
404 | - * @return string |
|
405 | - * @since 8.0.0 |
|
406 | - */ |
|
407 | - public function getWebRoot(); |
|
408 | - |
|
409 | - /** |
|
410 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
411 | - * @since 8.0.0 |
|
412 | - */ |
|
413 | - public function getMountProviderCollection(); |
|
414 | - |
|
415 | - /** |
|
416 | - * Get the IniWrapper |
|
417 | - * |
|
418 | - * @return \bantu\IniGetWrapper\IniGetWrapper |
|
419 | - * @since 8.0.0 |
|
420 | - */ |
|
421 | - public function getIniWrapper(); |
|
422 | - /** |
|
423 | - * @return \OCP\Command\IBus |
|
424 | - * @since 8.1.0 |
|
425 | - */ |
|
426 | - public function getCommandBus(); |
|
427 | - |
|
428 | - /** |
|
429 | - * Creates a new mailer |
|
430 | - * |
|
431 | - * @return \OCP\Mail\IMailer |
|
432 | - * @since 8.1.0 |
|
433 | - */ |
|
434 | - public function getMailer(); |
|
435 | - |
|
436 | - /** |
|
437 | - * Get the locking provider |
|
438 | - * |
|
439 | - * @return \OCP\Lock\ILockingProvider |
|
440 | - * @since 8.1.0 |
|
441 | - */ |
|
442 | - public function getLockingProvider(); |
|
443 | - |
|
444 | - /** |
|
445 | - * @return \OCP\Files\Mount\IMountManager |
|
446 | - * @since 8.2.0 |
|
447 | - */ |
|
448 | - public function getMountManager(); |
|
449 | - |
|
450 | - /** |
|
451 | - * Get the MimeTypeDetector |
|
452 | - * |
|
453 | - * @return \OCP\Files\IMimeTypeDetector |
|
454 | - * @since 8.2.0 |
|
455 | - */ |
|
456 | - public function getMimeTypeDetector(); |
|
457 | - |
|
458 | - /** |
|
459 | - * Get the MimeTypeLoader |
|
460 | - * |
|
461 | - * @return \OCP\Files\IMimeTypeLoader |
|
462 | - * @since 8.2.0 |
|
463 | - */ |
|
464 | - public function getMimeTypeLoader(); |
|
465 | - |
|
466 | - /** |
|
467 | - * Get the EventDispatcher |
|
468 | - * |
|
469 | - * @return EventDispatcherInterface |
|
470 | - * @since 8.2.0 |
|
471 | - */ |
|
472 | - public function getEventDispatcher(); |
|
473 | - |
|
474 | - /** |
|
475 | - * Get the Notification Manager |
|
476 | - * |
|
477 | - * @return \OCP\Notification\IManager |
|
478 | - * @since 9.0.0 |
|
479 | - */ |
|
480 | - public function getNotificationManager(); |
|
481 | - |
|
482 | - /** |
|
483 | - * @return \OCP\Comments\ICommentsManager |
|
484 | - * @since 9.0.0 |
|
485 | - */ |
|
486 | - public function getCommentsManager(); |
|
487 | - |
|
488 | - /** |
|
489 | - * Returns the system-tag manager |
|
490 | - * |
|
491 | - * @return \OCP\SystemTag\ISystemTagManager |
|
492 | - * |
|
493 | - * @since 9.0.0 |
|
494 | - */ |
|
495 | - public function getSystemTagManager(); |
|
496 | - |
|
497 | - /** |
|
498 | - * Returns the system-tag object mapper |
|
499 | - * |
|
500 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
501 | - * |
|
502 | - * @since 9.0.0 |
|
503 | - */ |
|
504 | - public function getSystemTagObjectMapper(); |
|
505 | - |
|
506 | - /** |
|
507 | - * Returns the share manager |
|
508 | - * |
|
509 | - * @return \OCP\Share\IManager |
|
510 | - * @since 9.0.0 |
|
511 | - */ |
|
512 | - public function getShareManager(); |
|
513 | - |
|
514 | - /** |
|
515 | - * @return IContentSecurityPolicyManager |
|
516 | - * @since 9.0.0 |
|
517 | - */ |
|
518 | - public function getContentSecurityPolicyManager(); |
|
519 | - |
|
520 | - /** |
|
521 | - * @return \OCP\IDateTimeZone |
|
522 | - * @since 8.0.0 |
|
523 | - */ |
|
524 | - public function getDateTimeZone(); |
|
525 | - |
|
526 | - /** |
|
527 | - * @return \OCP\IDateTimeFormatter |
|
528 | - * @since 8.0.0 |
|
529 | - */ |
|
530 | - public function getDateTimeFormatter(); |
|
531 | - |
|
532 | - /** |
|
533 | - * @return \OCP\Federation\ICloudIdManager |
|
534 | - * @since 12.0.0 |
|
535 | - */ |
|
536 | - public function getCloudIdManager(); |
|
537 | - |
|
538 | - /** |
|
539 | - * @return \OCP\Remote\Api\IApiFactory |
|
540 | - * @since 13.0.0 |
|
541 | - */ |
|
542 | - public function getRemoteApiFactory(); |
|
543 | - |
|
544 | - /** |
|
545 | - * @return \OCP\Remote\IInstanceFactory |
|
546 | - * @since 13.0.0 |
|
547 | - */ |
|
548 | - public function getRemoteInstanceFactory(); |
|
61 | + /** |
|
62 | + * The calendar manager will act as a broker between consumers for calendar information and |
|
63 | + * providers which actual deliver the calendar information. |
|
64 | + * |
|
65 | + * @return \OCP\Calendar\IManager |
|
66 | + * @since 13.0.0 |
|
67 | + */ |
|
68 | + public function getCalendarManager(); |
|
69 | + |
|
70 | + /** |
|
71 | + * The contacts manager will act as a broker between consumers for contacts information and |
|
72 | + * providers which actual deliver the contact information. |
|
73 | + * |
|
74 | + * @return \OCP\Contacts\IManager |
|
75 | + * @since 6.0.0 |
|
76 | + */ |
|
77 | + public function getContactsManager(); |
|
78 | + |
|
79 | + /** |
|
80 | + * The current request object holding all information about the request currently being processed |
|
81 | + * is returned from this method. |
|
82 | + * In case the current execution was not initiated by a web request null is returned |
|
83 | + * |
|
84 | + * @return \OCP\IRequest |
|
85 | + * @since 6.0.0 |
|
86 | + */ |
|
87 | + public function getRequest(); |
|
88 | + |
|
89 | + /** |
|
90 | + * Returns the preview manager which can create preview images for a given file |
|
91 | + * |
|
92 | + * @return \OCP\IPreview |
|
93 | + * @since 6.0.0 |
|
94 | + */ |
|
95 | + public function getPreviewManager(); |
|
96 | + |
|
97 | + /** |
|
98 | + * Returns the tag manager which can get and set tags for different object types |
|
99 | + * |
|
100 | + * @see \OCP\ITagManager::load() |
|
101 | + * @return \OCP\ITagManager |
|
102 | + * @since 6.0.0 |
|
103 | + */ |
|
104 | + public function getTagManager(); |
|
105 | + |
|
106 | + /** |
|
107 | + * Returns the root folder of ownCloud's data directory |
|
108 | + * |
|
109 | + * @return \OCP\Files\IRootFolder |
|
110 | + * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
111 | + */ |
|
112 | + public function getRootFolder(); |
|
113 | + |
|
114 | + /** |
|
115 | + * Returns a view to ownCloud's files folder |
|
116 | + * |
|
117 | + * @param string $userId user ID |
|
118 | + * @return \OCP\Files\Folder |
|
119 | + * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
120 | + * @see getUserFolder in \OCP\Files\IRootFolder |
|
121 | + */ |
|
122 | + public function getUserFolder($userId = null); |
|
123 | + |
|
124 | + /** |
|
125 | + * Returns an app-specific view in ownClouds data directory |
|
126 | + * |
|
127 | + * @return \OCP\Files\Folder |
|
128 | + * @since 6.0.0 |
|
129 | + * @deprecated 9.2.0 use IAppData |
|
130 | + */ |
|
131 | + public function getAppFolder(); |
|
132 | + |
|
133 | + /** |
|
134 | + * Returns a user manager |
|
135 | + * |
|
136 | + * @return \OCP\IUserManager |
|
137 | + * @since 8.0.0 |
|
138 | + */ |
|
139 | + public function getUserManager(); |
|
140 | + |
|
141 | + /** |
|
142 | + * Returns a group manager |
|
143 | + * |
|
144 | + * @return \OCP\IGroupManager |
|
145 | + * @since 8.0.0 |
|
146 | + */ |
|
147 | + public function getGroupManager(); |
|
148 | + |
|
149 | + /** |
|
150 | + * Returns the user session |
|
151 | + * |
|
152 | + * @return \OCP\IUserSession |
|
153 | + * @since 6.0.0 |
|
154 | + */ |
|
155 | + public function getUserSession(); |
|
156 | + |
|
157 | + /** |
|
158 | + * Returns the navigation manager |
|
159 | + * |
|
160 | + * @return \OCP\INavigationManager |
|
161 | + * @since 6.0.0 |
|
162 | + */ |
|
163 | + public function getNavigationManager(); |
|
164 | + |
|
165 | + /** |
|
166 | + * Returns the config manager |
|
167 | + * |
|
168 | + * @return \OCP\IConfig |
|
169 | + * @since 6.0.0 |
|
170 | + */ |
|
171 | + public function getConfig(); |
|
172 | + |
|
173 | + /** |
|
174 | + * Returns a Crypto instance |
|
175 | + * |
|
176 | + * @return \OCP\Security\ICrypto |
|
177 | + * @since 8.0.0 |
|
178 | + */ |
|
179 | + public function getCrypto(); |
|
180 | + |
|
181 | + /** |
|
182 | + * Returns a Hasher instance |
|
183 | + * |
|
184 | + * @return \OCP\Security\IHasher |
|
185 | + * @since 8.0.0 |
|
186 | + */ |
|
187 | + public function getHasher(); |
|
188 | + |
|
189 | + /** |
|
190 | + * Returns a SecureRandom instance |
|
191 | + * |
|
192 | + * @return \OCP\Security\ISecureRandom |
|
193 | + * @since 8.1.0 |
|
194 | + */ |
|
195 | + public function getSecureRandom(); |
|
196 | + |
|
197 | + /** |
|
198 | + * Returns a CredentialsManager instance |
|
199 | + * |
|
200 | + * @return \OCP\Security\ICredentialsManager |
|
201 | + * @since 9.0.0 |
|
202 | + */ |
|
203 | + public function getCredentialsManager(); |
|
204 | + |
|
205 | + /** |
|
206 | + * Returns the app config manager |
|
207 | + * |
|
208 | + * @return \OCP\IAppConfig |
|
209 | + * @since 7.0.0 |
|
210 | + */ |
|
211 | + public function getAppConfig(); |
|
212 | + |
|
213 | + /** |
|
214 | + * @return \OCP\L10N\IFactory |
|
215 | + * @since 8.2.0 |
|
216 | + */ |
|
217 | + public function getL10NFactory(); |
|
218 | + |
|
219 | + /** |
|
220 | + * get an L10N instance |
|
221 | + * @param string $app appid |
|
222 | + * @param string $lang |
|
223 | + * @return \OCP\IL10N |
|
224 | + * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
225 | + */ |
|
226 | + public function getL10N($app, $lang = null); |
|
227 | + |
|
228 | + /** |
|
229 | + * @return \OC\Encryption\Manager |
|
230 | + * @since 8.1.0 |
|
231 | + */ |
|
232 | + public function getEncryptionManager(); |
|
233 | + |
|
234 | + /** |
|
235 | + * @return \OC\Encryption\File |
|
236 | + * @since 8.1.0 |
|
237 | + */ |
|
238 | + public function getEncryptionFilesHelper(); |
|
239 | + |
|
240 | + /** |
|
241 | + * @return \OCP\Encryption\Keys\IStorage |
|
242 | + * @since 8.1.0 |
|
243 | + */ |
|
244 | + public function getEncryptionKeyStorage(); |
|
245 | + |
|
246 | + /** |
|
247 | + * Returns the URL generator |
|
248 | + * |
|
249 | + * @return \OCP\IURLGenerator |
|
250 | + * @since 6.0.0 |
|
251 | + */ |
|
252 | + public function getURLGenerator(); |
|
253 | + |
|
254 | + /** |
|
255 | + * Returns an ICache instance |
|
256 | + * |
|
257 | + * @return \OCP\ICache |
|
258 | + * @since 6.0.0 |
|
259 | + */ |
|
260 | + public function getCache(); |
|
261 | + |
|
262 | + /** |
|
263 | + * Returns an \OCP\CacheFactory instance |
|
264 | + * |
|
265 | + * @return \OCP\ICacheFactory |
|
266 | + * @since 7.0.0 |
|
267 | + */ |
|
268 | + public function getMemCacheFactory(); |
|
269 | + |
|
270 | + /** |
|
271 | + * Returns the current session |
|
272 | + * |
|
273 | + * @return \OCP\ISession |
|
274 | + * @since 6.0.0 |
|
275 | + */ |
|
276 | + public function getSession(); |
|
277 | + |
|
278 | + /** |
|
279 | + * Returns the activity manager |
|
280 | + * |
|
281 | + * @return \OCP\Activity\IManager |
|
282 | + * @since 6.0.0 |
|
283 | + */ |
|
284 | + public function getActivityManager(); |
|
285 | + |
|
286 | + /** |
|
287 | + * Returns the current session |
|
288 | + * |
|
289 | + * @return \OCP\IDBConnection |
|
290 | + * @since 6.0.0 |
|
291 | + */ |
|
292 | + public function getDatabaseConnection(); |
|
293 | + |
|
294 | + /** |
|
295 | + * Returns an avatar manager, used for avatar functionality |
|
296 | + * |
|
297 | + * @return \OCP\IAvatarManager |
|
298 | + * @since 6.0.0 |
|
299 | + */ |
|
300 | + public function getAvatarManager(); |
|
301 | + |
|
302 | + /** |
|
303 | + * Returns an job list for controlling background jobs |
|
304 | + * |
|
305 | + * @return \OCP\BackgroundJob\IJobList |
|
306 | + * @since 7.0.0 |
|
307 | + */ |
|
308 | + public function getJobList(); |
|
309 | + |
|
310 | + /** |
|
311 | + * Returns a logger instance |
|
312 | + * |
|
313 | + * @return \OCP\ILogger |
|
314 | + * @since 8.0.0 |
|
315 | + */ |
|
316 | + public function getLogger(); |
|
317 | + |
|
318 | + /** |
|
319 | + * returns a log factory instance |
|
320 | + * |
|
321 | + * @return ILogFactory |
|
322 | + * @since 14.0.0 |
|
323 | + */ |
|
324 | + public function getLogFactory(); |
|
325 | + |
|
326 | + /** |
|
327 | + * Returns a router for generating and matching urls |
|
328 | + * |
|
329 | + * @return \OCP\Route\IRouter |
|
330 | + * @since 7.0.0 |
|
331 | + */ |
|
332 | + public function getRouter(); |
|
333 | + |
|
334 | + /** |
|
335 | + * Returns a search instance |
|
336 | + * |
|
337 | + * @return \OCP\ISearch |
|
338 | + * @since 7.0.0 |
|
339 | + */ |
|
340 | + public function getSearch(); |
|
341 | + |
|
342 | + /** |
|
343 | + * Get the certificate manager for the user |
|
344 | + * |
|
345 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
346 | + * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
347 | + * @since 8.0.0 |
|
348 | + */ |
|
349 | + public function getCertificateManager($userId = null); |
|
350 | + |
|
351 | + /** |
|
352 | + * Create a new event source |
|
353 | + * |
|
354 | + * @return \OCP\IEventSource |
|
355 | + * @since 8.0.0 |
|
356 | + */ |
|
357 | + public function createEventSource(); |
|
358 | + |
|
359 | + /** |
|
360 | + * Returns an instance of the HTTP client service |
|
361 | + * |
|
362 | + * @return \OCP\Http\Client\IClientService |
|
363 | + * @since 8.1.0 |
|
364 | + */ |
|
365 | + public function getHTTPClientService(); |
|
366 | + |
|
367 | + /** |
|
368 | + * Get the active event logger |
|
369 | + * |
|
370 | + * @return \OCP\Diagnostics\IEventLogger |
|
371 | + * @since 8.0.0 |
|
372 | + */ |
|
373 | + public function getEventLogger(); |
|
374 | + |
|
375 | + /** |
|
376 | + * Get the active query logger |
|
377 | + * |
|
378 | + * The returned logger only logs data when debug mode is enabled |
|
379 | + * |
|
380 | + * @return \OCP\Diagnostics\IQueryLogger |
|
381 | + * @since 8.0.0 |
|
382 | + */ |
|
383 | + public function getQueryLogger(); |
|
384 | + |
|
385 | + /** |
|
386 | + * Get the manager for temporary files and folders |
|
387 | + * |
|
388 | + * @return \OCP\ITempManager |
|
389 | + * @since 8.0.0 |
|
390 | + */ |
|
391 | + public function getTempManager(); |
|
392 | + |
|
393 | + /** |
|
394 | + * Get the app manager |
|
395 | + * |
|
396 | + * @return \OCP\App\IAppManager |
|
397 | + * @since 8.0.0 |
|
398 | + */ |
|
399 | + public function getAppManager(); |
|
400 | + |
|
401 | + /** |
|
402 | + * Get the webroot |
|
403 | + * |
|
404 | + * @return string |
|
405 | + * @since 8.0.0 |
|
406 | + */ |
|
407 | + public function getWebRoot(); |
|
408 | + |
|
409 | + /** |
|
410 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
411 | + * @since 8.0.0 |
|
412 | + */ |
|
413 | + public function getMountProviderCollection(); |
|
414 | + |
|
415 | + /** |
|
416 | + * Get the IniWrapper |
|
417 | + * |
|
418 | + * @return \bantu\IniGetWrapper\IniGetWrapper |
|
419 | + * @since 8.0.0 |
|
420 | + */ |
|
421 | + public function getIniWrapper(); |
|
422 | + /** |
|
423 | + * @return \OCP\Command\IBus |
|
424 | + * @since 8.1.0 |
|
425 | + */ |
|
426 | + public function getCommandBus(); |
|
427 | + |
|
428 | + /** |
|
429 | + * Creates a new mailer |
|
430 | + * |
|
431 | + * @return \OCP\Mail\IMailer |
|
432 | + * @since 8.1.0 |
|
433 | + */ |
|
434 | + public function getMailer(); |
|
435 | + |
|
436 | + /** |
|
437 | + * Get the locking provider |
|
438 | + * |
|
439 | + * @return \OCP\Lock\ILockingProvider |
|
440 | + * @since 8.1.0 |
|
441 | + */ |
|
442 | + public function getLockingProvider(); |
|
443 | + |
|
444 | + /** |
|
445 | + * @return \OCP\Files\Mount\IMountManager |
|
446 | + * @since 8.2.0 |
|
447 | + */ |
|
448 | + public function getMountManager(); |
|
449 | + |
|
450 | + /** |
|
451 | + * Get the MimeTypeDetector |
|
452 | + * |
|
453 | + * @return \OCP\Files\IMimeTypeDetector |
|
454 | + * @since 8.2.0 |
|
455 | + */ |
|
456 | + public function getMimeTypeDetector(); |
|
457 | + |
|
458 | + /** |
|
459 | + * Get the MimeTypeLoader |
|
460 | + * |
|
461 | + * @return \OCP\Files\IMimeTypeLoader |
|
462 | + * @since 8.2.0 |
|
463 | + */ |
|
464 | + public function getMimeTypeLoader(); |
|
465 | + |
|
466 | + /** |
|
467 | + * Get the EventDispatcher |
|
468 | + * |
|
469 | + * @return EventDispatcherInterface |
|
470 | + * @since 8.2.0 |
|
471 | + */ |
|
472 | + public function getEventDispatcher(); |
|
473 | + |
|
474 | + /** |
|
475 | + * Get the Notification Manager |
|
476 | + * |
|
477 | + * @return \OCP\Notification\IManager |
|
478 | + * @since 9.0.0 |
|
479 | + */ |
|
480 | + public function getNotificationManager(); |
|
481 | + |
|
482 | + /** |
|
483 | + * @return \OCP\Comments\ICommentsManager |
|
484 | + * @since 9.0.0 |
|
485 | + */ |
|
486 | + public function getCommentsManager(); |
|
487 | + |
|
488 | + /** |
|
489 | + * Returns the system-tag manager |
|
490 | + * |
|
491 | + * @return \OCP\SystemTag\ISystemTagManager |
|
492 | + * |
|
493 | + * @since 9.0.0 |
|
494 | + */ |
|
495 | + public function getSystemTagManager(); |
|
496 | + |
|
497 | + /** |
|
498 | + * Returns the system-tag object mapper |
|
499 | + * |
|
500 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
501 | + * |
|
502 | + * @since 9.0.0 |
|
503 | + */ |
|
504 | + public function getSystemTagObjectMapper(); |
|
505 | + |
|
506 | + /** |
|
507 | + * Returns the share manager |
|
508 | + * |
|
509 | + * @return \OCP\Share\IManager |
|
510 | + * @since 9.0.0 |
|
511 | + */ |
|
512 | + public function getShareManager(); |
|
513 | + |
|
514 | + /** |
|
515 | + * @return IContentSecurityPolicyManager |
|
516 | + * @since 9.0.0 |
|
517 | + */ |
|
518 | + public function getContentSecurityPolicyManager(); |
|
519 | + |
|
520 | + /** |
|
521 | + * @return \OCP\IDateTimeZone |
|
522 | + * @since 8.0.0 |
|
523 | + */ |
|
524 | + public function getDateTimeZone(); |
|
525 | + |
|
526 | + /** |
|
527 | + * @return \OCP\IDateTimeFormatter |
|
528 | + * @since 8.0.0 |
|
529 | + */ |
|
530 | + public function getDateTimeFormatter(); |
|
531 | + |
|
532 | + /** |
|
533 | + * @return \OCP\Federation\ICloudIdManager |
|
534 | + * @since 12.0.0 |
|
535 | + */ |
|
536 | + public function getCloudIdManager(); |
|
537 | + |
|
538 | + /** |
|
539 | + * @return \OCP\Remote\Api\IApiFactory |
|
540 | + * @since 13.0.0 |
|
541 | + */ |
|
542 | + public function getRemoteApiFactory(); |
|
543 | + |
|
544 | + /** |
|
545 | + * @return \OCP\Remote\IInstanceFactory |
|
546 | + * @since 13.0.0 |
|
547 | + */ |
|
548 | + public function getRemoteInstanceFactory(); |
|
549 | 549 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | use Symfony\Component\EventDispatcher\GenericEvent; |
34 | 34 | |
35 | 35 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
36 | - @set_time_limit(0); |
|
36 | + @set_time_limit(0); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | require_once '../../lib/base.php'; |
@@ -47,188 +47,188 @@ discard block |
||
47 | 47 | $eventSource->send('success', (string)$l->t('Preparing update')); |
48 | 48 | |
49 | 49 | class FeedBackHandler { |
50 | - /** @var integer */ |
|
51 | - private $progressStateMax = 100; |
|
52 | - /** @var integer */ |
|
53 | - private $progressStateStep = 0; |
|
54 | - /** @var string */ |
|
55 | - private $currentStep; |
|
56 | - /** @var \OCP\IEventSource */ |
|
57 | - private $eventSource; |
|
58 | - /** @var \OCP\IL10N */ |
|
59 | - private $l10n; |
|
60 | - |
|
61 | - public function __construct(\OCP\IEventSource $eventSource, \OCP\IL10N $l10n) { |
|
62 | - $this->eventSource = $eventSource; |
|
63 | - $this->l10n = $l10n; |
|
64 | - } |
|
65 | - |
|
66 | - public function handleRepairFeedback($event) { |
|
67 | - if (!$event instanceof GenericEvent) { |
|
68 | - return; |
|
69 | - } |
|
70 | - |
|
71 | - switch ($event->getSubject()) { |
|
72 | - case '\OC\Repair::startProgress': |
|
73 | - $this->progressStateMax = $event->getArgument(0); |
|
74 | - $this->progressStateStep = 0; |
|
75 | - $this->currentStep = $event->getArgument(1); |
|
76 | - break; |
|
77 | - case '\OC\Repair::advance': |
|
78 | - $this->progressStateStep += $event->getArgument(0); |
|
79 | - $desc = $event->getArgument(1); |
|
80 | - if (empty($desc)) { |
|
81 | - $desc = $this->currentStep; |
|
82 | - } |
|
83 | - $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc])); |
|
84 | - break; |
|
85 | - case '\OC\Repair::finishProgress': |
|
86 | - $this->progressStateMax = $this->progressStateStep; |
|
87 | - $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep])); |
|
88 | - break; |
|
89 | - case '\OC\Repair::step': |
|
90 | - break; |
|
91 | - case '\OC\Repair::info': |
|
92 | - break; |
|
93 | - case '\OC\Repair::warning': |
|
94 | - $this->eventSource->send('notice', (string)$this->l10n->t('Repair warning: ') . $event->getArgument(0)); |
|
95 | - break; |
|
96 | - case '\OC\Repair::error': |
|
97 | - $this->eventSource->send('notice', (string)$this->l10n->t('Repair error: ') . $event->getArgument(0)); |
|
98 | - break; |
|
99 | - } |
|
100 | - } |
|
50 | + /** @var integer */ |
|
51 | + private $progressStateMax = 100; |
|
52 | + /** @var integer */ |
|
53 | + private $progressStateStep = 0; |
|
54 | + /** @var string */ |
|
55 | + private $currentStep; |
|
56 | + /** @var \OCP\IEventSource */ |
|
57 | + private $eventSource; |
|
58 | + /** @var \OCP\IL10N */ |
|
59 | + private $l10n; |
|
60 | + |
|
61 | + public function __construct(\OCP\IEventSource $eventSource, \OCP\IL10N $l10n) { |
|
62 | + $this->eventSource = $eventSource; |
|
63 | + $this->l10n = $l10n; |
|
64 | + } |
|
65 | + |
|
66 | + public function handleRepairFeedback($event) { |
|
67 | + if (!$event instanceof GenericEvent) { |
|
68 | + return; |
|
69 | + } |
|
70 | + |
|
71 | + switch ($event->getSubject()) { |
|
72 | + case '\OC\Repair::startProgress': |
|
73 | + $this->progressStateMax = $event->getArgument(0); |
|
74 | + $this->progressStateStep = 0; |
|
75 | + $this->currentStep = $event->getArgument(1); |
|
76 | + break; |
|
77 | + case '\OC\Repair::advance': |
|
78 | + $this->progressStateStep += $event->getArgument(0); |
|
79 | + $desc = $event->getArgument(1); |
|
80 | + if (empty($desc)) { |
|
81 | + $desc = $this->currentStep; |
|
82 | + } |
|
83 | + $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc])); |
|
84 | + break; |
|
85 | + case '\OC\Repair::finishProgress': |
|
86 | + $this->progressStateMax = $this->progressStateStep; |
|
87 | + $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep])); |
|
88 | + break; |
|
89 | + case '\OC\Repair::step': |
|
90 | + break; |
|
91 | + case '\OC\Repair::info': |
|
92 | + break; |
|
93 | + case '\OC\Repair::warning': |
|
94 | + $this->eventSource->send('notice', (string)$this->l10n->t('Repair warning: ') . $event->getArgument(0)); |
|
95 | + break; |
|
96 | + case '\OC\Repair::error': |
|
97 | + $this->eventSource->send('notice', (string)$this->l10n->t('Repair error: ') . $event->getArgument(0)); |
|
98 | + break; |
|
99 | + } |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | if (\OCP\Util::needUpgrade()) { |
104 | 104 | |
105 | - $config = \OC::$server->getSystemConfig(); |
|
106 | - if ($config->getValue('upgrade.disable-web', false)) { |
|
107 | - $eventSource->send('failure', (string)$l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
108 | - $eventSource->close(); |
|
109 | - exit(); |
|
110 | - } |
|
111 | - |
|
112 | - // if a user is currently logged in, their session must be ignored to |
|
113 | - // avoid side effects |
|
114 | - \OC_User::setIncognitoMode(true); |
|
115 | - |
|
116 | - $logger = \OC::$server->getLogger(); |
|
117 | - $config = \OC::$server->getConfig(); |
|
118 | - $updater = new \OC\Updater( |
|
119 | - $config, |
|
120 | - \OC::$server->getIntegrityCodeChecker(), |
|
121 | - $logger, |
|
122 | - \OC::$server->query(\OC\Installer::class) |
|
123 | - ); |
|
124 | - $incompatibleApps = []; |
|
125 | - |
|
126 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
127 | - $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($eventSource, $l) { |
|
128 | - if ($event instanceof GenericEvent) { |
|
129 | - $eventSource->send('success', (string)$l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()])); |
|
130 | - } |
|
131 | - }); |
|
132 | - $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($eventSource, $l) { |
|
133 | - if ($event instanceof GenericEvent) { |
|
134 | - $eventSource->send('success', (string)$l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()])); |
|
135 | - } |
|
136 | - }); |
|
137 | - $feedBack = new FeedBackHandler($eventSource, $l); |
|
138 | - $dispatcher->addListener('\OC\Repair::startProgress', [$feedBack, 'handleRepairFeedback']); |
|
139 | - $dispatcher->addListener('\OC\Repair::advance', [$feedBack, 'handleRepairFeedback']); |
|
140 | - $dispatcher->addListener('\OC\Repair::finishProgress', [$feedBack, 'handleRepairFeedback']); |
|
141 | - $dispatcher->addListener('\OC\Repair::step', [$feedBack, 'handleRepairFeedback']); |
|
142 | - $dispatcher->addListener('\OC\Repair::info', [$feedBack, 'handleRepairFeedback']); |
|
143 | - $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']); |
|
144 | - $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']); |
|
145 | - |
|
146 | - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) { |
|
147 | - $eventSource->send('success', (string)$l->t('Turned on maintenance mode')); |
|
148 | - }); |
|
149 | - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) { |
|
150 | - $eventSource->send('success', (string)$l->t('Turned off maintenance mode')); |
|
151 | - }); |
|
152 | - $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) { |
|
153 | - $eventSource->send('success', (string)$l->t('Maintenance mode is kept active')); |
|
154 | - }); |
|
155 | - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($eventSource, $l) { |
|
156 | - $eventSource->send('success', (string)$l->t('Updating database schema')); |
|
157 | - }); |
|
158 | - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { |
|
159 | - $eventSource->send('success', (string)$l->t('Updated database')); |
|
160 | - }); |
|
161 | - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($eventSource, $l) { |
|
162 | - $eventSource->send('success', (string)$l->t('Checking whether the database schema can be updated (this can take a long time depending on the database size)')); |
|
163 | - }); |
|
164 | - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) { |
|
165 | - $eventSource->send('success', (string)$l->t('Checked database schema update')); |
|
166 | - }); |
|
167 | - $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) { |
|
168 | - $eventSource->send('success', (string)$l->t('Checking updates of apps')); |
|
169 | - }); |
|
170 | - $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($eventSource, $l) { |
|
171 | - $eventSource->send('success', (string)$l->t('Checking for update of app "%s" in appstore', [$app])); |
|
172 | - }); |
|
173 | - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) { |
|
174 | - $eventSource->send('success', (string)$l->t('Update app "%s" from appstore', [$app])); |
|
175 | - }); |
|
176 | - $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($eventSource, $l) { |
|
177 | - $eventSource->send('success', (string)$l->t('Checked for update of app "%s" in appstore', [$app])); |
|
178 | - }); |
|
179 | - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) { |
|
180 | - $eventSource->send('success', (string)$l->t('Checking whether the database schema for %s can be updated (this can take a long time depending on the database size)', [$app])); |
|
181 | - }); |
|
182 | - $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) { |
|
183 | - $eventSource->send('success', (string)$l->t('Checked database schema update for apps')); |
|
184 | - }); |
|
185 | - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) { |
|
186 | - $eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version))); |
|
187 | - }); |
|
188 | - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) { |
|
189 | - $incompatibleApps[]= $app; |
|
190 | - }); |
|
191 | - $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) { |
|
192 | - $eventSource->send('failure', $message); |
|
193 | - $eventSource->close(); |
|
194 | - $config->setSystemValue('maintenance', false); |
|
195 | - }); |
|
196 | - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { |
|
197 | - $eventSource->send('success', (string)$l->t('Set log level to debug')); |
|
198 | - }); |
|
199 | - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { |
|
200 | - $eventSource->send('success', (string)$l->t('Reset log level')); |
|
201 | - }); |
|
202 | - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($eventSource, $l) { |
|
203 | - $eventSource->send('success', (string)$l->t('Starting code integrity check')); |
|
204 | - }); |
|
205 | - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($eventSource, $l) { |
|
206 | - $eventSource->send('success', (string)$l->t('Finished code integrity check')); |
|
207 | - }); |
|
208 | - |
|
209 | - try { |
|
210 | - $updater->upgrade(); |
|
211 | - } catch (\Exception $e) { |
|
212 | - \OC::$server->getLogger()->logException($e, [ |
|
213 | - 'level' => ILogger::ERROR, |
|
214 | - 'app' => 'update', |
|
215 | - ]); |
|
216 | - $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage()); |
|
217 | - $eventSource->close(); |
|
218 | - exit(); |
|
219 | - } |
|
220 | - |
|
221 | - $disabledApps = []; |
|
222 | - foreach ($incompatibleApps as $app) { |
|
223 | - $disabledApps[$app] = (string) $l->t('%s (incompatible)', [$app]); |
|
224 | - } |
|
225 | - |
|
226 | - if (!empty($disabledApps)) { |
|
227 | - $eventSource->send('notice', |
|
228 | - (string)$l->t('Following apps have been disabled: %s', [implode(', ', $disabledApps)])); |
|
229 | - } |
|
105 | + $config = \OC::$server->getSystemConfig(); |
|
106 | + if ($config->getValue('upgrade.disable-web', false)) { |
|
107 | + $eventSource->send('failure', (string)$l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
108 | + $eventSource->close(); |
|
109 | + exit(); |
|
110 | + } |
|
111 | + |
|
112 | + // if a user is currently logged in, their session must be ignored to |
|
113 | + // avoid side effects |
|
114 | + \OC_User::setIncognitoMode(true); |
|
115 | + |
|
116 | + $logger = \OC::$server->getLogger(); |
|
117 | + $config = \OC::$server->getConfig(); |
|
118 | + $updater = new \OC\Updater( |
|
119 | + $config, |
|
120 | + \OC::$server->getIntegrityCodeChecker(), |
|
121 | + $logger, |
|
122 | + \OC::$server->query(\OC\Installer::class) |
|
123 | + ); |
|
124 | + $incompatibleApps = []; |
|
125 | + |
|
126 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
127 | + $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($eventSource, $l) { |
|
128 | + if ($event instanceof GenericEvent) { |
|
129 | + $eventSource->send('success', (string)$l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()])); |
|
130 | + } |
|
131 | + }); |
|
132 | + $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($eventSource, $l) { |
|
133 | + if ($event instanceof GenericEvent) { |
|
134 | + $eventSource->send('success', (string)$l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()])); |
|
135 | + } |
|
136 | + }); |
|
137 | + $feedBack = new FeedBackHandler($eventSource, $l); |
|
138 | + $dispatcher->addListener('\OC\Repair::startProgress', [$feedBack, 'handleRepairFeedback']); |
|
139 | + $dispatcher->addListener('\OC\Repair::advance', [$feedBack, 'handleRepairFeedback']); |
|
140 | + $dispatcher->addListener('\OC\Repair::finishProgress', [$feedBack, 'handleRepairFeedback']); |
|
141 | + $dispatcher->addListener('\OC\Repair::step', [$feedBack, 'handleRepairFeedback']); |
|
142 | + $dispatcher->addListener('\OC\Repair::info', [$feedBack, 'handleRepairFeedback']); |
|
143 | + $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']); |
|
144 | + $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']); |
|
145 | + |
|
146 | + $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) { |
|
147 | + $eventSource->send('success', (string)$l->t('Turned on maintenance mode')); |
|
148 | + }); |
|
149 | + $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) { |
|
150 | + $eventSource->send('success', (string)$l->t('Turned off maintenance mode')); |
|
151 | + }); |
|
152 | + $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) { |
|
153 | + $eventSource->send('success', (string)$l->t('Maintenance mode is kept active')); |
|
154 | + }); |
|
155 | + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($eventSource, $l) { |
|
156 | + $eventSource->send('success', (string)$l->t('Updating database schema')); |
|
157 | + }); |
|
158 | + $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { |
|
159 | + $eventSource->send('success', (string)$l->t('Updated database')); |
|
160 | + }); |
|
161 | + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($eventSource, $l) { |
|
162 | + $eventSource->send('success', (string)$l->t('Checking whether the database schema can be updated (this can take a long time depending on the database size)')); |
|
163 | + }); |
|
164 | + $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) { |
|
165 | + $eventSource->send('success', (string)$l->t('Checked database schema update')); |
|
166 | + }); |
|
167 | + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) { |
|
168 | + $eventSource->send('success', (string)$l->t('Checking updates of apps')); |
|
169 | + }); |
|
170 | + $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($eventSource, $l) { |
|
171 | + $eventSource->send('success', (string)$l->t('Checking for update of app "%s" in appstore', [$app])); |
|
172 | + }); |
|
173 | + $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) { |
|
174 | + $eventSource->send('success', (string)$l->t('Update app "%s" from appstore', [$app])); |
|
175 | + }); |
|
176 | + $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($eventSource, $l) { |
|
177 | + $eventSource->send('success', (string)$l->t('Checked for update of app "%s" in appstore', [$app])); |
|
178 | + }); |
|
179 | + $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) { |
|
180 | + $eventSource->send('success', (string)$l->t('Checking whether the database schema for %s can be updated (this can take a long time depending on the database size)', [$app])); |
|
181 | + }); |
|
182 | + $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) { |
|
183 | + $eventSource->send('success', (string)$l->t('Checked database schema update for apps')); |
|
184 | + }); |
|
185 | + $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) { |
|
186 | + $eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version))); |
|
187 | + }); |
|
188 | + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) { |
|
189 | + $incompatibleApps[]= $app; |
|
190 | + }); |
|
191 | + $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) { |
|
192 | + $eventSource->send('failure', $message); |
|
193 | + $eventSource->close(); |
|
194 | + $config->setSystemValue('maintenance', false); |
|
195 | + }); |
|
196 | + $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { |
|
197 | + $eventSource->send('success', (string)$l->t('Set log level to debug')); |
|
198 | + }); |
|
199 | + $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { |
|
200 | + $eventSource->send('success', (string)$l->t('Reset log level')); |
|
201 | + }); |
|
202 | + $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($eventSource, $l) { |
|
203 | + $eventSource->send('success', (string)$l->t('Starting code integrity check')); |
|
204 | + }); |
|
205 | + $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($eventSource, $l) { |
|
206 | + $eventSource->send('success', (string)$l->t('Finished code integrity check')); |
|
207 | + }); |
|
208 | + |
|
209 | + try { |
|
210 | + $updater->upgrade(); |
|
211 | + } catch (\Exception $e) { |
|
212 | + \OC::$server->getLogger()->logException($e, [ |
|
213 | + 'level' => ILogger::ERROR, |
|
214 | + 'app' => 'update', |
|
215 | + ]); |
|
216 | + $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage()); |
|
217 | + $eventSource->close(); |
|
218 | + exit(); |
|
219 | + } |
|
220 | + |
|
221 | + $disabledApps = []; |
|
222 | + foreach ($incompatibleApps as $app) { |
|
223 | + $disabledApps[$app] = (string) $l->t('%s (incompatible)', [$app]); |
|
224 | + } |
|
225 | + |
|
226 | + if (!empty($disabledApps)) { |
|
227 | + $eventSource->send('notice', |
|
228 | + (string)$l->t('Following apps have been disabled: %s', [implode(', ', $disabledApps)])); |
|
229 | + } |
|
230 | 230 | } else { |
231 | - $eventSource->send('notice', (string)$l->t('Already up to date')); |
|
231 | + $eventSource->send('notice', (string)$l->t('Already up to date')); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | $eventSource->send('done', ''); |
@@ -33,97 +33,97 @@ |
||
33 | 33 | use OCP\ILogger; |
34 | 34 | |
35 | 35 | class SetupController { |
36 | - /** @var Setup */ |
|
37 | - protected $setupHelper; |
|
38 | - /** @var string */ |
|
39 | - private $autoConfigFile; |
|
36 | + /** @var Setup */ |
|
37 | + protected $setupHelper; |
|
38 | + /** @var string */ |
|
39 | + private $autoConfigFile; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param Setup $setupHelper |
|
43 | - */ |
|
44 | - function __construct(Setup $setupHelper) { |
|
45 | - $this->autoConfigFile = \OC::$configDir.'autoconfig.php'; |
|
46 | - $this->setupHelper = $setupHelper; |
|
47 | - } |
|
41 | + /** |
|
42 | + * @param Setup $setupHelper |
|
43 | + */ |
|
44 | + function __construct(Setup $setupHelper) { |
|
45 | + $this->autoConfigFile = \OC::$configDir.'autoconfig.php'; |
|
46 | + $this->setupHelper = $setupHelper; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param $post |
|
51 | - */ |
|
52 | - public function run($post) { |
|
53 | - // Check for autosetup: |
|
54 | - $post = $this->loadAutoConfig($post); |
|
55 | - $opts = $this->setupHelper->getSystemInfo(); |
|
49 | + /** |
|
50 | + * @param $post |
|
51 | + */ |
|
52 | + public function run($post) { |
|
53 | + // Check for autosetup: |
|
54 | + $post = $this->loadAutoConfig($post); |
|
55 | + $opts = $this->setupHelper->getSystemInfo(); |
|
56 | 56 | |
57 | - // convert 'abcpassword' to 'abcpass' |
|
58 | - if (isset($post['adminpassword'])) { |
|
59 | - $post['adminpass'] = $post['adminpassword']; |
|
60 | - } |
|
61 | - if (isset($post['dbpassword'])) { |
|
62 | - $post['dbpass'] = $post['dbpassword']; |
|
63 | - } |
|
57 | + // convert 'abcpassword' to 'abcpass' |
|
58 | + if (isset($post['adminpassword'])) { |
|
59 | + $post['adminpass'] = $post['adminpassword']; |
|
60 | + } |
|
61 | + if (isset($post['dbpassword'])) { |
|
62 | + $post['dbpass'] = $post['dbpassword']; |
|
63 | + } |
|
64 | 64 | |
65 | - if(isset($post['install']) AND $post['install']=='true') { |
|
66 | - // We have to launch the installation process : |
|
67 | - $e = $this->setupHelper->install($post); |
|
68 | - $errors = array('errors' => $e); |
|
65 | + if(isset($post['install']) AND $post['install']=='true') { |
|
66 | + // We have to launch the installation process : |
|
67 | + $e = $this->setupHelper->install($post); |
|
68 | + $errors = array('errors' => $e); |
|
69 | 69 | |
70 | - if(count($e) > 0) { |
|
71 | - $options = array_merge($opts, $post, $errors); |
|
72 | - $this->display($options); |
|
73 | - } else { |
|
74 | - $this->finishSetup(); |
|
75 | - } |
|
76 | - } else { |
|
77 | - $options = array_merge($opts, $post); |
|
78 | - $this->display($options); |
|
79 | - } |
|
80 | - } |
|
70 | + if(count($e) > 0) { |
|
71 | + $options = array_merge($opts, $post, $errors); |
|
72 | + $this->display($options); |
|
73 | + } else { |
|
74 | + $this->finishSetup(); |
|
75 | + } |
|
76 | + } else { |
|
77 | + $options = array_merge($opts, $post); |
|
78 | + $this->display($options); |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | - public function display($post) { |
|
83 | - $defaults = array( |
|
84 | - 'adminlogin' => '', |
|
85 | - 'adminpass' => '', |
|
86 | - 'dbuser' => '', |
|
87 | - 'dbpass' => '', |
|
88 | - 'dbname' => '', |
|
89 | - 'dbtablespace' => '', |
|
90 | - 'dbhost' => 'localhost', |
|
91 | - 'dbtype' => '', |
|
92 | - ); |
|
93 | - $parameters = array_merge($defaults, $post); |
|
82 | + public function display($post) { |
|
83 | + $defaults = array( |
|
84 | + 'adminlogin' => '', |
|
85 | + 'adminpass' => '', |
|
86 | + 'dbuser' => '', |
|
87 | + 'dbpass' => '', |
|
88 | + 'dbname' => '', |
|
89 | + 'dbtablespace' => '', |
|
90 | + 'dbhost' => 'localhost', |
|
91 | + 'dbtype' => '', |
|
92 | + ); |
|
93 | + $parameters = array_merge($defaults, $post); |
|
94 | 94 | |
95 | - \OC_Util::addVendorScript('strengthify/jquery.strengthify'); |
|
96 | - \OC_Util::addVendorStyle('strengthify/strengthify'); |
|
97 | - \OC_Util::addScript('setup'); |
|
98 | - \OC_Template::printGuestPage('', 'installation', $parameters); |
|
99 | - } |
|
95 | + \OC_Util::addVendorScript('strengthify/jquery.strengthify'); |
|
96 | + \OC_Util::addVendorStyle('strengthify/strengthify'); |
|
97 | + \OC_Util::addScript('setup'); |
|
98 | + \OC_Template::printGuestPage('', 'installation', $parameters); |
|
99 | + } |
|
100 | 100 | |
101 | - public function finishSetup() { |
|
102 | - if( file_exists( $this->autoConfigFile )) { |
|
103 | - unlink($this->autoConfigFile); |
|
104 | - } |
|
105 | - \OC::$server->getIntegrityCodeChecker()->runInstanceVerification(); |
|
106 | - \OC_Util::redirectToDefaultPage(); |
|
107 | - } |
|
101 | + public function finishSetup() { |
|
102 | + if( file_exists( $this->autoConfigFile )) { |
|
103 | + unlink($this->autoConfigFile); |
|
104 | + } |
|
105 | + \OC::$server->getIntegrityCodeChecker()->runInstanceVerification(); |
|
106 | + \OC_Util::redirectToDefaultPage(); |
|
107 | + } |
|
108 | 108 | |
109 | - public function loadAutoConfig($post) { |
|
110 | - if( file_exists($this->autoConfigFile)) { |
|
111 | - \OCP\Util::writeLog('core', 'Autoconfig file found, setting up ownCloud…', ILogger::INFO); |
|
112 | - $AUTOCONFIG = array(); |
|
113 | - include $this->autoConfigFile; |
|
114 | - $post = array_merge ($post, $AUTOCONFIG); |
|
115 | - } |
|
109 | + public function loadAutoConfig($post) { |
|
110 | + if( file_exists($this->autoConfigFile)) { |
|
111 | + \OCP\Util::writeLog('core', 'Autoconfig file found, setting up ownCloud…', ILogger::INFO); |
|
112 | + $AUTOCONFIG = array(); |
|
113 | + include $this->autoConfigFile; |
|
114 | + $post = array_merge ($post, $AUTOCONFIG); |
|
115 | + } |
|
116 | 116 | |
117 | - $dbIsSet = isset($post['dbtype']); |
|
118 | - $directoryIsSet = isset($post['directory']); |
|
119 | - $adminAccountIsSet = isset($post['adminlogin']); |
|
117 | + $dbIsSet = isset($post['dbtype']); |
|
118 | + $directoryIsSet = isset($post['directory']); |
|
119 | + $adminAccountIsSet = isset($post['adminlogin']); |
|
120 | 120 | |
121 | - if ($dbIsSet AND $directoryIsSet AND $adminAccountIsSet) { |
|
122 | - $post['install'] = 'true'; |
|
123 | - } |
|
124 | - $post['dbIsSet'] = $dbIsSet; |
|
125 | - $post['directoryIsSet'] = $directoryIsSet; |
|
121 | + if ($dbIsSet AND $directoryIsSet AND $adminAccountIsSet) { |
|
122 | + $post['install'] = 'true'; |
|
123 | + } |
|
124 | + $post['dbIsSet'] = $dbIsSet; |
|
125 | + $post['directoryIsSet'] = $directoryIsSet; |
|
126 | 126 | |
127 | - return $post; |
|
128 | - } |
|
127 | + return $post; |
|
128 | + } |
|
129 | 129 | } |
@@ -40,284 +40,284 @@ |
||
40 | 40 | |
41 | 41 | class Storage extends Wrapper { |
42 | 42 | |
43 | - private $mountPoint; |
|
44 | - // remember already deleted files to avoid infinite loops if the trash bin |
|
45 | - // move files across storages |
|
46 | - private $deletedFiles = array(); |
|
47 | - |
|
48 | - /** |
|
49 | - * Disable trash logic |
|
50 | - * |
|
51 | - * @var bool |
|
52 | - */ |
|
53 | - private static $disableTrash = false; |
|
54 | - |
|
55 | - /** |
|
56 | - * remember which file/folder was moved out of s shared folder |
|
57 | - * in this case we want to add a copy to the owners trash bin |
|
58 | - * |
|
59 | - * @var array |
|
60 | - */ |
|
61 | - private static $moveOutOfSharedFolder = []; |
|
62 | - |
|
63 | - /** @var IUserManager */ |
|
64 | - private $userManager; |
|
65 | - |
|
66 | - /** @var ILogger */ |
|
67 | - private $logger; |
|
68 | - |
|
69 | - /** @var EventDispatcher */ |
|
70 | - private $eventDispatcher; |
|
71 | - |
|
72 | - /** @var IRootFolder */ |
|
73 | - private $rootFolder; |
|
74 | - |
|
75 | - /** |
|
76 | - * Storage constructor. |
|
77 | - * |
|
78 | - * @param array $parameters |
|
79 | - * @param IUserManager|null $userManager |
|
80 | - * @param ILogger|null $logger |
|
81 | - * @param EventDispatcher|null $eventDispatcher |
|
82 | - * @param IRootFolder|null $rootFolder |
|
83 | - */ |
|
84 | - public function __construct($parameters, |
|
85 | - IUserManager $userManager = null, |
|
86 | - ILogger $logger = null, |
|
87 | - EventDispatcher $eventDispatcher = null, |
|
88 | - IRootFolder $rootFolder = null) { |
|
89 | - $this->mountPoint = $parameters['mountPoint']; |
|
90 | - $this->userManager = $userManager; |
|
91 | - $this->logger = $logger; |
|
92 | - $this->eventDispatcher = $eventDispatcher; |
|
93 | - $this->rootFolder = $rootFolder; |
|
94 | - parent::__construct($parameters); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @internal |
|
99 | - */ |
|
100 | - public static function preRenameHook($params) { |
|
101 | - // in cross-storage cases, a rename is a copy + unlink, |
|
102 | - // that last unlink must not go to trash, only exception: |
|
103 | - // if the file was moved from a shared storage to a local folder, |
|
104 | - // in this case the owner should get a copy in his trash bin so that |
|
105 | - // they can restore the files again |
|
106 | - |
|
107 | - $oldPath = $params['oldpath']; |
|
108 | - $newPath = dirname($params['newpath']); |
|
109 | - $currentUser = \OC::$server->getUserSession()->getUser(); |
|
110 | - |
|
111 | - $fileMovedOutOfSharedFolder = false; |
|
112 | - |
|
113 | - try { |
|
114 | - if ($currentUser) { |
|
115 | - $currentUserId = $currentUser->getUID(); |
|
116 | - |
|
117 | - $view = new View($currentUserId . '/files'); |
|
118 | - $fileInfo = $view->getFileInfo($oldPath); |
|
119 | - if ($fileInfo) { |
|
120 | - $sourceStorage = $fileInfo->getStorage(); |
|
121 | - $sourceOwner = $view->getOwner($oldPath); |
|
122 | - $targetOwner = $view->getOwner($newPath); |
|
123 | - |
|
124 | - if ($sourceOwner !== $targetOwner |
|
125 | - && $sourceStorage->instanceOfStorage('OCA\Files_Sharing\SharedStorage') |
|
126 | - ) { |
|
127 | - $fileMovedOutOfSharedFolder = true; |
|
128 | - } |
|
129 | - } |
|
130 | - } |
|
131 | - } catch (\Exception $e) { |
|
132 | - // do nothing, in this case we just disable the trashbin and continue |
|
133 | - \OC::$server->getLogger()->logException($e, [ |
|
134 | - 'message' => 'Trashbin storage could not check if a file was moved out of a shared folder.', |
|
135 | - 'level' => ILogger::DEBUG, |
|
136 | - 'app' => 'files_trashbin', |
|
137 | - ]); |
|
138 | - } |
|
139 | - |
|
140 | - if($fileMovedOutOfSharedFolder) { |
|
141 | - self::$moveOutOfSharedFolder['/' . $currentUserId . '/files' . $oldPath] = true; |
|
142 | - } else { |
|
143 | - self::$disableTrash = true; |
|
144 | - } |
|
145 | - |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * @internal |
|
150 | - */ |
|
151 | - public static function postRenameHook($params) { |
|
152 | - self::$disableTrash = false; |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Rename path1 to path2 by calling the wrapped storage. |
|
157 | - * |
|
158 | - * @param string $path1 first path |
|
159 | - * @param string $path2 second path |
|
160 | - * @return bool |
|
161 | - */ |
|
162 | - public function rename($path1, $path2) { |
|
163 | - $result = $this->storage->rename($path1, $path2); |
|
164 | - if ($result === false) { |
|
165 | - // when rename failed, the post_rename hook isn't triggered, |
|
166 | - // but we still want to reenable the trash logic |
|
167 | - self::$disableTrash = false; |
|
168 | - } |
|
169 | - return $result; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Deletes the given file by moving it into the trashbin. |
|
174 | - * |
|
175 | - * @param string $path path of file or folder to delete |
|
176 | - * |
|
177 | - * @return bool true if the operation succeeded, false otherwise |
|
178 | - */ |
|
179 | - public function unlink($path) { |
|
180 | - try { |
|
181 | - if (isset(self::$moveOutOfSharedFolder[$this->mountPoint . $path])) { |
|
182 | - $result = $this->doDelete($path, 'unlink', true); |
|
183 | - unset(self::$moveOutOfSharedFolder[$this->mountPoint . $path]); |
|
184 | - } else { |
|
185 | - $result = $this->doDelete($path, 'unlink'); |
|
186 | - } |
|
187 | - } catch (GenericEncryptionException $e) { |
|
188 | - // in case of a encryption exception we delete the file right away |
|
189 | - $this->logger->info( |
|
190 | - "Can't move file" . $path . |
|
191 | - "to the trash bin, therefore it was deleted right away"); |
|
192 | - |
|
193 | - $result = $this->storage->unlink($path); |
|
194 | - } |
|
195 | - |
|
196 | - return $result; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Deletes the given folder by moving it into the trashbin. |
|
201 | - * |
|
202 | - * @param string $path path of folder to delete |
|
203 | - * |
|
204 | - * @return bool true if the operation succeeded, false otherwise |
|
205 | - */ |
|
206 | - public function rmdir($path) { |
|
207 | - if (isset(self::$moveOutOfSharedFolder[$this->mountPoint . $path])) { |
|
208 | - $result = $this->doDelete($path, 'rmdir', true); |
|
209 | - unset(self::$moveOutOfSharedFolder[$this->mountPoint . $path]); |
|
210 | - } else { |
|
211 | - $result = $this->doDelete($path, 'rmdir'); |
|
212 | - } |
|
213 | - |
|
214 | - return $result; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * check if it is a file located in data/user/files only files in the |
|
219 | - * 'files' directory should be moved to the trash |
|
220 | - * |
|
221 | - * @param $path |
|
222 | - * @return bool |
|
223 | - */ |
|
224 | - protected function shouldMoveToTrash($path){ |
|
225 | - |
|
226 | - // check if there is a app which want to disable the trash bin for this file |
|
227 | - $fileId = $this->storage->getCache()->getId($path); |
|
228 | - $nodes = $this->rootFolder->getById($fileId); |
|
229 | - foreach ($nodes as $node) { |
|
230 | - $event = $this->createMoveToTrashEvent($node); |
|
231 | - $this->eventDispatcher->dispatch('OCA\Files_Trashbin::moveToTrash', $event); |
|
232 | - if ($event->shouldMoveToTrashBin() === false) { |
|
233 | - return false; |
|
234 | - } |
|
235 | - } |
|
236 | - |
|
237 | - $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path); |
|
238 | - $parts = explode('/', $normalized); |
|
239 | - if (count($parts) < 4) { |
|
240 | - return false; |
|
241 | - } |
|
242 | - |
|
243 | - if ($parts[2] === 'files' && $this->userManager->userExists($parts[1])) { |
|
244 | - return true; |
|
245 | - } |
|
246 | - |
|
247 | - return false; |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * get move to trash event |
|
252 | - * |
|
253 | - * @param Node $node |
|
254 | - * @return MoveToTrashEvent |
|
255 | - */ |
|
256 | - protected function createMoveToTrashEvent(Node $node) { |
|
257 | - return new MoveToTrashEvent($node); |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
261 | - * Run the delete operation with the given method |
|
262 | - * |
|
263 | - * @param string $path path of file or folder to delete |
|
264 | - * @param string $method either "unlink" or "rmdir" |
|
265 | - * @param bool $ownerOnly delete for owner only (if file gets moved out of a shared folder) |
|
266 | - * |
|
267 | - * @return bool true if the operation succeeded, false otherwise |
|
268 | - */ |
|
269 | - private function doDelete($path, $method, $ownerOnly = false) { |
|
270 | - if (self::$disableTrash |
|
271 | - || !\OC::$server->getAppManager()->isEnabledForUser('files_trashbin') |
|
272 | - || (pathinfo($path, PATHINFO_EXTENSION) === 'part') |
|
273 | - || $this->shouldMoveToTrash($path) === false |
|
274 | - ) { |
|
275 | - return call_user_func_array([$this->storage, $method], [$path]); |
|
276 | - } |
|
277 | - |
|
278 | - // check permissions before we continue, this is especially important for |
|
279 | - // shared files |
|
280 | - if (!$this->isDeletable($path)) { |
|
281 | - return false; |
|
282 | - } |
|
283 | - |
|
284 | - $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path, true, false, true); |
|
285 | - $result = true; |
|
286 | - $view = Filesystem::getView(); |
|
287 | - if (!isset($this->deletedFiles[$normalized]) && $view instanceof View) { |
|
288 | - $this->deletedFiles[$normalized] = $normalized; |
|
289 | - if ($filesPath = $view->getRelativePath($normalized)) { |
|
290 | - $filesPath = trim($filesPath, '/'); |
|
291 | - $result = \OCA\Files_Trashbin\Trashbin::move2trash($filesPath, $ownerOnly); |
|
292 | - // in cross-storage cases the file will be copied |
|
293 | - // but not deleted, so we delete it here |
|
294 | - if ($result) { |
|
295 | - call_user_func_array([$this->storage, $method], [$path]); |
|
296 | - } |
|
297 | - } else { |
|
298 | - $result = call_user_func_array([$this->storage, $method], [$path]); |
|
299 | - } |
|
300 | - unset($this->deletedFiles[$normalized]); |
|
301 | - } else if ($this->storage->file_exists($path)) { |
|
302 | - $result = call_user_func_array([$this->storage, $method], [$path]); |
|
303 | - } |
|
304 | - |
|
305 | - return $result; |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * Setup the storate wrapper callback |
|
310 | - */ |
|
311 | - public static function setupStorage() { |
|
312 | - \OC\Files\Filesystem::addStorageWrapper('oc_trashbin', function ($mountPoint, $storage) { |
|
313 | - return new \OCA\Files_Trashbin\Storage( |
|
314 | - array('storage' => $storage, 'mountPoint' => $mountPoint), |
|
315 | - \OC::$server->getUserManager(), |
|
316 | - \OC::$server->getLogger(), |
|
317 | - \OC::$server->getEventDispatcher(), |
|
318 | - \OC::$server->getLazyRootFolder() |
|
319 | - ); |
|
320 | - }, 1); |
|
321 | - } |
|
43 | + private $mountPoint; |
|
44 | + // remember already deleted files to avoid infinite loops if the trash bin |
|
45 | + // move files across storages |
|
46 | + private $deletedFiles = array(); |
|
47 | + |
|
48 | + /** |
|
49 | + * Disable trash logic |
|
50 | + * |
|
51 | + * @var bool |
|
52 | + */ |
|
53 | + private static $disableTrash = false; |
|
54 | + |
|
55 | + /** |
|
56 | + * remember which file/folder was moved out of s shared folder |
|
57 | + * in this case we want to add a copy to the owners trash bin |
|
58 | + * |
|
59 | + * @var array |
|
60 | + */ |
|
61 | + private static $moveOutOfSharedFolder = []; |
|
62 | + |
|
63 | + /** @var IUserManager */ |
|
64 | + private $userManager; |
|
65 | + |
|
66 | + /** @var ILogger */ |
|
67 | + private $logger; |
|
68 | + |
|
69 | + /** @var EventDispatcher */ |
|
70 | + private $eventDispatcher; |
|
71 | + |
|
72 | + /** @var IRootFolder */ |
|
73 | + private $rootFolder; |
|
74 | + |
|
75 | + /** |
|
76 | + * Storage constructor. |
|
77 | + * |
|
78 | + * @param array $parameters |
|
79 | + * @param IUserManager|null $userManager |
|
80 | + * @param ILogger|null $logger |
|
81 | + * @param EventDispatcher|null $eventDispatcher |
|
82 | + * @param IRootFolder|null $rootFolder |
|
83 | + */ |
|
84 | + public function __construct($parameters, |
|
85 | + IUserManager $userManager = null, |
|
86 | + ILogger $logger = null, |
|
87 | + EventDispatcher $eventDispatcher = null, |
|
88 | + IRootFolder $rootFolder = null) { |
|
89 | + $this->mountPoint = $parameters['mountPoint']; |
|
90 | + $this->userManager = $userManager; |
|
91 | + $this->logger = $logger; |
|
92 | + $this->eventDispatcher = $eventDispatcher; |
|
93 | + $this->rootFolder = $rootFolder; |
|
94 | + parent::__construct($parameters); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @internal |
|
99 | + */ |
|
100 | + public static function preRenameHook($params) { |
|
101 | + // in cross-storage cases, a rename is a copy + unlink, |
|
102 | + // that last unlink must not go to trash, only exception: |
|
103 | + // if the file was moved from a shared storage to a local folder, |
|
104 | + // in this case the owner should get a copy in his trash bin so that |
|
105 | + // they can restore the files again |
|
106 | + |
|
107 | + $oldPath = $params['oldpath']; |
|
108 | + $newPath = dirname($params['newpath']); |
|
109 | + $currentUser = \OC::$server->getUserSession()->getUser(); |
|
110 | + |
|
111 | + $fileMovedOutOfSharedFolder = false; |
|
112 | + |
|
113 | + try { |
|
114 | + if ($currentUser) { |
|
115 | + $currentUserId = $currentUser->getUID(); |
|
116 | + |
|
117 | + $view = new View($currentUserId . '/files'); |
|
118 | + $fileInfo = $view->getFileInfo($oldPath); |
|
119 | + if ($fileInfo) { |
|
120 | + $sourceStorage = $fileInfo->getStorage(); |
|
121 | + $sourceOwner = $view->getOwner($oldPath); |
|
122 | + $targetOwner = $view->getOwner($newPath); |
|
123 | + |
|
124 | + if ($sourceOwner !== $targetOwner |
|
125 | + && $sourceStorage->instanceOfStorage('OCA\Files_Sharing\SharedStorage') |
|
126 | + ) { |
|
127 | + $fileMovedOutOfSharedFolder = true; |
|
128 | + } |
|
129 | + } |
|
130 | + } |
|
131 | + } catch (\Exception $e) { |
|
132 | + // do nothing, in this case we just disable the trashbin and continue |
|
133 | + \OC::$server->getLogger()->logException($e, [ |
|
134 | + 'message' => 'Trashbin storage could not check if a file was moved out of a shared folder.', |
|
135 | + 'level' => ILogger::DEBUG, |
|
136 | + 'app' => 'files_trashbin', |
|
137 | + ]); |
|
138 | + } |
|
139 | + |
|
140 | + if($fileMovedOutOfSharedFolder) { |
|
141 | + self::$moveOutOfSharedFolder['/' . $currentUserId . '/files' . $oldPath] = true; |
|
142 | + } else { |
|
143 | + self::$disableTrash = true; |
|
144 | + } |
|
145 | + |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * @internal |
|
150 | + */ |
|
151 | + public static function postRenameHook($params) { |
|
152 | + self::$disableTrash = false; |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Rename path1 to path2 by calling the wrapped storage. |
|
157 | + * |
|
158 | + * @param string $path1 first path |
|
159 | + * @param string $path2 second path |
|
160 | + * @return bool |
|
161 | + */ |
|
162 | + public function rename($path1, $path2) { |
|
163 | + $result = $this->storage->rename($path1, $path2); |
|
164 | + if ($result === false) { |
|
165 | + // when rename failed, the post_rename hook isn't triggered, |
|
166 | + // but we still want to reenable the trash logic |
|
167 | + self::$disableTrash = false; |
|
168 | + } |
|
169 | + return $result; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Deletes the given file by moving it into the trashbin. |
|
174 | + * |
|
175 | + * @param string $path path of file or folder to delete |
|
176 | + * |
|
177 | + * @return bool true if the operation succeeded, false otherwise |
|
178 | + */ |
|
179 | + public function unlink($path) { |
|
180 | + try { |
|
181 | + if (isset(self::$moveOutOfSharedFolder[$this->mountPoint . $path])) { |
|
182 | + $result = $this->doDelete($path, 'unlink', true); |
|
183 | + unset(self::$moveOutOfSharedFolder[$this->mountPoint . $path]); |
|
184 | + } else { |
|
185 | + $result = $this->doDelete($path, 'unlink'); |
|
186 | + } |
|
187 | + } catch (GenericEncryptionException $e) { |
|
188 | + // in case of a encryption exception we delete the file right away |
|
189 | + $this->logger->info( |
|
190 | + "Can't move file" . $path . |
|
191 | + "to the trash bin, therefore it was deleted right away"); |
|
192 | + |
|
193 | + $result = $this->storage->unlink($path); |
|
194 | + } |
|
195 | + |
|
196 | + return $result; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Deletes the given folder by moving it into the trashbin. |
|
201 | + * |
|
202 | + * @param string $path path of folder to delete |
|
203 | + * |
|
204 | + * @return bool true if the operation succeeded, false otherwise |
|
205 | + */ |
|
206 | + public function rmdir($path) { |
|
207 | + if (isset(self::$moveOutOfSharedFolder[$this->mountPoint . $path])) { |
|
208 | + $result = $this->doDelete($path, 'rmdir', true); |
|
209 | + unset(self::$moveOutOfSharedFolder[$this->mountPoint . $path]); |
|
210 | + } else { |
|
211 | + $result = $this->doDelete($path, 'rmdir'); |
|
212 | + } |
|
213 | + |
|
214 | + return $result; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * check if it is a file located in data/user/files only files in the |
|
219 | + * 'files' directory should be moved to the trash |
|
220 | + * |
|
221 | + * @param $path |
|
222 | + * @return bool |
|
223 | + */ |
|
224 | + protected function shouldMoveToTrash($path){ |
|
225 | + |
|
226 | + // check if there is a app which want to disable the trash bin for this file |
|
227 | + $fileId = $this->storage->getCache()->getId($path); |
|
228 | + $nodes = $this->rootFolder->getById($fileId); |
|
229 | + foreach ($nodes as $node) { |
|
230 | + $event = $this->createMoveToTrashEvent($node); |
|
231 | + $this->eventDispatcher->dispatch('OCA\Files_Trashbin::moveToTrash', $event); |
|
232 | + if ($event->shouldMoveToTrashBin() === false) { |
|
233 | + return false; |
|
234 | + } |
|
235 | + } |
|
236 | + |
|
237 | + $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path); |
|
238 | + $parts = explode('/', $normalized); |
|
239 | + if (count($parts) < 4) { |
|
240 | + return false; |
|
241 | + } |
|
242 | + |
|
243 | + if ($parts[2] === 'files' && $this->userManager->userExists($parts[1])) { |
|
244 | + return true; |
|
245 | + } |
|
246 | + |
|
247 | + return false; |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * get move to trash event |
|
252 | + * |
|
253 | + * @param Node $node |
|
254 | + * @return MoveToTrashEvent |
|
255 | + */ |
|
256 | + protected function createMoveToTrashEvent(Node $node) { |
|
257 | + return new MoveToTrashEvent($node); |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * Run the delete operation with the given method |
|
262 | + * |
|
263 | + * @param string $path path of file or folder to delete |
|
264 | + * @param string $method either "unlink" or "rmdir" |
|
265 | + * @param bool $ownerOnly delete for owner only (if file gets moved out of a shared folder) |
|
266 | + * |
|
267 | + * @return bool true if the operation succeeded, false otherwise |
|
268 | + */ |
|
269 | + private function doDelete($path, $method, $ownerOnly = false) { |
|
270 | + if (self::$disableTrash |
|
271 | + || !\OC::$server->getAppManager()->isEnabledForUser('files_trashbin') |
|
272 | + || (pathinfo($path, PATHINFO_EXTENSION) === 'part') |
|
273 | + || $this->shouldMoveToTrash($path) === false |
|
274 | + ) { |
|
275 | + return call_user_func_array([$this->storage, $method], [$path]); |
|
276 | + } |
|
277 | + |
|
278 | + // check permissions before we continue, this is especially important for |
|
279 | + // shared files |
|
280 | + if (!$this->isDeletable($path)) { |
|
281 | + return false; |
|
282 | + } |
|
283 | + |
|
284 | + $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path, true, false, true); |
|
285 | + $result = true; |
|
286 | + $view = Filesystem::getView(); |
|
287 | + if (!isset($this->deletedFiles[$normalized]) && $view instanceof View) { |
|
288 | + $this->deletedFiles[$normalized] = $normalized; |
|
289 | + if ($filesPath = $view->getRelativePath($normalized)) { |
|
290 | + $filesPath = trim($filesPath, '/'); |
|
291 | + $result = \OCA\Files_Trashbin\Trashbin::move2trash($filesPath, $ownerOnly); |
|
292 | + // in cross-storage cases the file will be copied |
|
293 | + // but not deleted, so we delete it here |
|
294 | + if ($result) { |
|
295 | + call_user_func_array([$this->storage, $method], [$path]); |
|
296 | + } |
|
297 | + } else { |
|
298 | + $result = call_user_func_array([$this->storage, $method], [$path]); |
|
299 | + } |
|
300 | + unset($this->deletedFiles[$normalized]); |
|
301 | + } else if ($this->storage->file_exists($path)) { |
|
302 | + $result = call_user_func_array([$this->storage, $method], [$path]); |
|
303 | + } |
|
304 | + |
|
305 | + return $result; |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * Setup the storate wrapper callback |
|
310 | + */ |
|
311 | + public static function setupStorage() { |
|
312 | + \OC\Files\Filesystem::addStorageWrapper('oc_trashbin', function ($mountPoint, $storage) { |
|
313 | + return new \OCA\Files_Trashbin\Storage( |
|
314 | + array('storage' => $storage, 'mountPoint' => $mountPoint), |
|
315 | + \OC::$server->getUserManager(), |
|
316 | + \OC::$server->getLogger(), |
|
317 | + \OC::$server->getEventDispatcher(), |
|
318 | + \OC::$server->getLazyRootFolder() |
|
319 | + ); |
|
320 | + }, 1); |
|
321 | + } |
|
322 | 322 | |
323 | 323 | } |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | |
36 | 36 | // "empty trash" command |
37 | 37 | if (isset($_POST['allfiles']) && (string)$_POST['allfiles'] === 'true'){ |
38 | - $deleteAll = true; |
|
39 | - if ($folder === '/' || $folder === '') { |
|
40 | - OCA\Files_Trashbin\Trashbin::deleteAll(); |
|
41 | - $list = array(); |
|
42 | - } else { |
|
43 | - $list[] = $folder; |
|
44 | - $folder = dirname($folder); |
|
45 | - } |
|
38 | + $deleteAll = true; |
|
39 | + if ($folder === '/' || $folder === '') { |
|
40 | + OCA\Files_Trashbin\Trashbin::deleteAll(); |
|
41 | + $list = array(); |
|
42 | + } else { |
|
43 | + $list[] = $folder; |
|
44 | + $folder = dirname($folder); |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | else { |
48 | - $deleteAll = false; |
|
49 | - $files = (string)$_POST['files']; |
|
50 | - $list = json_decode($files); |
|
48 | + $deleteAll = false; |
|
49 | + $files = (string)$_POST['files']; |
|
50 | + $list = json_decode($files); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $folder = rtrim($folder, '/') . '/'; |
@@ -56,38 +56,38 @@ discard block |
||
56 | 56 | |
57 | 57 | $i = 0; |
58 | 58 | foreach ($list as $file) { |
59 | - if ($folder === '/') { |
|
60 | - $file = ltrim($file, '/'); |
|
61 | - $delimiter = strrpos($file, '.d'); |
|
62 | - $filename = substr($file, 0, $delimiter); |
|
63 | - $timestamp = substr($file, $delimiter+2); |
|
64 | - } else { |
|
65 | - $filename = $folder . '/' . $file; |
|
66 | - $timestamp = null; |
|
67 | - } |
|
59 | + if ($folder === '/') { |
|
60 | + $file = ltrim($file, '/'); |
|
61 | + $delimiter = strrpos($file, '.d'); |
|
62 | + $filename = substr($file, 0, $delimiter); |
|
63 | + $timestamp = substr($file, $delimiter+2); |
|
64 | + } else { |
|
65 | + $filename = $folder . '/' . $file; |
|
66 | + $timestamp = null; |
|
67 | + } |
|
68 | 68 | |
69 | - OCA\Files_Trashbin\Trashbin::delete($filename, \OCP\User::getUser(), $timestamp); |
|
70 | - if (OCA\Files_Trashbin\Trashbin::file_exists($filename, $timestamp)) { |
|
71 | - $error[] = $filename; |
|
72 | - \OCP\Util::writeLog('trashbin','can\'t delete ' . $filename . ' permanently.', ILogger::ERROR); |
|
73 | - } |
|
74 | - // only list deleted files if not deleting everything |
|
75 | - else if (!$deleteAll) { |
|
76 | - $success[$i]['filename'] = $file; |
|
77 | - $success[$i]['timestamp'] = $timestamp; |
|
78 | - $i++; |
|
79 | - } |
|
69 | + OCA\Files_Trashbin\Trashbin::delete($filename, \OCP\User::getUser(), $timestamp); |
|
70 | + if (OCA\Files_Trashbin\Trashbin::file_exists($filename, $timestamp)) { |
|
71 | + $error[] = $filename; |
|
72 | + \OCP\Util::writeLog('trashbin','can\'t delete ' . $filename . ' permanently.', ILogger::ERROR); |
|
73 | + } |
|
74 | + // only list deleted files if not deleting everything |
|
75 | + else if (!$deleteAll) { |
|
76 | + $success[$i]['filename'] = $file; |
|
77 | + $success[$i]['timestamp'] = $timestamp; |
|
78 | + $i++; |
|
79 | + } |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | if ( $error ) { |
83 | - $filelist = ''; |
|
84 | - foreach ( $error as $e ) { |
|
85 | - $filelist .= $e.', '; |
|
86 | - } |
|
87 | - $l = \OC::$server->getL10N('files_trashbin'); |
|
88 | - $message = $l->t("Couldn't delete %s permanently", array(rtrim($filelist, ', '))); |
|
89 | - \OC_JSON::error(array("data" => array("message" => $message, |
|
90 | - "success" => $success, "error" => $error))); |
|
83 | + $filelist = ''; |
|
84 | + foreach ( $error as $e ) { |
|
85 | + $filelist .= $e.', '; |
|
86 | + } |
|
87 | + $l = \OC::$server->getL10N('files_trashbin'); |
|
88 | + $message = $l->t("Couldn't delete %s permanently", array(rtrim($filelist, ', '))); |
|
89 | + \OC_JSON::error(array("data" => array("message" => $message, |
|
90 | + "success" => $success, "error" => $error))); |
|
91 | 91 | } else { |
92 | - \OC_JSON::success(array("data" => array("success" => $success))); |
|
92 | + \OC_JSON::success(array("data" => array("success" => $success))); |
|
93 | 93 | } |
@@ -35,25 +35,25 @@ discard block |
||
35 | 35 | |
36 | 36 | $dir = '/'; |
37 | 37 | if (isset($_POST['dir'])) { |
38 | - $dir = rtrim((string)$_POST['dir'], '/'). '/'; |
|
38 | + $dir = rtrim((string)$_POST['dir'], '/'). '/'; |
|
39 | 39 | } |
40 | 40 | $allFiles = false; |
41 | 41 | if (isset($_POST['allfiles']) && (string)$_POST['allfiles'] === 'true') { |
42 | - $allFiles = true; |
|
43 | - $list = array(); |
|
44 | - $dirListing = true; |
|
45 | - if ($dir === '' || $dir === '/') { |
|
46 | - $dirListing = false; |
|
47 | - } |
|
48 | - foreach (OCA\Files_Trashbin\Helper::getTrashFiles($dir, \OCP\User::getUser()) as $file) { |
|
49 | - $fileName = $file['name']; |
|
50 | - if (!$dirListing) { |
|
51 | - $fileName .= '.d' . $file['mtime']; |
|
52 | - } |
|
53 | - $list[] = $fileName; |
|
54 | - } |
|
42 | + $allFiles = true; |
|
43 | + $list = array(); |
|
44 | + $dirListing = true; |
|
45 | + if ($dir === '' || $dir === '/') { |
|
46 | + $dirListing = false; |
|
47 | + } |
|
48 | + foreach (OCA\Files_Trashbin\Helper::getTrashFiles($dir, \OCP\User::getUser()) as $file) { |
|
49 | + $fileName = $file['name']; |
|
50 | + if (!$dirListing) { |
|
51 | + $fileName .= '.d' . $file['mtime']; |
|
52 | + } |
|
53 | + $list[] = $fileName; |
|
54 | + } |
|
55 | 55 | } else { |
56 | - $list = json_decode($_POST['files']); |
|
56 | + $list = json_decode($_POST['files']); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | $error = array(); |
@@ -61,38 +61,38 @@ discard block |
||
61 | 61 | |
62 | 62 | $i = 0; |
63 | 63 | foreach ($list as $file) { |
64 | - $path = $dir . '/' . $file; |
|
65 | - if ($dir === '/') { |
|
66 | - $file = ltrim($file, '/'); |
|
67 | - $delimiter = strrpos($file, '.d'); |
|
68 | - $filename = substr($file, 0, $delimiter); |
|
69 | - $timestamp = substr($file, $delimiter+2); |
|
70 | - } else { |
|
71 | - $path_parts = pathinfo($file); |
|
72 | - $filename = $path_parts['basename']; |
|
73 | - $timestamp = null; |
|
74 | - } |
|
64 | + $path = $dir . '/' . $file; |
|
65 | + if ($dir === '/') { |
|
66 | + $file = ltrim($file, '/'); |
|
67 | + $delimiter = strrpos($file, '.d'); |
|
68 | + $filename = substr($file, 0, $delimiter); |
|
69 | + $timestamp = substr($file, $delimiter+2); |
|
70 | + } else { |
|
71 | + $path_parts = pathinfo($file); |
|
72 | + $filename = $path_parts['basename']; |
|
73 | + $timestamp = null; |
|
74 | + } |
|
75 | 75 | |
76 | - if ( !OCA\Files_Trashbin\Trashbin::restore($path, $filename, $timestamp) ) { |
|
77 | - $error[] = $filename; |
|
78 | - \OCP\Util::writeLog('trashbin', 'can\'t restore ' . $filename, ILogger::ERROR); |
|
79 | - } else { |
|
80 | - $success[$i]['filename'] = $file; |
|
81 | - $success[$i]['timestamp'] = $timestamp; |
|
82 | - $i++; |
|
83 | - } |
|
76 | + if ( !OCA\Files_Trashbin\Trashbin::restore($path, $filename, $timestamp) ) { |
|
77 | + $error[] = $filename; |
|
78 | + \OCP\Util::writeLog('trashbin', 'can\'t restore ' . $filename, ILogger::ERROR); |
|
79 | + } else { |
|
80 | + $success[$i]['filename'] = $file; |
|
81 | + $success[$i]['timestamp'] = $timestamp; |
|
82 | + $i++; |
|
83 | + } |
|
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | 87 | if ( $error ) { |
88 | - $filelist = ''; |
|
89 | - foreach ( $error as $e ) { |
|
90 | - $filelist .= $e.', '; |
|
91 | - } |
|
92 | - $l = OC::$server->getL10N('files_trashbin'); |
|
93 | - $message = $l->t("Couldn't restore %s", array(rtrim($filelist, ', '))); |
|
94 | - \OC_JSON::error(array("data" => array("message" => $message, |
|
95 | - "success" => $success, "error" => $error))); |
|
88 | + $filelist = ''; |
|
89 | + foreach ( $error as $e ) { |
|
90 | + $filelist .= $e.', '; |
|
91 | + } |
|
92 | + $l = OC::$server->getL10N('files_trashbin'); |
|
93 | + $message = $l->t("Couldn't restore %s", array(rtrim($filelist, ', '))); |
|
94 | + \OC_JSON::error(array("data" => array("message" => $message, |
|
95 | + "success" => $success, "error" => $error))); |
|
96 | 96 | } else { |
97 | - \OC_JSON::success(array("data" => array("success" => $success))); |
|
97 | + \OC_JSON::success(array("data" => array("success" => $success))); |
|
98 | 98 | } |