@@ -30,41 +30,41 @@ |
||
30 | 30 | * @var $this \OCP\Route\IRouter |
31 | 31 | **/ |
32 | 32 | \OC_Mount_Config::$app->registerRoutes( |
33 | - $this, |
|
34 | - [ |
|
35 | - 'resources' => [ |
|
36 | - 'global_storages' => ['url' => '/globalstorages'], |
|
37 | - 'user_storages' => ['url' => '/userstorages'], |
|
38 | - 'user_global_storages' => ['url' => '/userglobalstorages'], |
|
39 | - ], |
|
40 | - 'routes' => [ |
|
41 | - [ |
|
42 | - 'name' => 'Ajax#getSshKeys', |
|
43 | - 'url' => '/ajax/public_key.php', |
|
44 | - 'verb' => 'POST', |
|
45 | - 'requirements' => [], |
|
46 | - ], |
|
47 | - [ |
|
48 | - 'name' => 'Ajax#saveGlobalCredentials', |
|
49 | - 'url' => '/globalcredentials', |
|
50 | - 'verb' => 'POST', |
|
51 | - ], |
|
52 | - ], |
|
53 | - 'ocs' => [ |
|
54 | - [ |
|
55 | - 'name' => 'Api#getUserMounts', |
|
56 | - 'url' => '/api/v1/mounts', |
|
57 | - 'verb' => 'GET', |
|
58 | - ], |
|
59 | - ], |
|
60 | - ] |
|
33 | + $this, |
|
34 | + [ |
|
35 | + 'resources' => [ |
|
36 | + 'global_storages' => ['url' => '/globalstorages'], |
|
37 | + 'user_storages' => ['url' => '/userstorages'], |
|
38 | + 'user_global_storages' => ['url' => '/userglobalstorages'], |
|
39 | + ], |
|
40 | + 'routes' => [ |
|
41 | + [ |
|
42 | + 'name' => 'Ajax#getSshKeys', |
|
43 | + 'url' => '/ajax/public_key.php', |
|
44 | + 'verb' => 'POST', |
|
45 | + 'requirements' => [], |
|
46 | + ], |
|
47 | + [ |
|
48 | + 'name' => 'Ajax#saveGlobalCredentials', |
|
49 | + 'url' => '/globalcredentials', |
|
50 | + 'verb' => 'POST', |
|
51 | + ], |
|
52 | + ], |
|
53 | + 'ocs' => [ |
|
54 | + [ |
|
55 | + 'name' => 'Api#getUserMounts', |
|
56 | + 'url' => '/api/v1/mounts', |
|
57 | + 'verb' => 'GET', |
|
58 | + ], |
|
59 | + ], |
|
60 | + ] |
|
61 | 61 | ); |
62 | 62 | |
63 | 63 | $this->create('files_external_oauth1', 'ajax/oauth1.php') |
64 | - ->actionInclude('files_external/ajax/oauth1.php'); |
|
64 | + ->actionInclude('files_external/ajax/oauth1.php'); |
|
65 | 65 | $this->create('files_external_oauth2', 'ajax/oauth2.php') |
66 | - ->actionInclude('files_external/ajax/oauth2.php'); |
|
66 | + ->actionInclude('files_external/ajax/oauth2.php'); |
|
67 | 67 | |
68 | 68 | |
69 | 69 | $this->create('files_external_list_applicable', '/applicable') |
70 | - ->actionInclude('files_external/ajax/applicable.php'); |
|
70 | + ->actionInclude('files_external/ajax/applicable.php'); |
@@ -31,41 +31,41 @@ |
||
31 | 31 | * @since 7.0.0 |
32 | 32 | */ |
33 | 33 | interface IAppConfig { |
34 | - /** |
|
35 | - * check if a key is set in the appconfig |
|
36 | - * @param string $app |
|
37 | - * @param string $key |
|
38 | - * @return bool |
|
39 | - * @since 7.0.0 |
|
40 | - */ |
|
41 | - public function hasKey($app, $key); |
|
34 | + /** |
|
35 | + * check if a key is set in the appconfig |
|
36 | + * @param string $app |
|
37 | + * @param string $key |
|
38 | + * @return bool |
|
39 | + * @since 7.0.0 |
|
40 | + */ |
|
41 | + public function hasKey($app, $key); |
|
42 | 42 | |
43 | - /** |
|
44 | - * get multiply values, either the app or key can be used as wildcard by setting it to false |
|
45 | - * |
|
46 | - * @param string|false $key |
|
47 | - * @param string|false $app |
|
48 | - * @return array|false |
|
49 | - * @since 7.0.0 |
|
50 | - */ |
|
51 | - public function getValues($app, $key); |
|
43 | + /** |
|
44 | + * get multiply values, either the app or key can be used as wildcard by setting it to false |
|
45 | + * |
|
46 | + * @param string|false $key |
|
47 | + * @param string|false $app |
|
48 | + * @return array|false |
|
49 | + * @since 7.0.0 |
|
50 | + */ |
|
51 | + public function getValues($app, $key); |
|
52 | 52 | |
53 | - /** |
|
54 | - * get all values of the app or and filters out sensitive data |
|
55 | - * |
|
56 | - * @param string $app |
|
57 | - * @return array |
|
58 | - * @since 12.0.0 |
|
59 | - */ |
|
60 | - public function getFilteredValues($app); |
|
53 | + /** |
|
54 | + * get all values of the app or and filters out sensitive data |
|
55 | + * |
|
56 | + * @param string $app |
|
57 | + * @return array |
|
58 | + * @since 12.0.0 |
|
59 | + */ |
|
60 | + public function getFilteredValues($app); |
|
61 | 61 | |
62 | - /** |
|
63 | - * Get all apps using the config |
|
64 | - * @return array an array of app ids |
|
65 | - * |
|
66 | - * This function returns a list of all apps that have at least one |
|
67 | - * entry in the appconfig table. |
|
68 | - * @since 7.0.0 |
|
69 | - */ |
|
70 | - public function getApps(); |
|
62 | + /** |
|
63 | + * Get all apps using the config |
|
64 | + * @return array an array of app ids |
|
65 | + * |
|
66 | + * This function returns a list of all apps that have at least one |
|
67 | + * entry in the appconfig table. |
|
68 | + * @since 7.0.0 |
|
69 | + */ |
|
70 | + public function getApps(); |
|
71 | 71 | } |
@@ -37,241 +37,241 @@ |
||
37 | 37 | |
38 | 38 | class BackgroundJob extends TimedJob { |
39 | 39 | |
40 | - protected $connectionNotifications = [3, 7, 14, 30]; |
|
41 | - |
|
42 | - /** @var IConfig */ |
|
43 | - protected $config; |
|
44 | - |
|
45 | - /** @var IManager */ |
|
46 | - protected $notificationManager; |
|
47 | - |
|
48 | - /** @var IGroupManager */ |
|
49 | - protected $groupManager; |
|
50 | - |
|
51 | - /** @var IAppManager */ |
|
52 | - protected $appManager; |
|
53 | - |
|
54 | - /** @var IClientService */ |
|
55 | - protected $client; |
|
56 | - |
|
57 | - /** @var Installer */ |
|
58 | - protected $installer; |
|
59 | - |
|
60 | - /** @var string[] */ |
|
61 | - protected $users; |
|
62 | - |
|
63 | - /** |
|
64 | - * NotificationBackgroundJob constructor. |
|
65 | - * |
|
66 | - * @param IConfig $config |
|
67 | - * @param IManager $notificationManager |
|
68 | - * @param IGroupManager $groupManager |
|
69 | - * @param IAppManager $appManager |
|
70 | - * @param IClientService $client |
|
71 | - * @param Installer $installer |
|
72 | - */ |
|
73 | - public function __construct(IConfig $config, IManager $notificationManager, IGroupManager $groupManager, IAppManager $appManager, IClientService $client, Installer $installer) { |
|
74 | - // Run once a day |
|
75 | - $this->setInterval(60 * 60 * 24); |
|
76 | - |
|
77 | - $this->config = $config; |
|
78 | - $this->notificationManager = $notificationManager; |
|
79 | - $this->groupManager = $groupManager; |
|
80 | - $this->appManager = $appManager; |
|
81 | - $this->client = $client; |
|
82 | - $this->installer = $installer; |
|
83 | - } |
|
84 | - |
|
85 | - protected function run($argument) { |
|
86 | - $this->checkCoreUpdate(); |
|
87 | - $this->checkAppUpdates(); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Check for ownCloud update |
|
92 | - */ |
|
93 | - protected function checkCoreUpdate() { |
|
94 | - if (\in_array($this->getChannel(), ['daily', 'git'], true)) { |
|
95 | - // "These aren't the update channels you're looking for." - Ben Obi-Wan Kenobi |
|
96 | - return; |
|
97 | - } |
|
98 | - |
|
99 | - $updater = $this->createVersionCheck(); |
|
100 | - |
|
101 | - $status = $updater->check(); |
|
102 | - if ($status === false) { |
|
103 | - $errors = 1 + (int) $this->config->getAppValue('updatenotification', 'update_check_errors', 0); |
|
104 | - $this->config->setAppValue('updatenotification', 'update_check_errors', $errors); |
|
105 | - |
|
106 | - if (\in_array($errors, $this->connectionNotifications, true)) { |
|
107 | - $this->sendErrorNotifications($errors); |
|
108 | - } |
|
109 | - } else if (\is_array($status)) { |
|
110 | - $this->config->setAppValue('updatenotification', 'update_check_errors', 0); |
|
111 | - $this->clearErrorNotifications(); |
|
112 | - |
|
113 | - if (isset($status['version'])) { |
|
114 | - $this->createNotifications('core', $status['version'], $status['versionstring']); |
|
115 | - } |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Send a message to the admin when the update server could not be reached |
|
121 | - * @param int $numDays |
|
122 | - */ |
|
123 | - protected function sendErrorNotifications($numDays) { |
|
124 | - $this->clearErrorNotifications(); |
|
125 | - |
|
126 | - $notification = $this->notificationManager->createNotification(); |
|
127 | - try { |
|
128 | - $notification->setApp('updatenotification') |
|
129 | - ->setDateTime(new \DateTime()) |
|
130 | - ->setObject('updatenotification', 'error') |
|
131 | - ->setSubject('connection_error', ['days' => $numDays]); |
|
132 | - |
|
133 | - foreach ($this->getUsersToNotify() as $uid) { |
|
134 | - $notification->setUser($uid); |
|
135 | - $this->notificationManager->notify($notification); |
|
136 | - } |
|
137 | - } catch (\InvalidArgumentException $e) { |
|
138 | - return; |
|
139 | - } |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Remove error notifications again |
|
144 | - */ |
|
145 | - protected function clearErrorNotifications() { |
|
146 | - $notification = $this->notificationManager->createNotification(); |
|
147 | - try { |
|
148 | - $notification->setApp('updatenotification') |
|
149 | - ->setSubject('connection_error') |
|
150 | - ->setObject('updatenotification', 'error'); |
|
151 | - } catch (\InvalidArgumentException $e) { |
|
152 | - return; |
|
153 | - } |
|
154 | - $this->notificationManager->markProcessed($notification); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Check all installed apps for updates |
|
159 | - */ |
|
160 | - protected function checkAppUpdates() { |
|
161 | - $apps = $this->appManager->getInstalledApps(); |
|
162 | - foreach ($apps as $app) { |
|
163 | - $update = $this->isUpdateAvailable($app); |
|
164 | - if ($update !== false) { |
|
165 | - $this->createNotifications($app, $update); |
|
166 | - } |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Create notifications for this app version |
|
172 | - * |
|
173 | - * @param string $app |
|
174 | - * @param string $version |
|
175 | - * @param string $visibleVersion |
|
176 | - */ |
|
177 | - protected function createNotifications($app, $version, $visibleVersion = '') { |
|
178 | - $lastNotification = $this->config->getAppValue('updatenotification', $app, false); |
|
179 | - if ($lastNotification === $version) { |
|
180 | - // We already notified about this update |
|
181 | - return; |
|
182 | - } |
|
183 | - |
|
184 | - if ($lastNotification !== false) { |
|
185 | - // Delete old updates |
|
186 | - $this->deleteOutdatedNotifications($app, $lastNotification); |
|
187 | - } |
|
188 | - |
|
189 | - $notification = $this->notificationManager->createNotification(); |
|
190 | - try { |
|
191 | - $notification->setApp('updatenotification') |
|
192 | - ->setDateTime(new \DateTime()) |
|
193 | - ->setObject($app, $version); |
|
194 | - |
|
195 | - if ($visibleVersion !== '') { |
|
196 | - $notification->setSubject('update_available', ['version' => $visibleVersion]); |
|
197 | - } else { |
|
198 | - $notification->setSubject('update_available'); |
|
199 | - } |
|
200 | - |
|
201 | - foreach ($this->getUsersToNotify() as $uid) { |
|
202 | - $notification->setUser($uid); |
|
203 | - $this->notificationManager->notify($notification); |
|
204 | - } |
|
205 | - } catch (\InvalidArgumentException $e) { |
|
206 | - return; |
|
207 | - } |
|
208 | - |
|
209 | - $this->config->setAppValue('updatenotification', $app, $version); |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * @return string[] |
|
214 | - */ |
|
215 | - protected function getUsersToNotify(): array { |
|
216 | - if ($this->users !== null) { |
|
217 | - return $this->users; |
|
218 | - } |
|
219 | - |
|
220 | - $notifyGroups = (array) json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true); |
|
221 | - $this->users = []; |
|
222 | - foreach ($notifyGroups as $group) { |
|
223 | - $groupToNotify = $this->groupManager->get($group); |
|
224 | - if ($groupToNotify instanceof IGroup) { |
|
225 | - foreach ($groupToNotify->getUsers() as $user) { |
|
226 | - $this->users[$user->getUID()] = true; |
|
227 | - } |
|
228 | - } |
|
229 | - } |
|
230 | - |
|
231 | - $this->users = array_keys($this->users); |
|
232 | - |
|
233 | - return $this->users; |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Delete notifications for old updates |
|
238 | - * |
|
239 | - * @param string $app |
|
240 | - * @param string $version |
|
241 | - */ |
|
242 | - protected function deleteOutdatedNotifications($app, $version) { |
|
243 | - $notification = $this->notificationManager->createNotification(); |
|
244 | - try { |
|
245 | - $notification->setApp('updatenotification') |
|
246 | - ->setObject($app, $version); |
|
247 | - } catch (\InvalidArgumentException $e) { |
|
248 | - return; |
|
249 | - } |
|
250 | - $this->notificationManager->markProcessed($notification); |
|
251 | - } |
|
252 | - |
|
253 | - /** |
|
254 | - * @return VersionCheck |
|
255 | - */ |
|
256 | - protected function createVersionCheck(): VersionCheck { |
|
257 | - return new VersionCheck( |
|
258 | - $this->client, |
|
259 | - $this->config |
|
260 | - ); |
|
261 | - } |
|
262 | - |
|
263 | - /** |
|
264 | - * @return string |
|
265 | - */ |
|
266 | - protected function getChannel(): string { |
|
267 | - return \OC_Util::getChannel(); |
|
268 | - } |
|
269 | - |
|
270 | - /** |
|
271 | - * @param string $app |
|
272 | - * @return string|false |
|
273 | - */ |
|
274 | - protected function isUpdateAvailable($app) { |
|
275 | - return $this->installer->isUpdateAvailable($app); |
|
276 | - } |
|
40 | + protected $connectionNotifications = [3, 7, 14, 30]; |
|
41 | + |
|
42 | + /** @var IConfig */ |
|
43 | + protected $config; |
|
44 | + |
|
45 | + /** @var IManager */ |
|
46 | + protected $notificationManager; |
|
47 | + |
|
48 | + /** @var IGroupManager */ |
|
49 | + protected $groupManager; |
|
50 | + |
|
51 | + /** @var IAppManager */ |
|
52 | + protected $appManager; |
|
53 | + |
|
54 | + /** @var IClientService */ |
|
55 | + protected $client; |
|
56 | + |
|
57 | + /** @var Installer */ |
|
58 | + protected $installer; |
|
59 | + |
|
60 | + /** @var string[] */ |
|
61 | + protected $users; |
|
62 | + |
|
63 | + /** |
|
64 | + * NotificationBackgroundJob constructor. |
|
65 | + * |
|
66 | + * @param IConfig $config |
|
67 | + * @param IManager $notificationManager |
|
68 | + * @param IGroupManager $groupManager |
|
69 | + * @param IAppManager $appManager |
|
70 | + * @param IClientService $client |
|
71 | + * @param Installer $installer |
|
72 | + */ |
|
73 | + public function __construct(IConfig $config, IManager $notificationManager, IGroupManager $groupManager, IAppManager $appManager, IClientService $client, Installer $installer) { |
|
74 | + // Run once a day |
|
75 | + $this->setInterval(60 * 60 * 24); |
|
76 | + |
|
77 | + $this->config = $config; |
|
78 | + $this->notificationManager = $notificationManager; |
|
79 | + $this->groupManager = $groupManager; |
|
80 | + $this->appManager = $appManager; |
|
81 | + $this->client = $client; |
|
82 | + $this->installer = $installer; |
|
83 | + } |
|
84 | + |
|
85 | + protected function run($argument) { |
|
86 | + $this->checkCoreUpdate(); |
|
87 | + $this->checkAppUpdates(); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Check for ownCloud update |
|
92 | + */ |
|
93 | + protected function checkCoreUpdate() { |
|
94 | + if (\in_array($this->getChannel(), ['daily', 'git'], true)) { |
|
95 | + // "These aren't the update channels you're looking for." - Ben Obi-Wan Kenobi |
|
96 | + return; |
|
97 | + } |
|
98 | + |
|
99 | + $updater = $this->createVersionCheck(); |
|
100 | + |
|
101 | + $status = $updater->check(); |
|
102 | + if ($status === false) { |
|
103 | + $errors = 1 + (int) $this->config->getAppValue('updatenotification', 'update_check_errors', 0); |
|
104 | + $this->config->setAppValue('updatenotification', 'update_check_errors', $errors); |
|
105 | + |
|
106 | + if (\in_array($errors, $this->connectionNotifications, true)) { |
|
107 | + $this->sendErrorNotifications($errors); |
|
108 | + } |
|
109 | + } else if (\is_array($status)) { |
|
110 | + $this->config->setAppValue('updatenotification', 'update_check_errors', 0); |
|
111 | + $this->clearErrorNotifications(); |
|
112 | + |
|
113 | + if (isset($status['version'])) { |
|
114 | + $this->createNotifications('core', $status['version'], $status['versionstring']); |
|
115 | + } |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Send a message to the admin when the update server could not be reached |
|
121 | + * @param int $numDays |
|
122 | + */ |
|
123 | + protected function sendErrorNotifications($numDays) { |
|
124 | + $this->clearErrorNotifications(); |
|
125 | + |
|
126 | + $notification = $this->notificationManager->createNotification(); |
|
127 | + try { |
|
128 | + $notification->setApp('updatenotification') |
|
129 | + ->setDateTime(new \DateTime()) |
|
130 | + ->setObject('updatenotification', 'error') |
|
131 | + ->setSubject('connection_error', ['days' => $numDays]); |
|
132 | + |
|
133 | + foreach ($this->getUsersToNotify() as $uid) { |
|
134 | + $notification->setUser($uid); |
|
135 | + $this->notificationManager->notify($notification); |
|
136 | + } |
|
137 | + } catch (\InvalidArgumentException $e) { |
|
138 | + return; |
|
139 | + } |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * Remove error notifications again |
|
144 | + */ |
|
145 | + protected function clearErrorNotifications() { |
|
146 | + $notification = $this->notificationManager->createNotification(); |
|
147 | + try { |
|
148 | + $notification->setApp('updatenotification') |
|
149 | + ->setSubject('connection_error') |
|
150 | + ->setObject('updatenotification', 'error'); |
|
151 | + } catch (\InvalidArgumentException $e) { |
|
152 | + return; |
|
153 | + } |
|
154 | + $this->notificationManager->markProcessed($notification); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * Check all installed apps for updates |
|
159 | + */ |
|
160 | + protected function checkAppUpdates() { |
|
161 | + $apps = $this->appManager->getInstalledApps(); |
|
162 | + foreach ($apps as $app) { |
|
163 | + $update = $this->isUpdateAvailable($app); |
|
164 | + if ($update !== false) { |
|
165 | + $this->createNotifications($app, $update); |
|
166 | + } |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Create notifications for this app version |
|
172 | + * |
|
173 | + * @param string $app |
|
174 | + * @param string $version |
|
175 | + * @param string $visibleVersion |
|
176 | + */ |
|
177 | + protected function createNotifications($app, $version, $visibleVersion = '') { |
|
178 | + $lastNotification = $this->config->getAppValue('updatenotification', $app, false); |
|
179 | + if ($lastNotification === $version) { |
|
180 | + // We already notified about this update |
|
181 | + return; |
|
182 | + } |
|
183 | + |
|
184 | + if ($lastNotification !== false) { |
|
185 | + // Delete old updates |
|
186 | + $this->deleteOutdatedNotifications($app, $lastNotification); |
|
187 | + } |
|
188 | + |
|
189 | + $notification = $this->notificationManager->createNotification(); |
|
190 | + try { |
|
191 | + $notification->setApp('updatenotification') |
|
192 | + ->setDateTime(new \DateTime()) |
|
193 | + ->setObject($app, $version); |
|
194 | + |
|
195 | + if ($visibleVersion !== '') { |
|
196 | + $notification->setSubject('update_available', ['version' => $visibleVersion]); |
|
197 | + } else { |
|
198 | + $notification->setSubject('update_available'); |
|
199 | + } |
|
200 | + |
|
201 | + foreach ($this->getUsersToNotify() as $uid) { |
|
202 | + $notification->setUser($uid); |
|
203 | + $this->notificationManager->notify($notification); |
|
204 | + } |
|
205 | + } catch (\InvalidArgumentException $e) { |
|
206 | + return; |
|
207 | + } |
|
208 | + |
|
209 | + $this->config->setAppValue('updatenotification', $app, $version); |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * @return string[] |
|
214 | + */ |
|
215 | + protected function getUsersToNotify(): array { |
|
216 | + if ($this->users !== null) { |
|
217 | + return $this->users; |
|
218 | + } |
|
219 | + |
|
220 | + $notifyGroups = (array) json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true); |
|
221 | + $this->users = []; |
|
222 | + foreach ($notifyGroups as $group) { |
|
223 | + $groupToNotify = $this->groupManager->get($group); |
|
224 | + if ($groupToNotify instanceof IGroup) { |
|
225 | + foreach ($groupToNotify->getUsers() as $user) { |
|
226 | + $this->users[$user->getUID()] = true; |
|
227 | + } |
|
228 | + } |
|
229 | + } |
|
230 | + |
|
231 | + $this->users = array_keys($this->users); |
|
232 | + |
|
233 | + return $this->users; |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Delete notifications for old updates |
|
238 | + * |
|
239 | + * @param string $app |
|
240 | + * @param string $version |
|
241 | + */ |
|
242 | + protected function deleteOutdatedNotifications($app, $version) { |
|
243 | + $notification = $this->notificationManager->createNotification(); |
|
244 | + try { |
|
245 | + $notification->setApp('updatenotification') |
|
246 | + ->setObject($app, $version); |
|
247 | + } catch (\InvalidArgumentException $e) { |
|
248 | + return; |
|
249 | + } |
|
250 | + $this->notificationManager->markProcessed($notification); |
|
251 | + } |
|
252 | + |
|
253 | + /** |
|
254 | + * @return VersionCheck |
|
255 | + */ |
|
256 | + protected function createVersionCheck(): VersionCheck { |
|
257 | + return new VersionCheck( |
|
258 | + $this->client, |
|
259 | + $this->config |
|
260 | + ); |
|
261 | + } |
|
262 | + |
|
263 | + /** |
|
264 | + * @return string |
|
265 | + */ |
|
266 | + protected function getChannel(): string { |
|
267 | + return \OC_Util::getChannel(); |
|
268 | + } |
|
269 | + |
|
270 | + /** |
|
271 | + * @param string $app |
|
272 | + * @return string|false |
|
273 | + */ |
|
274 | + protected function isUpdateAvailable($app) { |
|
275 | + return $this->installer->isUpdateAvailable($app); |
|
276 | + } |
|
277 | 277 | } |
@@ -38,63 +38,63 @@ |
||
38 | 38 | use OCP\Util; |
39 | 39 | |
40 | 40 | class AdminController extends Controller { |
41 | - /** @var IJobList */ |
|
42 | - private $jobList; |
|
43 | - /** @var ISecureRandom */ |
|
44 | - private $secureRandom; |
|
45 | - /** @var IConfig */ |
|
46 | - private $config; |
|
47 | - /** @var ITimeFactory */ |
|
48 | - private $timeFactory; |
|
49 | - /** @var IL10N */ |
|
50 | - private $l10n; |
|
41 | + /** @var IJobList */ |
|
42 | + private $jobList; |
|
43 | + /** @var ISecureRandom */ |
|
44 | + private $secureRandom; |
|
45 | + /** @var IConfig */ |
|
46 | + private $config; |
|
47 | + /** @var ITimeFactory */ |
|
48 | + private $timeFactory; |
|
49 | + /** @var IL10N */ |
|
50 | + private $l10n; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param string $appName |
|
54 | - * @param IRequest $request |
|
55 | - * @param IJobList $jobList |
|
56 | - * @param ISecureRandom $secureRandom |
|
57 | - * @param IConfig $config |
|
58 | - * @param ITimeFactory $timeFactory |
|
59 | - * @param IL10N $l10n |
|
60 | - */ |
|
61 | - public function __construct($appName, |
|
62 | - IRequest $request, |
|
63 | - IJobList $jobList, |
|
64 | - ISecureRandom $secureRandom, |
|
65 | - IConfig $config, |
|
66 | - ITimeFactory $timeFactory, |
|
67 | - IL10N $l10n) { |
|
68 | - parent::__construct($appName, $request); |
|
69 | - $this->jobList = $jobList; |
|
70 | - $this->secureRandom = $secureRandom; |
|
71 | - $this->config = $config; |
|
72 | - $this->timeFactory = $timeFactory; |
|
73 | - $this->l10n = $l10n; |
|
74 | - } |
|
52 | + /** |
|
53 | + * @param string $appName |
|
54 | + * @param IRequest $request |
|
55 | + * @param IJobList $jobList |
|
56 | + * @param ISecureRandom $secureRandom |
|
57 | + * @param IConfig $config |
|
58 | + * @param ITimeFactory $timeFactory |
|
59 | + * @param IL10N $l10n |
|
60 | + */ |
|
61 | + public function __construct($appName, |
|
62 | + IRequest $request, |
|
63 | + IJobList $jobList, |
|
64 | + ISecureRandom $secureRandom, |
|
65 | + IConfig $config, |
|
66 | + ITimeFactory $timeFactory, |
|
67 | + IL10N $l10n) { |
|
68 | + parent::__construct($appName, $request); |
|
69 | + $this->jobList = $jobList; |
|
70 | + $this->secureRandom = $secureRandom; |
|
71 | + $this->config = $config; |
|
72 | + $this->timeFactory = $timeFactory; |
|
73 | + $this->l10n = $l10n; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string $channel |
|
78 | - * @return DataResponse |
|
79 | - */ |
|
80 | - public function setChannel(string $channel): DataResponse { |
|
81 | - Util::setChannel($channel); |
|
82 | - $this->config->setAppValue('core', 'lastupdatedat', 0); |
|
83 | - return new DataResponse(['status' => 'success', 'data' => ['message' => $this->l10n->t('Channel updated')]]); |
|
84 | - } |
|
76 | + /** |
|
77 | + * @param string $channel |
|
78 | + * @return DataResponse |
|
79 | + */ |
|
80 | + public function setChannel(string $channel): DataResponse { |
|
81 | + Util::setChannel($channel); |
|
82 | + $this->config->setAppValue('core', 'lastupdatedat', 0); |
|
83 | + return new DataResponse(['status' => 'success', 'data' => ['message' => $this->l10n->t('Channel updated')]]); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @return DataResponse |
|
88 | - */ |
|
89 | - public function createCredentials(): DataResponse { |
|
90 | - // Create a new job and store the creation date |
|
91 | - $this->jobList->add(ResetTokenBackgroundJob::class); |
|
92 | - $this->config->setAppValue('core', 'updater.secret.created', $this->timeFactory->getTime()); |
|
86 | + /** |
|
87 | + * @return DataResponse |
|
88 | + */ |
|
89 | + public function createCredentials(): DataResponse { |
|
90 | + // Create a new job and store the creation date |
|
91 | + $this->jobList->add(ResetTokenBackgroundJob::class); |
|
92 | + $this->config->setAppValue('core', 'updater.secret.created', $this->timeFactory->getTime()); |
|
93 | 93 | |
94 | - // Create a new token |
|
95 | - $newToken = $this->secureRandom->generate(64); |
|
96 | - $this->config->setSystemValue('updater.secret', password_hash($newToken, PASSWORD_DEFAULT)); |
|
94 | + // Create a new token |
|
95 | + $newToken = $this->secureRandom->generate(64); |
|
96 | + $this->config->setSystemValue('updater.secret', password_hash($newToken, PASSWORD_DEFAULT)); |
|
97 | 97 | |
98 | - return new DataResponse($newToken); |
|
99 | - } |
|
98 | + return new DataResponse($newToken); |
|
99 | + } |
|
100 | 100 | } |
@@ -31,45 +31,45 @@ |
||
31 | 31 | * @package OCA\AdminAudit\Actions |
32 | 32 | */ |
33 | 33 | class Security extends Action { |
34 | - /** |
|
35 | - * Log twofactor auth enabled |
|
36 | - * |
|
37 | - * @param IUser $user |
|
38 | - * @param array $params |
|
39 | - */ |
|
40 | - public function twofactorFailed(IUser $user, array $params) { |
|
41 | - $params['uid'] = $user->getUID(); |
|
42 | - $params['displayName'] = $user->getDisplayName(); |
|
34 | + /** |
|
35 | + * Log twofactor auth enabled |
|
36 | + * |
|
37 | + * @param IUser $user |
|
38 | + * @param array $params |
|
39 | + */ |
|
40 | + public function twofactorFailed(IUser $user, array $params) { |
|
41 | + $params['uid'] = $user->getUID(); |
|
42 | + $params['displayName'] = $user->getDisplayName(); |
|
43 | 43 | |
44 | - $this->log( |
|
45 | - 'Failed two factor attempt by user %s (%s) with provider %s', |
|
46 | - $params, |
|
47 | - [ |
|
48 | - 'displayName', |
|
49 | - 'uid', |
|
50 | - 'provider', |
|
51 | - ] |
|
52 | - ); |
|
53 | - } |
|
44 | + $this->log( |
|
45 | + 'Failed two factor attempt by user %s (%s) with provider %s', |
|
46 | + $params, |
|
47 | + [ |
|
48 | + 'displayName', |
|
49 | + 'uid', |
|
50 | + 'provider', |
|
51 | + ] |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Logs unsharing of data |
|
57 | - * |
|
58 | - * @param IUser $user |
|
59 | - * @param array $params |
|
60 | - */ |
|
61 | - public function twofactorSuccess(IUser $user, array $params) { |
|
62 | - $params['uid'] = $user->getUID(); |
|
63 | - $params['displayName'] = $user->getDisplayName(); |
|
55 | + /** |
|
56 | + * Logs unsharing of data |
|
57 | + * |
|
58 | + * @param IUser $user |
|
59 | + * @param array $params |
|
60 | + */ |
|
61 | + public function twofactorSuccess(IUser $user, array $params) { |
|
62 | + $params['uid'] = $user->getUID(); |
|
63 | + $params['displayName'] = $user->getDisplayName(); |
|
64 | 64 | |
65 | - $this->log( |
|
66 | - 'Successful two factor attempt by user %s (%s) with provider %s', |
|
67 | - $params, |
|
68 | - [ |
|
69 | - 'displayName', |
|
70 | - 'uid', |
|
71 | - 'provider', |
|
72 | - ] |
|
73 | - ); |
|
74 | - } |
|
65 | + $this->log( |
|
66 | + 'Successful two factor attempt by user %s (%s) with provider %s', |
|
67 | + $params, |
|
68 | + [ |
|
69 | + 'displayName', |
|
70 | + 'uid', |
|
71 | + 'provider', |
|
72 | + ] |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | } |
@@ -36,47 +36,47 @@ |
||
36 | 36 | */ |
37 | 37 | class OwncloudGuestShareType implements IRepairStep { |
38 | 38 | |
39 | - /** @var IDBConnection */ |
|
40 | - private $connection; |
|
39 | + /** @var IDBConnection */ |
|
40 | + private $connection; |
|
41 | 41 | |
42 | - /** @var IConfig */ |
|
43 | - private $config; |
|
42 | + /** @var IConfig */ |
|
43 | + private $config; |
|
44 | 44 | |
45 | 45 | |
46 | - public function __construct(IDBConnection $connection, IConfig $config) { |
|
47 | - $this->connection = $connection; |
|
48 | - $this->config = $config; |
|
49 | - } |
|
46 | + public function __construct(IDBConnection $connection, IConfig $config) { |
|
47 | + $this->connection = $connection; |
|
48 | + $this->config = $config; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Returns the step's name |
|
53 | - * |
|
54 | - * @return string |
|
55 | - * @since 9.1.0 |
|
56 | - */ |
|
57 | - public function getName() { |
|
58 | - return 'Fix the share type of guest shares when migrating from ownCloud'; |
|
59 | - } |
|
51 | + /** |
|
52 | + * Returns the step's name |
|
53 | + * |
|
54 | + * @return string |
|
55 | + * @since 9.1.0 |
|
56 | + */ |
|
57 | + public function getName() { |
|
58 | + return 'Fix the share type of guest shares when migrating from ownCloud'; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param IOutput $output |
|
63 | - */ |
|
64 | - public function run(IOutput $output) { |
|
65 | - if (!$this->shouldRun()) { |
|
66 | - return; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @param IOutput $output |
|
63 | + */ |
|
64 | + public function run(IOutput $output) { |
|
65 | + if (!$this->shouldRun()) { |
|
66 | + return; |
|
67 | + } |
|
68 | 68 | |
69 | - $query = $this->connection->getQueryBuilder(); |
|
70 | - $query->update('share') |
|
71 | - ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) |
|
72 | - ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL))); |
|
73 | - $query->execute(); |
|
74 | - } |
|
69 | + $query = $this->connection->getQueryBuilder(); |
|
70 | + $query->update('share') |
|
71 | + ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) |
|
72 | + ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL))); |
|
73 | + $query->execute(); |
|
74 | + } |
|
75 | 75 | |
76 | - protected function shouldRun() { |
|
77 | - $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
78 | - return $appVersion === '0.10.0' || |
|
79 | - $this->config->getAppValue('core', 'vendor', '') === 'owncloud'; |
|
80 | - } |
|
76 | + protected function shouldRun() { |
|
77 | + $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
78 | + return $appVersion === '0.10.0' || |
|
79 | + $this->config->getAppValue('core', 'vendor', '') === 'owncloud'; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | } |
@@ -30,33 +30,33 @@ |
||
30 | 30 | |
31 | 31 | class Base extends \OC\Core\Command\Base { |
32 | 32 | |
33 | - /** @var IUserManager */ |
|
34 | - protected $userManager; |
|
33 | + /** @var IUserManager */ |
|
34 | + protected $userManager; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Return possible values for the named option |
|
38 | - * |
|
39 | - * @param string $optionName |
|
40 | - * @param CompletionContext $context |
|
41 | - * @return string[] |
|
42 | - */ |
|
43 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
44 | - return []; |
|
45 | - } |
|
36 | + /** |
|
37 | + * Return possible values for the named option |
|
38 | + * |
|
39 | + * @param string $optionName |
|
40 | + * @param CompletionContext $context |
|
41 | + * @return string[] |
|
42 | + */ |
|
43 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
44 | + return []; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Return possible values for the named argument |
|
49 | - * |
|
50 | - * @param string $argumentName |
|
51 | - * @param CompletionContext $context |
|
52 | - * @return string[] |
|
53 | - */ |
|
54 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
55 | - if ($argumentName === 'uid') { |
|
56 | - return array_map(function(IUser $user) { |
|
57 | - return $user->getUID(); |
|
58 | - }, $this->userManager->search($context->getCurrentWord(), 100)); |
|
59 | - } |
|
60 | - return []; |
|
61 | - } |
|
47 | + /** |
|
48 | + * Return possible values for the named argument |
|
49 | + * |
|
50 | + * @param string $argumentName |
|
51 | + * @param CompletionContext $context |
|
52 | + * @return string[] |
|
53 | + */ |
|
54 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
55 | + if ($argumentName === 'uid') { |
|
56 | + return array_map(function(IUser $user) { |
|
57 | + return $user->getUID(); |
|
58 | + }, $this->userManager->search($context->getCurrentWord(), 100)); |
|
59 | + } |
|
60 | + return []; |
|
61 | + } |
|
62 | 62 | } |
@@ -23,63 +23,63 @@ |
||
23 | 23 | namespace OC\App\CodeChecker; |
24 | 24 | |
25 | 25 | class PrivateCheck extends AbstractCheck { |
26 | - /** |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - protected function getLocalDescription() { |
|
30 | - return 'private'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + protected function getLocalDescription() { |
|
30 | + return 'private'; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - public function getLocalClasses() { |
|
37 | - return [ |
|
38 | - // classes replaced by the public api |
|
39 | - 'OC_API' => '6.0.0', |
|
40 | - 'OC_App' => '6.0.0', |
|
41 | - 'OC_AppConfig' => '6.0.0', |
|
42 | - 'OC_Avatar' => '6.0.0', |
|
43 | - 'OC_BackgroundJob' => '6.0.0', |
|
44 | - 'OC_Config' => '6.0.0', |
|
45 | - 'OC_DB' => '6.0.0', |
|
46 | - 'OC_Files' => '6.0.0', |
|
47 | - 'OC_Helper' => '6.0.0', |
|
48 | - 'OC_Hook' => '6.0.0', |
|
49 | - 'OC_Image' => '6.0.0', |
|
50 | - 'OC_JSON' => '6.0.0', |
|
51 | - 'OC_L10N' => '6.0.0', |
|
52 | - 'OC_Log' => '6.0.0', |
|
53 | - 'OC_Mail' => '6.0.0', |
|
54 | - 'OC_Preferences' => '6.0.0', |
|
55 | - 'OC_Search_Provider' => '6.0.0', |
|
56 | - 'OC_Search_Result' => '6.0.0', |
|
57 | - 'OC_Request' => '6.0.0', |
|
58 | - 'OC_Response' => '6.0.0', |
|
59 | - 'OC_Template' => '6.0.0', |
|
60 | - 'OC_User' => '6.0.0', |
|
61 | - 'OC_Util' => '6.0.0', |
|
62 | - ]; |
|
63 | - } |
|
33 | + /** |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + public function getLocalClasses() { |
|
37 | + return [ |
|
38 | + // classes replaced by the public api |
|
39 | + 'OC_API' => '6.0.0', |
|
40 | + 'OC_App' => '6.0.0', |
|
41 | + 'OC_AppConfig' => '6.0.0', |
|
42 | + 'OC_Avatar' => '6.0.0', |
|
43 | + 'OC_BackgroundJob' => '6.0.0', |
|
44 | + 'OC_Config' => '6.0.0', |
|
45 | + 'OC_DB' => '6.0.0', |
|
46 | + 'OC_Files' => '6.0.0', |
|
47 | + 'OC_Helper' => '6.0.0', |
|
48 | + 'OC_Hook' => '6.0.0', |
|
49 | + 'OC_Image' => '6.0.0', |
|
50 | + 'OC_JSON' => '6.0.0', |
|
51 | + 'OC_L10N' => '6.0.0', |
|
52 | + 'OC_Log' => '6.0.0', |
|
53 | + 'OC_Mail' => '6.0.0', |
|
54 | + 'OC_Preferences' => '6.0.0', |
|
55 | + 'OC_Search_Provider' => '6.0.0', |
|
56 | + 'OC_Search_Result' => '6.0.0', |
|
57 | + 'OC_Request' => '6.0.0', |
|
58 | + 'OC_Response' => '6.0.0', |
|
59 | + 'OC_Template' => '6.0.0', |
|
60 | + 'OC_User' => '6.0.0', |
|
61 | + 'OC_Util' => '6.0.0', |
|
62 | + ]; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - public function getLocalConstants() { |
|
69 | - return []; |
|
70 | - } |
|
65 | + /** |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + public function getLocalConstants() { |
|
69 | + return []; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - public function getLocalFunctions() { |
|
76 | - return []; |
|
77 | - } |
|
72 | + /** |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + public function getLocalFunctions() { |
|
76 | + return []; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - public function getLocalMethods() { |
|
83 | - return []; |
|
84 | - } |
|
79 | + /** |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + public function getLocalMethods() { |
|
83 | + return []; |
|
84 | + } |
|
85 | 85 | } |
@@ -26,27 +26,27 @@ |
||
26 | 26 | |
27 | 27 | class RequestTime extends Controller { |
28 | 28 | |
29 | - /** |
|
30 | - * @NoAdminRequired |
|
31 | - * |
|
32 | - * @param string $search |
|
33 | - * @return JSONResponse |
|
34 | - */ |
|
35 | - public function getTimezones($search = '') { |
|
36 | - $timezones = \DateTimeZone::listIdentifiers(); |
|
29 | + /** |
|
30 | + * @NoAdminRequired |
|
31 | + * |
|
32 | + * @param string $search |
|
33 | + * @return JSONResponse |
|
34 | + */ |
|
35 | + public function getTimezones($search = '') { |
|
36 | + $timezones = \DateTimeZone::listIdentifiers(); |
|
37 | 37 | |
38 | - if ($search !== '') { |
|
39 | - $timezones = array_filter($timezones, function ($timezone) use ($search) { |
|
40 | - return stripos($timezone, $search) !== false; |
|
41 | - }); |
|
42 | - } |
|
38 | + if ($search !== '') { |
|
39 | + $timezones = array_filter($timezones, function ($timezone) use ($search) { |
|
40 | + return stripos($timezone, $search) !== false; |
|
41 | + }); |
|
42 | + } |
|
43 | 43 | |
44 | - $timezones = array_slice($timezones, 0, 10); |
|
44 | + $timezones = array_slice($timezones, 0, 10); |
|
45 | 45 | |
46 | - $response = []; |
|
47 | - foreach ($timezones as $timezone) { |
|
48 | - $response[$timezone] = $timezone; |
|
49 | - } |
|
50 | - return new JSONResponse($response); |
|
51 | - } |
|
46 | + $response = []; |
|
47 | + foreach ($timezones as $timezone) { |
|
48 | + $response[$timezone] = $timezone; |
|
49 | + } |
|
50 | + return new JSONResponse($response); |
|
51 | + } |
|
52 | 52 | } |