@@ -26,7 +26,7 @@ |
||
26 | 26 | |
27 | 27 | // Do we have some data to inject ? |
28 | 28 | if (is_array($_['serverData'])) { |
29 | - ?> |
|
29 | + ?> |
|
30 | 30 | <span id="serverData" data-server="<?php p(json_encode($_['serverData'])); ?>"></span> |
31 | 31 | <?php |
32 | 32 | } ?> |
@@ -31,15 +31,15 @@ |
||
31 | 31 | use OCP\Settings\ISettings; |
32 | 32 | |
33 | 33 | class PersonalSettings implements ISettings { |
34 | - public function getForm(): TemplateResponse { |
|
35 | - return new TemplateResponse(Application::APP_ID, 'settings-personal'); |
|
36 | - } |
|
34 | + public function getForm(): TemplateResponse { |
|
35 | + return new TemplateResponse(Application::APP_ID, 'settings-personal'); |
|
36 | + } |
|
37 | 37 | |
38 | - public function getSection(): string { |
|
39 | - return 'sharing'; |
|
40 | - } |
|
38 | + public function getSection(): string { |
|
39 | + return 'sharing'; |
|
40 | + } |
|
41 | 41 | |
42 | - public function getPriority(): int { |
|
43 | - return 90; |
|
44 | - } |
|
42 | + public function getPriority(): int { |
|
43 | + return 90; |
|
44 | + } |
|
45 | 45 | } |
@@ -37,100 +37,100 @@ |
||
37 | 37 | use OCP\IUser; |
38 | 38 | |
39 | 39 | class ResourceProvider implements IProvider { |
40 | - public const RESOURCE_TYPE = 'file'; |
|
41 | - |
|
42 | - /** @var IRootFolder */ |
|
43 | - protected $rootFolder; |
|
44 | - /** @var IPreview */ |
|
45 | - private $preview; |
|
46 | - /** @var IURLGenerator */ |
|
47 | - private $urlGenerator; |
|
48 | - |
|
49 | - /** @var array */ |
|
50 | - protected $nodes = []; |
|
51 | - |
|
52 | - public function __construct(IRootFolder $rootFolder, |
|
53 | - IPreview $preview, |
|
54 | - IURLGenerator $urlGenerator) { |
|
55 | - $this->rootFolder = $rootFolder; |
|
56 | - $this->preview = $preview; |
|
57 | - $this->urlGenerator = $urlGenerator; |
|
58 | - } |
|
59 | - |
|
60 | - private function getNode(IResource $resource): ?Node { |
|
61 | - if (isset($this->nodes[(int) $resource->getId()])) { |
|
62 | - return $this->nodes[(int) $resource->getId()]; |
|
63 | - } |
|
64 | - $nodes = $this->rootFolder->getById((int) $resource->getId()); |
|
65 | - if (!empty($nodes)) { |
|
66 | - $this->nodes[(int) $resource->getId()] = array_shift($nodes); |
|
67 | - return $this->nodes[(int) $resource->getId()]; |
|
68 | - } |
|
69 | - return null; |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * @param IResource $resource |
|
74 | - * @return array |
|
75 | - * @since 16.0.0 |
|
76 | - */ |
|
77 | - public function getResourceRichObject(IResource $resource): array { |
|
78 | - if (isset($this->nodes[(int) $resource->getId()])) { |
|
79 | - $node = $this->nodes[(int) $resource->getId()]->getPath(); |
|
80 | - } else { |
|
81 | - $node = $this->getNode($resource); |
|
82 | - } |
|
83 | - |
|
84 | - if ($node instanceof Node) { |
|
85 | - $link = $this->urlGenerator->linkToRouteAbsolute( |
|
86 | - 'files.viewcontroller.showFile', |
|
87 | - ['fileid' => $resource->getId()] |
|
88 | - ); |
|
89 | - return [ |
|
90 | - 'type' => 'file', |
|
91 | - 'id' => $resource->getId(), |
|
92 | - 'name' => $node->getName(), |
|
93 | - 'path' => $node->getInternalPath(), |
|
94 | - 'link' => $link, |
|
95 | - 'mimetype' => $node->getMimetype(), |
|
96 | - 'preview-available' => $this->preview->isAvailable($node), |
|
97 | - ]; |
|
98 | - } |
|
99 | - |
|
100 | - throw new ResourceException('File not found'); |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Can a user/guest access the collection |
|
105 | - * |
|
106 | - * @param IResource $resource |
|
107 | - * @param IUser $user |
|
108 | - * @return bool |
|
109 | - * @since 16.0.0 |
|
110 | - */ |
|
111 | - public function canAccessResource(IResource $resource, IUser $user = null): bool { |
|
112 | - if (!$user instanceof IUser) { |
|
113 | - return false; |
|
114 | - } |
|
115 | - |
|
116 | - $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
117 | - $nodes = $userFolder->getById((int) $resource->getId()); |
|
118 | - |
|
119 | - if (!empty($nodes)) { |
|
120 | - $this->nodes[(int) $resource->getId()] = array_shift($nodes); |
|
121 | - return true; |
|
122 | - } |
|
123 | - |
|
124 | - return false; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Get the resource type of the provider |
|
129 | - * |
|
130 | - * @return string |
|
131 | - * @since 16.0.0 |
|
132 | - */ |
|
133 | - public function getType(): string { |
|
134 | - return self::RESOURCE_TYPE; |
|
135 | - } |
|
40 | + public const RESOURCE_TYPE = 'file'; |
|
41 | + |
|
42 | + /** @var IRootFolder */ |
|
43 | + protected $rootFolder; |
|
44 | + /** @var IPreview */ |
|
45 | + private $preview; |
|
46 | + /** @var IURLGenerator */ |
|
47 | + private $urlGenerator; |
|
48 | + |
|
49 | + /** @var array */ |
|
50 | + protected $nodes = []; |
|
51 | + |
|
52 | + public function __construct(IRootFolder $rootFolder, |
|
53 | + IPreview $preview, |
|
54 | + IURLGenerator $urlGenerator) { |
|
55 | + $this->rootFolder = $rootFolder; |
|
56 | + $this->preview = $preview; |
|
57 | + $this->urlGenerator = $urlGenerator; |
|
58 | + } |
|
59 | + |
|
60 | + private function getNode(IResource $resource): ?Node { |
|
61 | + if (isset($this->nodes[(int) $resource->getId()])) { |
|
62 | + return $this->nodes[(int) $resource->getId()]; |
|
63 | + } |
|
64 | + $nodes = $this->rootFolder->getById((int) $resource->getId()); |
|
65 | + if (!empty($nodes)) { |
|
66 | + $this->nodes[(int) $resource->getId()] = array_shift($nodes); |
|
67 | + return $this->nodes[(int) $resource->getId()]; |
|
68 | + } |
|
69 | + return null; |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * @param IResource $resource |
|
74 | + * @return array |
|
75 | + * @since 16.0.0 |
|
76 | + */ |
|
77 | + public function getResourceRichObject(IResource $resource): array { |
|
78 | + if (isset($this->nodes[(int) $resource->getId()])) { |
|
79 | + $node = $this->nodes[(int) $resource->getId()]->getPath(); |
|
80 | + } else { |
|
81 | + $node = $this->getNode($resource); |
|
82 | + } |
|
83 | + |
|
84 | + if ($node instanceof Node) { |
|
85 | + $link = $this->urlGenerator->linkToRouteAbsolute( |
|
86 | + 'files.viewcontroller.showFile', |
|
87 | + ['fileid' => $resource->getId()] |
|
88 | + ); |
|
89 | + return [ |
|
90 | + 'type' => 'file', |
|
91 | + 'id' => $resource->getId(), |
|
92 | + 'name' => $node->getName(), |
|
93 | + 'path' => $node->getInternalPath(), |
|
94 | + 'link' => $link, |
|
95 | + 'mimetype' => $node->getMimetype(), |
|
96 | + 'preview-available' => $this->preview->isAvailable($node), |
|
97 | + ]; |
|
98 | + } |
|
99 | + |
|
100 | + throw new ResourceException('File not found'); |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Can a user/guest access the collection |
|
105 | + * |
|
106 | + * @param IResource $resource |
|
107 | + * @param IUser $user |
|
108 | + * @return bool |
|
109 | + * @since 16.0.0 |
|
110 | + */ |
|
111 | + public function canAccessResource(IResource $resource, IUser $user = null): bool { |
|
112 | + if (!$user instanceof IUser) { |
|
113 | + return false; |
|
114 | + } |
|
115 | + |
|
116 | + $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
117 | + $nodes = $userFolder->getById((int) $resource->getId()); |
|
118 | + |
|
119 | + if (!empty($nodes)) { |
|
120 | + $this->nodes[(int) $resource->getId()] = array_shift($nodes); |
|
121 | + return true; |
|
122 | + } |
|
123 | + |
|
124 | + return false; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Get the resource type of the provider |
|
129 | + * |
|
130 | + * @return string |
|
131 | + * @since 16.0.0 |
|
132 | + */ |
|
133 | + public function getType(): string { |
|
134 | + return self::RESOURCE_TYPE; |
|
135 | + } |
|
136 | 136 | } |
@@ -42,141 +42,141 @@ |
||
42 | 42 | |
43 | 43 | class TransferOwnership extends QueuedJob { |
44 | 44 | |
45 | - /** @var IUserManager $userManager */ |
|
46 | - private $userManager; |
|
47 | - |
|
48 | - /** @var OwnershipTransferService */ |
|
49 | - private $transferService; |
|
50 | - |
|
51 | - /** @var ILogger */ |
|
52 | - private $logger; |
|
53 | - |
|
54 | - /** @var NotificationManager */ |
|
55 | - private $notificationManager; |
|
56 | - |
|
57 | - /** @var TransferOwnershipMapper */ |
|
58 | - private $mapper; |
|
59 | - /** @var IRootFolder */ |
|
60 | - private $rootFolder; |
|
61 | - |
|
62 | - public function __construct(ITimeFactory $timeFactory, |
|
63 | - IUserManager $userManager, |
|
64 | - OwnershipTransferService $transferService, |
|
65 | - ILogger $logger, |
|
66 | - NotificationManager $notificationManager, |
|
67 | - TransferOwnershipMapper $mapper, |
|
68 | - IRootFolder $rootFolder) { |
|
69 | - parent::__construct($timeFactory); |
|
70 | - |
|
71 | - $this->userManager = $userManager; |
|
72 | - $this->transferService = $transferService; |
|
73 | - $this->logger = $logger; |
|
74 | - $this->notificationManager = $notificationManager; |
|
75 | - $this->mapper = $mapper; |
|
76 | - $this->rootFolder = $rootFolder; |
|
77 | - } |
|
78 | - |
|
79 | - protected function run($argument) { |
|
80 | - $id = $argument['id']; |
|
81 | - |
|
82 | - $transfer = $this->mapper->getById($id); |
|
83 | - $sourceUser = $transfer->getSourceUser(); |
|
84 | - $destinationUser = $transfer->getTargetUser(); |
|
85 | - $fileId = $transfer->getFileId(); |
|
86 | - |
|
87 | - $userFolder = $this->rootFolder->getUserFolder($sourceUser); |
|
88 | - $nodes = $userFolder->getById($fileId); |
|
89 | - |
|
90 | - if (empty($nodes)) { |
|
91 | - $this->logger->alert('Could not transfer ownership: Node not found'); |
|
92 | - $this->failedNotication($transfer); |
|
93 | - return; |
|
94 | - } |
|
95 | - $path = $userFolder->getRelativePath($nodes[0]->getPath()); |
|
96 | - |
|
97 | - $sourceUserObject = $this->userManager->get($sourceUser); |
|
98 | - $destinationUserObject = $this->userManager->get($destinationUser); |
|
99 | - |
|
100 | - if (!$sourceUserObject instanceof IUser) { |
|
101 | - $this->logger->alert('Could not transfer ownership: Unknown source user ' . $sourceUser); |
|
102 | - $this->failedNotication($transfer); |
|
103 | - return; |
|
104 | - } |
|
105 | - |
|
106 | - if (!$destinationUserObject instanceof IUser) { |
|
107 | - $this->logger->alert("Unknown destination user $destinationUser"); |
|
108 | - $this->failedNotication($transfer); |
|
109 | - return; |
|
110 | - } |
|
111 | - |
|
112 | - try { |
|
113 | - $this->transferService->transfer( |
|
114 | - $sourceUserObject, |
|
115 | - $destinationUserObject, |
|
116 | - ltrim($path, '/') |
|
117 | - ); |
|
118 | - $this->successNotification($transfer); |
|
119 | - } catch (TransferOwnershipException $e) { |
|
120 | - $this->logger->logException($e); |
|
121 | - $this->failedNotication($transfer); |
|
122 | - } |
|
123 | - |
|
124 | - $this->mapper->delete($transfer); |
|
125 | - } |
|
126 | - |
|
127 | - private function failedNotication(Transfer $transfer): void { |
|
128 | - // Send notification to source user |
|
129 | - $notification = $this->notificationManager->createNotification(); |
|
130 | - $notification->setUser($transfer->getSourceUser()) |
|
131 | - ->setApp(Application::APP_ID) |
|
132 | - ->setDateTime($this->time->getDateTime()) |
|
133 | - ->setSubject('transferOwnershipFailedSource', [ |
|
134 | - 'sourceUser' => $transfer->getSourceUser(), |
|
135 | - 'targetUser' => $transfer->getTargetUser(), |
|
136 | - 'nodeName' => $transfer->getNodeName(), |
|
137 | - ]) |
|
138 | - ->setObject('transfer', (string)$transfer->getId()); |
|
139 | - $this->notificationManager->notify($notification); |
|
140 | - |
|
141 | - // Send notification to source user |
|
142 | - $notification = $this->notificationManager->createNotification(); |
|
143 | - $notification->setUser($transfer->getTargetUser()) |
|
144 | - ->setApp(Application::APP_ID) |
|
145 | - ->setDateTime($this->time->getDateTime()) |
|
146 | - ->setSubject('transferOwnershipFailedTarget', [ |
|
147 | - 'sourceUser' => $transfer->getSourceUser(), |
|
148 | - 'targetUser' => $transfer->getTargetUser(), |
|
149 | - 'nodeName' => $transfer->getNodeName(), |
|
150 | - ]) |
|
151 | - ->setObject('transfer', (string)$transfer->getId()); |
|
152 | - $this->notificationManager->notify($notification); |
|
153 | - } |
|
154 | - |
|
155 | - private function successNotification(Transfer $transfer): void { |
|
156 | - // Send notification to source user |
|
157 | - $notification = $this->notificationManager->createNotification(); |
|
158 | - $notification->setUser($transfer->getSourceUser()) |
|
159 | - ->setApp(Application::APP_ID) |
|
160 | - ->setDateTime($this->time->getDateTime()) |
|
161 | - ->setSubject('transferOwnershipDoneSource', [ |
|
162 | - 'sourceUser' => $transfer->getSourceUser(), |
|
163 | - 'targetUser' => $transfer->getTargetUser(), |
|
164 | - 'nodeName' => $transfer->getNodeName(), |
|
165 | - ]) |
|
166 | - ->setObject('transfer', (string)$transfer->getId()); |
|
167 | - $this->notificationManager->notify($notification); |
|
168 | - |
|
169 | - // Send notification to source user |
|
170 | - $notification = $this->notificationManager->createNotification(); |
|
171 | - $notification->setUser($transfer->getTargetUser()) |
|
172 | - ->setApp(Application::APP_ID) |
|
173 | - ->setDateTime($this->time->getDateTime()) |
|
174 | - ->setSubject('transferOwnershipDoneTarget', [ |
|
175 | - 'sourceUser' => $transfer->getSourceUser(), |
|
176 | - 'targetUser' => $transfer->getTargetUser(), |
|
177 | - 'nodeName' => $transfer->getNodeName(), |
|
178 | - ]) |
|
179 | - ->setObject('transfer', (string)$transfer->getId()); |
|
180 | - $this->notificationManager->notify($notification); |
|
181 | - } |
|
45 | + /** @var IUserManager $userManager */ |
|
46 | + private $userManager; |
|
47 | + |
|
48 | + /** @var OwnershipTransferService */ |
|
49 | + private $transferService; |
|
50 | + |
|
51 | + /** @var ILogger */ |
|
52 | + private $logger; |
|
53 | + |
|
54 | + /** @var NotificationManager */ |
|
55 | + private $notificationManager; |
|
56 | + |
|
57 | + /** @var TransferOwnershipMapper */ |
|
58 | + private $mapper; |
|
59 | + /** @var IRootFolder */ |
|
60 | + private $rootFolder; |
|
61 | + |
|
62 | + public function __construct(ITimeFactory $timeFactory, |
|
63 | + IUserManager $userManager, |
|
64 | + OwnershipTransferService $transferService, |
|
65 | + ILogger $logger, |
|
66 | + NotificationManager $notificationManager, |
|
67 | + TransferOwnershipMapper $mapper, |
|
68 | + IRootFolder $rootFolder) { |
|
69 | + parent::__construct($timeFactory); |
|
70 | + |
|
71 | + $this->userManager = $userManager; |
|
72 | + $this->transferService = $transferService; |
|
73 | + $this->logger = $logger; |
|
74 | + $this->notificationManager = $notificationManager; |
|
75 | + $this->mapper = $mapper; |
|
76 | + $this->rootFolder = $rootFolder; |
|
77 | + } |
|
78 | + |
|
79 | + protected function run($argument) { |
|
80 | + $id = $argument['id']; |
|
81 | + |
|
82 | + $transfer = $this->mapper->getById($id); |
|
83 | + $sourceUser = $transfer->getSourceUser(); |
|
84 | + $destinationUser = $transfer->getTargetUser(); |
|
85 | + $fileId = $transfer->getFileId(); |
|
86 | + |
|
87 | + $userFolder = $this->rootFolder->getUserFolder($sourceUser); |
|
88 | + $nodes = $userFolder->getById($fileId); |
|
89 | + |
|
90 | + if (empty($nodes)) { |
|
91 | + $this->logger->alert('Could not transfer ownership: Node not found'); |
|
92 | + $this->failedNotication($transfer); |
|
93 | + return; |
|
94 | + } |
|
95 | + $path = $userFolder->getRelativePath($nodes[0]->getPath()); |
|
96 | + |
|
97 | + $sourceUserObject = $this->userManager->get($sourceUser); |
|
98 | + $destinationUserObject = $this->userManager->get($destinationUser); |
|
99 | + |
|
100 | + if (!$sourceUserObject instanceof IUser) { |
|
101 | + $this->logger->alert('Could not transfer ownership: Unknown source user ' . $sourceUser); |
|
102 | + $this->failedNotication($transfer); |
|
103 | + return; |
|
104 | + } |
|
105 | + |
|
106 | + if (!$destinationUserObject instanceof IUser) { |
|
107 | + $this->logger->alert("Unknown destination user $destinationUser"); |
|
108 | + $this->failedNotication($transfer); |
|
109 | + return; |
|
110 | + } |
|
111 | + |
|
112 | + try { |
|
113 | + $this->transferService->transfer( |
|
114 | + $sourceUserObject, |
|
115 | + $destinationUserObject, |
|
116 | + ltrim($path, '/') |
|
117 | + ); |
|
118 | + $this->successNotification($transfer); |
|
119 | + } catch (TransferOwnershipException $e) { |
|
120 | + $this->logger->logException($e); |
|
121 | + $this->failedNotication($transfer); |
|
122 | + } |
|
123 | + |
|
124 | + $this->mapper->delete($transfer); |
|
125 | + } |
|
126 | + |
|
127 | + private function failedNotication(Transfer $transfer): void { |
|
128 | + // Send notification to source user |
|
129 | + $notification = $this->notificationManager->createNotification(); |
|
130 | + $notification->setUser($transfer->getSourceUser()) |
|
131 | + ->setApp(Application::APP_ID) |
|
132 | + ->setDateTime($this->time->getDateTime()) |
|
133 | + ->setSubject('transferOwnershipFailedSource', [ |
|
134 | + 'sourceUser' => $transfer->getSourceUser(), |
|
135 | + 'targetUser' => $transfer->getTargetUser(), |
|
136 | + 'nodeName' => $transfer->getNodeName(), |
|
137 | + ]) |
|
138 | + ->setObject('transfer', (string)$transfer->getId()); |
|
139 | + $this->notificationManager->notify($notification); |
|
140 | + |
|
141 | + // Send notification to source user |
|
142 | + $notification = $this->notificationManager->createNotification(); |
|
143 | + $notification->setUser($transfer->getTargetUser()) |
|
144 | + ->setApp(Application::APP_ID) |
|
145 | + ->setDateTime($this->time->getDateTime()) |
|
146 | + ->setSubject('transferOwnershipFailedTarget', [ |
|
147 | + 'sourceUser' => $transfer->getSourceUser(), |
|
148 | + 'targetUser' => $transfer->getTargetUser(), |
|
149 | + 'nodeName' => $transfer->getNodeName(), |
|
150 | + ]) |
|
151 | + ->setObject('transfer', (string)$transfer->getId()); |
|
152 | + $this->notificationManager->notify($notification); |
|
153 | + } |
|
154 | + |
|
155 | + private function successNotification(Transfer $transfer): void { |
|
156 | + // Send notification to source user |
|
157 | + $notification = $this->notificationManager->createNotification(); |
|
158 | + $notification->setUser($transfer->getSourceUser()) |
|
159 | + ->setApp(Application::APP_ID) |
|
160 | + ->setDateTime($this->time->getDateTime()) |
|
161 | + ->setSubject('transferOwnershipDoneSource', [ |
|
162 | + 'sourceUser' => $transfer->getSourceUser(), |
|
163 | + 'targetUser' => $transfer->getTargetUser(), |
|
164 | + 'nodeName' => $transfer->getNodeName(), |
|
165 | + ]) |
|
166 | + ->setObject('transfer', (string)$transfer->getId()); |
|
167 | + $this->notificationManager->notify($notification); |
|
168 | + |
|
169 | + // Send notification to source user |
|
170 | + $notification = $this->notificationManager->createNotification(); |
|
171 | + $notification->setUser($transfer->getTargetUser()) |
|
172 | + ->setApp(Application::APP_ID) |
|
173 | + ->setDateTime($this->time->getDateTime()) |
|
174 | + ->setSubject('transferOwnershipDoneTarget', [ |
|
175 | + 'sourceUser' => $transfer->getSourceUser(), |
|
176 | + 'targetUser' => $transfer->getTargetUser(), |
|
177 | + 'nodeName' => $transfer->getNodeName(), |
|
178 | + ]) |
|
179 | + ->setObject('transfer', (string)$transfer->getId()); |
|
180 | + $this->notificationManager->notify($notification); |
|
181 | + } |
|
182 | 182 | } |
@@ -33,99 +33,99 @@ |
||
33 | 33 | */ |
34 | 34 | abstract class ExternalCalendar implements CalDAV\ICalendar, DAV\IProperties { |
35 | 35 | |
36 | - /** @var string */ |
|
37 | - private const PREFIX = 'app-generated'; |
|
36 | + /** @var string */ |
|
37 | + private const PREFIX = 'app-generated'; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var string |
|
41 | - * |
|
42 | - * Double dash is a valid delimiter, |
|
43 | - * because it will always split the calendarURIs correctly: |
|
44 | - * - our prefix contains only one dash and won't be split |
|
45 | - * - appIds are not allowed to contain dashes as per spec: |
|
46 | - * > must contain only lowercase ASCII characters and underscore |
|
47 | - * - explode has a limit of three, so even if the app-generated |
|
48 | - * calendar uri has double dashes, it won't be split |
|
49 | - */ |
|
50 | - private const DELIMITER = '--'; |
|
39 | + /** |
|
40 | + * @var string |
|
41 | + * |
|
42 | + * Double dash is a valid delimiter, |
|
43 | + * because it will always split the calendarURIs correctly: |
|
44 | + * - our prefix contains only one dash and won't be split |
|
45 | + * - appIds are not allowed to contain dashes as per spec: |
|
46 | + * > must contain only lowercase ASCII characters and underscore |
|
47 | + * - explode has a limit of three, so even if the app-generated |
|
48 | + * calendar uri has double dashes, it won't be split |
|
49 | + */ |
|
50 | + private const DELIMITER = '--'; |
|
51 | 51 | |
52 | - /** @var string */ |
|
53 | - private $appId; |
|
52 | + /** @var string */ |
|
53 | + private $appId; |
|
54 | 54 | |
55 | - /** @var string */ |
|
56 | - private $calendarUri; |
|
55 | + /** @var string */ |
|
56 | + private $calendarUri; |
|
57 | 57 | |
58 | - /** |
|
59 | - * ExternalCalendar constructor. |
|
60 | - * |
|
61 | - * @param string $appId |
|
62 | - * @param string $calendarUri |
|
63 | - */ |
|
64 | - public function __construct(string $appId, string $calendarUri) { |
|
65 | - $this->appId = $appId; |
|
66 | - $this->calendarUri = $calendarUri; |
|
67 | - } |
|
58 | + /** |
|
59 | + * ExternalCalendar constructor. |
|
60 | + * |
|
61 | + * @param string $appId |
|
62 | + * @param string $calendarUri |
|
63 | + */ |
|
64 | + public function __construct(string $appId, string $calendarUri) { |
|
65 | + $this->appId = $appId; |
|
66 | + $this->calendarUri = $calendarUri; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @inheritDoc |
|
71 | - */ |
|
72 | - final public function getName() { |
|
73 | - return implode(self::DELIMITER, [ |
|
74 | - self::PREFIX, |
|
75 | - $this->appId, |
|
76 | - $this->calendarUri, |
|
77 | - ]); |
|
78 | - } |
|
69 | + /** |
|
70 | + * @inheritDoc |
|
71 | + */ |
|
72 | + final public function getName() { |
|
73 | + return implode(self::DELIMITER, [ |
|
74 | + self::PREFIX, |
|
75 | + $this->appId, |
|
76 | + $this->calendarUri, |
|
77 | + ]); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @inheritDoc |
|
82 | - */ |
|
83 | - final public function setName($name) { |
|
84 | - throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported'); |
|
85 | - } |
|
80 | + /** |
|
81 | + * @inheritDoc |
|
82 | + */ |
|
83 | + final public function setName($name) { |
|
84 | + throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported'); |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @inheritDoc |
|
89 | - */ |
|
90 | - final public function createDirectory($name) { |
|
91 | - throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed'); |
|
92 | - } |
|
87 | + /** |
|
88 | + * @inheritDoc |
|
89 | + */ |
|
90 | + final public function createDirectory($name) { |
|
91 | + throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed'); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Checks whether the calendar uri is app-generated |
|
96 | - * |
|
97 | - * @param string $calendarUri |
|
98 | - * @return bool |
|
99 | - */ |
|
100 | - public static function isAppGeneratedCalendar(string $calendarUri):bool { |
|
101 | - return strpos($calendarUri, self::PREFIX) === 0 && substr_count($calendarUri, self::DELIMITER) >= 2; |
|
102 | - } |
|
94 | + /** |
|
95 | + * Checks whether the calendar uri is app-generated |
|
96 | + * |
|
97 | + * @param string $calendarUri |
|
98 | + * @return bool |
|
99 | + */ |
|
100 | + public static function isAppGeneratedCalendar(string $calendarUri):bool { |
|
101 | + return strpos($calendarUri, self::PREFIX) === 0 && substr_count($calendarUri, self::DELIMITER) >= 2; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Splits an app-generated calendar-uri into appId and calendarUri |
|
106 | - * |
|
107 | - * @param string $calendarUri |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - public static function splitAppGeneratedCalendarUri(string $calendarUri):array { |
|
111 | - $array = array_slice(explode(self::DELIMITER, $calendarUri, 3), 1); |
|
112 | - // Check the array has expected amount of elements |
|
113 | - // and none of them is an empty string |
|
114 | - if (\count($array) !== 2 || \in_array('', $array, true)) { |
|
115 | - throw new \InvalidArgumentException('Provided calendar uri was not app-generated'); |
|
116 | - } |
|
104 | + /** |
|
105 | + * Splits an app-generated calendar-uri into appId and calendarUri |
|
106 | + * |
|
107 | + * @param string $calendarUri |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + public static function splitAppGeneratedCalendarUri(string $calendarUri):array { |
|
111 | + $array = array_slice(explode(self::DELIMITER, $calendarUri, 3), 1); |
|
112 | + // Check the array has expected amount of elements |
|
113 | + // and none of them is an empty string |
|
114 | + if (\count($array) !== 2 || \in_array('', $array, true)) { |
|
115 | + throw new \InvalidArgumentException('Provided calendar uri was not app-generated'); |
|
116 | + } |
|
117 | 117 | |
118 | - return $array; |
|
119 | - } |
|
118 | + return $array; |
|
119 | + } |
|
120 | 120 | |
121 | - /** |
|
122 | - * Checks whether a calendar-name, the user wants to create, violates |
|
123 | - * the reserved name for calendar uris |
|
124 | - * |
|
125 | - * @param string $calendarUri |
|
126 | - * @return bool |
|
127 | - */ |
|
128 | - public static function doesViolateReservedName(string $calendarUri):bool { |
|
129 | - return strpos($calendarUri, self::PREFIX) === 0; |
|
130 | - } |
|
121 | + /** |
|
122 | + * Checks whether a calendar-name, the user wants to create, violates |
|
123 | + * the reserved name for calendar uris |
|
124 | + * |
|
125 | + * @param string $calendarUri |
|
126 | + * @return bool |
|
127 | + */ |
|
128 | + public static function doesViolateReservedName(string $calendarUri):bool { |
|
129 | + return strpos($calendarUri, self::PREFIX) === 0; |
|
130 | + } |
|
131 | 131 | } |
@@ -35,51 +35,51 @@ |
||
35 | 35 | */ |
36 | 36 | class FilesDropPlugin extends ServerPlugin { |
37 | 37 | |
38 | - /** @var View */ |
|
39 | - private $view; |
|
38 | + /** @var View */ |
|
39 | + private $view; |
|
40 | 40 | |
41 | - /** @var bool */ |
|
42 | - private $enabled = false; |
|
41 | + /** @var bool */ |
|
42 | + private $enabled = false; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param View $view |
|
46 | - */ |
|
47 | - public function setView($view) { |
|
48 | - $this->view = $view; |
|
49 | - } |
|
44 | + /** |
|
45 | + * @param View $view |
|
46 | + */ |
|
47 | + public function setView($view) { |
|
48 | + $this->view = $view; |
|
49 | + } |
|
50 | 50 | |
51 | - public function enable() { |
|
52 | - $this->enabled = true; |
|
53 | - } |
|
51 | + public function enable() { |
|
52 | + $this->enabled = true; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * This initializes the plugin. |
|
58 | - * |
|
59 | - * @param \Sabre\DAV\Server $server Sabre server |
|
60 | - * |
|
61 | - * @return void |
|
62 | - * @throws MethodNotAllowed |
|
63 | - */ |
|
64 | - public function initialize(\Sabre\DAV\Server $server) { |
|
65 | - $server->on('beforeMethod:*', [$this, 'beforeMethod'], 999); |
|
66 | - $this->enabled = false; |
|
67 | - } |
|
56 | + /** |
|
57 | + * This initializes the plugin. |
|
58 | + * |
|
59 | + * @param \Sabre\DAV\Server $server Sabre server |
|
60 | + * |
|
61 | + * @return void |
|
62 | + * @throws MethodNotAllowed |
|
63 | + */ |
|
64 | + public function initialize(\Sabre\DAV\Server $server) { |
|
65 | + $server->on('beforeMethod:*', [$this, 'beforeMethod'], 999); |
|
66 | + $this->enabled = false; |
|
67 | + } |
|
68 | 68 | |
69 | - public function beforeMethod(RequestInterface $request, ResponseInterface $response) { |
|
70 | - if (!$this->enabled) { |
|
71 | - return; |
|
72 | - } |
|
69 | + public function beforeMethod(RequestInterface $request, ResponseInterface $response) { |
|
70 | + if (!$this->enabled) { |
|
71 | + return; |
|
72 | + } |
|
73 | 73 | |
74 | - if ($request->getMethod() !== 'PUT') { |
|
75 | - throw new MethodNotAllowed('Only PUT is allowed on files drop'); |
|
76 | - } |
|
74 | + if ($request->getMethod() !== 'PUT') { |
|
75 | + throw new MethodNotAllowed('Only PUT is allowed on files drop'); |
|
76 | + } |
|
77 | 77 | |
78 | - $path = explode('/', $request->getPath()); |
|
79 | - $path = array_pop($path); |
|
78 | + $path = explode('/', $request->getPath()); |
|
79 | + $path = array_pop($path); |
|
80 | 80 | |
81 | - $newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view); |
|
82 | - $url = $request->getBaseUrl() . $newName; |
|
83 | - $request->setUrl($url); |
|
84 | - } |
|
81 | + $newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view); |
|
82 | + $url = $request->getBaseUrl() . $newName; |
|
83 | + $request->setUrl($url); |
|
84 | + } |
|
85 | 85 | } |
@@ -34,52 +34,52 @@ |
||
34 | 34 | |
35 | 35 | class RefreshWebcalJobRegistrar implements IRepairStep { |
36 | 36 | |
37 | - /** @var IDBConnection */ |
|
38 | - private $connection; |
|
37 | + /** @var IDBConnection */ |
|
38 | + private $connection; |
|
39 | 39 | |
40 | - /** @var IJobList */ |
|
41 | - private $jobList; |
|
40 | + /** @var IJobList */ |
|
41 | + private $jobList; |
|
42 | 42 | |
43 | - /** |
|
44 | - * FixBirthdayCalendarComponent constructor. |
|
45 | - * |
|
46 | - * @param IDBConnection $connection |
|
47 | - * @param IJobList $jobList |
|
48 | - */ |
|
49 | - public function __construct(IDBConnection $connection, IJobList $jobList) { |
|
50 | - $this->connection = $connection; |
|
51 | - $this->jobList = $jobList; |
|
52 | - } |
|
43 | + /** |
|
44 | + * FixBirthdayCalendarComponent constructor. |
|
45 | + * |
|
46 | + * @param IDBConnection $connection |
|
47 | + * @param IJobList $jobList |
|
48 | + */ |
|
49 | + public function __construct(IDBConnection $connection, IJobList $jobList) { |
|
50 | + $this->connection = $connection; |
|
51 | + $this->jobList = $jobList; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @inheritdoc |
|
56 | - */ |
|
57 | - public function getName() { |
|
58 | - return 'Registering background jobs to update cache for webcal calendars'; |
|
59 | - } |
|
54 | + /** |
|
55 | + * @inheritdoc |
|
56 | + */ |
|
57 | + public function getName() { |
|
58 | + return 'Registering background jobs to update cache for webcal calendars'; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @inheritdoc |
|
63 | - */ |
|
64 | - public function run(IOutput $output) { |
|
65 | - $query = $this->connection->getQueryBuilder(); |
|
66 | - $query->select(['principaluri', 'uri']) |
|
67 | - ->from('calendarsubscriptions'); |
|
68 | - $stmt = $query->execute(); |
|
61 | + /** |
|
62 | + * @inheritdoc |
|
63 | + */ |
|
64 | + public function run(IOutput $output) { |
|
65 | + $query = $this->connection->getQueryBuilder(); |
|
66 | + $query->select(['principaluri', 'uri']) |
|
67 | + ->from('calendarsubscriptions'); |
|
68 | + $stmt = $query->execute(); |
|
69 | 69 | |
70 | - $count = 0; |
|
71 | - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
72 | - $args = [ |
|
73 | - 'principaluri' => $row['principaluri'], |
|
74 | - 'uri' => $row['uri'], |
|
75 | - ]; |
|
70 | + $count = 0; |
|
71 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
72 | + $args = [ |
|
73 | + 'principaluri' => $row['principaluri'], |
|
74 | + 'uri' => $row['uri'], |
|
75 | + ]; |
|
76 | 76 | |
77 | - if (!$this->jobList->has(RefreshWebcalJob::class, $args)) { |
|
78 | - $this->jobList->add(RefreshWebcalJob::class, $args); |
|
79 | - $count++; |
|
80 | - } |
|
81 | - } |
|
77 | + if (!$this->jobList->has(RefreshWebcalJob::class, $args)) { |
|
78 | + $this->jobList->add(RefreshWebcalJob::class, $args); |
|
79 | + $count++; |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - $output->info("Added $count background jobs to update webcal calendars"); |
|
84 | - } |
|
83 | + $output->info("Added $count background jobs to update webcal calendars"); |
|
84 | + } |
|
85 | 85 | } |
@@ -28,51 +28,51 @@ |
||
28 | 28 | use OCP\WorkflowEngine\IManager; |
29 | 29 | |
30 | 30 | class ScopeContext { |
31 | - /** @var int */ |
|
32 | - private $scope; |
|
33 | - /** @var string */ |
|
34 | - private $scopeId; |
|
35 | - /** @var string */ |
|
36 | - private $hash; |
|
31 | + /** @var int */ |
|
32 | + private $scope; |
|
33 | + /** @var string */ |
|
34 | + private $scopeId; |
|
35 | + /** @var string */ |
|
36 | + private $hash; |
|
37 | 37 | |
38 | - public function __construct(int $scope, string $scopeId = null) { |
|
39 | - $this->scope = $this->evaluateScope($scope); |
|
40 | - $this->scopeId = $this->evaluateScopeId($scopeId); |
|
41 | - } |
|
38 | + public function __construct(int $scope, string $scopeId = null) { |
|
39 | + $this->scope = $this->evaluateScope($scope); |
|
40 | + $this->scopeId = $this->evaluateScopeId($scopeId); |
|
41 | + } |
|
42 | 42 | |
43 | - private function evaluateScope(int $scope): int { |
|
44 | - if (in_array($scope, [IManager::SCOPE_ADMIN, IManager::SCOPE_USER], true)) { |
|
45 | - return $scope; |
|
46 | - } |
|
47 | - throw new \InvalidArgumentException('Invalid scope'); |
|
48 | - } |
|
43 | + private function evaluateScope(int $scope): int { |
|
44 | + if (in_array($scope, [IManager::SCOPE_ADMIN, IManager::SCOPE_USER], true)) { |
|
45 | + return $scope; |
|
46 | + } |
|
47 | + throw new \InvalidArgumentException('Invalid scope'); |
|
48 | + } |
|
49 | 49 | |
50 | - private function evaluateScopeId(string $scopeId = null): string { |
|
51 | - if ($this->scope === IManager::SCOPE_USER |
|
52 | - && trim((string)$scopeId) === '') { |
|
53 | - throw new \InvalidArgumentException('user scope requires a user id'); |
|
54 | - } |
|
55 | - return trim((string)$scopeId); |
|
56 | - } |
|
50 | + private function evaluateScopeId(string $scopeId = null): string { |
|
51 | + if ($this->scope === IManager::SCOPE_USER |
|
52 | + && trim((string)$scopeId) === '') { |
|
53 | + throw new \InvalidArgumentException('user scope requires a user id'); |
|
54 | + } |
|
55 | + return trim((string)$scopeId); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return int |
|
60 | - */ |
|
61 | - public function getScope(): int { |
|
62 | - return $this->scope; |
|
63 | - } |
|
58 | + /** |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + public function getScope(): int { |
|
62 | + return $this->scope; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function getScopeId(): string { |
|
69 | - return $this->scopeId; |
|
70 | - } |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function getScopeId(): string { |
|
69 | + return $this->scopeId; |
|
70 | + } |
|
71 | 71 | |
72 | - public function getHash(): string { |
|
73 | - if ($this->hash === null) { |
|
74 | - $this->hash = \hash('sha256', $this->getScope() . '::' . $this->getScopeId()); |
|
75 | - } |
|
76 | - return $this->hash; |
|
77 | - } |
|
72 | + public function getHash(): string { |
|
73 | + if ($this->hash === null) { |
|
74 | + $this->hash = \hash('sha256', $this->getScope() . '::' . $this->getScopeId()); |
|
75 | + } |
|
76 | + return $this->hash; |
|
77 | + } |
|
78 | 78 | } |
@@ -30,67 +30,67 @@ |
||
30 | 30 | use OCP\WorkflowEngine\IOperation; |
31 | 31 | |
32 | 32 | class LogContext { |
33 | - /** @var array */ |
|
34 | - protected $details; |
|
33 | + /** @var array */ |
|
34 | + protected $details; |
|
35 | 35 | |
36 | - public function setDescription(string $description): LogContext { |
|
37 | - $this->details['message'] = $description; |
|
38 | - return $this; |
|
39 | - } |
|
36 | + public function setDescription(string $description): LogContext { |
|
37 | + $this->details['message'] = $description; |
|
38 | + return $this; |
|
39 | + } |
|
40 | 40 | |
41 | - public function setScopes(array $scopes): LogContext { |
|
42 | - $this->details['scopes'] = []; |
|
43 | - foreach ($scopes as $scope) { |
|
44 | - if ($scope instanceof ScopeContext) { |
|
45 | - switch ($scope->getScope()) { |
|
46 | - case IManager::SCOPE_ADMIN: |
|
47 | - $this->details['scopes'][] = ['scope' => 'admin']; |
|
48 | - break; |
|
49 | - case IManager::SCOPE_USER: |
|
50 | - $this->details['scopes'][] = [ |
|
51 | - 'scope' => 'user', |
|
52 | - 'uid' => $scope->getScopeId(), |
|
53 | - ]; |
|
54 | - break; |
|
55 | - default: |
|
56 | - continue 2; |
|
57 | - } |
|
58 | - } |
|
59 | - } |
|
60 | - return $this; |
|
61 | - } |
|
41 | + public function setScopes(array $scopes): LogContext { |
|
42 | + $this->details['scopes'] = []; |
|
43 | + foreach ($scopes as $scope) { |
|
44 | + if ($scope instanceof ScopeContext) { |
|
45 | + switch ($scope->getScope()) { |
|
46 | + case IManager::SCOPE_ADMIN: |
|
47 | + $this->details['scopes'][] = ['scope' => 'admin']; |
|
48 | + break; |
|
49 | + case IManager::SCOPE_USER: |
|
50 | + $this->details['scopes'][] = [ |
|
51 | + 'scope' => 'user', |
|
52 | + 'uid' => $scope->getScopeId(), |
|
53 | + ]; |
|
54 | + break; |
|
55 | + default: |
|
56 | + continue 2; |
|
57 | + } |
|
58 | + } |
|
59 | + } |
|
60 | + return $this; |
|
61 | + } |
|
62 | 62 | |
63 | - public function setOperation(?IOperation $operation): LogContext { |
|
64 | - if ($operation instanceof IOperation) { |
|
65 | - $this->details['operation'] = [ |
|
66 | - 'class' => get_class($operation), |
|
67 | - 'name' => $operation->getDisplayName(), |
|
68 | - ]; |
|
69 | - } |
|
70 | - return $this; |
|
71 | - } |
|
63 | + public function setOperation(?IOperation $operation): LogContext { |
|
64 | + if ($operation instanceof IOperation) { |
|
65 | + $this->details['operation'] = [ |
|
66 | + 'class' => get_class($operation), |
|
67 | + 'name' => $operation->getDisplayName(), |
|
68 | + ]; |
|
69 | + } |
|
70 | + return $this; |
|
71 | + } |
|
72 | 72 | |
73 | - public function setEntity(?IEntity $entity): LogContext { |
|
74 | - if ($entity instanceof IEntity) { |
|
75 | - $this->details['entity'] = [ |
|
76 | - 'class' => get_class($entity), |
|
77 | - 'name' => $entity->getName(), |
|
78 | - ]; |
|
79 | - } |
|
80 | - return $this; |
|
81 | - } |
|
73 | + public function setEntity(?IEntity $entity): LogContext { |
|
74 | + if ($entity instanceof IEntity) { |
|
75 | + $this->details['entity'] = [ |
|
76 | + 'class' => get_class($entity), |
|
77 | + 'name' => $entity->getName(), |
|
78 | + ]; |
|
79 | + } |
|
80 | + return $this; |
|
81 | + } |
|
82 | 82 | |
83 | - public function setConfiguration(array $configuration): LogContext { |
|
84 | - $this->details['configuration'] = $configuration; |
|
85 | - return $this; |
|
86 | - } |
|
83 | + public function setConfiguration(array $configuration): LogContext { |
|
84 | + $this->details['configuration'] = $configuration; |
|
85 | + return $this; |
|
86 | + } |
|
87 | 87 | |
88 | - public function setEventName(string $eventName): LogContext { |
|
89 | - $this->details['eventName'] = $eventName; |
|
90 | - return $this; |
|
91 | - } |
|
88 | + public function setEventName(string $eventName): LogContext { |
|
89 | + $this->details['eventName'] = $eventName; |
|
90 | + return $this; |
|
91 | + } |
|
92 | 92 | |
93 | - public function getDetails(): array { |
|
94 | - return $this->details; |
|
95 | - } |
|
93 | + public function getDetails(): array { |
|
94 | + return $this->details; |
|
95 | + } |
|
96 | 96 | } |