@@ -36,15 +36,15 @@ |
||
36 | 36 | * @deprecated |
37 | 37 | */ |
38 | 38 | interface IOperationCompat { |
39 | - /** |
|
40 | - * Like onEvent, but used with events that are not based on |
|
41 | - * \OCP\EventDispatcher\Event. |
|
42 | - * |
|
43 | - * This method is introduced for compatibility reasons and will be removed |
|
44 | - * in 2023 again. |
|
45 | - * |
|
46 | - * @since 18.0.0 |
|
47 | - * @deprecated |
|
48 | - */ |
|
49 | - public function onEventCompat(string $eventName, $event, IRuleMatcher $ruleMatcher): void; |
|
39 | + /** |
|
40 | + * Like onEvent, but used with events that are not based on |
|
41 | + * \OCP\EventDispatcher\Event. |
|
42 | + * |
|
43 | + * This method is introduced for compatibility reasons and will be removed |
|
44 | + * in 2023 again. |
|
45 | + * |
|
46 | + * @since 18.0.0 |
|
47 | + * @deprecated |
|
48 | + */ |
|
49 | + public function onEventCompat(string $eventName, $event, IRuleMatcher $ruleMatcher): void; |
|
50 | 50 | } |
@@ -36,12 +36,12 @@ |
||
36 | 36 | * @deprecated |
37 | 37 | */ |
38 | 38 | interface IEntityCompat extends IEntity { |
39 | - /** |
|
40 | - * Like prepareRuleMatcherCompat, but works with events that are not based |
|
41 | - * on \OCP\EventDispatcher\Event. |
|
42 | - * |
|
43 | - * @since 18.0.0 |
|
44 | - * @deprecated |
|
45 | - */ |
|
46 | - public function prepareRuleMatcherCompat(IRuleMatcher $ruleMatcher, string $eventName, $event): void; |
|
39 | + /** |
|
40 | + * Like prepareRuleMatcherCompat, but works with events that are not based |
|
41 | + * on \OCP\EventDispatcher\Event. |
|
42 | + * |
|
43 | + * @since 18.0.0 |
|
44 | + * @deprecated |
|
45 | + */ |
|
46 | + public function prepareRuleMatcherCompat(IRuleMatcher $ruleMatcher, string $eventName, $event): void; |
|
47 | 47 | } |
@@ -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 | } |
@@ -232,7 +232,7 @@ |
||
232 | 232 | |
233 | 233 | $placeholders = $replacements = []; |
234 | 234 | foreach ($subjectParameters as $placeholder => $parameter) { |
235 | - $placeholders[] = '{' . $placeholder . '}'; |
|
235 | + $placeholders[] = '{'.$placeholder.'}'; |
|
236 | 236 | $replacements[] = $parameter['name']; |
237 | 237 | } |
238 | 238 |
@@ -43,217 +43,217 @@ |
||
43 | 43 | use OCP\Share\IShare; |
44 | 44 | |
45 | 45 | class Notifier implements INotifier { |
46 | - public const INCOMING_USER_SHARE = 'incoming_user_share'; |
|
47 | - public const INCOMING_GROUP_SHARE = 'incoming_group_share'; |
|
46 | + public const INCOMING_USER_SHARE = 'incoming_user_share'; |
|
47 | + public const INCOMING_GROUP_SHARE = 'incoming_group_share'; |
|
48 | 48 | |
49 | - /** @var IFactory */ |
|
50 | - protected $l10nFactory; |
|
51 | - /** @var IManager */ |
|
52 | - private $shareManager; |
|
53 | - /** @var IRootFolder */ |
|
54 | - private $rootFolder; |
|
55 | - /** @var IGroupManager */ |
|
56 | - protected $groupManager; |
|
57 | - /** @var IUserManager */ |
|
58 | - protected $userManager; |
|
59 | - /** @var IURLGenerator */ |
|
60 | - protected $url; |
|
49 | + /** @var IFactory */ |
|
50 | + protected $l10nFactory; |
|
51 | + /** @var IManager */ |
|
52 | + private $shareManager; |
|
53 | + /** @var IRootFolder */ |
|
54 | + private $rootFolder; |
|
55 | + /** @var IGroupManager */ |
|
56 | + protected $groupManager; |
|
57 | + /** @var IUserManager */ |
|
58 | + protected $userManager; |
|
59 | + /** @var IURLGenerator */ |
|
60 | + protected $url; |
|
61 | 61 | |
62 | - public function __construct(IFactory $l10nFactory, |
|
63 | - IManager $shareManager, |
|
64 | - IRootFolder $rootFolder, |
|
65 | - IGroupManager $groupManager, |
|
66 | - IUserManager $userManager, |
|
67 | - IURLGenerator $url) { |
|
68 | - $this->l10nFactory = $l10nFactory; |
|
69 | - $this->shareManager = $shareManager; |
|
70 | - $this->rootFolder = $rootFolder; |
|
71 | - $this->groupManager = $groupManager; |
|
72 | - $this->userManager = $userManager; |
|
73 | - $this->url = $url; |
|
74 | - } |
|
62 | + public function __construct(IFactory $l10nFactory, |
|
63 | + IManager $shareManager, |
|
64 | + IRootFolder $rootFolder, |
|
65 | + IGroupManager $groupManager, |
|
66 | + IUserManager $userManager, |
|
67 | + IURLGenerator $url) { |
|
68 | + $this->l10nFactory = $l10nFactory; |
|
69 | + $this->shareManager = $shareManager; |
|
70 | + $this->rootFolder = $rootFolder; |
|
71 | + $this->groupManager = $groupManager; |
|
72 | + $this->userManager = $userManager; |
|
73 | + $this->url = $url; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Identifier of the notifier, only use [a-z0-9_] |
|
78 | - * |
|
79 | - * @return string |
|
80 | - * @since 17.0.0 |
|
81 | - */ |
|
82 | - public function getID(): string { |
|
83 | - return 'files_sharing'; |
|
84 | - } |
|
76 | + /** |
|
77 | + * Identifier of the notifier, only use [a-z0-9_] |
|
78 | + * |
|
79 | + * @return string |
|
80 | + * @since 17.0.0 |
|
81 | + */ |
|
82 | + public function getID(): string { |
|
83 | + return 'files_sharing'; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Human readable name describing the notifier |
|
88 | - * |
|
89 | - * @return string |
|
90 | - * @since 17.0.0 |
|
91 | - */ |
|
92 | - public function getName(): string { |
|
93 | - return $this->l10nFactory->get('files_sharing')->t('File sharing'); |
|
94 | - } |
|
86 | + /** |
|
87 | + * Human readable name describing the notifier |
|
88 | + * |
|
89 | + * @return string |
|
90 | + * @since 17.0.0 |
|
91 | + */ |
|
92 | + public function getName(): string { |
|
93 | + return $this->l10nFactory->get('files_sharing')->t('File sharing'); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @param INotification $notification |
|
98 | - * @param string $languageCode The code of the language that should be used to prepare the notification |
|
99 | - * @return INotification |
|
100 | - * @throws \InvalidArgumentException When the notification was not prepared by a notifier |
|
101 | - * @throws AlreadyProcessedException When the notification is not needed anymore and should be deleted |
|
102 | - * @since 9.0.0 |
|
103 | - */ |
|
104 | - public function prepare(INotification $notification, string $languageCode): INotification { |
|
105 | - if ($notification->getApp() !== 'files_sharing' || |
|
106 | - ($notification->getSubject() !== 'expiresTomorrow' && |
|
107 | - $notification->getObjectType() !== 'share')) { |
|
108 | - throw new \InvalidArgumentException('Unhandled app or subject'); |
|
109 | - } |
|
96 | + /** |
|
97 | + * @param INotification $notification |
|
98 | + * @param string $languageCode The code of the language that should be used to prepare the notification |
|
99 | + * @return INotification |
|
100 | + * @throws \InvalidArgumentException When the notification was not prepared by a notifier |
|
101 | + * @throws AlreadyProcessedException When the notification is not needed anymore and should be deleted |
|
102 | + * @since 9.0.0 |
|
103 | + */ |
|
104 | + public function prepare(INotification $notification, string $languageCode): INotification { |
|
105 | + if ($notification->getApp() !== 'files_sharing' || |
|
106 | + ($notification->getSubject() !== 'expiresTomorrow' && |
|
107 | + $notification->getObjectType() !== 'share')) { |
|
108 | + throw new \InvalidArgumentException('Unhandled app or subject'); |
|
109 | + } |
|
110 | 110 | |
111 | - $l = $this->l10nFactory->get('files_sharing', $languageCode); |
|
112 | - $attemptId = $notification->getObjectId(); |
|
111 | + $l = $this->l10nFactory->get('files_sharing', $languageCode); |
|
112 | + $attemptId = $notification->getObjectId(); |
|
113 | 113 | |
114 | - try { |
|
115 | - $share = $this->shareManager->getShareById($attemptId, $notification->getUser()); |
|
116 | - } catch (ShareNotFound $e) { |
|
117 | - throw new AlreadyProcessedException(); |
|
118 | - } |
|
114 | + try { |
|
115 | + $share = $this->shareManager->getShareById($attemptId, $notification->getUser()); |
|
116 | + } catch (ShareNotFound $e) { |
|
117 | + throw new AlreadyProcessedException(); |
|
118 | + } |
|
119 | 119 | |
120 | - if ($notification->getSubject() === 'expiresTomorrow') { |
|
121 | - $notification = $this->parseShareExpiration($share, $notification, $l); |
|
122 | - } else { |
|
123 | - $notification = $this->parseShareInvitation($share, $notification, $l); |
|
124 | - } |
|
125 | - return $notification; |
|
126 | - } |
|
120 | + if ($notification->getSubject() === 'expiresTomorrow') { |
|
121 | + $notification = $this->parseShareExpiration($share, $notification, $l); |
|
122 | + } else { |
|
123 | + $notification = $this->parseShareInvitation($share, $notification, $l); |
|
124 | + } |
|
125 | + return $notification; |
|
126 | + } |
|
127 | 127 | |
128 | - protected function parseShareExpiration(IShare $share, INotification $notification, IL10N $l): INotification { |
|
129 | - $node = $share->getNode(); |
|
130 | - $userFolder = $this->rootFolder->getUserFolder($notification->getUser()); |
|
131 | - $path = $userFolder->getRelativePath($node->getPath()); |
|
128 | + protected function parseShareExpiration(IShare $share, INotification $notification, IL10N $l): INotification { |
|
129 | + $node = $share->getNode(); |
|
130 | + $userFolder = $this->rootFolder->getUserFolder($notification->getUser()); |
|
131 | + $path = $userFolder->getRelativePath($node->getPath()); |
|
132 | 132 | |
133 | - $notification |
|
134 | - ->setParsedSubject($l->t('Share will expire tomorrow')) |
|
135 | - ->setParsedMessage($l->t('One or more of your shares will expire tomorrow')) |
|
136 | - ->setRichMessage( |
|
137 | - $l->t('Your share of {node} will expire tomorrow'), |
|
138 | - [ |
|
139 | - 'node' => [ |
|
140 | - 'type' => 'file', |
|
141 | - 'id' => $node->getId(), |
|
142 | - 'name' => $node->getName(), |
|
143 | - 'path' => $path, |
|
144 | - ], |
|
145 | - ] |
|
146 | - ); |
|
133 | + $notification |
|
134 | + ->setParsedSubject($l->t('Share will expire tomorrow')) |
|
135 | + ->setParsedMessage($l->t('One or more of your shares will expire tomorrow')) |
|
136 | + ->setRichMessage( |
|
137 | + $l->t('Your share of {node} will expire tomorrow'), |
|
138 | + [ |
|
139 | + 'node' => [ |
|
140 | + 'type' => 'file', |
|
141 | + 'id' => $node->getId(), |
|
142 | + 'name' => $node->getName(), |
|
143 | + 'path' => $path, |
|
144 | + ], |
|
145 | + ] |
|
146 | + ); |
|
147 | 147 | |
148 | - return $notification; |
|
149 | - } |
|
148 | + return $notification; |
|
149 | + } |
|
150 | 150 | |
151 | - protected function parseShareInvitation(IShare $share, INotification $notification, IL10N $l): INotification { |
|
152 | - if ($share->getShareType() === IShare::TYPE_USER) { |
|
153 | - if ($share->getStatus() !== IShare::STATUS_PENDING) { |
|
154 | - throw new AlreadyProcessedException(); |
|
155 | - } |
|
156 | - } elseif ($share->getShareType() === IShare::TYPE_GROUP) { |
|
157 | - if ($share->getStatus() !== IShare::STATUS_PENDING) { |
|
158 | - throw new AlreadyProcessedException(); |
|
159 | - } |
|
160 | - } else { |
|
161 | - throw new \InvalidArgumentException('Invalid share type'); |
|
162 | - } |
|
151 | + protected function parseShareInvitation(IShare $share, INotification $notification, IL10N $l): INotification { |
|
152 | + if ($share->getShareType() === IShare::TYPE_USER) { |
|
153 | + if ($share->getStatus() !== IShare::STATUS_PENDING) { |
|
154 | + throw new AlreadyProcessedException(); |
|
155 | + } |
|
156 | + } elseif ($share->getShareType() === IShare::TYPE_GROUP) { |
|
157 | + if ($share->getStatus() !== IShare::STATUS_PENDING) { |
|
158 | + throw new AlreadyProcessedException(); |
|
159 | + } |
|
160 | + } else { |
|
161 | + throw new \InvalidArgumentException('Invalid share type'); |
|
162 | + } |
|
163 | 163 | |
164 | - switch ($notification->getSubject()) { |
|
165 | - case self::INCOMING_USER_SHARE: |
|
166 | - if ($share->getSharedWith() !== $notification->getUser()) { |
|
167 | - throw new AlreadyProcessedException(); |
|
168 | - } |
|
164 | + switch ($notification->getSubject()) { |
|
165 | + case self::INCOMING_USER_SHARE: |
|
166 | + if ($share->getSharedWith() !== $notification->getUser()) { |
|
167 | + throw new AlreadyProcessedException(); |
|
168 | + } |
|
169 | 169 | |
170 | - $sharer = $this->userManager->get($share->getSharedBy()); |
|
171 | - if (!$sharer instanceof IUser) { |
|
172 | - throw new \InvalidArgumentException('Temporary failure'); |
|
173 | - } |
|
170 | + $sharer = $this->userManager->get($share->getSharedBy()); |
|
171 | + if (!$sharer instanceof IUser) { |
|
172 | + throw new \InvalidArgumentException('Temporary failure'); |
|
173 | + } |
|
174 | 174 | |
175 | - $subject = $l->t('You received {share} as a share by {user}'); |
|
176 | - $subjectParameters = [ |
|
177 | - 'share' => [ |
|
178 | - 'type' => 'highlight', |
|
179 | - 'id' => $notification->getObjectId(), |
|
180 | - 'name' => $share->getTarget(), |
|
181 | - ], |
|
182 | - 'user' => [ |
|
183 | - 'type' => 'user', |
|
184 | - 'id' => $sharer->getUID(), |
|
185 | - 'name' => $sharer->getDisplayName(), |
|
186 | - ], |
|
187 | - ]; |
|
188 | - break; |
|
175 | + $subject = $l->t('You received {share} as a share by {user}'); |
|
176 | + $subjectParameters = [ |
|
177 | + 'share' => [ |
|
178 | + 'type' => 'highlight', |
|
179 | + 'id' => $notification->getObjectId(), |
|
180 | + 'name' => $share->getTarget(), |
|
181 | + ], |
|
182 | + 'user' => [ |
|
183 | + 'type' => 'user', |
|
184 | + 'id' => $sharer->getUID(), |
|
185 | + 'name' => $sharer->getDisplayName(), |
|
186 | + ], |
|
187 | + ]; |
|
188 | + break; |
|
189 | 189 | |
190 | - case self::INCOMING_GROUP_SHARE: |
|
191 | - $user = $this->userManager->get($notification->getUser()); |
|
192 | - if (!$user instanceof IUser) { |
|
193 | - throw new AlreadyProcessedException(); |
|
194 | - } |
|
190 | + case self::INCOMING_GROUP_SHARE: |
|
191 | + $user = $this->userManager->get($notification->getUser()); |
|
192 | + if (!$user instanceof IUser) { |
|
193 | + throw new AlreadyProcessedException(); |
|
194 | + } |
|
195 | 195 | |
196 | - $group = $this->groupManager->get($share->getSharedWith()); |
|
197 | - if ($group === null || !$group->inGroup($user)) { |
|
198 | - throw new AlreadyProcessedException(); |
|
199 | - } |
|
196 | + $group = $this->groupManager->get($share->getSharedWith()); |
|
197 | + if ($group === null || !$group->inGroup($user)) { |
|
198 | + throw new AlreadyProcessedException(); |
|
199 | + } |
|
200 | 200 | |
201 | - if ($share->getPermissions() === 0) { |
|
202 | - // Already rejected |
|
203 | - throw new AlreadyProcessedException(); |
|
204 | - } |
|
201 | + if ($share->getPermissions() === 0) { |
|
202 | + // Already rejected |
|
203 | + throw new AlreadyProcessedException(); |
|
204 | + } |
|
205 | 205 | |
206 | - $sharer = $this->userManager->get($share->getSharedBy()); |
|
207 | - if (!$sharer instanceof IUser) { |
|
208 | - throw new \InvalidArgumentException('Temporary failure'); |
|
209 | - } |
|
206 | + $sharer = $this->userManager->get($share->getSharedBy()); |
|
207 | + if (!$sharer instanceof IUser) { |
|
208 | + throw new \InvalidArgumentException('Temporary failure'); |
|
209 | + } |
|
210 | 210 | |
211 | - $subject = $l->t('You received {share} to group {group} as a share by {user}'); |
|
212 | - $subjectParameters = [ |
|
213 | - 'share' => [ |
|
214 | - 'type' => 'highlight', |
|
215 | - 'id' => $notification->getObjectId(), |
|
216 | - 'name' => $share->getTarget(), |
|
217 | - ], |
|
218 | - 'group' => [ |
|
219 | - 'type' => 'user-group', |
|
220 | - 'id' => $group->getGID(), |
|
221 | - 'name' => $group->getDisplayName(), |
|
222 | - ], |
|
223 | - 'user' => [ |
|
224 | - 'type' => 'user', |
|
225 | - 'id' => $sharer->getUID(), |
|
226 | - 'name' => $sharer->getDisplayName(), |
|
227 | - ], |
|
228 | - ]; |
|
229 | - break; |
|
211 | + $subject = $l->t('You received {share} to group {group} as a share by {user}'); |
|
212 | + $subjectParameters = [ |
|
213 | + 'share' => [ |
|
214 | + 'type' => 'highlight', |
|
215 | + 'id' => $notification->getObjectId(), |
|
216 | + 'name' => $share->getTarget(), |
|
217 | + ], |
|
218 | + 'group' => [ |
|
219 | + 'type' => 'user-group', |
|
220 | + 'id' => $group->getGID(), |
|
221 | + 'name' => $group->getDisplayName(), |
|
222 | + ], |
|
223 | + 'user' => [ |
|
224 | + 'type' => 'user', |
|
225 | + 'id' => $sharer->getUID(), |
|
226 | + 'name' => $sharer->getDisplayName(), |
|
227 | + ], |
|
228 | + ]; |
|
229 | + break; |
|
230 | 230 | |
231 | - default: |
|
232 | - throw new \InvalidArgumentException('Invalid subject'); |
|
233 | - } |
|
231 | + default: |
|
232 | + throw new \InvalidArgumentException('Invalid subject'); |
|
233 | + } |
|
234 | 234 | |
235 | - $placeholders = $replacements = []; |
|
236 | - foreach ($subjectParameters as $placeholder => $parameter) { |
|
237 | - $placeholders[] = '{' . $placeholder . '}'; |
|
238 | - $replacements[] = $parameter['name']; |
|
239 | - } |
|
235 | + $placeholders = $replacements = []; |
|
236 | + foreach ($subjectParameters as $placeholder => $parameter) { |
|
237 | + $placeholders[] = '{' . $placeholder . '}'; |
|
238 | + $replacements[] = $parameter['name']; |
|
239 | + } |
|
240 | 240 | |
241 | - $notification->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
242 | - ->setRichSubject($subject, $subjectParameters) |
|
243 | - ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
241 | + $notification->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
242 | + ->setRichSubject($subject, $subjectParameters) |
|
243 | + ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
244 | 244 | |
245 | - $acceptAction = $notification->createAction(); |
|
246 | - $acceptAction->setParsedLabel($l->t('Accept')) |
|
247 | - ->setLink($this->url->linkToOCSRouteAbsolute('files_sharing.ShareAPI.acceptShare', ['id' => $share->getId()]), 'POST') |
|
248 | - ->setPrimary(true); |
|
249 | - $notification->addParsedAction($acceptAction); |
|
245 | + $acceptAction = $notification->createAction(); |
|
246 | + $acceptAction->setParsedLabel($l->t('Accept')) |
|
247 | + ->setLink($this->url->linkToOCSRouteAbsolute('files_sharing.ShareAPI.acceptShare', ['id' => $share->getId()]), 'POST') |
|
248 | + ->setPrimary(true); |
|
249 | + $notification->addParsedAction($acceptAction); |
|
250 | 250 | |
251 | - $rejectAction = $notification->createAction(); |
|
252 | - $rejectAction->setParsedLabel($l->t('Reject')) |
|
253 | - ->setLink($this->url->linkToOCSRouteAbsolute('files_sharing.ShareAPI.deleteShare', ['id' => $share->getId()]), 'DELETE') |
|
254 | - ->setPrimary(false); |
|
255 | - $notification->addParsedAction($rejectAction); |
|
251 | + $rejectAction = $notification->createAction(); |
|
252 | + $rejectAction->setParsedLabel($l->t('Reject')) |
|
253 | + ->setLink($this->url->linkToOCSRouteAbsolute('files_sharing.ShareAPI.deleteShare', ['id' => $share->getId()]), 'DELETE') |
|
254 | + ->setPrimary(false); |
|
255 | + $notification->addParsedAction($rejectAction); |
|
256 | 256 | |
257 | - return $notification; |
|
258 | - } |
|
257 | + return $notification; |
|
258 | + } |
|
259 | 259 | } |
@@ -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 | } |
@@ -31,34 +31,34 @@ |
||
31 | 31 | */ |
32 | 32 | interface IMenuAction { |
33 | 33 | |
34 | - /** |
|
35 | - * @since 14.0.0 |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function getId(): string; |
|
34 | + /** |
|
35 | + * @since 14.0.0 |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function getId(): string; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @since 14.0.0 |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function getLabel(): string; |
|
40 | + /** |
|
41 | + * @since 14.0.0 |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function getLabel(): string; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @since 14.0.0 |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function getLink(): string; |
|
46 | + /** |
|
47 | + * @since 14.0.0 |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function getLink(): string; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @since 14.0.0 |
|
54 | - * @return int |
|
55 | - */ |
|
56 | - public function getPriority(): int; |
|
52 | + /** |
|
53 | + * @since 14.0.0 |
|
54 | + * @return int |
|
55 | + */ |
|
56 | + public function getPriority(): int; |
|
57 | 57 | |
58 | - /** |
|
59 | - * @since 14.0.0 |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function render(): string; |
|
58 | + /** |
|
59 | + * @since 14.0.0 |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function render(): string; |
|
63 | 63 | |
64 | 64 | } |
@@ -33,21 +33,21 @@ |
||
33 | 33 | class TimeFactory implements ITimeFactory { |
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @return int the result of a call to time() |
|
38 | - */ |
|
39 | - public function getTime(): int { |
|
40 | - return time(); |
|
41 | - } |
|
36 | + /** |
|
37 | + * @return int the result of a call to time() |
|
38 | + */ |
|
39 | + public function getTime(): int { |
|
40 | + return time(); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param string $time |
|
45 | - * @param \DateTimeZone $timezone |
|
46 | - * @return \DateTime |
|
47 | - * @since 15.0.0 |
|
48 | - */ |
|
49 | - public function getDateTime(string $time = 'now', \DateTimeZone $timezone = null): \DateTime { |
|
50 | - return new \DateTime($time, $timezone); |
|
51 | - } |
|
43 | + /** |
|
44 | + * @param string $time |
|
45 | + * @param \DateTimeZone $timezone |
|
46 | + * @return \DateTime |
|
47 | + * @since 15.0.0 |
|
48 | + */ |
|
49 | + public function getDateTime(string $time = 'now', \DateTimeZone $timezone = null): \DateTime { |
|
50 | + return new \DateTime($time, $timezone); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | } |
@@ -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 | } |
@@ -30,25 +30,25 @@ |
||
30 | 30 | |
31 | 31 | class PreLoginHookCommand extends ALoginCommand { |
32 | 32 | |
33 | - /** @var IUserManager */ |
|
34 | - private $userManager; |
|
35 | - |
|
36 | - public function __construct(IUserManager $userManager) { |
|
37 | - $this->userManager = $userManager; |
|
38 | - } |
|
39 | - |
|
40 | - public function process(LoginData $loginData): LoginResult { |
|
41 | - if ($this->userManager instanceof PublicEmitter) { |
|
42 | - $this->userManager->emit( |
|
43 | - '\OC\User', |
|
44 | - 'preLogin', |
|
45 | - [ |
|
46 | - $loginData->getUsername(), |
|
47 | - $loginData->getPassword(), |
|
48 | - ] |
|
49 | - ); |
|
50 | - } |
|
51 | - |
|
52 | - return $this->processNextOrFinishSuccessfully($loginData); |
|
53 | - } |
|
33 | + /** @var IUserManager */ |
|
34 | + private $userManager; |
|
35 | + |
|
36 | + public function __construct(IUserManager $userManager) { |
|
37 | + $this->userManager = $userManager; |
|
38 | + } |
|
39 | + |
|
40 | + public function process(LoginData $loginData): LoginResult { |
|
41 | + if ($this->userManager instanceof PublicEmitter) { |
|
42 | + $this->userManager->emit( |
|
43 | + '\OC\User', |
|
44 | + 'preLogin', |
|
45 | + [ |
|
46 | + $loginData->getUsername(), |
|
47 | + $loginData->getPassword(), |
|
48 | + ] |
|
49 | + ); |
|
50 | + } |
|
51 | + |
|
52 | + return $this->processNextOrFinishSuccessfully($loginData); |
|
53 | + } |
|
54 | 54 | } |