@@ -9,13 +9,13 @@ |
||
9 | 9 | * later. See the COPYING file. |
10 | 10 | */ |
11 | 11 | if (\OC::$server->getConfig()->getSystemValue('debug', false)) { |
12 | - script('updatenotification', 'vue'); |
|
12 | + script('updatenotification', 'vue'); |
|
13 | 13 | } else { |
14 | - script('updatenotification', 'vue.min'); |
|
14 | + script('updatenotification', 'vue.min'); |
|
15 | 15 | } |
16 | 16 | script('updatenotification', [ |
17 | - 'components/root', |
|
18 | - 'admin', |
|
17 | + 'components/root', |
|
18 | + 'admin', |
|
19 | 19 | ]); |
20 | 20 | style('updatenotification', 'admin'); |
21 | 21 | /** @var array $_ */ |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | /** |
4 | 4 | * @copyright (c) 2018 Joas Schilling <[email protected]> |
5 | 5 | * |
@@ -32,53 +32,53 @@ |
||
32 | 32 | use OCP\Util; |
33 | 33 | |
34 | 34 | class Application extends App { |
35 | - public function __construct() { |
|
36 | - parent::__construct('updatenotification', []); |
|
37 | - } |
|
35 | + public function __construct() { |
|
36 | + parent::__construct('updatenotification', []); |
|
37 | + } |
|
38 | 38 | |
39 | - public function register() { |
|
40 | - $server = $this->getContainer()->getServer(); |
|
39 | + public function register() { |
|
40 | + $server = $this->getContainer()->getServer(); |
|
41 | 41 | |
42 | - if ($server->getConfig()->getSystemValue('updatechecker', true) !== true) { |
|
43 | - // Updater check is disabled |
|
44 | - return; |
|
45 | - } |
|
42 | + if ($server->getConfig()->getSystemValue('updatechecker', true) !== true) { |
|
43 | + // Updater check is disabled |
|
44 | + return; |
|
45 | + } |
|
46 | 46 | |
47 | - $user = $server->getUserSession()->getUser(); |
|
48 | - if (!$user instanceof IUser) { |
|
49 | - // Nothing to do for guests |
|
50 | - return; |
|
51 | - } |
|
47 | + $user = $server->getUserSession()->getUser(); |
|
48 | + if (!$user instanceof IUser) { |
|
49 | + // Nothing to do for guests |
|
50 | + return; |
|
51 | + } |
|
52 | 52 | |
53 | - if ($server->getAppManager()->isEnabledForUser('notifications')) { |
|
54 | - // Notifications app is available, so we register. |
|
55 | - // Since notifications also work for non-admins we don't check this here. |
|
56 | - $this->registerNotifier(); |
|
57 | - } else if ($server->getGroupManager()->isAdmin($user->getUID())) { |
|
58 | - try { |
|
59 | - $updateChecker = $this->getContainer()->query(UpdateChecker::class); |
|
60 | - } catch (QueryException $e) { |
|
61 | - $server->getLogger()->logException($e); |
|
62 | - return; |
|
63 | - } |
|
53 | + if ($server->getAppManager()->isEnabledForUser('notifications')) { |
|
54 | + // Notifications app is available, so we register. |
|
55 | + // Since notifications also work for non-admins we don't check this here. |
|
56 | + $this->registerNotifier(); |
|
57 | + } else if ($server->getGroupManager()->isAdmin($user->getUID())) { |
|
58 | + try { |
|
59 | + $updateChecker = $this->getContainer()->query(UpdateChecker::class); |
|
60 | + } catch (QueryException $e) { |
|
61 | + $server->getLogger()->logException($e); |
|
62 | + return; |
|
63 | + } |
|
64 | 64 | |
65 | - if ($updateChecker->getUpdateState() !== []) { |
|
66 | - Util::addScript('updatenotification', 'legacy-notification'); |
|
67 | - \OC_Hook::connect('\OCP\Config', 'js', $updateChecker, 'populateJavaScriptVariables'); |
|
68 | - } |
|
69 | - } |
|
70 | - } |
|
65 | + if ($updateChecker->getUpdateState() !== []) { |
|
66 | + Util::addScript('updatenotification', 'legacy-notification'); |
|
67 | + \OC_Hook::connect('\OCP\Config', 'js', $updateChecker, 'populateJavaScriptVariables'); |
|
68 | + } |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - public function registerNotifier() { |
|
73 | - $notificationsManager = $this->getContainer()->getServer()->getNotificationManager(); |
|
74 | - $notificationsManager->registerNotifier(function() { |
|
75 | - return $this->getContainer()->query(Notifier::class); |
|
76 | - }, function() { |
|
77 | - $l = $this->getContainer()->getServer()->getL10N('updatenotification'); |
|
78 | - return [ |
|
79 | - 'id' => 'updatenotification', |
|
80 | - 'name' => $l->t('Update notifications'), |
|
81 | - ]; |
|
82 | - }); |
|
83 | - } |
|
72 | + public function registerNotifier() { |
|
73 | + $notificationsManager = $this->getContainer()->getServer()->getNotificationManager(); |
|
74 | + $notificationsManager->registerNotifier(function() { |
|
75 | + return $this->getContainer()->query(Notifier::class); |
|
76 | + }, function() { |
|
77 | + $l = $this->getContainer()->getServer()->getL10N('updatenotification'); |
|
78 | + return [ |
|
79 | + 'id' => 'updatenotification', |
|
80 | + 'name' => $l->t('Update notifications'), |
|
81 | + ]; |
|
82 | + }); |
|
83 | + } |
|
84 | 84 | } |
@@ -34,87 +34,87 @@ |
||
34 | 34 | use OCP\Util; |
35 | 35 | |
36 | 36 | class Admin implements ISettings { |
37 | - /** @var IConfig */ |
|
38 | - private $config; |
|
39 | - /** @var UpdateChecker */ |
|
40 | - private $updateChecker; |
|
41 | - /** @var IDateTimeFormatter */ |
|
42 | - private $dateTimeFormatter; |
|
37 | + /** @var IConfig */ |
|
38 | + private $config; |
|
39 | + /** @var UpdateChecker */ |
|
40 | + private $updateChecker; |
|
41 | + /** @var IDateTimeFormatter */ |
|
42 | + private $dateTimeFormatter; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param IConfig $config |
|
46 | - * @param UpdateChecker $updateChecker |
|
47 | - * @param IDateTimeFormatter $dateTimeFormatter |
|
48 | - */ |
|
49 | - public function __construct(IConfig $config, |
|
50 | - UpdateChecker $updateChecker, |
|
51 | - IDateTimeFormatter $dateTimeFormatter) { |
|
52 | - $this->config = $config; |
|
53 | - $this->updateChecker = $updateChecker; |
|
54 | - $this->dateTimeFormatter = $dateTimeFormatter; |
|
55 | - } |
|
44 | + /** |
|
45 | + * @param IConfig $config |
|
46 | + * @param UpdateChecker $updateChecker |
|
47 | + * @param IDateTimeFormatter $dateTimeFormatter |
|
48 | + */ |
|
49 | + public function __construct(IConfig $config, |
|
50 | + UpdateChecker $updateChecker, |
|
51 | + IDateTimeFormatter $dateTimeFormatter) { |
|
52 | + $this->config = $config; |
|
53 | + $this->updateChecker = $updateChecker; |
|
54 | + $this->dateTimeFormatter = $dateTimeFormatter; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return TemplateResponse |
|
59 | - */ |
|
60 | - public function getForm(): TemplateResponse { |
|
61 | - $lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat'); |
|
62 | - $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp); |
|
57 | + /** |
|
58 | + * @return TemplateResponse |
|
59 | + */ |
|
60 | + public function getForm(): TemplateResponse { |
|
61 | + $lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat'); |
|
62 | + $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp); |
|
63 | 63 | |
64 | - $channels = [ |
|
65 | - 'daily', |
|
66 | - 'beta', |
|
67 | - 'stable', |
|
68 | - 'production', |
|
69 | - ]; |
|
70 | - $currentChannel = Util::getChannel(); |
|
71 | - if ($currentChannel === 'git') { |
|
72 | - $channels[] = 'git'; |
|
73 | - } |
|
64 | + $channels = [ |
|
65 | + 'daily', |
|
66 | + 'beta', |
|
67 | + 'stable', |
|
68 | + 'production', |
|
69 | + ]; |
|
70 | + $currentChannel = Util::getChannel(); |
|
71 | + if ($currentChannel === 'git') { |
|
72 | + $channels[] = 'git'; |
|
73 | + } |
|
74 | 74 | |
75 | - $updateState = $this->updateChecker->getUpdateState(); |
|
75 | + $updateState = $this->updateChecker->getUpdateState(); |
|
76 | 76 | |
77 | - $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true); |
|
77 | + $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true); |
|
78 | 78 | |
79 | - $defaultUpdateServerURL = 'https://updates.nextcloud.com/server/'; |
|
80 | - $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL); |
|
79 | + $defaultUpdateServerURL = 'https://updates.nextcloud.com/server/'; |
|
80 | + $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL); |
|
81 | 81 | |
82 | - $params = [ |
|
83 | - 'isNewVersionAvailable' => !empty($updateState['updateAvailable']), |
|
84 | - 'isUpdateChecked' => $lastUpdateCheckTimestamp > 0, |
|
85 | - 'lastChecked' => $lastUpdateCheck, |
|
86 | - 'currentChannel' => $currentChannel, |
|
87 | - 'channels' => $channels, |
|
88 | - 'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'], |
|
89 | - 'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'], |
|
90 | - 'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'], |
|
91 | - 'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL, |
|
92 | - 'updateServerURL' => $updateServerURL, |
|
93 | - 'notifyGroups' => implode('|', $notifyGroups), |
|
94 | - ]; |
|
82 | + $params = [ |
|
83 | + 'isNewVersionAvailable' => !empty($updateState['updateAvailable']), |
|
84 | + 'isUpdateChecked' => $lastUpdateCheckTimestamp > 0, |
|
85 | + 'lastChecked' => $lastUpdateCheck, |
|
86 | + 'currentChannel' => $currentChannel, |
|
87 | + 'channels' => $channels, |
|
88 | + 'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'], |
|
89 | + 'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'], |
|
90 | + 'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'], |
|
91 | + 'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL, |
|
92 | + 'updateServerURL' => $updateServerURL, |
|
93 | + 'notifyGroups' => implode('|', $notifyGroups), |
|
94 | + ]; |
|
95 | 95 | |
96 | - $params = [ |
|
97 | - 'json' => json_encode($params), |
|
98 | - ]; |
|
96 | + $params = [ |
|
97 | + 'json' => json_encode($params), |
|
98 | + ]; |
|
99 | 99 | |
100 | - return new TemplateResponse('updatenotification', 'admin', $params, ''); |
|
101 | - } |
|
100 | + return new TemplateResponse('updatenotification', 'admin', $params, ''); |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * @return string the section ID, e.g. 'sharing' |
|
105 | - */ |
|
106 | - public function getSection(): string { |
|
107 | - return 'server'; |
|
108 | - } |
|
103 | + /** |
|
104 | + * @return string the section ID, e.g. 'sharing' |
|
105 | + */ |
|
106 | + public function getSection(): string { |
|
107 | + return 'server'; |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * @return int whether the form should be rather on the top or bottom of |
|
112 | - * the admin section. The forms are arranged in ascending order of the |
|
113 | - * priority values. It is required to return a value between 0 and 100. |
|
114 | - * |
|
115 | - * E.g.: 70 |
|
116 | - */ |
|
117 | - public function getPriority(): int { |
|
118 | - return 1; |
|
119 | - } |
|
110 | + /** |
|
111 | + * @return int whether the form should be rather on the top or bottom of |
|
112 | + * the admin section. The forms are arranged in ascending order of the |
|
113 | + * priority values. It is required to return a value between 0 and 100. |
|
114 | + * |
|
115 | + * E.g.: 70 |
|
116 | + */ |
|
117 | + public function getPriority(): int { |
|
118 | + return 1; |
|
119 | + } |
|
120 | 120 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | /** |
4 | 4 | * @copyright Copyright (c) 2016, ownCloud, Inc. |
5 | 5 | * |