@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | private function findFileWithExtension($class, $ext) |
371 | 371 | { |
372 | 372 | // PSR-4 lookup |
373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
374 | 374 | |
375 | 375 | $first = $class[0]; |
376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
377 | 377 | $subPath = $class; |
378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
380 | - $search = $subPath . '\\'; |
|
380 | + $search = $subPath.'\\'; |
|
381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
385 | 385 | return $file; |
386 | 386 | } |
387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | |
392 | 392 | // PSR-4 fallback dirs |
393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
395 | 395 | return $file; |
396 | 396 | } |
397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
404 | 404 | } else { |
405 | 405 | // PEAR-like class name |
406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
411 | 411 | if (0 === strpos($class, $prefix)) { |
412 | 412 | foreach ($dirs as $dir) { |
413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
414 | 414 | return $file; |
415 | 415 | } |
416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | // PSR-0 fallback dirs |
422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
424 | 424 | return $file; |
425 | 425 | } |
426 | 426 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'OCA\\Settings\\' => array($baseDir . '/../lib'), |
|
9 | + 'OCA\\Settings\\' => array($baseDir.'/../lib'), |
|
10 | 10 | ); |
@@ -28,53 +28,53 @@ |
||
28 | 28 | * @since 15.0.0 |
29 | 29 | */ |
30 | 30 | interface ITrashItem extends FileInfo { |
31 | - /** |
|
32 | - * Get the trash backend for this item |
|
33 | - * |
|
34 | - * @return ITrashBackend |
|
35 | - * @since 15.0.0 |
|
36 | - */ |
|
37 | - public function getTrashBackend(): ITrashBackend; |
|
31 | + /** |
|
32 | + * Get the trash backend for this item |
|
33 | + * |
|
34 | + * @return ITrashBackend |
|
35 | + * @since 15.0.0 |
|
36 | + */ |
|
37 | + public function getTrashBackend(): ITrashBackend; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Get the original location for the trash item |
|
41 | - * |
|
42 | - * @return string |
|
43 | - * @since 15.0.0 |
|
44 | - */ |
|
45 | - public function getOriginalLocation(): string; |
|
39 | + /** |
|
40 | + * Get the original location for the trash item |
|
41 | + * |
|
42 | + * @return string |
|
43 | + * @since 15.0.0 |
|
44 | + */ |
|
45 | + public function getOriginalLocation(): string; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Get the timestamp that the file was moved to trash |
|
49 | - * |
|
50 | - * @return int |
|
51 | - * @since 15.0.0 |
|
52 | - */ |
|
53 | - public function getDeletedTime(): int; |
|
47 | + /** |
|
48 | + * Get the timestamp that the file was moved to trash |
|
49 | + * |
|
50 | + * @return int |
|
51 | + * @since 15.0.0 |
|
52 | + */ |
|
53 | + public function getDeletedTime(): int; |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get the path of the item relative to the users trashbin |
|
57 | - * |
|
58 | - * @return string |
|
59 | - * @since 15.0.0 |
|
60 | - */ |
|
61 | - public function getTrashPath(): string; |
|
55 | + /** |
|
56 | + * Get the path of the item relative to the users trashbin |
|
57 | + * |
|
58 | + * @return string |
|
59 | + * @since 15.0.0 |
|
60 | + */ |
|
61 | + public function getTrashPath(): string; |
|
62 | 62 | |
63 | - /** |
|
64 | - * Whether the item is a deleted item in the root of the trash, or a file in a subfolder |
|
65 | - * |
|
66 | - * @return bool |
|
67 | - * @since 15.0.0 |
|
68 | - */ |
|
69 | - public function isRootItem(): bool; |
|
63 | + /** |
|
64 | + * Whether the item is a deleted item in the root of the trash, or a file in a subfolder |
|
65 | + * |
|
66 | + * @return bool |
|
67 | + * @since 15.0.0 |
|
68 | + */ |
|
69 | + public function isRootItem(): bool; |
|
70 | 70 | |
71 | - /** |
|
72 | - * Get the user for which this trash item applies |
|
73 | - * |
|
74 | - * @return IUser |
|
75 | - * @since 15.0.0 |
|
76 | - */ |
|
77 | - public function getUser(): IUser; |
|
71 | + /** |
|
72 | + * Get the user for which this trash item applies |
|
73 | + * |
|
74 | + * @return IUser |
|
75 | + * @since 15.0.0 |
|
76 | + */ |
|
77 | + public function getUser(): IUser; |
|
78 | 78 | |
79 | - public function getTitle(): string; |
|
79 | + public function getTitle(): string; |
|
80 | 80 | } |
@@ -73,10 +73,10 @@ |
||
73 | 73 | Request::USER_AGENT_ANDROID_MOBILE_CHROME, |
74 | 74 | Request::USER_AGENT_FREEBOX, |
75 | 75 | ])) { |
76 | - $response->addHeader('Content-Disposition', 'attachment; filename="' . rawurlencode($filename) . '"'); |
|
76 | + $response->addHeader('Content-Disposition', 'attachment; filename="'.rawurlencode($filename).'"'); |
|
77 | 77 | } else { |
78 | - $response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\'' . rawurlencode($filename) |
|
79 | - . '; filename="' . rawurlencode($filename) . '"'); |
|
78 | + $response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\''.rawurlencode($filename) |
|
79 | + . '; filename="'.rawurlencode($filename).'"'); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 |
@@ -38,67 +38,67 @@ |
||
38 | 38 | use Sabre\HTTP\ResponseInterface; |
39 | 39 | |
40 | 40 | class Plugin extends ServerPlugin { |
41 | - private Server $server; |
|
42 | - private IRequest $request; |
|
43 | - |
|
44 | - public const VERSION_LABEL = '{http://nextcloud.org/ns}version-label'; |
|
45 | - |
|
46 | - public function __construct( |
|
47 | - IRequest $request |
|
48 | - ) { |
|
49 | - $this->request = $request; |
|
50 | - } |
|
51 | - |
|
52 | - public function initialize(Server $server) { |
|
53 | - $this->server = $server; |
|
54 | - |
|
55 | - $server->on('afterMethod:GET', [$this, 'afterGet']); |
|
56 | - $server->on('propFind', [$this, 'propFind']); |
|
57 | - $server->on('propPatch', [$this, 'propPatch']); |
|
58 | - } |
|
59 | - |
|
60 | - public function afterGet(RequestInterface $request, ResponseInterface $response) { |
|
61 | - $path = $request->getPath(); |
|
62 | - if (!str_starts_with($path, 'versions')) { |
|
63 | - return; |
|
64 | - } |
|
65 | - |
|
66 | - try { |
|
67 | - $node = $this->server->tree->getNodeForPath($path); |
|
68 | - } catch (NotFound $e) { |
|
69 | - return; |
|
70 | - } |
|
71 | - |
|
72 | - if (!($node instanceof VersionFile)) { |
|
73 | - return; |
|
74 | - } |
|
75 | - |
|
76 | - $filename = $node->getVersion()->getSourceFileName(); |
|
77 | - |
|
78 | - if ($this->request->isUserAgent( |
|
79 | - [ |
|
80 | - Request::USER_AGENT_IE, |
|
81 | - Request::USER_AGENT_ANDROID_MOBILE_CHROME, |
|
82 | - Request::USER_AGENT_FREEBOX, |
|
83 | - ])) { |
|
84 | - $response->addHeader('Content-Disposition', 'attachment; filename="' . rawurlencode($filename) . '"'); |
|
85 | - } else { |
|
86 | - $response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\'' . rawurlencode($filename) |
|
87 | - . '; filename="' . rawurlencode($filename) . '"'); |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - public function propFind(PropFind $propFind, INode $node): void { |
|
92 | - if ($node instanceof VersionFile) { |
|
93 | - $propFind->handle(self::VERSION_LABEL, fn() => $node->getLabel()); |
|
94 | - } |
|
95 | - } |
|
96 | - |
|
97 | - public function propPatch($path, PropPatch $propPatch): void { |
|
98 | - $node = $this->server->tree->getNodeForPath($path); |
|
99 | - |
|
100 | - if ($node instanceof VersionFile) { |
|
101 | - $propPatch->handle(self::VERSION_LABEL, fn ($label) => $node->setLabel($label)); |
|
102 | - } |
|
103 | - } |
|
41 | + private Server $server; |
|
42 | + private IRequest $request; |
|
43 | + |
|
44 | + public const VERSION_LABEL = '{http://nextcloud.org/ns}version-label'; |
|
45 | + |
|
46 | + public function __construct( |
|
47 | + IRequest $request |
|
48 | + ) { |
|
49 | + $this->request = $request; |
|
50 | + } |
|
51 | + |
|
52 | + public function initialize(Server $server) { |
|
53 | + $this->server = $server; |
|
54 | + |
|
55 | + $server->on('afterMethod:GET', [$this, 'afterGet']); |
|
56 | + $server->on('propFind', [$this, 'propFind']); |
|
57 | + $server->on('propPatch', [$this, 'propPatch']); |
|
58 | + } |
|
59 | + |
|
60 | + public function afterGet(RequestInterface $request, ResponseInterface $response) { |
|
61 | + $path = $request->getPath(); |
|
62 | + if (!str_starts_with($path, 'versions')) { |
|
63 | + return; |
|
64 | + } |
|
65 | + |
|
66 | + try { |
|
67 | + $node = $this->server->tree->getNodeForPath($path); |
|
68 | + } catch (NotFound $e) { |
|
69 | + return; |
|
70 | + } |
|
71 | + |
|
72 | + if (!($node instanceof VersionFile)) { |
|
73 | + return; |
|
74 | + } |
|
75 | + |
|
76 | + $filename = $node->getVersion()->getSourceFileName(); |
|
77 | + |
|
78 | + if ($this->request->isUserAgent( |
|
79 | + [ |
|
80 | + Request::USER_AGENT_IE, |
|
81 | + Request::USER_AGENT_ANDROID_MOBILE_CHROME, |
|
82 | + Request::USER_AGENT_FREEBOX, |
|
83 | + ])) { |
|
84 | + $response->addHeader('Content-Disposition', 'attachment; filename="' . rawurlencode($filename) . '"'); |
|
85 | + } else { |
|
86 | + $response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\'' . rawurlencode($filename) |
|
87 | + . '; filename="' . rawurlencode($filename) . '"'); |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + public function propFind(PropFind $propFind, INode $node): void { |
|
92 | + if ($node instanceof VersionFile) { |
|
93 | + $propFind->handle(self::VERSION_LABEL, fn() => $node->getLabel()); |
|
94 | + } |
|
95 | + } |
|
96 | + |
|
97 | + public function propPatch($path, PropPatch $propPatch): void { |
|
98 | + $node = $this->server->tree->getNodeForPath($path); |
|
99 | + |
|
100 | + if ($node instanceof VersionFile) { |
|
101 | + $propPatch->handle(self::VERSION_LABEL, fn ($label) => $node->setLabel($label)); |
|
102 | + } |
|
103 | + } |
|
104 | 104 | } |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | $codes = $this->mapper->getBackupCodes($user); |
106 | 106 | $total = count($codes); |
107 | 107 | $used = 0; |
108 | - array_walk($codes, function (BackupCode $code) use (&$used) { |
|
109 | - if (1 === (int)$code->getUsed()) { |
|
108 | + array_walk($codes, function(BackupCode $code) use (&$used) { |
|
109 | + if (1 === (int) $code->getUsed()) { |
|
110 | 110 | $used++; |
111 | 111 | } |
112 | 112 | }); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $dbCodes = $this->mapper->getBackupCodes($user); |
127 | 127 | |
128 | 128 | foreach ($dbCodes as $dbCode) { |
129 | - if (0 === (int)$dbCode->getUsed() && $this->hasher->verify($code, $dbCode->getCode())) { |
|
129 | + if (0 === (int) $dbCode->getUsed() && $this->hasher->verify($code, $dbCode->getCode())) { |
|
130 | 130 | $dbCode->setUsed(1); |
131 | 131 | $this->mapper->update($dbCode); |
132 | 132 | return true; |
@@ -37,107 +37,107 @@ |
||
37 | 37 | use OCP\Security\ISecureRandom; |
38 | 38 | |
39 | 39 | class BackupCodeStorage { |
40 | - private static $CODE_LENGTH = 16; |
|
41 | - |
|
42 | - /** @var BackupCodeMapper */ |
|
43 | - private $mapper; |
|
44 | - |
|
45 | - /** @var IHasher */ |
|
46 | - private $hasher; |
|
47 | - |
|
48 | - /** @var ISecureRandom */ |
|
49 | - private $random; |
|
50 | - |
|
51 | - /** @var IEventDispatcher */ |
|
52 | - private $eventDispatcher; |
|
53 | - |
|
54 | - public function __construct(BackupCodeMapper $mapper, |
|
55 | - ISecureRandom $random, |
|
56 | - IHasher $hasher, |
|
57 | - IEventDispatcher $eventDispatcher) { |
|
58 | - $this->mapper = $mapper; |
|
59 | - $this->hasher = $hasher; |
|
60 | - $this->random = $random; |
|
61 | - $this->eventDispatcher = $eventDispatcher; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * @param IUser $user |
|
66 | - * @param int $number |
|
67 | - * @return string[] |
|
68 | - */ |
|
69 | - public function createCodes(IUser $user, int $number = 10): array { |
|
70 | - $result = []; |
|
71 | - |
|
72 | - // Delete existing ones |
|
73 | - $this->mapper->deleteCodes($user); |
|
74 | - |
|
75 | - $uid = $user->getUID(); |
|
76 | - foreach (range(1, min([$number, 20])) as $i) { |
|
77 | - $code = $this->random->generate(self::$CODE_LENGTH, ISecureRandom::CHAR_HUMAN_READABLE); |
|
78 | - |
|
79 | - $dbCode = new BackupCode(); |
|
80 | - $dbCode->setUserId($uid); |
|
81 | - $dbCode->setCode($this->hasher->hash($code)); |
|
82 | - $dbCode->setUsed(0); |
|
83 | - $this->mapper->insert($dbCode); |
|
84 | - |
|
85 | - $result[] = $code; |
|
86 | - } |
|
87 | - |
|
88 | - $this->eventDispatcher->dispatchTyped(new CodesGenerated($user)); |
|
89 | - |
|
90 | - return $result; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param IUser $user |
|
95 | - * @return bool |
|
96 | - */ |
|
97 | - public function hasBackupCodes(IUser $user): bool { |
|
98 | - $codes = $this->mapper->getBackupCodes($user); |
|
99 | - return count($codes) > 0; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @param IUser $user |
|
104 | - * @return array |
|
105 | - */ |
|
106 | - public function getBackupCodesState(IUser $user): array { |
|
107 | - $codes = $this->mapper->getBackupCodes($user); |
|
108 | - $total = count($codes); |
|
109 | - $used = 0; |
|
110 | - array_walk($codes, function (BackupCode $code) use (&$used) { |
|
111 | - if (1 === (int)$code->getUsed()) { |
|
112 | - $used++; |
|
113 | - } |
|
114 | - }); |
|
115 | - return [ |
|
116 | - 'enabled' => $total > 0, |
|
117 | - 'total' => $total, |
|
118 | - 'used' => $used, |
|
119 | - ]; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @param IUser $user |
|
124 | - * @param string $code |
|
125 | - * @return bool |
|
126 | - */ |
|
127 | - public function validateCode(IUser $user, string $code): bool { |
|
128 | - $dbCodes = $this->mapper->getBackupCodes($user); |
|
129 | - |
|
130 | - foreach ($dbCodes as $dbCode) { |
|
131 | - if (0 === (int)$dbCode->getUsed() && $this->hasher->verify($code, $dbCode->getCode())) { |
|
132 | - $dbCode->setUsed(1); |
|
133 | - $this->mapper->update($dbCode); |
|
134 | - return true; |
|
135 | - } |
|
136 | - } |
|
137 | - return false; |
|
138 | - } |
|
139 | - |
|
140 | - public function deleteCodes(IUser $user): void { |
|
141 | - $this->mapper->deleteCodes($user); |
|
142 | - } |
|
40 | + private static $CODE_LENGTH = 16; |
|
41 | + |
|
42 | + /** @var BackupCodeMapper */ |
|
43 | + private $mapper; |
|
44 | + |
|
45 | + /** @var IHasher */ |
|
46 | + private $hasher; |
|
47 | + |
|
48 | + /** @var ISecureRandom */ |
|
49 | + private $random; |
|
50 | + |
|
51 | + /** @var IEventDispatcher */ |
|
52 | + private $eventDispatcher; |
|
53 | + |
|
54 | + public function __construct(BackupCodeMapper $mapper, |
|
55 | + ISecureRandom $random, |
|
56 | + IHasher $hasher, |
|
57 | + IEventDispatcher $eventDispatcher) { |
|
58 | + $this->mapper = $mapper; |
|
59 | + $this->hasher = $hasher; |
|
60 | + $this->random = $random; |
|
61 | + $this->eventDispatcher = $eventDispatcher; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * @param IUser $user |
|
66 | + * @param int $number |
|
67 | + * @return string[] |
|
68 | + */ |
|
69 | + public function createCodes(IUser $user, int $number = 10): array { |
|
70 | + $result = []; |
|
71 | + |
|
72 | + // Delete existing ones |
|
73 | + $this->mapper->deleteCodes($user); |
|
74 | + |
|
75 | + $uid = $user->getUID(); |
|
76 | + foreach (range(1, min([$number, 20])) as $i) { |
|
77 | + $code = $this->random->generate(self::$CODE_LENGTH, ISecureRandom::CHAR_HUMAN_READABLE); |
|
78 | + |
|
79 | + $dbCode = new BackupCode(); |
|
80 | + $dbCode->setUserId($uid); |
|
81 | + $dbCode->setCode($this->hasher->hash($code)); |
|
82 | + $dbCode->setUsed(0); |
|
83 | + $this->mapper->insert($dbCode); |
|
84 | + |
|
85 | + $result[] = $code; |
|
86 | + } |
|
87 | + |
|
88 | + $this->eventDispatcher->dispatchTyped(new CodesGenerated($user)); |
|
89 | + |
|
90 | + return $result; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param IUser $user |
|
95 | + * @return bool |
|
96 | + */ |
|
97 | + public function hasBackupCodes(IUser $user): bool { |
|
98 | + $codes = $this->mapper->getBackupCodes($user); |
|
99 | + return count($codes) > 0; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @param IUser $user |
|
104 | + * @return array |
|
105 | + */ |
|
106 | + public function getBackupCodesState(IUser $user): array { |
|
107 | + $codes = $this->mapper->getBackupCodes($user); |
|
108 | + $total = count($codes); |
|
109 | + $used = 0; |
|
110 | + array_walk($codes, function (BackupCode $code) use (&$used) { |
|
111 | + if (1 === (int)$code->getUsed()) { |
|
112 | + $used++; |
|
113 | + } |
|
114 | + }); |
|
115 | + return [ |
|
116 | + 'enabled' => $total > 0, |
|
117 | + 'total' => $total, |
|
118 | + 'used' => $used, |
|
119 | + ]; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * @param IUser $user |
|
124 | + * @param string $code |
|
125 | + * @return bool |
|
126 | + */ |
|
127 | + public function validateCode(IUser $user, string $code): bool { |
|
128 | + $dbCodes = $this->mapper->getBackupCodes($user); |
|
129 | + |
|
130 | + foreach ($dbCodes as $dbCode) { |
|
131 | + if (0 === (int)$dbCode->getUsed() && $this->hasher->verify($code, $dbCode->getCode())) { |
|
132 | + $dbCode->setUsed(1); |
|
133 | + $this->mapper->update($dbCode); |
|
134 | + return true; |
|
135 | + } |
|
136 | + } |
|
137 | + return false; |
|
138 | + } |
|
139 | + |
|
140 | + public function deleteCodes(IUser $user): void { |
|
141 | + $this->mapper->deleteCodes($user); |
|
142 | + } |
|
143 | 143 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | //Current time |
66 | 66 | $minTime = $this->time->getDateTime(); |
67 | 67 | $minTime->add(new \DateInterval('P1D')); |
68 | - $minTime->setTime(0,0,0); |
|
68 | + $minTime->setTime(0, 0, 0); |
|
69 | 69 | |
70 | 70 | $maxTime = clone $minTime; |
71 | 71 | $maxTime->setTime(23, 59, 59); |
@@ -36,64 +36,64 @@ |
||
36 | 36 | use Symfony\Component\Console\Output\OutputInterface; |
37 | 37 | |
38 | 38 | class ExiprationNotification extends Command { |
39 | - /** @var NotificationManager */ |
|
40 | - private $notificationManager; |
|
41 | - /** @var IDBConnection */ |
|
42 | - private $connection; |
|
43 | - /** @var ITimeFactory */ |
|
44 | - private $time; |
|
45 | - /** @var ShareManager */ |
|
46 | - private $shareManager; |
|
39 | + /** @var NotificationManager */ |
|
40 | + private $notificationManager; |
|
41 | + /** @var IDBConnection */ |
|
42 | + private $connection; |
|
43 | + /** @var ITimeFactory */ |
|
44 | + private $time; |
|
45 | + /** @var ShareManager */ |
|
46 | + private $shareManager; |
|
47 | 47 | |
48 | - public function __construct(ITimeFactory $time, |
|
49 | - NotificationManager $notificationManager, |
|
50 | - IDBConnection $connection, |
|
51 | - ShareManager $shareManager) { |
|
52 | - parent::__construct(); |
|
48 | + public function __construct(ITimeFactory $time, |
|
49 | + NotificationManager $notificationManager, |
|
50 | + IDBConnection $connection, |
|
51 | + ShareManager $shareManager) { |
|
52 | + parent::__construct(); |
|
53 | 53 | |
54 | - $this->notificationManager = $notificationManager; |
|
55 | - $this->connection = $connection; |
|
56 | - $this->time = $time; |
|
57 | - $this->shareManager = $shareManager; |
|
58 | - } |
|
54 | + $this->notificationManager = $notificationManager; |
|
55 | + $this->connection = $connection; |
|
56 | + $this->time = $time; |
|
57 | + $this->shareManager = $shareManager; |
|
58 | + } |
|
59 | 59 | |
60 | - protected function configure() { |
|
61 | - $this |
|
62 | - ->setName('sharing:expiration-notification') |
|
63 | - ->setDescription('Notify share initiators when a share will expire the next day.'); |
|
64 | - } |
|
60 | + protected function configure() { |
|
61 | + $this |
|
62 | + ->setName('sharing:expiration-notification') |
|
63 | + ->setDescription('Notify share initiators when a share will expire the next day.'); |
|
64 | + } |
|
65 | 65 | |
66 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
67 | - //Current time |
|
68 | - $minTime = $this->time->getDateTime(); |
|
69 | - $minTime->add(new \DateInterval('P1D')); |
|
70 | - $minTime->setTime(0,0,0); |
|
66 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
67 | + //Current time |
|
68 | + $minTime = $this->time->getDateTime(); |
|
69 | + $minTime->add(new \DateInterval('P1D')); |
|
70 | + $minTime->setTime(0,0,0); |
|
71 | 71 | |
72 | - $maxTime = clone $minTime; |
|
73 | - $maxTime->setTime(23, 59, 59); |
|
72 | + $maxTime = clone $minTime; |
|
73 | + $maxTime->setTime(23, 59, 59); |
|
74 | 74 | |
75 | - $shares = $this->shareManager->getAllShares(); |
|
75 | + $shares = $this->shareManager->getAllShares(); |
|
76 | 76 | |
77 | - $now = $this->time->getDateTime(); |
|
77 | + $now = $this->time->getDateTime(); |
|
78 | 78 | |
79 | - /** @var IShare $share */ |
|
80 | - foreach ($shares as $share) { |
|
81 | - if ($share->getExpirationDate() === null |
|
82 | - || $share->getExpirationDate()->getTimestamp() < $minTime->getTimestamp() |
|
83 | - || $share->getExpirationDate()->getTimestamp() > $maxTime->getTimestamp()) { |
|
84 | - continue; |
|
85 | - } |
|
79 | + /** @var IShare $share */ |
|
80 | + foreach ($shares as $share) { |
|
81 | + if ($share->getExpirationDate() === null |
|
82 | + || $share->getExpirationDate()->getTimestamp() < $minTime->getTimestamp() |
|
83 | + || $share->getExpirationDate()->getTimestamp() > $maxTime->getTimestamp()) { |
|
84 | + continue; |
|
85 | + } |
|
86 | 86 | |
87 | - $notification = $this->notificationManager->createNotification(); |
|
88 | - $notification->setApp('files_sharing') |
|
89 | - ->setDateTime($now) |
|
90 | - ->setObject('share', $share->getFullId()) |
|
91 | - ->setSubject('expiresTomorrow'); |
|
87 | + $notification = $this->notificationManager->createNotification(); |
|
88 | + $notification->setApp('files_sharing') |
|
89 | + ->setDateTime($now) |
|
90 | + ->setObject('share', $share->getFullId()) |
|
91 | + ->setSubject('expiresTomorrow'); |
|
92 | 92 | |
93 | - // Only send to initiator for now |
|
94 | - $notification->setUser($share->getSharedBy()); |
|
95 | - $this->notificationManager->notify($notification); |
|
96 | - } |
|
97 | - return 0; |
|
98 | - } |
|
93 | + // Only send to initiator for now |
|
94 | + $notification->setUser($share->getSharedBy()); |
|
95 | + $this->notificationManager->notify($notification); |
|
96 | + } |
|
97 | + return 0; |
|
98 | + } |
|
99 | 99 | } |
@@ -25,164 +25,164 @@ |
||
25 | 25 | use OCP\IUser; |
26 | 26 | |
27 | 27 | class TrashItem implements ITrashItem { |
28 | - /** @var ITrashBackend */ |
|
29 | - private $backend; |
|
30 | - /** @var string */ |
|
31 | - private $orignalLocation; |
|
32 | - /** @var int */ |
|
33 | - private $deletedTime; |
|
34 | - /** @var string */ |
|
35 | - private $trashPath; |
|
36 | - /** @var FileInfo */ |
|
37 | - private $fileInfo; |
|
38 | - /** @var IUser */ |
|
39 | - private $user; |
|
40 | - |
|
41 | - public function __construct( |
|
42 | - ITrashBackend $backend, |
|
43 | - string $originalLocation, |
|
44 | - int $deletedTime, |
|
45 | - string $trashPath, |
|
46 | - FileInfo $fileInfo, |
|
47 | - IUser $user |
|
48 | - ) { |
|
49 | - $this->backend = $backend; |
|
50 | - $this->orignalLocation = $originalLocation; |
|
51 | - $this->deletedTime = $deletedTime; |
|
52 | - $this->trashPath = $trashPath; |
|
53 | - $this->fileInfo = $fileInfo; |
|
54 | - $this->user = $user; |
|
55 | - } |
|
56 | - |
|
57 | - public function getTrashBackend(): ITrashBackend { |
|
58 | - return $this->backend; |
|
59 | - } |
|
60 | - |
|
61 | - public function getOriginalLocation(): string { |
|
62 | - return $this->orignalLocation; |
|
63 | - } |
|
64 | - |
|
65 | - public function getDeletedTime(): int { |
|
66 | - return $this->deletedTime; |
|
67 | - } |
|
68 | - |
|
69 | - public function getTrashPath(): string { |
|
70 | - return $this->trashPath; |
|
71 | - } |
|
72 | - |
|
73 | - public function isRootItem(): bool { |
|
74 | - return substr_count($this->getTrashPath(), '/') === 1; |
|
75 | - } |
|
76 | - |
|
77 | - public function getUser(): IUser { |
|
78 | - return $this->user; |
|
79 | - } |
|
80 | - |
|
81 | - public function getEtag() { |
|
82 | - return $this->fileInfo->getEtag(); |
|
83 | - } |
|
84 | - |
|
85 | - public function getSize($includeMounts = true) { |
|
86 | - return $this->fileInfo->getSize($includeMounts); |
|
87 | - } |
|
88 | - |
|
89 | - public function getMtime() { |
|
90 | - return $this->fileInfo->getMtime(); |
|
91 | - } |
|
92 | - |
|
93 | - public function getName() { |
|
94 | - return $this->fileInfo->getName(); |
|
95 | - } |
|
96 | - |
|
97 | - public function getInternalPath() { |
|
98 | - return $this->fileInfo->getInternalPath(); |
|
99 | - } |
|
100 | - |
|
101 | - public function getPath() { |
|
102 | - return $this->fileInfo->getPath(); |
|
103 | - } |
|
104 | - |
|
105 | - public function getMimetype() { |
|
106 | - return $this->fileInfo->getMimetype(); |
|
107 | - } |
|
108 | - |
|
109 | - public function getMimePart() { |
|
110 | - return $this->fileInfo->getMimePart(); |
|
111 | - } |
|
112 | - |
|
113 | - public function getStorage() { |
|
114 | - return $this->fileInfo->getStorage(); |
|
115 | - } |
|
116 | - |
|
117 | - public function getId() { |
|
118 | - return $this->fileInfo->getId(); |
|
119 | - } |
|
120 | - |
|
121 | - public function isEncrypted() { |
|
122 | - return $this->fileInfo->isEncrypted(); |
|
123 | - } |
|
124 | - |
|
125 | - public function getPermissions() { |
|
126 | - return $this->fileInfo->getPermissions(); |
|
127 | - } |
|
128 | - |
|
129 | - public function getType() { |
|
130 | - return $this->fileInfo->getType(); |
|
131 | - } |
|
132 | - |
|
133 | - public function isReadable() { |
|
134 | - return $this->fileInfo->isReadable(); |
|
135 | - } |
|
136 | - |
|
137 | - public function isUpdateable() { |
|
138 | - return $this->fileInfo->isUpdateable(); |
|
139 | - } |
|
140 | - |
|
141 | - public function isCreatable() { |
|
142 | - return $this->fileInfo->isCreatable(); |
|
143 | - } |
|
144 | - |
|
145 | - public function isDeletable() { |
|
146 | - return $this->fileInfo->isDeletable(); |
|
147 | - } |
|
148 | - |
|
149 | - public function isShareable() { |
|
150 | - return $this->fileInfo->isShareable(); |
|
151 | - } |
|
152 | - |
|
153 | - public function isShared() { |
|
154 | - return $this->fileInfo->isShared(); |
|
155 | - } |
|
28 | + /** @var ITrashBackend */ |
|
29 | + private $backend; |
|
30 | + /** @var string */ |
|
31 | + private $orignalLocation; |
|
32 | + /** @var int */ |
|
33 | + private $deletedTime; |
|
34 | + /** @var string */ |
|
35 | + private $trashPath; |
|
36 | + /** @var FileInfo */ |
|
37 | + private $fileInfo; |
|
38 | + /** @var IUser */ |
|
39 | + private $user; |
|
40 | + |
|
41 | + public function __construct( |
|
42 | + ITrashBackend $backend, |
|
43 | + string $originalLocation, |
|
44 | + int $deletedTime, |
|
45 | + string $trashPath, |
|
46 | + FileInfo $fileInfo, |
|
47 | + IUser $user |
|
48 | + ) { |
|
49 | + $this->backend = $backend; |
|
50 | + $this->orignalLocation = $originalLocation; |
|
51 | + $this->deletedTime = $deletedTime; |
|
52 | + $this->trashPath = $trashPath; |
|
53 | + $this->fileInfo = $fileInfo; |
|
54 | + $this->user = $user; |
|
55 | + } |
|
56 | + |
|
57 | + public function getTrashBackend(): ITrashBackend { |
|
58 | + return $this->backend; |
|
59 | + } |
|
60 | + |
|
61 | + public function getOriginalLocation(): string { |
|
62 | + return $this->orignalLocation; |
|
63 | + } |
|
64 | + |
|
65 | + public function getDeletedTime(): int { |
|
66 | + return $this->deletedTime; |
|
67 | + } |
|
68 | + |
|
69 | + public function getTrashPath(): string { |
|
70 | + return $this->trashPath; |
|
71 | + } |
|
72 | + |
|
73 | + public function isRootItem(): bool { |
|
74 | + return substr_count($this->getTrashPath(), '/') === 1; |
|
75 | + } |
|
76 | + |
|
77 | + public function getUser(): IUser { |
|
78 | + return $this->user; |
|
79 | + } |
|
80 | + |
|
81 | + public function getEtag() { |
|
82 | + return $this->fileInfo->getEtag(); |
|
83 | + } |
|
84 | + |
|
85 | + public function getSize($includeMounts = true) { |
|
86 | + return $this->fileInfo->getSize($includeMounts); |
|
87 | + } |
|
88 | + |
|
89 | + public function getMtime() { |
|
90 | + return $this->fileInfo->getMtime(); |
|
91 | + } |
|
92 | + |
|
93 | + public function getName() { |
|
94 | + return $this->fileInfo->getName(); |
|
95 | + } |
|
96 | + |
|
97 | + public function getInternalPath() { |
|
98 | + return $this->fileInfo->getInternalPath(); |
|
99 | + } |
|
100 | + |
|
101 | + public function getPath() { |
|
102 | + return $this->fileInfo->getPath(); |
|
103 | + } |
|
104 | + |
|
105 | + public function getMimetype() { |
|
106 | + return $this->fileInfo->getMimetype(); |
|
107 | + } |
|
108 | + |
|
109 | + public function getMimePart() { |
|
110 | + return $this->fileInfo->getMimePart(); |
|
111 | + } |
|
112 | + |
|
113 | + public function getStorage() { |
|
114 | + return $this->fileInfo->getStorage(); |
|
115 | + } |
|
116 | + |
|
117 | + public function getId() { |
|
118 | + return $this->fileInfo->getId(); |
|
119 | + } |
|
120 | + |
|
121 | + public function isEncrypted() { |
|
122 | + return $this->fileInfo->isEncrypted(); |
|
123 | + } |
|
124 | + |
|
125 | + public function getPermissions() { |
|
126 | + return $this->fileInfo->getPermissions(); |
|
127 | + } |
|
128 | + |
|
129 | + public function getType() { |
|
130 | + return $this->fileInfo->getType(); |
|
131 | + } |
|
132 | + |
|
133 | + public function isReadable() { |
|
134 | + return $this->fileInfo->isReadable(); |
|
135 | + } |
|
136 | + |
|
137 | + public function isUpdateable() { |
|
138 | + return $this->fileInfo->isUpdateable(); |
|
139 | + } |
|
140 | + |
|
141 | + public function isCreatable() { |
|
142 | + return $this->fileInfo->isCreatable(); |
|
143 | + } |
|
144 | + |
|
145 | + public function isDeletable() { |
|
146 | + return $this->fileInfo->isDeletable(); |
|
147 | + } |
|
148 | + |
|
149 | + public function isShareable() { |
|
150 | + return $this->fileInfo->isShareable(); |
|
151 | + } |
|
152 | + |
|
153 | + public function isShared() { |
|
154 | + return $this->fileInfo->isShared(); |
|
155 | + } |
|
156 | 156 | |
157 | - public function isMounted() { |
|
158 | - return $this->fileInfo->isMounted(); |
|
159 | - } |
|
157 | + public function isMounted() { |
|
158 | + return $this->fileInfo->isMounted(); |
|
159 | + } |
|
160 | 160 | |
161 | - public function getMountPoint() { |
|
162 | - return $this->fileInfo->getMountPoint(); |
|
163 | - } |
|
161 | + public function getMountPoint() { |
|
162 | + return $this->fileInfo->getMountPoint(); |
|
163 | + } |
|
164 | 164 | |
165 | - public function getOwner() { |
|
166 | - return $this->fileInfo->getOwner(); |
|
167 | - } |
|
165 | + public function getOwner() { |
|
166 | + return $this->fileInfo->getOwner(); |
|
167 | + } |
|
168 | 168 | |
169 | - public function getChecksum() { |
|
170 | - return $this->fileInfo->getChecksum(); |
|
171 | - } |
|
169 | + public function getChecksum() { |
|
170 | + return $this->fileInfo->getChecksum(); |
|
171 | + } |
|
172 | 172 | |
173 | - public function getExtension(): string { |
|
174 | - return $this->fileInfo->getExtension(); |
|
175 | - } |
|
173 | + public function getExtension(): string { |
|
174 | + return $this->fileInfo->getExtension(); |
|
175 | + } |
|
176 | 176 | |
177 | - public function getTitle(): string { |
|
178 | - return $this->getOriginalLocation(); |
|
179 | - } |
|
177 | + public function getTitle(): string { |
|
178 | + return $this->getOriginalLocation(); |
|
179 | + } |
|
180 | 180 | |
181 | - public function getCreationTime(): int { |
|
182 | - return $this->fileInfo->getCreationTime(); |
|
183 | - } |
|
181 | + public function getCreationTime(): int { |
|
182 | + return $this->fileInfo->getCreationTime(); |
|
183 | + } |
|
184 | 184 | |
185 | - public function getUploadTime(): int { |
|
186 | - return $this->fileInfo->getUploadTime(); |
|
187 | - } |
|
185 | + public function getUploadTime(): int { |
|
186 | + return $this->fileInfo->getUploadTime(); |
|
187 | + } |
|
188 | 188 | } |
@@ -33,47 +33,47 @@ |
||
33 | 33 | |
34 | 34 | class SetAcceptedStatus implements IRepairStep { |
35 | 35 | |
36 | - /** @var IDBConnection */ |
|
37 | - private $connection; |
|
36 | + /** @var IDBConnection */ |
|
37 | + private $connection; |
|
38 | 38 | |
39 | - /** @var IConfig */ |
|
40 | - private $config; |
|
39 | + /** @var IConfig */ |
|
40 | + private $config; |
|
41 | 41 | |
42 | 42 | |
43 | - public function __construct(IDBConnection $connection, IConfig $config) { |
|
44 | - $this->connection = $connection; |
|
45 | - $this->config = $config; |
|
46 | - } |
|
43 | + public function __construct(IDBConnection $connection, IConfig $config) { |
|
44 | + $this->connection = $connection; |
|
45 | + $this->config = $config; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Returns the step's name |
|
50 | - * |
|
51 | - * @return string |
|
52 | - * @since 9.1.0 |
|
53 | - */ |
|
54 | - public function getName(): string { |
|
55 | - return 'Set existing shares as accepted'; |
|
56 | - } |
|
48 | + /** |
|
49 | + * Returns the step's name |
|
50 | + * |
|
51 | + * @return string |
|
52 | + * @since 9.1.0 |
|
53 | + */ |
|
54 | + public function getName(): string { |
|
55 | + return 'Set existing shares as accepted'; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @param IOutput $output |
|
60 | - */ |
|
61 | - public function run(IOutput $output): void { |
|
62 | - if (!$this->shouldRun()) { |
|
63 | - return; |
|
64 | - } |
|
58 | + /** |
|
59 | + * @param IOutput $output |
|
60 | + */ |
|
61 | + public function run(IOutput $output): void { |
|
62 | + if (!$this->shouldRun()) { |
|
63 | + return; |
|
64 | + } |
|
65 | 65 | |
66 | - $query = $this->connection->getQueryBuilder(); |
|
67 | - $query |
|
68 | - ->update('share') |
|
69 | - ->set('accepted', $query->createNamedParameter(IShare::STATUS_ACCEPTED)) |
|
70 | - ->where($query->expr()->in('share_type', $query->createNamedParameter([IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_USERGROUP], IQueryBuilder::PARAM_INT_ARRAY))); |
|
71 | - $query->execute(); |
|
72 | - } |
|
66 | + $query = $this->connection->getQueryBuilder(); |
|
67 | + $query |
|
68 | + ->update('share') |
|
69 | + ->set('accepted', $query->createNamedParameter(IShare::STATUS_ACCEPTED)) |
|
70 | + ->where($query->expr()->in('share_type', $query->createNamedParameter([IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_USERGROUP], IQueryBuilder::PARAM_INT_ARRAY))); |
|
71 | + $query->execute(); |
|
72 | + } |
|
73 | 73 | |
74 | - protected function shouldRun() { |
|
75 | - $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
76 | - return version_compare($appVersion, '1.10.1', '<'); |
|
77 | - } |
|
74 | + protected function shouldRun() { |
|
75 | + $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
76 | + return version_compare($appVersion, '1.10.1', '<'); |
|
77 | + } |
|
78 | 78 | |
79 | 79 | } |
@@ -29,21 +29,21 @@ |
||
29 | 29 | use OC\AppFramework\DependencyInjection\DIContainer; |
30 | 30 | |
31 | 31 | class RouteActionHandler { |
32 | - private $controllerName; |
|
33 | - private $actionName; |
|
34 | - private $container; |
|
32 | + private $controllerName; |
|
33 | + private $actionName; |
|
34 | + private $container; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param string $controllerName |
|
38 | - * @param string $actionName |
|
39 | - */ |
|
40 | - public function __construct(DIContainer $container, $controllerName, $actionName) { |
|
41 | - $this->controllerName = $controllerName; |
|
42 | - $this->actionName = $actionName; |
|
43 | - $this->container = $container; |
|
44 | - } |
|
36 | + /** |
|
37 | + * @param string $controllerName |
|
38 | + * @param string $actionName |
|
39 | + */ |
|
40 | + public function __construct(DIContainer $container, $controllerName, $actionName) { |
|
41 | + $this->controllerName = $controllerName; |
|
42 | + $this->actionName = $actionName; |
|
43 | + $this->container = $container; |
|
44 | + } |
|
45 | 45 | |
46 | - public function __invoke($params) { |
|
47 | - App::main($this->controllerName, $this->actionName, $this->container, $params); |
|
48 | - } |
|
46 | + public function __invoke($params) { |
|
47 | + App::main($this->controllerName, $this->actionName, $this->container, $params); |
|
48 | + } |
|
49 | 49 | } |