@@ -35,35 +35,35 @@ |
||
35 | 35 | * @since 8.1.0 |
36 | 36 | */ |
37 | 37 | class StreamResponse extends Response implements ICallbackResponse { |
38 | - /** @var string */ |
|
39 | - private $filePath; |
|
38 | + /** @var string */ |
|
39 | + private $filePath; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param string|resource $filePath the path to the file or a file handle which should be streamed |
|
43 | - * @since 8.1.0 |
|
44 | - */ |
|
45 | - public function __construct($filePath) { |
|
46 | - parent::__construct(); |
|
41 | + /** |
|
42 | + * @param string|resource $filePath the path to the file or a file handle which should be streamed |
|
43 | + * @since 8.1.0 |
|
44 | + */ |
|
45 | + public function __construct($filePath) { |
|
46 | + parent::__construct(); |
|
47 | 47 | |
48 | - $this->filePath = $filePath; |
|
49 | - } |
|
48 | + $this->filePath = $filePath; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Streams the file using readfile |
|
54 | - * |
|
55 | - * @param IOutput $output a small wrapper that handles output |
|
56 | - * @since 8.1.0 |
|
57 | - */ |
|
58 | - public function callback(IOutput $output) { |
|
59 | - // handle caching |
|
60 | - if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
61 | - if (!(is_resource($this->filePath) || file_exists($this->filePath))) { |
|
62 | - $output->setHttpResponseCode(Http::STATUS_NOT_FOUND); |
|
63 | - } elseif ($output->setReadfile($this->filePath) === false) { |
|
64 | - $output->setHttpResponseCode(Http::STATUS_BAD_REQUEST); |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
52 | + /** |
|
53 | + * Streams the file using readfile |
|
54 | + * |
|
55 | + * @param IOutput $output a small wrapper that handles output |
|
56 | + * @since 8.1.0 |
|
57 | + */ |
|
58 | + public function callback(IOutput $output) { |
|
59 | + // handle caching |
|
60 | + if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
61 | + if (!(is_resource($this->filePath) || file_exists($this->filePath))) { |
|
62 | + $output->setHttpResponseCode(Http::STATUS_NOT_FOUND); |
|
63 | + } elseif ($output->setReadfile($this->filePath) === false) { |
|
64 | + $output->setHttpResponseCode(Http::STATUS_BAD_REQUEST); |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | 69 | } |
@@ -34,43 +34,43 @@ |
||
34 | 34 | * @since 8.0.0 |
35 | 35 | */ |
36 | 36 | interface IQueryLogger extends SQLLogger { |
37 | - /** |
|
38 | - * Mark the start of a query providing query SQL statement, its parameters and types. |
|
39 | - * This method should be called as close to the DB as possible and after |
|
40 | - * query is finished finalized with stopQuery() method. |
|
41 | - * |
|
42 | - * @param string $sql |
|
43 | - * @param array|null $params |
|
44 | - * @param array|null $types |
|
45 | - * @since 8.0.0 |
|
46 | - */ |
|
47 | - public function startQuery($sql, array $params = null, array $types = null); |
|
37 | + /** |
|
38 | + * Mark the start of a query providing query SQL statement, its parameters and types. |
|
39 | + * This method should be called as close to the DB as possible and after |
|
40 | + * query is finished finalized with stopQuery() method. |
|
41 | + * |
|
42 | + * @param string $sql |
|
43 | + * @param array|null $params |
|
44 | + * @param array|null $types |
|
45 | + * @since 8.0.0 |
|
46 | + */ |
|
47 | + public function startQuery($sql, array $params = null, array $types = null); |
|
48 | 48 | |
49 | - /** |
|
50 | - * Mark the end of the current active query. Ending query should store \OCP\Diagnostics\IQuery to |
|
51 | - * be returned with getQueries() method. |
|
52 | - * |
|
53 | - * @return mixed |
|
54 | - * @since 8.0.0 |
|
55 | - */ |
|
56 | - public function stopQuery(); |
|
49 | + /** |
|
50 | + * Mark the end of the current active query. Ending query should store \OCP\Diagnostics\IQuery to |
|
51 | + * be returned with getQueries() method. |
|
52 | + * |
|
53 | + * @return mixed |
|
54 | + * @since 8.0.0 |
|
55 | + */ |
|
56 | + public function stopQuery(); |
|
57 | 57 | |
58 | - /** |
|
59 | - * This method should return all \OCP\Diagnostics\IQuery objects stored using |
|
60 | - * startQuery()/stopQuery() methods. |
|
61 | - * |
|
62 | - * @return \OCP\Diagnostics\IQuery[] |
|
63 | - * @since 8.0.0 |
|
64 | - */ |
|
65 | - public function getQueries(); |
|
58 | + /** |
|
59 | + * This method should return all \OCP\Diagnostics\IQuery objects stored using |
|
60 | + * startQuery()/stopQuery() methods. |
|
61 | + * |
|
62 | + * @return \OCP\Diagnostics\IQuery[] |
|
63 | + * @since 8.0.0 |
|
64 | + */ |
|
65 | + public function getQueries(); |
|
66 | 66 | |
67 | - /** |
|
68 | - * Activate the module for the duration of the request. Deactivated module |
|
69 | - * does not create and store \OCP\Diagnostics\IQuery objects. |
|
70 | - * Only activated module should create and store objects to be |
|
71 | - * returned with getQueries() call. |
|
72 | - * |
|
73 | - * @since 12.0.0 |
|
74 | - */ |
|
75 | - public function activate(); |
|
67 | + /** |
|
68 | + * Activate the module for the duration of the request. Deactivated module |
|
69 | + * does not create and store \OCP\Diagnostics\IQuery objects. |
|
70 | + * Only activated module should create and store objects to be |
|
71 | + * returned with getQueries() call. |
|
72 | + * |
|
73 | + * @since 12.0.0 |
|
74 | + */ |
|
75 | + public function activate(); |
|
76 | 76 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $searchResult->markExactIdMatch($resultType); |
113 | 113 | } |
114 | 114 | $result['exact'][] = [ |
115 | - 'label' => $contact['FN'] . " ($cloudId)", |
|
115 | + 'label' => $contact['FN']." ($cloudId)", |
|
116 | 116 | 'uuid' => $contact['UID'], |
117 | 117 | 'name' => $contact['FN'], |
118 | 118 | 'type' => $cloudIdType, |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | ]; |
125 | 125 | } else { |
126 | 126 | $result['wide'][] = [ |
127 | - 'label' => $contact['FN'] . " ($cloudId)", |
|
127 | + 'label' => $contact['FN']." ($cloudId)", |
|
128 | 128 | 'uuid' => $contact['UID'], |
129 | 129 | 'name' => $contact['FN'], |
130 | 130 | 'type' => $cloudIdType, |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $localUser = $this->userManager->get($remoteUser); |
155 | 155 | if ($localUser === null || $search !== $localUser->getCloudId()) { |
156 | 156 | $result['exact'][] = [ |
157 | - 'label' => $remoteUser . " ($serverUrl)", |
|
157 | + 'label' => $remoteUser." ($serverUrl)", |
|
158 | 158 | 'uuid' => $remoteUser, |
159 | 159 | 'name' => $remoteUser, |
160 | 160 | 'value' => [ |
@@ -37,160 +37,160 @@ |
||
37 | 37 | use OCP\Share\IShare; |
38 | 38 | |
39 | 39 | class RemotePlugin implements ISearchPlugin { |
40 | - protected $shareeEnumeration; |
|
40 | + protected $shareeEnumeration; |
|
41 | 41 | |
42 | - /** @var IManager */ |
|
43 | - private $contactsManager; |
|
44 | - /** @var ICloudIdManager */ |
|
45 | - private $cloudIdManager; |
|
46 | - /** @var IConfig */ |
|
47 | - private $config; |
|
48 | - /** @var IUserManager */ |
|
49 | - private $userManager; |
|
50 | - /** @var string */ |
|
51 | - private $userId = ''; |
|
42 | + /** @var IManager */ |
|
43 | + private $contactsManager; |
|
44 | + /** @var ICloudIdManager */ |
|
45 | + private $cloudIdManager; |
|
46 | + /** @var IConfig */ |
|
47 | + private $config; |
|
48 | + /** @var IUserManager */ |
|
49 | + private $userManager; |
|
50 | + /** @var string */ |
|
51 | + private $userId = ''; |
|
52 | 52 | |
53 | - public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdManager, IConfig $config, IUserManager $userManager, IUserSession $userSession) { |
|
54 | - $this->contactsManager = $contactsManager; |
|
55 | - $this->cloudIdManager = $cloudIdManager; |
|
56 | - $this->config = $config; |
|
57 | - $this->userManager = $userManager; |
|
58 | - $user = $userSession->getUser(); |
|
59 | - if ($user !== null) { |
|
60 | - $this->userId = $user->getUID(); |
|
61 | - } |
|
62 | - $this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes'; |
|
63 | - } |
|
53 | + public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdManager, IConfig $config, IUserManager $userManager, IUserSession $userSession) { |
|
54 | + $this->contactsManager = $contactsManager; |
|
55 | + $this->cloudIdManager = $cloudIdManager; |
|
56 | + $this->config = $config; |
|
57 | + $this->userManager = $userManager; |
|
58 | + $user = $userSession->getUser(); |
|
59 | + if ($user !== null) { |
|
60 | + $this->userId = $user->getUID(); |
|
61 | + } |
|
62 | + $this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes'; |
|
63 | + } |
|
64 | 64 | |
65 | - public function search($search, $limit, $offset, ISearchResult $searchResult) { |
|
66 | - $result = ['wide' => [], 'exact' => []]; |
|
67 | - $resultType = new SearchResultType('remotes'); |
|
65 | + public function search($search, $limit, $offset, ISearchResult $searchResult) { |
|
66 | + $result = ['wide' => [], 'exact' => []]; |
|
67 | + $resultType = new SearchResultType('remotes'); |
|
68 | 68 | |
69 | - // Search in contacts |
|
70 | - $addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN'], [ |
|
71 | - 'limit' => $limit, |
|
72 | - 'offset' => $offset, |
|
73 | - 'enumeration' => false, |
|
74 | - 'fullmatch' => false, |
|
75 | - ]); |
|
76 | - foreach ($addressBookContacts as $contact) { |
|
77 | - if (isset($contact['isLocalSystemBook'])) { |
|
78 | - continue; |
|
79 | - } |
|
80 | - if (isset($contact['CLOUD'])) { |
|
81 | - $cloudIds = $contact['CLOUD']; |
|
82 | - if (is_string($cloudIds)) { |
|
83 | - $cloudIds = [$cloudIds]; |
|
84 | - } |
|
85 | - $lowerSearch = strtolower($search); |
|
86 | - foreach ($cloudIds as $cloudId) { |
|
87 | - $cloudIdType = ''; |
|
88 | - if (\is_array($cloudId)) { |
|
89 | - $cloudIdData = $cloudId; |
|
90 | - $cloudId = $cloudIdData['value']; |
|
91 | - $cloudIdType = $cloudIdData['type']; |
|
92 | - } |
|
93 | - try { |
|
94 | - [$remoteUser, $serverUrl] = $this->splitUserRemote($cloudId); |
|
95 | - } catch (\InvalidArgumentException $e) { |
|
96 | - continue; |
|
97 | - } |
|
69 | + // Search in contacts |
|
70 | + $addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN'], [ |
|
71 | + 'limit' => $limit, |
|
72 | + 'offset' => $offset, |
|
73 | + 'enumeration' => false, |
|
74 | + 'fullmatch' => false, |
|
75 | + ]); |
|
76 | + foreach ($addressBookContacts as $contact) { |
|
77 | + if (isset($contact['isLocalSystemBook'])) { |
|
78 | + continue; |
|
79 | + } |
|
80 | + if (isset($contact['CLOUD'])) { |
|
81 | + $cloudIds = $contact['CLOUD']; |
|
82 | + if (is_string($cloudIds)) { |
|
83 | + $cloudIds = [$cloudIds]; |
|
84 | + } |
|
85 | + $lowerSearch = strtolower($search); |
|
86 | + foreach ($cloudIds as $cloudId) { |
|
87 | + $cloudIdType = ''; |
|
88 | + if (\is_array($cloudId)) { |
|
89 | + $cloudIdData = $cloudId; |
|
90 | + $cloudId = $cloudIdData['value']; |
|
91 | + $cloudIdType = $cloudIdData['type']; |
|
92 | + } |
|
93 | + try { |
|
94 | + [$remoteUser, $serverUrl] = $this->splitUserRemote($cloudId); |
|
95 | + } catch (\InvalidArgumentException $e) { |
|
96 | + continue; |
|
97 | + } |
|
98 | 98 | |
99 | - $localUser = $this->userManager->get($remoteUser); |
|
100 | - /** |
|
101 | - * Add local share if remote cloud id matches a local user ones |
|
102 | - */ |
|
103 | - if ($localUser !== null && $remoteUser !== $this->userId && $cloudId === $localUser->getCloudId()) { |
|
104 | - $result['wide'][] = [ |
|
105 | - 'label' => $contact['FN'], |
|
106 | - 'uuid' => $contact['UID'], |
|
107 | - 'value' => [ |
|
108 | - 'shareType' => IShare::TYPE_USER, |
|
109 | - 'shareWith' => $remoteUser |
|
110 | - ], |
|
111 | - 'shareWithDisplayNameUnique' => $contact['EMAIL'] !== null && $contact['EMAIL'] !== '' ? $contact['EMAIL'] : $contact['UID'], |
|
112 | - ]; |
|
113 | - } |
|
99 | + $localUser = $this->userManager->get($remoteUser); |
|
100 | + /** |
|
101 | + * Add local share if remote cloud id matches a local user ones |
|
102 | + */ |
|
103 | + if ($localUser !== null && $remoteUser !== $this->userId && $cloudId === $localUser->getCloudId()) { |
|
104 | + $result['wide'][] = [ |
|
105 | + 'label' => $contact['FN'], |
|
106 | + 'uuid' => $contact['UID'], |
|
107 | + 'value' => [ |
|
108 | + 'shareType' => IShare::TYPE_USER, |
|
109 | + 'shareWith' => $remoteUser |
|
110 | + ], |
|
111 | + 'shareWithDisplayNameUnique' => $contact['EMAIL'] !== null && $contact['EMAIL'] !== '' ? $contact['EMAIL'] : $contact['UID'], |
|
112 | + ]; |
|
113 | + } |
|
114 | 114 | |
115 | - if (strtolower($contact['FN']) === $lowerSearch || strtolower($cloudId) === $lowerSearch) { |
|
116 | - if (strtolower($cloudId) === $lowerSearch) { |
|
117 | - $searchResult->markExactIdMatch($resultType); |
|
118 | - } |
|
119 | - $result['exact'][] = [ |
|
120 | - 'label' => $contact['FN'] . " ($cloudId)", |
|
121 | - 'uuid' => $contact['UID'], |
|
122 | - 'name' => $contact['FN'], |
|
123 | - 'type' => $cloudIdType, |
|
124 | - 'value' => [ |
|
125 | - 'shareType' => IShare::TYPE_REMOTE, |
|
126 | - 'shareWith' => $cloudId, |
|
127 | - 'server' => $serverUrl, |
|
128 | - ], |
|
129 | - ]; |
|
130 | - } else { |
|
131 | - $result['wide'][] = [ |
|
132 | - 'label' => $contact['FN'] . " ($cloudId)", |
|
133 | - 'uuid' => $contact['UID'], |
|
134 | - 'name' => $contact['FN'], |
|
135 | - 'type' => $cloudIdType, |
|
136 | - 'value' => [ |
|
137 | - 'shareType' => IShare::TYPE_REMOTE, |
|
138 | - 'shareWith' => $cloudId, |
|
139 | - 'server' => $serverUrl, |
|
140 | - ], |
|
141 | - ]; |
|
142 | - } |
|
143 | - } |
|
144 | - } |
|
145 | - } |
|
115 | + if (strtolower($contact['FN']) === $lowerSearch || strtolower($cloudId) === $lowerSearch) { |
|
116 | + if (strtolower($cloudId) === $lowerSearch) { |
|
117 | + $searchResult->markExactIdMatch($resultType); |
|
118 | + } |
|
119 | + $result['exact'][] = [ |
|
120 | + 'label' => $contact['FN'] . " ($cloudId)", |
|
121 | + 'uuid' => $contact['UID'], |
|
122 | + 'name' => $contact['FN'], |
|
123 | + 'type' => $cloudIdType, |
|
124 | + 'value' => [ |
|
125 | + 'shareType' => IShare::TYPE_REMOTE, |
|
126 | + 'shareWith' => $cloudId, |
|
127 | + 'server' => $serverUrl, |
|
128 | + ], |
|
129 | + ]; |
|
130 | + } else { |
|
131 | + $result['wide'][] = [ |
|
132 | + 'label' => $contact['FN'] . " ($cloudId)", |
|
133 | + 'uuid' => $contact['UID'], |
|
134 | + 'name' => $contact['FN'], |
|
135 | + 'type' => $cloudIdType, |
|
136 | + 'value' => [ |
|
137 | + 'shareType' => IShare::TYPE_REMOTE, |
|
138 | + 'shareWith' => $cloudId, |
|
139 | + 'server' => $serverUrl, |
|
140 | + ], |
|
141 | + ]; |
|
142 | + } |
|
143 | + } |
|
144 | + } |
|
145 | + } |
|
146 | 146 | |
147 | - if (!$this->shareeEnumeration) { |
|
148 | - $result['wide'] = []; |
|
149 | - } else { |
|
150 | - $result['wide'] = array_slice($result['wide'], $offset, $limit); |
|
151 | - } |
|
147 | + if (!$this->shareeEnumeration) { |
|
148 | + $result['wide'] = []; |
|
149 | + } else { |
|
150 | + $result['wide'] = array_slice($result['wide'], $offset, $limit); |
|
151 | + } |
|
152 | 152 | |
153 | - /** |
|
154 | - * Add generic share with remote item for valid cloud ids that are not users of the local instance |
|
155 | - */ |
|
156 | - if (!$searchResult->hasExactIdMatch($resultType) && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) { |
|
157 | - try { |
|
158 | - [$remoteUser, $serverUrl] = $this->splitUserRemote($search); |
|
159 | - $localUser = $this->userManager->get($remoteUser); |
|
160 | - if ($localUser === null || $search !== $localUser->getCloudId()) { |
|
161 | - $result['exact'][] = [ |
|
162 | - 'label' => $remoteUser . " ($serverUrl)", |
|
163 | - 'uuid' => $remoteUser, |
|
164 | - 'name' => $remoteUser, |
|
165 | - 'value' => [ |
|
166 | - 'shareType' => IShare::TYPE_REMOTE, |
|
167 | - 'shareWith' => $search, |
|
168 | - 'server' => $serverUrl, |
|
169 | - ], |
|
170 | - ]; |
|
171 | - } |
|
172 | - } catch (\InvalidArgumentException $e) { |
|
173 | - } |
|
174 | - } |
|
153 | + /** |
|
154 | + * Add generic share with remote item for valid cloud ids that are not users of the local instance |
|
155 | + */ |
|
156 | + if (!$searchResult->hasExactIdMatch($resultType) && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) { |
|
157 | + try { |
|
158 | + [$remoteUser, $serverUrl] = $this->splitUserRemote($search); |
|
159 | + $localUser = $this->userManager->get($remoteUser); |
|
160 | + if ($localUser === null || $search !== $localUser->getCloudId()) { |
|
161 | + $result['exact'][] = [ |
|
162 | + 'label' => $remoteUser . " ($serverUrl)", |
|
163 | + 'uuid' => $remoteUser, |
|
164 | + 'name' => $remoteUser, |
|
165 | + 'value' => [ |
|
166 | + 'shareType' => IShare::TYPE_REMOTE, |
|
167 | + 'shareWith' => $search, |
|
168 | + 'server' => $serverUrl, |
|
169 | + ], |
|
170 | + ]; |
|
171 | + } |
|
172 | + } catch (\InvalidArgumentException $e) { |
|
173 | + } |
|
174 | + } |
|
175 | 175 | |
176 | - $searchResult->addResultSet($resultType, $result['wide'], $result['exact']); |
|
176 | + $searchResult->addResultSet($resultType, $result['wide'], $result['exact']); |
|
177 | 177 | |
178 | - return true; |
|
179 | - } |
|
178 | + return true; |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
182 | - * split user and remote from federated cloud id |
|
183 | - * |
|
184 | - * @param string $address federated share address |
|
185 | - * @return array [user, remoteURL] |
|
186 | - * @throws \InvalidArgumentException |
|
187 | - */ |
|
188 | - public function splitUserRemote($address) { |
|
189 | - try { |
|
190 | - $cloudId = $this->cloudIdManager->resolveCloudId($address); |
|
191 | - return [$cloudId->getUser(), $cloudId->getRemote()]; |
|
192 | - } catch (\InvalidArgumentException $e) { |
|
193 | - throw new \InvalidArgumentException('Invalid Federated Cloud ID', 0, $e); |
|
194 | - } |
|
195 | - } |
|
181 | + /** |
|
182 | + * split user and remote from federated cloud id |
|
183 | + * |
|
184 | + * @param string $address federated share address |
|
185 | + * @return array [user, remoteURL] |
|
186 | + * @throws \InvalidArgumentException |
|
187 | + */ |
|
188 | + public function splitUserRemote($address) { |
|
189 | + try { |
|
190 | + $cloudId = $this->cloudIdManager->resolveCloudId($address); |
|
191 | + return [$cloudId->getUser(), $cloudId->getRemote()]; |
|
192 | + } catch (\InvalidArgumentException $e) { |
|
193 | + throw new \InvalidArgumentException('Invalid Federated Cloud ID', 0, $e); |
|
194 | + } |
|
195 | + } |
|
196 | 196 | } |
@@ -24,12 +24,12 @@ |
||
24 | 24 | namespace OC; |
25 | 25 | |
26 | 26 | class Color { |
27 | - public $r; |
|
28 | - public $g; |
|
29 | - public $b; |
|
30 | - public function __construct($r, $g, $b) { |
|
31 | - $this->r = $r; |
|
32 | - $this->g = $g; |
|
33 | - $this->b = $b; |
|
34 | - } |
|
27 | + public $r; |
|
28 | + public $g; |
|
29 | + public $b; |
|
30 | + public function __construct($r, $g, $b) { |
|
31 | + $this->r = $r; |
|
32 | + $this->g = $g; |
|
33 | + $this->b = $b; |
|
34 | + } |
|
35 | 35 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | - /** @var array $_ */ |
|
3 | - /** @var \OCP\IL10N $l */ |
|
2 | + /** @var array $_ */ |
|
3 | + /** @var \OCP\IL10N $l */ |
|
4 | 4 | script('encryption', 'settings-personal'); |
5 | 5 | ?> |
6 | 6 | <form id="ocDefaultEncryptionModule" class="section"> |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | <br /> |
20 | 20 | <?php p($l->t("Set your old private key password to your current log-in password:")); ?> |
21 | 21 | <?php if ($_["recoveryEnabledForUser"]): |
22 | - p($l->t(" If you don't remember your old password you can ask your administrator to recover your files.")); |
|
23 | - endif; ?> |
|
22 | + p($l->t(" If you don't remember your old password you can ask your administrator to recover your files.")); |
|
23 | + endif; ?> |
|
24 | 24 | <br /> |
25 | 25 | <input |
26 | 26 | type="password" |
@@ -34,14 +34,14 @@ |
||
34 | 34 | use OCP\Util; |
35 | 35 | |
36 | 36 | class LoadAdditionalScripts implements IEventListener { |
37 | - public function handle(Event $event): void { |
|
38 | - if (!($event instanceof LoadAdditionalScriptsEvent)) { |
|
39 | - return; |
|
40 | - } |
|
37 | + public function handle(Event $event): void { |
|
38 | + if (!($event instanceof LoadAdditionalScriptsEvent)) { |
|
39 | + return; |
|
40 | + } |
|
41 | 41 | |
42 | - // TODO: make sure to only include the sidebar script when |
|
43 | - // we properly split it between files list and sidebar |
|
44 | - Util::addScript(Application::APP_ID, 'comments'); |
|
45 | - } |
|
42 | + // TODO: make sure to only include the sidebar script when |
|
43 | + // we properly split it between files list and sidebar |
|
44 | + Util::addScript(Application::APP_ID, 'comments'); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |
@@ -194,7 +194,7 @@ |
||
194 | 194 | $httpClient = $this->clientService->newClient(); |
195 | 195 | |
196 | 196 | try { |
197 | - $response = $httpClient->post($remote . '/index.php/apps/federatedfilesharing/createFederatedShare', |
|
197 | + $response = $httpClient->post($remote.'/index.php/apps/federatedfilesharing/createFederatedShare', |
|
198 | 198 | [ |
199 | 199 | 'body' => |
200 | 200 | [ |
@@ -57,188 +57,188 @@ |
||
57 | 57 | */ |
58 | 58 | class MountPublicLinkController extends Controller { |
59 | 59 | |
60 | - /** @var FederatedShareProvider */ |
|
61 | - private $federatedShareProvider; |
|
62 | - |
|
63 | - /** @var AddressHandler */ |
|
64 | - private $addressHandler; |
|
65 | - |
|
66 | - /** @var IManager */ |
|
67 | - private $shareManager; |
|
68 | - |
|
69 | - /** @var ISession */ |
|
70 | - private $session; |
|
71 | - |
|
72 | - /** @var IL10N */ |
|
73 | - private $l; |
|
74 | - |
|
75 | - /** @var IUserSession */ |
|
76 | - private $userSession; |
|
77 | - |
|
78 | - /** @var IClientService */ |
|
79 | - private $clientService; |
|
80 | - |
|
81 | - /** @var ICloudIdManager */ |
|
82 | - private $cloudIdManager; |
|
83 | - |
|
84 | - /** |
|
85 | - * MountPublicLinkController constructor. |
|
86 | - * |
|
87 | - * @param string $appName |
|
88 | - * @param IRequest $request |
|
89 | - * @param FederatedShareProvider $federatedShareProvider |
|
90 | - * @param IManager $shareManager |
|
91 | - * @param AddressHandler $addressHandler |
|
92 | - * @param ISession $session |
|
93 | - * @param IL10N $l |
|
94 | - * @param IUserSession $userSession |
|
95 | - * @param IClientService $clientService |
|
96 | - * @param ICloudIdManager $cloudIdManager |
|
97 | - */ |
|
98 | - public function __construct($appName, |
|
99 | - IRequest $request, |
|
100 | - FederatedShareProvider $federatedShareProvider, |
|
101 | - IManager $shareManager, |
|
102 | - AddressHandler $addressHandler, |
|
103 | - ISession $session, |
|
104 | - IL10N $l, |
|
105 | - IUserSession $userSession, |
|
106 | - IClientService $clientService, |
|
107 | - ICloudIdManager $cloudIdManager |
|
108 | - ) { |
|
109 | - parent::__construct($appName, $request); |
|
110 | - |
|
111 | - $this->federatedShareProvider = $federatedShareProvider; |
|
112 | - $this->shareManager = $shareManager; |
|
113 | - $this->addressHandler = $addressHandler; |
|
114 | - $this->session = $session; |
|
115 | - $this->l = $l; |
|
116 | - $this->userSession = $userSession; |
|
117 | - $this->clientService = $clientService; |
|
118 | - $this->cloudIdManager = $cloudIdManager; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * send federated share to a user of a public link |
|
123 | - * |
|
124 | - * @NoCSRFRequired |
|
125 | - * @PublicPage |
|
126 | - * @BruteForceProtection(action=publicLink2FederatedShare) |
|
127 | - * |
|
128 | - * @param string $shareWith |
|
129 | - * @param string $token |
|
130 | - * @param string $password |
|
131 | - * @return JSONResponse |
|
132 | - */ |
|
133 | - public function createFederatedShare($shareWith, $token, $password = '') { |
|
134 | - if (!$this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) { |
|
135 | - return new JSONResponse( |
|
136 | - ['message' => 'This server doesn\'t support outgoing federated shares'], |
|
137 | - Http::STATUS_BAD_REQUEST |
|
138 | - ); |
|
139 | - } |
|
140 | - |
|
141 | - try { |
|
142 | - [, $server] = $this->addressHandler->splitUserRemote($shareWith); |
|
143 | - $share = $this->shareManager->getShareByToken($token); |
|
144 | - } catch (HintException $e) { |
|
145 | - $response = new JSONResponse(['message' => $e->getHint()], Http::STATUS_BAD_REQUEST); |
|
146 | - $response->throttle(); |
|
147 | - return $response; |
|
148 | - } |
|
149 | - |
|
150 | - // make sure that user is authenticated in case of a password protected link |
|
151 | - $storedPassword = $share->getPassword(); |
|
152 | - $authenticated = $this->session->get('public_link_authenticated') === $share->getId() || |
|
153 | - $this->shareManager->checkPassword($share, $password); |
|
154 | - if (!empty($storedPassword) && !$authenticated) { |
|
155 | - $response = new JSONResponse( |
|
156 | - ['message' => 'No permission to access the share'], |
|
157 | - Http::STATUS_BAD_REQUEST |
|
158 | - ); |
|
159 | - $response->throttle(); |
|
160 | - return $response; |
|
161 | - } |
|
162 | - |
|
163 | - if (($share->getPermissions() & Constants::PERMISSION_READ) === 0) { |
|
164 | - $response = new JSONResponse( |
|
165 | - ['message' => 'Mounting file drop not supported'], |
|
166 | - Http::STATUS_BAD_REQUEST |
|
167 | - ); |
|
168 | - $response->throttle(); |
|
169 | - return $response; |
|
170 | - } |
|
171 | - |
|
172 | - $share->setSharedWith($shareWith); |
|
173 | - $share->setShareType(IShare::TYPE_REMOTE); |
|
174 | - |
|
175 | - try { |
|
176 | - $this->federatedShareProvider->create($share); |
|
177 | - } catch (\Exception $e) { |
|
178 | - \OC::$server->getLogger()->logException($e, [ |
|
179 | - 'level' => ILogger::WARN, |
|
180 | - 'app' => 'federatedfilesharing', |
|
181 | - ]); |
|
182 | - return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
|
183 | - } |
|
184 | - |
|
185 | - return new JSONResponse(['remoteUrl' => $server]); |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * ask other server to get a federated share |
|
190 | - * |
|
191 | - * @NoAdminRequired |
|
192 | - * |
|
193 | - * @param string $token |
|
194 | - * @param string $remote |
|
195 | - * @param string $password |
|
196 | - * @param string $owner (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
197 | - * @param string $ownerDisplayName (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
198 | - * @param string $name (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
199 | - * @return JSONResponse |
|
200 | - */ |
|
201 | - public function askForFederatedShare($token, $remote, $password = '', $owner = '', $ownerDisplayName = '', $name = '') { |
|
202 | - // check if server admin allows to mount public links from other servers |
|
203 | - if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() === false) { |
|
204 | - return new JSONResponse(['message' => $this->l->t('Server to server sharing is not enabled on this server')], Http::STATUS_BAD_REQUEST); |
|
205 | - } |
|
206 | - |
|
207 | - $cloudId = $this->cloudIdManager->getCloudId($this->userSession->getUser()->getUID(), $this->addressHandler->generateRemoteURL()); |
|
208 | - |
|
209 | - $httpClient = $this->clientService->newClient(); |
|
210 | - |
|
211 | - try { |
|
212 | - $response = $httpClient->post($remote . '/index.php/apps/federatedfilesharing/createFederatedShare', |
|
213 | - [ |
|
214 | - 'body' => |
|
215 | - [ |
|
216 | - 'token' => $token, |
|
217 | - 'shareWith' => rtrim($cloudId->getId(), '/'), |
|
218 | - 'password' => $password |
|
219 | - ], |
|
220 | - 'connect_timeout' => 10, |
|
221 | - ] |
|
222 | - ); |
|
223 | - } catch (\Exception $e) { |
|
224 | - if (empty($password)) { |
|
225 | - $message = $this->l->t("Couldn't establish a federated share."); |
|
226 | - } else { |
|
227 | - $message = $this->l->t("Couldn't establish a federated share, maybe the password was wrong."); |
|
228 | - } |
|
229 | - return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST); |
|
230 | - } |
|
231 | - |
|
232 | - $body = $response->getBody(); |
|
233 | - $result = json_decode($body, true); |
|
234 | - |
|
235 | - if (is_array($result) && isset($result['remoteUrl'])) { |
|
236 | - return new JSONResponse(['message' => $this->l->t('Federated Share request sent, you will receive an invitation. Check your notifications.')]); |
|
237 | - } |
|
238 | - |
|
239 | - // if we doesn't get the expected response we assume that we try to add |
|
240 | - // a federated share from a Nextcloud <= 9 server |
|
241 | - $message = $this->l->t("Couldn't establish a federated share, it looks like the server to federate with is too old (Nextcloud <= 9)."); |
|
242 | - return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST); |
|
243 | - } |
|
60 | + /** @var FederatedShareProvider */ |
|
61 | + private $federatedShareProvider; |
|
62 | + |
|
63 | + /** @var AddressHandler */ |
|
64 | + private $addressHandler; |
|
65 | + |
|
66 | + /** @var IManager */ |
|
67 | + private $shareManager; |
|
68 | + |
|
69 | + /** @var ISession */ |
|
70 | + private $session; |
|
71 | + |
|
72 | + /** @var IL10N */ |
|
73 | + private $l; |
|
74 | + |
|
75 | + /** @var IUserSession */ |
|
76 | + private $userSession; |
|
77 | + |
|
78 | + /** @var IClientService */ |
|
79 | + private $clientService; |
|
80 | + |
|
81 | + /** @var ICloudIdManager */ |
|
82 | + private $cloudIdManager; |
|
83 | + |
|
84 | + /** |
|
85 | + * MountPublicLinkController constructor. |
|
86 | + * |
|
87 | + * @param string $appName |
|
88 | + * @param IRequest $request |
|
89 | + * @param FederatedShareProvider $federatedShareProvider |
|
90 | + * @param IManager $shareManager |
|
91 | + * @param AddressHandler $addressHandler |
|
92 | + * @param ISession $session |
|
93 | + * @param IL10N $l |
|
94 | + * @param IUserSession $userSession |
|
95 | + * @param IClientService $clientService |
|
96 | + * @param ICloudIdManager $cloudIdManager |
|
97 | + */ |
|
98 | + public function __construct($appName, |
|
99 | + IRequest $request, |
|
100 | + FederatedShareProvider $federatedShareProvider, |
|
101 | + IManager $shareManager, |
|
102 | + AddressHandler $addressHandler, |
|
103 | + ISession $session, |
|
104 | + IL10N $l, |
|
105 | + IUserSession $userSession, |
|
106 | + IClientService $clientService, |
|
107 | + ICloudIdManager $cloudIdManager |
|
108 | + ) { |
|
109 | + parent::__construct($appName, $request); |
|
110 | + |
|
111 | + $this->federatedShareProvider = $federatedShareProvider; |
|
112 | + $this->shareManager = $shareManager; |
|
113 | + $this->addressHandler = $addressHandler; |
|
114 | + $this->session = $session; |
|
115 | + $this->l = $l; |
|
116 | + $this->userSession = $userSession; |
|
117 | + $this->clientService = $clientService; |
|
118 | + $this->cloudIdManager = $cloudIdManager; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * send federated share to a user of a public link |
|
123 | + * |
|
124 | + * @NoCSRFRequired |
|
125 | + * @PublicPage |
|
126 | + * @BruteForceProtection(action=publicLink2FederatedShare) |
|
127 | + * |
|
128 | + * @param string $shareWith |
|
129 | + * @param string $token |
|
130 | + * @param string $password |
|
131 | + * @return JSONResponse |
|
132 | + */ |
|
133 | + public function createFederatedShare($shareWith, $token, $password = '') { |
|
134 | + if (!$this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) { |
|
135 | + return new JSONResponse( |
|
136 | + ['message' => 'This server doesn\'t support outgoing federated shares'], |
|
137 | + Http::STATUS_BAD_REQUEST |
|
138 | + ); |
|
139 | + } |
|
140 | + |
|
141 | + try { |
|
142 | + [, $server] = $this->addressHandler->splitUserRemote($shareWith); |
|
143 | + $share = $this->shareManager->getShareByToken($token); |
|
144 | + } catch (HintException $e) { |
|
145 | + $response = new JSONResponse(['message' => $e->getHint()], Http::STATUS_BAD_REQUEST); |
|
146 | + $response->throttle(); |
|
147 | + return $response; |
|
148 | + } |
|
149 | + |
|
150 | + // make sure that user is authenticated in case of a password protected link |
|
151 | + $storedPassword = $share->getPassword(); |
|
152 | + $authenticated = $this->session->get('public_link_authenticated') === $share->getId() || |
|
153 | + $this->shareManager->checkPassword($share, $password); |
|
154 | + if (!empty($storedPassword) && !$authenticated) { |
|
155 | + $response = new JSONResponse( |
|
156 | + ['message' => 'No permission to access the share'], |
|
157 | + Http::STATUS_BAD_REQUEST |
|
158 | + ); |
|
159 | + $response->throttle(); |
|
160 | + return $response; |
|
161 | + } |
|
162 | + |
|
163 | + if (($share->getPermissions() & Constants::PERMISSION_READ) === 0) { |
|
164 | + $response = new JSONResponse( |
|
165 | + ['message' => 'Mounting file drop not supported'], |
|
166 | + Http::STATUS_BAD_REQUEST |
|
167 | + ); |
|
168 | + $response->throttle(); |
|
169 | + return $response; |
|
170 | + } |
|
171 | + |
|
172 | + $share->setSharedWith($shareWith); |
|
173 | + $share->setShareType(IShare::TYPE_REMOTE); |
|
174 | + |
|
175 | + try { |
|
176 | + $this->federatedShareProvider->create($share); |
|
177 | + } catch (\Exception $e) { |
|
178 | + \OC::$server->getLogger()->logException($e, [ |
|
179 | + 'level' => ILogger::WARN, |
|
180 | + 'app' => 'federatedfilesharing', |
|
181 | + ]); |
|
182 | + return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
|
183 | + } |
|
184 | + |
|
185 | + return new JSONResponse(['remoteUrl' => $server]); |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * ask other server to get a federated share |
|
190 | + * |
|
191 | + * @NoAdminRequired |
|
192 | + * |
|
193 | + * @param string $token |
|
194 | + * @param string $remote |
|
195 | + * @param string $password |
|
196 | + * @param string $owner (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
197 | + * @param string $ownerDisplayName (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
198 | + * @param string $name (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
199 | + * @return JSONResponse |
|
200 | + */ |
|
201 | + public function askForFederatedShare($token, $remote, $password = '', $owner = '', $ownerDisplayName = '', $name = '') { |
|
202 | + // check if server admin allows to mount public links from other servers |
|
203 | + if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() === false) { |
|
204 | + return new JSONResponse(['message' => $this->l->t('Server to server sharing is not enabled on this server')], Http::STATUS_BAD_REQUEST); |
|
205 | + } |
|
206 | + |
|
207 | + $cloudId = $this->cloudIdManager->getCloudId($this->userSession->getUser()->getUID(), $this->addressHandler->generateRemoteURL()); |
|
208 | + |
|
209 | + $httpClient = $this->clientService->newClient(); |
|
210 | + |
|
211 | + try { |
|
212 | + $response = $httpClient->post($remote . '/index.php/apps/federatedfilesharing/createFederatedShare', |
|
213 | + [ |
|
214 | + 'body' => |
|
215 | + [ |
|
216 | + 'token' => $token, |
|
217 | + 'shareWith' => rtrim($cloudId->getId(), '/'), |
|
218 | + 'password' => $password |
|
219 | + ], |
|
220 | + 'connect_timeout' => 10, |
|
221 | + ] |
|
222 | + ); |
|
223 | + } catch (\Exception $e) { |
|
224 | + if (empty($password)) { |
|
225 | + $message = $this->l->t("Couldn't establish a federated share."); |
|
226 | + } else { |
|
227 | + $message = $this->l->t("Couldn't establish a federated share, maybe the password was wrong."); |
|
228 | + } |
|
229 | + return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST); |
|
230 | + } |
|
231 | + |
|
232 | + $body = $response->getBody(); |
|
233 | + $result = json_decode($body, true); |
|
234 | + |
|
235 | + if (is_array($result) && isset($result['remoteUrl'])) { |
|
236 | + return new JSONResponse(['message' => $this->l->t('Federated Share request sent, you will receive an invitation. Check your notifications.')]); |
|
237 | + } |
|
238 | + |
|
239 | + // if we doesn't get the expected response we assume that we try to add |
|
240 | + // a federated share from a Nextcloud <= 9 server |
|
241 | + $message = $this->l->t("Couldn't establish a federated share, it looks like the server to federate with is too old (Nextcloud <= 9)."); |
|
242 | + return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST); |
|
243 | + } |
|
244 | 244 | } |
@@ -34,14 +34,14 @@ |
||
34 | 34 | use OCP\Util; |
35 | 35 | |
36 | 36 | class LoadSidebarListener implements IEventListener { |
37 | - public function handle(Event $event): void { |
|
38 | - if (!($event instanceof LoadSidebar)) { |
|
39 | - return; |
|
40 | - } |
|
37 | + public function handle(Event $event): void { |
|
38 | + if (!($event instanceof LoadSidebar)) { |
|
39 | + return; |
|
40 | + } |
|
41 | 41 | |
42 | - // TODO: make sure to only include the sidebar script when |
|
43 | - // we properly split it between files list and sidebar |
|
44 | - Util::addScript(Application::APP_ID, 'files_versions'); |
|
45 | - } |
|
42 | + // TODO: make sure to only include the sidebar script when |
|
43 | + // we properly split it between files list and sidebar |
|
44 | + Util::addScript(Application::APP_ID, 'files_versions'); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |
@@ -34,14 +34,14 @@ |
||
34 | 34 | use OCP\Util; |
35 | 35 | |
36 | 36 | class LoadAdditionalListener implements IEventListener { |
37 | - public function handle(Event $event): void { |
|
38 | - if (!($event instanceof LoadAdditionalScriptsEvent)) { |
|
39 | - return; |
|
40 | - } |
|
37 | + public function handle(Event $event): void { |
|
38 | + if (!($event instanceof LoadAdditionalScriptsEvent)) { |
|
39 | + return; |
|
40 | + } |
|
41 | 41 | |
42 | - // TODO: make sure to only include the sidebar script when |
|
43 | - // we properly split it between files list and sidebar |
|
44 | - Util::addScript(Application::APP_ID, 'files_versions'); |
|
45 | - } |
|
42 | + // TODO: make sure to only include the sidebar script when |
|
43 | + // we properly split it between files list and sidebar |
|
44 | + Util::addScript(Application::APP_ID, 'files_versions'); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |