@@ -34,197 +34,197 @@ |
||
34 | 34 | use OCP\Notification\INotifier; |
35 | 35 | |
36 | 36 | class Notifier implements INotifier { |
37 | - /** @var IFactory */ |
|
38 | - protected $factory; |
|
39 | - /** @var IManager */ |
|
40 | - protected $contactsManager; |
|
41 | - /** @var IURLGenerator */ |
|
42 | - protected $url; |
|
43 | - /** @var array */ |
|
44 | - protected $federatedContacts; |
|
45 | - /** @var ICloudIdManager */ |
|
46 | - protected $cloudIdManager; |
|
47 | - |
|
48 | - /** |
|
49 | - * @param IFactory $factory |
|
50 | - * @param IManager $contactsManager |
|
51 | - * @param IURLGenerator $url |
|
52 | - * @param ICloudIdManager $cloudIdManager |
|
53 | - */ |
|
54 | - public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url, ICloudIdManager $cloudIdManager) { |
|
55 | - $this->factory = $factory; |
|
56 | - $this->contactsManager = $contactsManager; |
|
57 | - $this->url = $url; |
|
58 | - $this->cloudIdManager = $cloudIdManager; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @param INotification $notification |
|
63 | - * @param string $languageCode The code of the language that should be used to prepare the notification |
|
64 | - * @return INotification |
|
65 | - * @throws \InvalidArgumentException |
|
66 | - */ |
|
67 | - public function prepare(INotification $notification, $languageCode) { |
|
68 | - if ($notification->getApp() !== 'files_sharing') { |
|
69 | - // Not my app => throw |
|
70 | - throw new \InvalidArgumentException(); |
|
71 | - } |
|
72 | - |
|
73 | - // Read the language from the notification |
|
74 | - $l = $this->factory->get('files_sharing', $languageCode); |
|
75 | - |
|
76 | - switch ($notification->getSubject()) { |
|
77 | - // Deal with known subjects |
|
78 | - case 'remote_share': |
|
79 | - $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
80 | - |
|
81 | - $params = $notification->getSubjectParameters(); |
|
82 | - if ($params[0] !== $params[1] && $params[1] !== null) { |
|
83 | - $notification->setParsedSubject( |
|
84 | - $l->t('You received "%3$s" as a remote share from %1$s (on behalf of %2$s)', $params) |
|
85 | - ); |
|
86 | - $notification->setRichSubject( |
|
87 | - $l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'), |
|
88 | - [ |
|
89 | - 'share' => [ |
|
90 | - 'type' => 'pending-federated-share', |
|
91 | - 'id' => $notification->getObjectId(), |
|
92 | - 'name' => $params[2], |
|
93 | - ], |
|
94 | - 'user' => $this->createRemoteUser($params[0]), |
|
95 | - 'behalf' => $this->createRemoteUser($params[1]), |
|
96 | - ] |
|
97 | - ); |
|
98 | - } else { |
|
99 | - $notification->setParsedSubject( |
|
100 | - $l->t('You received "%3$s" as a remote share from %1$s', $params) |
|
101 | - ); |
|
102 | - $notification->setRichSubject( |
|
103 | - $l->t('You received {share} as a remote share from {user}'), |
|
104 | - [ |
|
105 | - 'share' => [ |
|
106 | - 'type' => 'pending-federated-share', |
|
107 | - 'id' => $notification->getObjectId(), |
|
108 | - 'name' => $params[2], |
|
109 | - ], |
|
110 | - 'user' => $this->createRemoteUser($params[0]), |
|
111 | - ] |
|
112 | - ); |
|
113 | - } |
|
114 | - |
|
115 | - // Deal with the actions for a known subject |
|
116 | - foreach ($notification->getActions() as $action) { |
|
117 | - switch ($action->getLabel()) { |
|
118 | - case 'accept': |
|
119 | - $action->setParsedLabel( |
|
120 | - (string) $l->t('Accept') |
|
121 | - ) |
|
122 | - ->setPrimary(true); |
|
123 | - break; |
|
124 | - |
|
125 | - case 'decline': |
|
126 | - $action->setParsedLabel( |
|
127 | - (string) $l->t('Decline') |
|
128 | - ); |
|
129 | - break; |
|
130 | - } |
|
131 | - |
|
132 | - $notification->addParsedAction($action); |
|
133 | - } |
|
134 | - return $notification; |
|
135 | - |
|
136 | - default: |
|
137 | - // Unknown subject => Unknown notification => throw |
|
138 | - throw new \InvalidArgumentException(); |
|
139 | - } |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * @param string $cloudId |
|
144 | - * @return array |
|
145 | - */ |
|
146 | - protected function createRemoteUser($cloudId) { |
|
147 | - $displayName = $cloudId; |
|
148 | - try { |
|
149 | - $resolvedId = $this->cloudIdManager->resolveCloudId($cloudId); |
|
150 | - $displayName = $this->getDisplayName($resolvedId); |
|
151 | - $user = $resolvedId->getUser(); |
|
152 | - $server = $resolvedId->getRemote(); |
|
153 | - } catch (HintException $e) { |
|
154 | - $user = $cloudId; |
|
155 | - $server = ''; |
|
156 | - } |
|
157 | - |
|
158 | - return [ |
|
159 | - 'type' => 'user', |
|
160 | - 'id' => $user, |
|
161 | - 'name' => $displayName, |
|
162 | - 'server' => $server, |
|
163 | - ]; |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Try to find the user in the contacts |
|
168 | - * |
|
169 | - * @param ICloudId $cloudId |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - protected function getDisplayName(ICloudId $cloudId) { |
|
173 | - $server = $cloudId->getRemote(); |
|
174 | - $user = $cloudId->getUser(); |
|
175 | - if (strpos($server, 'http://') === 0) { |
|
176 | - $server = substr($server, strlen('http://')); |
|
177 | - } else if (strpos($server, 'https://') === 0) { |
|
178 | - $server = substr($server, strlen('https://')); |
|
179 | - } |
|
180 | - |
|
181 | - try { |
|
182 | - return $this->getDisplayNameFromContact($cloudId->getId()); |
|
183 | - } catch (\OutOfBoundsException $e) { |
|
184 | - } |
|
185 | - |
|
186 | - try { |
|
187 | - $this->getDisplayNameFromContact($user . '@http://' . $server); |
|
188 | - } catch (\OutOfBoundsException $e) { |
|
189 | - } |
|
190 | - |
|
191 | - try { |
|
192 | - $this->getDisplayNameFromContact($user . '@https://' . $server); |
|
193 | - } catch (\OutOfBoundsException $e) { |
|
194 | - } |
|
195 | - |
|
196 | - return $cloudId->getId(); |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Try to find the user in the contacts |
|
201 | - * |
|
202 | - * @param string $federatedCloudId |
|
203 | - * @return string |
|
204 | - * @throws \OutOfBoundsException when there is no contact for the id |
|
205 | - */ |
|
206 | - protected function getDisplayNameFromContact($federatedCloudId) { |
|
207 | - if (isset($this->federatedContacts[$federatedCloudId])) { |
|
208 | - if ($this->federatedContacts[$federatedCloudId] !== '') { |
|
209 | - return $this->federatedContacts[$federatedCloudId]; |
|
210 | - } else { |
|
211 | - throw new \OutOfBoundsException('No contact found for federated cloud id'); |
|
212 | - } |
|
213 | - } |
|
214 | - |
|
215 | - $addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD']); |
|
216 | - foreach ($addressBookEntries as $entry) { |
|
217 | - if (isset($entry['CLOUD'])) { |
|
218 | - foreach ($entry['CLOUD'] as $cloudID) { |
|
219 | - if ($cloudID === $federatedCloudId) { |
|
220 | - $this->federatedContacts[$federatedCloudId] = $entry['FN']; |
|
221 | - return $entry['FN']; |
|
222 | - } |
|
223 | - } |
|
224 | - } |
|
225 | - } |
|
226 | - |
|
227 | - $this->federatedContacts[$federatedCloudId] = ''; |
|
228 | - throw new \OutOfBoundsException('No contact found for federated cloud id'); |
|
229 | - } |
|
37 | + /** @var IFactory */ |
|
38 | + protected $factory; |
|
39 | + /** @var IManager */ |
|
40 | + protected $contactsManager; |
|
41 | + /** @var IURLGenerator */ |
|
42 | + protected $url; |
|
43 | + /** @var array */ |
|
44 | + protected $federatedContacts; |
|
45 | + /** @var ICloudIdManager */ |
|
46 | + protected $cloudIdManager; |
|
47 | + |
|
48 | + /** |
|
49 | + * @param IFactory $factory |
|
50 | + * @param IManager $contactsManager |
|
51 | + * @param IURLGenerator $url |
|
52 | + * @param ICloudIdManager $cloudIdManager |
|
53 | + */ |
|
54 | + public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url, ICloudIdManager $cloudIdManager) { |
|
55 | + $this->factory = $factory; |
|
56 | + $this->contactsManager = $contactsManager; |
|
57 | + $this->url = $url; |
|
58 | + $this->cloudIdManager = $cloudIdManager; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @param INotification $notification |
|
63 | + * @param string $languageCode The code of the language that should be used to prepare the notification |
|
64 | + * @return INotification |
|
65 | + * @throws \InvalidArgumentException |
|
66 | + */ |
|
67 | + public function prepare(INotification $notification, $languageCode) { |
|
68 | + if ($notification->getApp() !== 'files_sharing') { |
|
69 | + // Not my app => throw |
|
70 | + throw new \InvalidArgumentException(); |
|
71 | + } |
|
72 | + |
|
73 | + // Read the language from the notification |
|
74 | + $l = $this->factory->get('files_sharing', $languageCode); |
|
75 | + |
|
76 | + switch ($notification->getSubject()) { |
|
77 | + // Deal with known subjects |
|
78 | + case 'remote_share': |
|
79 | + $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
80 | + |
|
81 | + $params = $notification->getSubjectParameters(); |
|
82 | + if ($params[0] !== $params[1] && $params[1] !== null) { |
|
83 | + $notification->setParsedSubject( |
|
84 | + $l->t('You received "%3$s" as a remote share from %1$s (on behalf of %2$s)', $params) |
|
85 | + ); |
|
86 | + $notification->setRichSubject( |
|
87 | + $l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'), |
|
88 | + [ |
|
89 | + 'share' => [ |
|
90 | + 'type' => 'pending-federated-share', |
|
91 | + 'id' => $notification->getObjectId(), |
|
92 | + 'name' => $params[2], |
|
93 | + ], |
|
94 | + 'user' => $this->createRemoteUser($params[0]), |
|
95 | + 'behalf' => $this->createRemoteUser($params[1]), |
|
96 | + ] |
|
97 | + ); |
|
98 | + } else { |
|
99 | + $notification->setParsedSubject( |
|
100 | + $l->t('You received "%3$s" as a remote share from %1$s', $params) |
|
101 | + ); |
|
102 | + $notification->setRichSubject( |
|
103 | + $l->t('You received {share} as a remote share from {user}'), |
|
104 | + [ |
|
105 | + 'share' => [ |
|
106 | + 'type' => 'pending-federated-share', |
|
107 | + 'id' => $notification->getObjectId(), |
|
108 | + 'name' => $params[2], |
|
109 | + ], |
|
110 | + 'user' => $this->createRemoteUser($params[0]), |
|
111 | + ] |
|
112 | + ); |
|
113 | + } |
|
114 | + |
|
115 | + // Deal with the actions for a known subject |
|
116 | + foreach ($notification->getActions() as $action) { |
|
117 | + switch ($action->getLabel()) { |
|
118 | + case 'accept': |
|
119 | + $action->setParsedLabel( |
|
120 | + (string) $l->t('Accept') |
|
121 | + ) |
|
122 | + ->setPrimary(true); |
|
123 | + break; |
|
124 | + |
|
125 | + case 'decline': |
|
126 | + $action->setParsedLabel( |
|
127 | + (string) $l->t('Decline') |
|
128 | + ); |
|
129 | + break; |
|
130 | + } |
|
131 | + |
|
132 | + $notification->addParsedAction($action); |
|
133 | + } |
|
134 | + return $notification; |
|
135 | + |
|
136 | + default: |
|
137 | + // Unknown subject => Unknown notification => throw |
|
138 | + throw new \InvalidArgumentException(); |
|
139 | + } |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * @param string $cloudId |
|
144 | + * @return array |
|
145 | + */ |
|
146 | + protected function createRemoteUser($cloudId) { |
|
147 | + $displayName = $cloudId; |
|
148 | + try { |
|
149 | + $resolvedId = $this->cloudIdManager->resolveCloudId($cloudId); |
|
150 | + $displayName = $this->getDisplayName($resolvedId); |
|
151 | + $user = $resolvedId->getUser(); |
|
152 | + $server = $resolvedId->getRemote(); |
|
153 | + } catch (HintException $e) { |
|
154 | + $user = $cloudId; |
|
155 | + $server = ''; |
|
156 | + } |
|
157 | + |
|
158 | + return [ |
|
159 | + 'type' => 'user', |
|
160 | + 'id' => $user, |
|
161 | + 'name' => $displayName, |
|
162 | + 'server' => $server, |
|
163 | + ]; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Try to find the user in the contacts |
|
168 | + * |
|
169 | + * @param ICloudId $cloudId |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + protected function getDisplayName(ICloudId $cloudId) { |
|
173 | + $server = $cloudId->getRemote(); |
|
174 | + $user = $cloudId->getUser(); |
|
175 | + if (strpos($server, 'http://') === 0) { |
|
176 | + $server = substr($server, strlen('http://')); |
|
177 | + } else if (strpos($server, 'https://') === 0) { |
|
178 | + $server = substr($server, strlen('https://')); |
|
179 | + } |
|
180 | + |
|
181 | + try { |
|
182 | + return $this->getDisplayNameFromContact($cloudId->getId()); |
|
183 | + } catch (\OutOfBoundsException $e) { |
|
184 | + } |
|
185 | + |
|
186 | + try { |
|
187 | + $this->getDisplayNameFromContact($user . '@http://' . $server); |
|
188 | + } catch (\OutOfBoundsException $e) { |
|
189 | + } |
|
190 | + |
|
191 | + try { |
|
192 | + $this->getDisplayNameFromContact($user . '@https://' . $server); |
|
193 | + } catch (\OutOfBoundsException $e) { |
|
194 | + } |
|
195 | + |
|
196 | + return $cloudId->getId(); |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Try to find the user in the contacts |
|
201 | + * |
|
202 | + * @param string $federatedCloudId |
|
203 | + * @return string |
|
204 | + * @throws \OutOfBoundsException when there is no contact for the id |
|
205 | + */ |
|
206 | + protected function getDisplayNameFromContact($federatedCloudId) { |
|
207 | + if (isset($this->federatedContacts[$federatedCloudId])) { |
|
208 | + if ($this->federatedContacts[$federatedCloudId] !== '') { |
|
209 | + return $this->federatedContacts[$federatedCloudId]; |
|
210 | + } else { |
|
211 | + throw new \OutOfBoundsException('No contact found for federated cloud id'); |
|
212 | + } |
|
213 | + } |
|
214 | + |
|
215 | + $addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD']); |
|
216 | + foreach ($addressBookEntries as $entry) { |
|
217 | + if (isset($entry['CLOUD'])) { |
|
218 | + foreach ($entry['CLOUD'] as $cloudID) { |
|
219 | + if ($cloudID === $federatedCloudId) { |
|
220 | + $this->federatedContacts[$federatedCloudId] = $entry['FN']; |
|
221 | + return $entry['FN']; |
|
222 | + } |
|
223 | + } |
|
224 | + } |
|
225 | + } |
|
226 | + |
|
227 | + $this->federatedContacts[$federatedCloudId] = ''; |
|
228 | + throw new \OutOfBoundsException('No contact found for federated cloud id'); |
|
229 | + } |
|
230 | 230 | } |
@@ -33,30 +33,30 @@ |
||
33 | 33 | */ |
34 | 34 | class TokenHandler { |
35 | 35 | |
36 | - const TOKEN_LENGTH = 15; |
|
37 | - |
|
38 | - /** @var ISecureRandom */ |
|
39 | - private $secureRandom; |
|
40 | - |
|
41 | - /** |
|
42 | - * TokenHandler constructor. |
|
43 | - * |
|
44 | - * @param ISecureRandom $secureRandom |
|
45 | - */ |
|
46 | - public function __construct(ISecureRandom $secureRandom) { |
|
47 | - $this->secureRandom = $secureRandom; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * generate to token used to authenticate federated shares |
|
52 | - * |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function generateToken() { |
|
56 | - $token = $this->secureRandom->generate( |
|
57 | - self::TOKEN_LENGTH, |
|
58 | - ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS); |
|
59 | - return $token; |
|
60 | - } |
|
36 | + const TOKEN_LENGTH = 15; |
|
37 | + |
|
38 | + /** @var ISecureRandom */ |
|
39 | + private $secureRandom; |
|
40 | + |
|
41 | + /** |
|
42 | + * TokenHandler constructor. |
|
43 | + * |
|
44 | + * @param ISecureRandom $secureRandom |
|
45 | + */ |
|
46 | + public function __construct(ISecureRandom $secureRandom) { |
|
47 | + $this->secureRandom = $secureRandom; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * generate to token used to authenticate federated shares |
|
52 | + * |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function generateToken() { |
|
56 | + $token = $this->secureRandom->generate( |
|
57 | + self::TOKEN_LENGTH, |
|
58 | + ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS); |
|
59 | + return $token; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | } |
@@ -28,10 +28,10 @@ |
||
28 | 28 | <?php if((int)$trustedServer['status'] === TrustedServers::STATUS_OK) { ?> |
29 | 29 | <span class="status success"></span> |
30 | 30 | <?php |
31 | - } elseif( |
|
32 | - (int)$trustedServer['status'] === TrustedServers::STATUS_PENDING || |
|
33 | - (int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED |
|
34 | - ) { ?> |
|
31 | + } elseif( |
|
32 | + (int)$trustedServer['status'] === TrustedServers::STATUS_PENDING || |
|
33 | + (int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED |
|
34 | + ) { ?> |
|
35 | 35 | <span class="status indeterminate"></span> |
36 | 36 | <?php } else {?> |
37 | 37 | <span class="status error"></span> |
@@ -29,41 +29,41 @@ |
||
29 | 29 | |
30 | 30 | class Admin implements ISettings { |
31 | 31 | |
32 | - /** @var TrustedServers */ |
|
33 | - private $trustedServers; |
|
32 | + /** @var TrustedServers */ |
|
33 | + private $trustedServers; |
|
34 | 34 | |
35 | - public function __construct(TrustedServers $trustedServers) { |
|
36 | - $this->trustedServers = $trustedServers; |
|
37 | - } |
|
35 | + public function __construct(TrustedServers $trustedServers) { |
|
36 | + $this->trustedServers = $trustedServers; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return TemplateResponse |
|
41 | - */ |
|
42 | - public function getForm() { |
|
43 | - $parameters = [ |
|
44 | - 'trustedServers' => $this->trustedServers->getServers(), |
|
45 | - 'autoAddServers' => $this->trustedServers->getAutoAddServers(), |
|
46 | - ]; |
|
39 | + /** |
|
40 | + * @return TemplateResponse |
|
41 | + */ |
|
42 | + public function getForm() { |
|
43 | + $parameters = [ |
|
44 | + 'trustedServers' => $this->trustedServers->getServers(), |
|
45 | + 'autoAddServers' => $this->trustedServers->getAutoAddServers(), |
|
46 | + ]; |
|
47 | 47 | |
48 | - return new TemplateResponse('federation', 'settings-admin', $parameters, ''); |
|
49 | - } |
|
48 | + return new TemplateResponse('federation', 'settings-admin', $parameters, ''); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return string the section ID, e.g. 'sharing' |
|
53 | - */ |
|
54 | - public function getSection() { |
|
55 | - return 'sharing'; |
|
56 | - } |
|
51 | + /** |
|
52 | + * @return string the section ID, e.g. 'sharing' |
|
53 | + */ |
|
54 | + public function getSection() { |
|
55 | + return 'sharing'; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return int whether the form should be rather on the top or bottom of |
|
60 | - * the admin section. The forms are arranged in ascending order of the |
|
61 | - * priority values. It is required to return a value between 0 and 100. |
|
62 | - * |
|
63 | - * E.g.: 70 |
|
64 | - */ |
|
65 | - public function getPriority() { |
|
66 | - return 30; |
|
67 | - } |
|
58 | + /** |
|
59 | + * @return int whether the form should be rather on the top or bottom of |
|
60 | + * the admin section. The forms are arranged in ascending order of the |
|
61 | + * priority values. It is required to return a value between 0 and 100. |
|
62 | + * |
|
63 | + * E.g.: 70 |
|
64 | + */ |
|
65 | + public function getPriority() { |
|
66 | + return 30; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | } |
@@ -27,25 +27,25 @@ |
||
27 | 27 | |
28 | 28 | class Hooks { |
29 | 29 | |
30 | - /** @var TrustedServers */ |
|
31 | - private $trustedServers; |
|
32 | - |
|
33 | - public function __construct(TrustedServers $trustedServers) { |
|
34 | - $this->trustedServers = $trustedServers; |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * add servers to the list of trusted servers once a federated share was established |
|
39 | - * |
|
40 | - * @param array $params |
|
41 | - */ |
|
42 | - public function addServerHook($params) { |
|
43 | - if ( |
|
44 | - $this->trustedServers->getAutoAddServers() === true && |
|
45 | - $this->trustedServers->isTrustedServer($params['server']) === false |
|
46 | - ) { |
|
47 | - $this->trustedServers->addServer($params['server']); |
|
48 | - } |
|
49 | - } |
|
30 | + /** @var TrustedServers */ |
|
31 | + private $trustedServers; |
|
32 | + |
|
33 | + public function __construct(TrustedServers $trustedServers) { |
|
34 | + $this->trustedServers = $trustedServers; |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * add servers to the list of trusted servers once a federated share was established |
|
39 | + * |
|
40 | + * @param array $params |
|
41 | + */ |
|
42 | + public function addServerHook($params) { |
|
43 | + if ( |
|
44 | + $this->trustedServers->getAutoAddServers() === true && |
|
45 | + $this->trustedServers->isTrustedServer($params['server']) === false |
|
46 | + ) { |
|
47 | + $this->trustedServers->addServer($params['server']); |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | 51 | } |
@@ -26,67 +26,67 @@ |
||
26 | 26 | |
27 | 27 | class PublicAuth implements BackendInterface { |
28 | 28 | |
29 | - /** @var string[] */ |
|
30 | - private $publicURLs; |
|
29 | + /** @var string[] */ |
|
30 | + private $publicURLs; |
|
31 | 31 | |
32 | - public function __construct() { |
|
33 | - $this->publicURLs = [ |
|
34 | - 'public-calendars', |
|
35 | - 'principals/system/public' |
|
36 | - ]; |
|
37 | - } |
|
32 | + public function __construct() { |
|
33 | + $this->publicURLs = [ |
|
34 | + 'public-calendars', |
|
35 | + 'principals/system/public' |
|
36 | + ]; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * When this method is called, the backend must check if authentication was |
|
41 | - * successful. |
|
42 | - * |
|
43 | - * The returned value must be one of the following |
|
44 | - * |
|
45 | - * [true, "principals/username"] |
|
46 | - * [false, "reason for failure"] |
|
47 | - * |
|
48 | - * If authentication was successful, it's expected that the authentication |
|
49 | - * backend returns a so-called principal url. |
|
50 | - * |
|
51 | - * Examples of a principal url: |
|
52 | - * |
|
53 | - * principals/admin |
|
54 | - * principals/user1 |
|
55 | - * principals/users/joe |
|
56 | - * principals/uid/123457 |
|
57 | - * |
|
58 | - * If you don't use WebDAV ACL (RFC3744) we recommend that you simply |
|
59 | - * return a string such as: |
|
60 | - * |
|
61 | - * principals/users/[username] |
|
62 | - * |
|
63 | - * @param RequestInterface $request |
|
64 | - * @param ResponseInterface $response |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - function check(RequestInterface $request, ResponseInterface $response) { |
|
39 | + /** |
|
40 | + * When this method is called, the backend must check if authentication was |
|
41 | + * successful. |
|
42 | + * |
|
43 | + * The returned value must be one of the following |
|
44 | + * |
|
45 | + * [true, "principals/username"] |
|
46 | + * [false, "reason for failure"] |
|
47 | + * |
|
48 | + * If authentication was successful, it's expected that the authentication |
|
49 | + * backend returns a so-called principal url. |
|
50 | + * |
|
51 | + * Examples of a principal url: |
|
52 | + * |
|
53 | + * principals/admin |
|
54 | + * principals/user1 |
|
55 | + * principals/users/joe |
|
56 | + * principals/uid/123457 |
|
57 | + * |
|
58 | + * If you don't use WebDAV ACL (RFC3744) we recommend that you simply |
|
59 | + * return a string such as: |
|
60 | + * |
|
61 | + * principals/users/[username] |
|
62 | + * |
|
63 | + * @param RequestInterface $request |
|
64 | + * @param ResponseInterface $response |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + function check(RequestInterface $request, ResponseInterface $response) { |
|
68 | 68 | |
69 | - if ($this->isRequestPublic($request)) { |
|
70 | - return [true, "principals/system/public"]; |
|
71 | - } |
|
72 | - return [false, "No public access to this resource."]; |
|
73 | - } |
|
69 | + if ($this->isRequestPublic($request)) { |
|
70 | + return [true, "principals/system/public"]; |
|
71 | + } |
|
72 | + return [false, "No public access to this resource."]; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @inheritdoc |
|
77 | - */ |
|
78 | - function challenge(RequestInterface $request, ResponseInterface $response) { |
|
79 | - } |
|
75 | + /** |
|
76 | + * @inheritdoc |
|
77 | + */ |
|
78 | + function challenge(RequestInterface $request, ResponseInterface $response) { |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @param RequestInterface $request |
|
83 | - * @return bool |
|
84 | - */ |
|
85 | - private function isRequestPublic(RequestInterface $request) { |
|
86 | - $url = $request->getPath(); |
|
87 | - $matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) { |
|
88 | - return strpos($url, $publicUrl, 0) === 0; |
|
89 | - }); |
|
90 | - return !empty($matchingUrls); |
|
91 | - } |
|
81 | + /** |
|
82 | + * @param RequestInterface $request |
|
83 | + * @return bool |
|
84 | + */ |
|
85 | + private function isRequestPublic(RequestInterface $request) { |
|
86 | + $url = $request->getPath(); |
|
87 | + $matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) { |
|
88 | + return strpos($url, $publicUrl, 0) === 0; |
|
89 | + }); |
|
90 | + return !empty($matchingUrls); |
|
91 | + } |
|
92 | 92 | } |
@@ -41,130 +41,130 @@ |
||
41 | 41 | */ |
42 | 42 | class Invite implements XmlSerializable { |
43 | 43 | |
44 | - /** |
|
45 | - * The list of users a calendar has been shared to. |
|
46 | - * |
|
47 | - * @var array |
|
48 | - */ |
|
49 | - protected $users; |
|
50 | - |
|
51 | - /** |
|
52 | - * The organizer contains information about the person who shared the |
|
53 | - * object. |
|
54 | - * |
|
55 | - * @var array|null |
|
56 | - */ |
|
57 | - protected $organizer; |
|
58 | - |
|
59 | - /** |
|
60 | - * Creates the property. |
|
61 | - * |
|
62 | - * Users is an array. Each element of the array has the following |
|
63 | - * properties: |
|
64 | - * |
|
65 | - * * href - Often a mailto: address |
|
66 | - * * commonName - Optional, for example a first and lastname for a user. |
|
67 | - * * status - One of the SharingPlugin::STATUS_* constants. |
|
68 | - * * readOnly - true or false |
|
69 | - * * summary - Optional, description of the share |
|
70 | - * |
|
71 | - * The organizer key is optional to specify. It's only useful when a |
|
72 | - * 'sharee' requests the sharing information. |
|
73 | - * |
|
74 | - * The organizer may have the following properties: |
|
75 | - * * href - Often a mailto: address. |
|
76 | - * * commonName - Optional human-readable name. |
|
77 | - * * firstName - Optional first name. |
|
78 | - * * lastName - Optional last name. |
|
79 | - * |
|
80 | - * If you wonder why these two structures are so different, I guess a |
|
81 | - * valid answer is that the current spec is still a draft. |
|
82 | - * |
|
83 | - * @param array $users |
|
84 | - */ |
|
85 | - function __construct(array $users, array $organizer = null) { |
|
86 | - |
|
87 | - $this->users = $users; |
|
88 | - $this->organizer = $organizer; |
|
89 | - |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Returns the list of users, as it was passed to the constructor. |
|
94 | - * |
|
95 | - * @return array |
|
96 | - */ |
|
97 | - function getValue() { |
|
98 | - |
|
99 | - return $this->users; |
|
100 | - |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * The xmlSerialize metod is called during xml writing. |
|
105 | - * |
|
106 | - * Use the $writer argument to write its own xml serialization. |
|
107 | - * |
|
108 | - * An important note: do _not_ create a parent element. Any element |
|
109 | - * implementing XmlSerializble should only ever write what's considered |
|
110 | - * its 'inner xml'. |
|
111 | - * |
|
112 | - * The parent of the current element is responsible for writing a |
|
113 | - * containing element. |
|
114 | - * |
|
115 | - * This allows serializers to be re-used for different element names. |
|
116 | - * |
|
117 | - * If you are opening new elements, you must also close them again. |
|
118 | - * |
|
119 | - * @param Writer $writer |
|
120 | - * @return void |
|
121 | - */ |
|
122 | - function xmlSerialize(Writer $writer) { |
|
123 | - |
|
124 | - $cs = '{' . Plugin::NS_OWNCLOUD . '}'; |
|
125 | - |
|
126 | - if (!is_null($this->organizer)) { |
|
127 | - |
|
128 | - $writer->startElement($cs . 'organizer'); |
|
129 | - $writer->writeElement('{DAV:}href', $this->organizer['href']); |
|
130 | - |
|
131 | - if (isset($this->organizer['commonName']) && $this->organizer['commonName']) { |
|
132 | - $writer->writeElement($cs . 'common-name', $this->organizer['commonName']); |
|
133 | - } |
|
134 | - if (isset($this->organizer['firstName']) && $this->organizer['firstName']) { |
|
135 | - $writer->writeElement($cs . 'first-name', $this->organizer['firstName']); |
|
136 | - } |
|
137 | - if (isset($this->organizer['lastName']) && $this->organizer['lastName']) { |
|
138 | - $writer->writeElement($cs . 'last-name', $this->organizer['lastName']); |
|
139 | - } |
|
140 | - $writer->endElement(); // organizer |
|
141 | - |
|
142 | - } |
|
143 | - |
|
144 | - foreach ($this->users as $user) { |
|
145 | - |
|
146 | - $writer->startElement($cs . 'user'); |
|
147 | - $writer->writeElement('{DAV:}href', $user['href']); |
|
148 | - if (isset($user['commonName']) && $user['commonName']) { |
|
149 | - $writer->writeElement($cs . 'common-name', $user['commonName']); |
|
150 | - } |
|
151 | - $writer->writeElement($cs . 'invite-accepted'); |
|
152 | - |
|
153 | - $writer->startElement($cs . 'access'); |
|
154 | - if ($user['readOnly']) { |
|
155 | - $writer->writeElement($cs . 'read'); |
|
156 | - } else { |
|
157 | - $writer->writeElement($cs . 'read-write'); |
|
158 | - } |
|
159 | - $writer->endElement(); // access |
|
160 | - |
|
161 | - if (isset($user['summary']) && $user['summary']) { |
|
162 | - $writer->writeElement($cs . 'summary', $user['summary']); |
|
163 | - } |
|
164 | - |
|
165 | - $writer->endElement(); //user |
|
166 | - |
|
167 | - } |
|
168 | - |
|
169 | - } |
|
44 | + /** |
|
45 | + * The list of users a calendar has been shared to. |
|
46 | + * |
|
47 | + * @var array |
|
48 | + */ |
|
49 | + protected $users; |
|
50 | + |
|
51 | + /** |
|
52 | + * The organizer contains information about the person who shared the |
|
53 | + * object. |
|
54 | + * |
|
55 | + * @var array|null |
|
56 | + */ |
|
57 | + protected $organizer; |
|
58 | + |
|
59 | + /** |
|
60 | + * Creates the property. |
|
61 | + * |
|
62 | + * Users is an array. Each element of the array has the following |
|
63 | + * properties: |
|
64 | + * |
|
65 | + * * href - Often a mailto: address |
|
66 | + * * commonName - Optional, for example a first and lastname for a user. |
|
67 | + * * status - One of the SharingPlugin::STATUS_* constants. |
|
68 | + * * readOnly - true or false |
|
69 | + * * summary - Optional, description of the share |
|
70 | + * |
|
71 | + * The organizer key is optional to specify. It's only useful when a |
|
72 | + * 'sharee' requests the sharing information. |
|
73 | + * |
|
74 | + * The organizer may have the following properties: |
|
75 | + * * href - Often a mailto: address. |
|
76 | + * * commonName - Optional human-readable name. |
|
77 | + * * firstName - Optional first name. |
|
78 | + * * lastName - Optional last name. |
|
79 | + * |
|
80 | + * If you wonder why these two structures are so different, I guess a |
|
81 | + * valid answer is that the current spec is still a draft. |
|
82 | + * |
|
83 | + * @param array $users |
|
84 | + */ |
|
85 | + function __construct(array $users, array $organizer = null) { |
|
86 | + |
|
87 | + $this->users = $users; |
|
88 | + $this->organizer = $organizer; |
|
89 | + |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Returns the list of users, as it was passed to the constructor. |
|
94 | + * |
|
95 | + * @return array |
|
96 | + */ |
|
97 | + function getValue() { |
|
98 | + |
|
99 | + return $this->users; |
|
100 | + |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * The xmlSerialize metod is called during xml writing. |
|
105 | + * |
|
106 | + * Use the $writer argument to write its own xml serialization. |
|
107 | + * |
|
108 | + * An important note: do _not_ create a parent element. Any element |
|
109 | + * implementing XmlSerializble should only ever write what's considered |
|
110 | + * its 'inner xml'. |
|
111 | + * |
|
112 | + * The parent of the current element is responsible for writing a |
|
113 | + * containing element. |
|
114 | + * |
|
115 | + * This allows serializers to be re-used for different element names. |
|
116 | + * |
|
117 | + * If you are opening new elements, you must also close them again. |
|
118 | + * |
|
119 | + * @param Writer $writer |
|
120 | + * @return void |
|
121 | + */ |
|
122 | + function xmlSerialize(Writer $writer) { |
|
123 | + |
|
124 | + $cs = '{' . Plugin::NS_OWNCLOUD . '}'; |
|
125 | + |
|
126 | + if (!is_null($this->organizer)) { |
|
127 | + |
|
128 | + $writer->startElement($cs . 'organizer'); |
|
129 | + $writer->writeElement('{DAV:}href', $this->organizer['href']); |
|
130 | + |
|
131 | + if (isset($this->organizer['commonName']) && $this->organizer['commonName']) { |
|
132 | + $writer->writeElement($cs . 'common-name', $this->organizer['commonName']); |
|
133 | + } |
|
134 | + if (isset($this->organizer['firstName']) && $this->organizer['firstName']) { |
|
135 | + $writer->writeElement($cs . 'first-name', $this->organizer['firstName']); |
|
136 | + } |
|
137 | + if (isset($this->organizer['lastName']) && $this->organizer['lastName']) { |
|
138 | + $writer->writeElement($cs . 'last-name', $this->organizer['lastName']); |
|
139 | + } |
|
140 | + $writer->endElement(); // organizer |
|
141 | + |
|
142 | + } |
|
143 | + |
|
144 | + foreach ($this->users as $user) { |
|
145 | + |
|
146 | + $writer->startElement($cs . 'user'); |
|
147 | + $writer->writeElement('{DAV:}href', $user['href']); |
|
148 | + if (isset($user['commonName']) && $user['commonName']) { |
|
149 | + $writer->writeElement($cs . 'common-name', $user['commonName']); |
|
150 | + } |
|
151 | + $writer->writeElement($cs . 'invite-accepted'); |
|
152 | + |
|
153 | + $writer->startElement($cs . 'access'); |
|
154 | + if ($user['readOnly']) { |
|
155 | + $writer->writeElement($cs . 'read'); |
|
156 | + } else { |
|
157 | + $writer->writeElement($cs . 'read-write'); |
|
158 | + } |
|
159 | + $writer->endElement(); // access |
|
160 | + |
|
161 | + if (isset($user['summary']) && $user['summary']) { |
|
162 | + $writer->writeElement($cs . 'summary', $user['summary']); |
|
163 | + } |
|
164 | + |
|
165 | + $writer->endElement(); //user |
|
166 | + |
|
167 | + } |
|
168 | + |
|
169 | + } |
|
170 | 170 | } |
@@ -28,48 +28,48 @@ |
||
28 | 28 | */ |
29 | 29 | interface IShareable extends INode { |
30 | 30 | |
31 | - /** |
|
32 | - * Updates the list of shares. |
|
33 | - * |
|
34 | - * The first array is a list of people that are to be added to the |
|
35 | - * resource. |
|
36 | - * |
|
37 | - * Every element in the add array has the following properties: |
|
38 | - * * href - A url. Usually a mailto: address |
|
39 | - * * commonName - Usually a first and last name, or false |
|
40 | - * * summary - A description of the share, can also be false |
|
41 | - * * readOnly - A boolean value |
|
42 | - * |
|
43 | - * Every element in the remove array is just the address string. |
|
44 | - * |
|
45 | - * @param array $add |
|
46 | - * @param array $remove |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - function updateShares(array $add, array $remove); |
|
31 | + /** |
|
32 | + * Updates the list of shares. |
|
33 | + * |
|
34 | + * The first array is a list of people that are to be added to the |
|
35 | + * resource. |
|
36 | + * |
|
37 | + * Every element in the add array has the following properties: |
|
38 | + * * href - A url. Usually a mailto: address |
|
39 | + * * commonName - Usually a first and last name, or false |
|
40 | + * * summary - A description of the share, can also be false |
|
41 | + * * readOnly - A boolean value |
|
42 | + * |
|
43 | + * Every element in the remove array is just the address string. |
|
44 | + * |
|
45 | + * @param array $add |
|
46 | + * @param array $remove |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + function updateShares(array $add, array $remove); |
|
50 | 50 | |
51 | - /** |
|
52 | - * Returns the list of people whom this resource is shared with. |
|
53 | - * |
|
54 | - * Every element in this array should have the following properties: |
|
55 | - * * href - Often a mailto: address |
|
56 | - * * commonName - Optional, for example a first + last name |
|
57 | - * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. |
|
58 | - * * readOnly - boolean |
|
59 | - * * summary - Optional, a description for the share |
|
60 | - * |
|
61 | - * @return array |
|
62 | - */ |
|
63 | - function getShares(); |
|
51 | + /** |
|
52 | + * Returns the list of people whom this resource is shared with. |
|
53 | + * |
|
54 | + * Every element in this array should have the following properties: |
|
55 | + * * href - Often a mailto: address |
|
56 | + * * commonName - Optional, for example a first + last name |
|
57 | + * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. |
|
58 | + * * readOnly - boolean |
|
59 | + * * summary - Optional, a description for the share |
|
60 | + * |
|
61 | + * @return array |
|
62 | + */ |
|
63 | + function getShares(); |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return int |
|
67 | - */ |
|
68 | - public function getResourceId(); |
|
65 | + /** |
|
66 | + * @return int |
|
67 | + */ |
|
68 | + public function getResourceId(); |
|
69 | 69 | |
70 | - /** |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function getOwner(); |
|
70 | + /** |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function getOwner(); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | \ No newline at end of file |
@@ -41,362 +41,362 @@ |
||
41 | 41 | |
42 | 42 | class FilesReportPlugin extends ServerPlugin { |
43 | 43 | |
44 | - // namespace |
|
45 | - const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
46 | - const REPORT_NAME = '{http://owncloud.org/ns}filter-files'; |
|
47 | - const SYSTEMTAG_PROPERTYNAME = '{http://owncloud.org/ns}systemtag'; |
|
48 | - |
|
49 | - /** |
|
50 | - * Reference to main server object |
|
51 | - * |
|
52 | - * @var \Sabre\DAV\Server |
|
53 | - */ |
|
54 | - private $server; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var Tree |
|
58 | - */ |
|
59 | - private $tree; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var View |
|
63 | - */ |
|
64 | - private $fileView; |
|
65 | - |
|
66 | - /** |
|
67 | - * @var ISystemTagManager |
|
68 | - */ |
|
69 | - private $tagManager; |
|
70 | - |
|
71 | - /** |
|
72 | - * @var ISystemTagObjectMapper |
|
73 | - */ |
|
74 | - private $tagMapper; |
|
75 | - |
|
76 | - /** |
|
77 | - * Manager for private tags |
|
78 | - * |
|
79 | - * @var ITagManager |
|
80 | - */ |
|
81 | - private $fileTagger; |
|
82 | - |
|
83 | - /** |
|
84 | - * @var IUserSession |
|
85 | - */ |
|
86 | - private $userSession; |
|
87 | - |
|
88 | - /** |
|
89 | - * @var IGroupManager |
|
90 | - */ |
|
91 | - private $groupManager; |
|
92 | - |
|
93 | - /** |
|
94 | - * @var Folder |
|
95 | - */ |
|
96 | - private $userFolder; |
|
97 | - |
|
98 | - /** |
|
99 | - * @param Tree $tree |
|
100 | - * @param View $view |
|
101 | - * @param ISystemTagManager $tagManager |
|
102 | - * @param ISystemTagObjectMapper $tagMapper |
|
103 | - * @param ITagManager $fileTagger manager for private tags |
|
104 | - * @param IUserSession $userSession |
|
105 | - * @param IGroupManager $groupManager |
|
106 | - * @param Folder $userFolder |
|
107 | - */ |
|
108 | - public function __construct(Tree $tree, |
|
109 | - View $view, |
|
110 | - ISystemTagManager $tagManager, |
|
111 | - ISystemTagObjectMapper $tagMapper, |
|
112 | - ITagManager $fileTagger, |
|
113 | - IUserSession $userSession, |
|
114 | - IGroupManager $groupManager, |
|
115 | - Folder $userFolder |
|
116 | - ) { |
|
117 | - $this->tree = $tree; |
|
118 | - $this->fileView = $view; |
|
119 | - $this->tagManager = $tagManager; |
|
120 | - $this->tagMapper = $tagMapper; |
|
121 | - $this->fileTagger = $fileTagger; |
|
122 | - $this->userSession = $userSession; |
|
123 | - $this->groupManager = $groupManager; |
|
124 | - $this->userFolder = $userFolder; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * This initializes the plugin. |
|
129 | - * |
|
130 | - * This function is called by \Sabre\DAV\Server, after |
|
131 | - * addPlugin is called. |
|
132 | - * |
|
133 | - * This method should set up the required event subscriptions. |
|
134 | - * |
|
135 | - * @param \Sabre\DAV\Server $server |
|
136 | - * @return void |
|
137 | - */ |
|
138 | - public function initialize(\Sabre\DAV\Server $server) { |
|
139 | - |
|
140 | - $server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc'; |
|
141 | - |
|
142 | - $this->server = $server; |
|
143 | - $this->server->on('report', array($this, 'onReport')); |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * Returns a list of reports this plugin supports. |
|
148 | - * |
|
149 | - * This will be used in the {DAV:}supported-report-set property. |
|
150 | - * |
|
151 | - * @param string $uri |
|
152 | - * @return array |
|
153 | - */ |
|
154 | - public function getSupportedReportSet($uri) { |
|
155 | - return [self::REPORT_NAME]; |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * REPORT operations to look for files |
|
160 | - * |
|
161 | - * @param string $reportName |
|
162 | - * @param $report |
|
163 | - * @param string $uri |
|
164 | - * @return bool |
|
165 | - * @throws BadRequest |
|
166 | - * @throws PreconditionFailed |
|
167 | - * @internal param $ [] $report |
|
168 | - */ |
|
169 | - public function onReport($reportName, $report, $uri) { |
|
170 | - $reportTargetNode = $this->server->tree->getNodeForPath($uri); |
|
171 | - if (!$reportTargetNode instanceof Directory || $reportName !== self::REPORT_NAME) { |
|
172 | - return; |
|
173 | - } |
|
174 | - |
|
175 | - $ns = '{' . $this::NS_OWNCLOUD . '}'; |
|
176 | - $requestedProps = []; |
|
177 | - $filterRules = []; |
|
178 | - |
|
179 | - // parse report properties and gather filter info |
|
180 | - foreach ($report as $reportProps) { |
|
181 | - $name = $reportProps['name']; |
|
182 | - if ($name === $ns . 'filter-rules') { |
|
183 | - $filterRules = $reportProps['value']; |
|
184 | - } else if ($name === '{DAV:}prop') { |
|
185 | - // propfind properties |
|
186 | - foreach ($reportProps['value'] as $propVal) { |
|
187 | - $requestedProps[] = $propVal['name']; |
|
188 | - } |
|
189 | - } |
|
190 | - } |
|
191 | - |
|
192 | - if (empty($filterRules)) { |
|
193 | - // an empty filter would return all existing files which would be slow |
|
194 | - throw new BadRequest('Missing filter-rule block in request'); |
|
195 | - } |
|
196 | - |
|
197 | - // gather all file ids matching filter |
|
198 | - try { |
|
199 | - $resultFileIds = $this->processFilterRules($filterRules); |
|
200 | - } catch (TagNotFoundException $e) { |
|
201 | - throw new PreconditionFailed('Cannot filter by non-existing tag', 0, $e); |
|
202 | - } |
|
203 | - |
|
204 | - // find sabre nodes by file id, restricted to the root node path |
|
205 | - $results = $this->findNodesByFileIds($reportTargetNode, $resultFileIds); |
|
206 | - |
|
207 | - $filesUri = $this->getFilesBaseUri($uri, $reportTargetNode->getPath()); |
|
208 | - $responses = $this->prepareResponses($filesUri, $requestedProps, $results); |
|
209 | - |
|
210 | - $xml = $this->server->xml->write( |
|
211 | - '{DAV:}multistatus', |
|
212 | - new MultiStatus($responses) |
|
213 | - ); |
|
214 | - |
|
215 | - $this->server->httpResponse->setStatus(207); |
|
216 | - $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); |
|
217 | - $this->server->httpResponse->setBody($xml); |
|
218 | - |
|
219 | - return false; |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Returns the base uri of the files root by removing |
|
224 | - * the subpath from the URI |
|
225 | - * |
|
226 | - * @param string $uri URI from this request |
|
227 | - * @param string $subPath subpath to remove from the URI |
|
228 | - * |
|
229 | - * @return string files base uri |
|
230 | - */ |
|
231 | - private function getFilesBaseUri($uri, $subPath) { |
|
232 | - $uri = trim($uri, '/'); |
|
233 | - $subPath = trim($subPath, '/'); |
|
234 | - if (empty($subPath)) { |
|
235 | - $filesUri = $uri; |
|
236 | - } else { |
|
237 | - $filesUri = substr($uri, 0, strlen($uri) - strlen($subPath)); |
|
238 | - } |
|
239 | - $filesUri = trim($filesUri, '/'); |
|
240 | - if (empty($filesUri)) { |
|
241 | - return ''; |
|
242 | - } |
|
243 | - return '/' . $filesUri; |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * Find file ids matching the given filter rules |
|
248 | - * |
|
249 | - * @param array $filterRules |
|
250 | - * @return array array of unique file id results |
|
251 | - * |
|
252 | - * @throws TagNotFoundException whenever a tag was not found |
|
253 | - */ |
|
254 | - protected function processFilterRules($filterRules) { |
|
255 | - $ns = '{' . $this::NS_OWNCLOUD . '}'; |
|
256 | - $resultFileIds = null; |
|
257 | - $systemTagIds = []; |
|
258 | - $favoriteFilter = null; |
|
259 | - foreach ($filterRules as $filterRule) { |
|
260 | - if ($filterRule['name'] === $ns . 'systemtag') { |
|
261 | - $systemTagIds[] = $filterRule['value']; |
|
262 | - } |
|
263 | - if ($filterRule['name'] === $ns . 'favorite') { |
|
264 | - $favoriteFilter = true; |
|
265 | - } |
|
266 | - } |
|
267 | - |
|
268 | - if ($favoriteFilter !== null) { |
|
269 | - $resultFileIds = $this->fileTagger->load('files')->getFavorites(); |
|
270 | - if (empty($resultFileIds)) { |
|
271 | - return []; |
|
272 | - } |
|
273 | - } |
|
274 | - |
|
275 | - if (!empty($systemTagIds)) { |
|
276 | - $fileIds = $this->getSystemTagFileIds($systemTagIds); |
|
277 | - if (empty($resultFileIds)) { |
|
278 | - $resultFileIds = $fileIds; |
|
279 | - } else { |
|
280 | - $resultFileIds = array_intersect($fileIds, $resultFileIds); |
|
281 | - } |
|
282 | - } |
|
283 | - |
|
284 | - return $resultFileIds; |
|
285 | - } |
|
286 | - |
|
287 | - private function getSystemTagFileIds($systemTagIds) { |
|
288 | - $resultFileIds = null; |
|
289 | - |
|
290 | - // check user permissions, if applicable |
|
291 | - if (!$this->isAdmin()) { |
|
292 | - // check visibility/permission |
|
293 | - $tags = $this->tagManager->getTagsByIds($systemTagIds); |
|
294 | - $unknownTagIds = []; |
|
295 | - foreach ($tags as $tag) { |
|
296 | - if (!$tag->isUserVisible()) { |
|
297 | - $unknownTagIds[] = $tag->getId(); |
|
298 | - } |
|
299 | - } |
|
300 | - |
|
301 | - if (!empty($unknownTagIds)) { |
|
302 | - throw new TagNotFoundException('Tag with ids ' . implode(', ', $unknownTagIds) . ' not found'); |
|
303 | - } |
|
304 | - } |
|
305 | - |
|
306 | - // fetch all file ids and intersect them |
|
307 | - foreach ($systemTagIds as $systemTagId) { |
|
308 | - $fileIds = $this->tagMapper->getObjectIdsForTags($systemTagId, 'files'); |
|
309 | - |
|
310 | - if (empty($fileIds)) { |
|
311 | - // This tag has no files, nothing can ever show up |
|
312 | - return []; |
|
313 | - } |
|
314 | - |
|
315 | - // first run ? |
|
316 | - if ($resultFileIds === null) { |
|
317 | - $resultFileIds = $fileIds; |
|
318 | - } else { |
|
319 | - $resultFileIds = array_intersect($resultFileIds, $fileIds); |
|
320 | - } |
|
321 | - |
|
322 | - if (empty($resultFileIds)) { |
|
323 | - // Empty intersection, nothing can show up anymore |
|
324 | - return []; |
|
325 | - } |
|
326 | - } |
|
327 | - return $resultFileIds; |
|
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * Prepare propfind response for the given nodes |
|
332 | - * |
|
333 | - * @param string $filesUri $filesUri URI leading to root of the files URI, |
|
334 | - * with a leading slash but no trailing slash |
|
335 | - * @param string[] $requestedProps requested properties |
|
336 | - * @param Node[] nodes nodes for which to fetch and prepare responses |
|
337 | - * @return Response[] |
|
338 | - */ |
|
339 | - public function prepareResponses($filesUri, $requestedProps, $nodes) { |
|
340 | - $responses = []; |
|
341 | - foreach ($nodes as $node) { |
|
342 | - $propFind = new PropFind($filesUri . $node->getPath(), $requestedProps); |
|
343 | - |
|
344 | - $this->server->getPropertiesByNode($propFind, $node); |
|
345 | - // copied from Sabre Server's getPropertiesForPath |
|
346 | - $result = $propFind->getResultForMultiStatus(); |
|
347 | - $result['href'] = $propFind->getPath(); |
|
348 | - |
|
349 | - $resourceType = $this->server->getResourceTypeForNode($node); |
|
350 | - if (in_array('{DAV:}collection', $resourceType) || in_array('{DAV:}principal', $resourceType)) { |
|
351 | - $result['href'] .= '/'; |
|
352 | - } |
|
353 | - |
|
354 | - $responses[] = new Response( |
|
355 | - rtrim($this->server->getBaseUri(), '/') . $filesUri . $node->getPath(), |
|
356 | - $result, |
|
357 | - 200 |
|
358 | - ); |
|
359 | - } |
|
360 | - return $responses; |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * Find Sabre nodes by file ids |
|
365 | - * |
|
366 | - * @param Node $rootNode root node for search |
|
367 | - * @param array $fileIds file ids |
|
368 | - * @return Node[] array of Sabre nodes |
|
369 | - */ |
|
370 | - public function findNodesByFileIds($rootNode, $fileIds) { |
|
371 | - $folder = $this->userFolder; |
|
372 | - if (trim($rootNode->getPath(), '/') !== '') { |
|
373 | - $folder = $folder->get($rootNode->getPath()); |
|
374 | - } |
|
375 | - |
|
376 | - $results = []; |
|
377 | - foreach ($fileIds as $fileId) { |
|
378 | - $entry = $folder->getById($fileId); |
|
379 | - if ($entry) { |
|
380 | - $entry = current($entry); |
|
381 | - if ($entry instanceof \OCP\Files\File) { |
|
382 | - $results[] = new File($this->fileView, $entry); |
|
383 | - } else if ($entry instanceof \OCP\Files\Folder) { |
|
384 | - $results[] = new Directory($this->fileView, $entry); |
|
385 | - } |
|
386 | - } |
|
387 | - } |
|
388 | - |
|
389 | - return $results; |
|
390 | - } |
|
391 | - |
|
392 | - /** |
|
393 | - * Returns whether the currently logged in user is an administrator |
|
394 | - */ |
|
395 | - private function isAdmin() { |
|
396 | - $user = $this->userSession->getUser(); |
|
397 | - if ($user !== null) { |
|
398 | - return $this->groupManager->isAdmin($user->getUID()); |
|
399 | - } |
|
400 | - return false; |
|
401 | - } |
|
44 | + // namespace |
|
45 | + const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
46 | + const REPORT_NAME = '{http://owncloud.org/ns}filter-files'; |
|
47 | + const SYSTEMTAG_PROPERTYNAME = '{http://owncloud.org/ns}systemtag'; |
|
48 | + |
|
49 | + /** |
|
50 | + * Reference to main server object |
|
51 | + * |
|
52 | + * @var \Sabre\DAV\Server |
|
53 | + */ |
|
54 | + private $server; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var Tree |
|
58 | + */ |
|
59 | + private $tree; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var View |
|
63 | + */ |
|
64 | + private $fileView; |
|
65 | + |
|
66 | + /** |
|
67 | + * @var ISystemTagManager |
|
68 | + */ |
|
69 | + private $tagManager; |
|
70 | + |
|
71 | + /** |
|
72 | + * @var ISystemTagObjectMapper |
|
73 | + */ |
|
74 | + private $tagMapper; |
|
75 | + |
|
76 | + /** |
|
77 | + * Manager for private tags |
|
78 | + * |
|
79 | + * @var ITagManager |
|
80 | + */ |
|
81 | + private $fileTagger; |
|
82 | + |
|
83 | + /** |
|
84 | + * @var IUserSession |
|
85 | + */ |
|
86 | + private $userSession; |
|
87 | + |
|
88 | + /** |
|
89 | + * @var IGroupManager |
|
90 | + */ |
|
91 | + private $groupManager; |
|
92 | + |
|
93 | + /** |
|
94 | + * @var Folder |
|
95 | + */ |
|
96 | + private $userFolder; |
|
97 | + |
|
98 | + /** |
|
99 | + * @param Tree $tree |
|
100 | + * @param View $view |
|
101 | + * @param ISystemTagManager $tagManager |
|
102 | + * @param ISystemTagObjectMapper $tagMapper |
|
103 | + * @param ITagManager $fileTagger manager for private tags |
|
104 | + * @param IUserSession $userSession |
|
105 | + * @param IGroupManager $groupManager |
|
106 | + * @param Folder $userFolder |
|
107 | + */ |
|
108 | + public function __construct(Tree $tree, |
|
109 | + View $view, |
|
110 | + ISystemTagManager $tagManager, |
|
111 | + ISystemTagObjectMapper $tagMapper, |
|
112 | + ITagManager $fileTagger, |
|
113 | + IUserSession $userSession, |
|
114 | + IGroupManager $groupManager, |
|
115 | + Folder $userFolder |
|
116 | + ) { |
|
117 | + $this->tree = $tree; |
|
118 | + $this->fileView = $view; |
|
119 | + $this->tagManager = $tagManager; |
|
120 | + $this->tagMapper = $tagMapper; |
|
121 | + $this->fileTagger = $fileTagger; |
|
122 | + $this->userSession = $userSession; |
|
123 | + $this->groupManager = $groupManager; |
|
124 | + $this->userFolder = $userFolder; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * This initializes the plugin. |
|
129 | + * |
|
130 | + * This function is called by \Sabre\DAV\Server, after |
|
131 | + * addPlugin is called. |
|
132 | + * |
|
133 | + * This method should set up the required event subscriptions. |
|
134 | + * |
|
135 | + * @param \Sabre\DAV\Server $server |
|
136 | + * @return void |
|
137 | + */ |
|
138 | + public function initialize(\Sabre\DAV\Server $server) { |
|
139 | + |
|
140 | + $server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc'; |
|
141 | + |
|
142 | + $this->server = $server; |
|
143 | + $this->server->on('report', array($this, 'onReport')); |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * Returns a list of reports this plugin supports. |
|
148 | + * |
|
149 | + * This will be used in the {DAV:}supported-report-set property. |
|
150 | + * |
|
151 | + * @param string $uri |
|
152 | + * @return array |
|
153 | + */ |
|
154 | + public function getSupportedReportSet($uri) { |
|
155 | + return [self::REPORT_NAME]; |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * REPORT operations to look for files |
|
160 | + * |
|
161 | + * @param string $reportName |
|
162 | + * @param $report |
|
163 | + * @param string $uri |
|
164 | + * @return bool |
|
165 | + * @throws BadRequest |
|
166 | + * @throws PreconditionFailed |
|
167 | + * @internal param $ [] $report |
|
168 | + */ |
|
169 | + public function onReport($reportName, $report, $uri) { |
|
170 | + $reportTargetNode = $this->server->tree->getNodeForPath($uri); |
|
171 | + if (!$reportTargetNode instanceof Directory || $reportName !== self::REPORT_NAME) { |
|
172 | + return; |
|
173 | + } |
|
174 | + |
|
175 | + $ns = '{' . $this::NS_OWNCLOUD . '}'; |
|
176 | + $requestedProps = []; |
|
177 | + $filterRules = []; |
|
178 | + |
|
179 | + // parse report properties and gather filter info |
|
180 | + foreach ($report as $reportProps) { |
|
181 | + $name = $reportProps['name']; |
|
182 | + if ($name === $ns . 'filter-rules') { |
|
183 | + $filterRules = $reportProps['value']; |
|
184 | + } else if ($name === '{DAV:}prop') { |
|
185 | + // propfind properties |
|
186 | + foreach ($reportProps['value'] as $propVal) { |
|
187 | + $requestedProps[] = $propVal['name']; |
|
188 | + } |
|
189 | + } |
|
190 | + } |
|
191 | + |
|
192 | + if (empty($filterRules)) { |
|
193 | + // an empty filter would return all existing files which would be slow |
|
194 | + throw new BadRequest('Missing filter-rule block in request'); |
|
195 | + } |
|
196 | + |
|
197 | + // gather all file ids matching filter |
|
198 | + try { |
|
199 | + $resultFileIds = $this->processFilterRules($filterRules); |
|
200 | + } catch (TagNotFoundException $e) { |
|
201 | + throw new PreconditionFailed('Cannot filter by non-existing tag', 0, $e); |
|
202 | + } |
|
203 | + |
|
204 | + // find sabre nodes by file id, restricted to the root node path |
|
205 | + $results = $this->findNodesByFileIds($reportTargetNode, $resultFileIds); |
|
206 | + |
|
207 | + $filesUri = $this->getFilesBaseUri($uri, $reportTargetNode->getPath()); |
|
208 | + $responses = $this->prepareResponses($filesUri, $requestedProps, $results); |
|
209 | + |
|
210 | + $xml = $this->server->xml->write( |
|
211 | + '{DAV:}multistatus', |
|
212 | + new MultiStatus($responses) |
|
213 | + ); |
|
214 | + |
|
215 | + $this->server->httpResponse->setStatus(207); |
|
216 | + $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); |
|
217 | + $this->server->httpResponse->setBody($xml); |
|
218 | + |
|
219 | + return false; |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * Returns the base uri of the files root by removing |
|
224 | + * the subpath from the URI |
|
225 | + * |
|
226 | + * @param string $uri URI from this request |
|
227 | + * @param string $subPath subpath to remove from the URI |
|
228 | + * |
|
229 | + * @return string files base uri |
|
230 | + */ |
|
231 | + private function getFilesBaseUri($uri, $subPath) { |
|
232 | + $uri = trim($uri, '/'); |
|
233 | + $subPath = trim($subPath, '/'); |
|
234 | + if (empty($subPath)) { |
|
235 | + $filesUri = $uri; |
|
236 | + } else { |
|
237 | + $filesUri = substr($uri, 0, strlen($uri) - strlen($subPath)); |
|
238 | + } |
|
239 | + $filesUri = trim($filesUri, '/'); |
|
240 | + if (empty($filesUri)) { |
|
241 | + return ''; |
|
242 | + } |
|
243 | + return '/' . $filesUri; |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * Find file ids matching the given filter rules |
|
248 | + * |
|
249 | + * @param array $filterRules |
|
250 | + * @return array array of unique file id results |
|
251 | + * |
|
252 | + * @throws TagNotFoundException whenever a tag was not found |
|
253 | + */ |
|
254 | + protected function processFilterRules($filterRules) { |
|
255 | + $ns = '{' . $this::NS_OWNCLOUD . '}'; |
|
256 | + $resultFileIds = null; |
|
257 | + $systemTagIds = []; |
|
258 | + $favoriteFilter = null; |
|
259 | + foreach ($filterRules as $filterRule) { |
|
260 | + if ($filterRule['name'] === $ns . 'systemtag') { |
|
261 | + $systemTagIds[] = $filterRule['value']; |
|
262 | + } |
|
263 | + if ($filterRule['name'] === $ns . 'favorite') { |
|
264 | + $favoriteFilter = true; |
|
265 | + } |
|
266 | + } |
|
267 | + |
|
268 | + if ($favoriteFilter !== null) { |
|
269 | + $resultFileIds = $this->fileTagger->load('files')->getFavorites(); |
|
270 | + if (empty($resultFileIds)) { |
|
271 | + return []; |
|
272 | + } |
|
273 | + } |
|
274 | + |
|
275 | + if (!empty($systemTagIds)) { |
|
276 | + $fileIds = $this->getSystemTagFileIds($systemTagIds); |
|
277 | + if (empty($resultFileIds)) { |
|
278 | + $resultFileIds = $fileIds; |
|
279 | + } else { |
|
280 | + $resultFileIds = array_intersect($fileIds, $resultFileIds); |
|
281 | + } |
|
282 | + } |
|
283 | + |
|
284 | + return $resultFileIds; |
|
285 | + } |
|
286 | + |
|
287 | + private function getSystemTagFileIds($systemTagIds) { |
|
288 | + $resultFileIds = null; |
|
289 | + |
|
290 | + // check user permissions, if applicable |
|
291 | + if (!$this->isAdmin()) { |
|
292 | + // check visibility/permission |
|
293 | + $tags = $this->tagManager->getTagsByIds($systemTagIds); |
|
294 | + $unknownTagIds = []; |
|
295 | + foreach ($tags as $tag) { |
|
296 | + if (!$tag->isUserVisible()) { |
|
297 | + $unknownTagIds[] = $tag->getId(); |
|
298 | + } |
|
299 | + } |
|
300 | + |
|
301 | + if (!empty($unknownTagIds)) { |
|
302 | + throw new TagNotFoundException('Tag with ids ' . implode(', ', $unknownTagIds) . ' not found'); |
|
303 | + } |
|
304 | + } |
|
305 | + |
|
306 | + // fetch all file ids and intersect them |
|
307 | + foreach ($systemTagIds as $systemTagId) { |
|
308 | + $fileIds = $this->tagMapper->getObjectIdsForTags($systemTagId, 'files'); |
|
309 | + |
|
310 | + if (empty($fileIds)) { |
|
311 | + // This tag has no files, nothing can ever show up |
|
312 | + return []; |
|
313 | + } |
|
314 | + |
|
315 | + // first run ? |
|
316 | + if ($resultFileIds === null) { |
|
317 | + $resultFileIds = $fileIds; |
|
318 | + } else { |
|
319 | + $resultFileIds = array_intersect($resultFileIds, $fileIds); |
|
320 | + } |
|
321 | + |
|
322 | + if (empty($resultFileIds)) { |
|
323 | + // Empty intersection, nothing can show up anymore |
|
324 | + return []; |
|
325 | + } |
|
326 | + } |
|
327 | + return $resultFileIds; |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * Prepare propfind response for the given nodes |
|
332 | + * |
|
333 | + * @param string $filesUri $filesUri URI leading to root of the files URI, |
|
334 | + * with a leading slash but no trailing slash |
|
335 | + * @param string[] $requestedProps requested properties |
|
336 | + * @param Node[] nodes nodes for which to fetch and prepare responses |
|
337 | + * @return Response[] |
|
338 | + */ |
|
339 | + public function prepareResponses($filesUri, $requestedProps, $nodes) { |
|
340 | + $responses = []; |
|
341 | + foreach ($nodes as $node) { |
|
342 | + $propFind = new PropFind($filesUri . $node->getPath(), $requestedProps); |
|
343 | + |
|
344 | + $this->server->getPropertiesByNode($propFind, $node); |
|
345 | + // copied from Sabre Server's getPropertiesForPath |
|
346 | + $result = $propFind->getResultForMultiStatus(); |
|
347 | + $result['href'] = $propFind->getPath(); |
|
348 | + |
|
349 | + $resourceType = $this->server->getResourceTypeForNode($node); |
|
350 | + if (in_array('{DAV:}collection', $resourceType) || in_array('{DAV:}principal', $resourceType)) { |
|
351 | + $result['href'] .= '/'; |
|
352 | + } |
|
353 | + |
|
354 | + $responses[] = new Response( |
|
355 | + rtrim($this->server->getBaseUri(), '/') . $filesUri . $node->getPath(), |
|
356 | + $result, |
|
357 | + 200 |
|
358 | + ); |
|
359 | + } |
|
360 | + return $responses; |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * Find Sabre nodes by file ids |
|
365 | + * |
|
366 | + * @param Node $rootNode root node for search |
|
367 | + * @param array $fileIds file ids |
|
368 | + * @return Node[] array of Sabre nodes |
|
369 | + */ |
|
370 | + public function findNodesByFileIds($rootNode, $fileIds) { |
|
371 | + $folder = $this->userFolder; |
|
372 | + if (trim($rootNode->getPath(), '/') !== '') { |
|
373 | + $folder = $folder->get($rootNode->getPath()); |
|
374 | + } |
|
375 | + |
|
376 | + $results = []; |
|
377 | + foreach ($fileIds as $fileId) { |
|
378 | + $entry = $folder->getById($fileId); |
|
379 | + if ($entry) { |
|
380 | + $entry = current($entry); |
|
381 | + if ($entry instanceof \OCP\Files\File) { |
|
382 | + $results[] = new File($this->fileView, $entry); |
|
383 | + } else if ($entry instanceof \OCP\Files\Folder) { |
|
384 | + $results[] = new Directory($this->fileView, $entry); |
|
385 | + } |
|
386 | + } |
|
387 | + } |
|
388 | + |
|
389 | + return $results; |
|
390 | + } |
|
391 | + |
|
392 | + /** |
|
393 | + * Returns whether the currently logged in user is an administrator |
|
394 | + */ |
|
395 | + private function isAdmin() { |
|
396 | + $user = $this->userSession->getUser(); |
|
397 | + if ($user !== null) { |
|
398 | + return $this->groupManager->isAdmin($user->getUID()); |
|
399 | + } |
|
400 | + return false; |
|
401 | + } |
|
402 | 402 | } |