@@ -34,84 +34,84 @@ |
||
| 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(); |
|
| 64 | + $channels = [ |
|
| 65 | + 'daily', |
|
| 66 | + 'beta', |
|
| 67 | + 'stable', |
|
| 68 | + 'production', |
|
| 69 | + ]; |
|
| 70 | + $currentChannel = Util::getChannel(); |
|
| 71 | 71 | |
| 72 | - // Remove the currently used channel from the channels list |
|
| 73 | - if(($key = array_search($currentChannel, $channels, true)) !== false) { |
|
| 74 | - unset($channels[$key]); |
|
| 75 | - } |
|
| 76 | - $updateState = $this->updateChecker->getUpdateState(); |
|
| 72 | + // Remove the currently used channel from the channels list |
|
| 73 | + if(($key = array_search($currentChannel, $channels, true)) !== false) { |
|
| 74 | + unset($channels[$key]); |
|
| 75 | + } |
|
| 76 | + $updateState = $this->updateChecker->getUpdateState(); |
|
| 77 | 77 | |
| 78 | - $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true); |
|
| 78 | + $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true); |
|
| 79 | 79 | |
| 80 | - $defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/'; |
|
| 81 | - $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL); |
|
| 80 | + $defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/'; |
|
| 81 | + $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL); |
|
| 82 | 82 | |
| 83 | - $params = [ |
|
| 84 | - 'isNewVersionAvailable' => !empty($updateState['updateAvailable']), |
|
| 85 | - 'isUpdateChecked' => $lastUpdateCheckTimestamp > 0, |
|
| 86 | - 'lastChecked' => $lastUpdateCheck, |
|
| 87 | - 'currentChannel' => $currentChannel, |
|
| 88 | - 'channels' => $channels, |
|
| 89 | - 'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'], |
|
| 90 | - 'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'], |
|
| 91 | - 'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'], |
|
| 92 | - 'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL, |
|
| 93 | - 'updateServerURL' => $updateServerURL, |
|
| 94 | - 'notify_groups' => implode('|', $notifyGroups), |
|
| 95 | - ]; |
|
| 83 | + $params = [ |
|
| 84 | + 'isNewVersionAvailable' => !empty($updateState['updateAvailable']), |
|
| 85 | + 'isUpdateChecked' => $lastUpdateCheckTimestamp > 0, |
|
| 86 | + 'lastChecked' => $lastUpdateCheck, |
|
| 87 | + 'currentChannel' => $currentChannel, |
|
| 88 | + 'channels' => $channels, |
|
| 89 | + 'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'], |
|
| 90 | + 'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'], |
|
| 91 | + 'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'], |
|
| 92 | + 'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL, |
|
| 93 | + 'updateServerURL' => $updateServerURL, |
|
| 94 | + 'notify_groups' => implode('|', $notifyGroups), |
|
| 95 | + ]; |
|
| 96 | 96 | |
| 97 | - return new TemplateResponse('updatenotification', 'admin', $params, ''); |
|
| 98 | - } |
|
| 97 | + return new TemplateResponse('updatenotification', 'admin', $params, ''); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * @return string the section ID, e.g. 'sharing' |
|
| 102 | - */ |
|
| 103 | - public function getSection(): string { |
|
| 104 | - return 'server'; |
|
| 105 | - } |
|
| 100 | + /** |
|
| 101 | + * @return string the section ID, e.g. 'sharing' |
|
| 102 | + */ |
|
| 103 | + public function getSection(): string { |
|
| 104 | + return 'server'; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * @return int whether the form should be rather on the top or bottom of |
|
| 109 | - * the admin section. The forms are arranged in ascending order of the |
|
| 110 | - * priority values. It is required to return a value between 0 and 100. |
|
| 111 | - * |
|
| 112 | - * E.g.: 70 |
|
| 113 | - */ |
|
| 114 | - public function getPriority(): int { |
|
| 115 | - return 1; |
|
| 116 | - } |
|
| 107 | + /** |
|
| 108 | + * @return int whether the form should be rather on the top or bottom of |
|
| 109 | + * the admin section. The forms are arranged in ascending order of the |
|
| 110 | + * priority values. It is required to return a value between 0 and 100. |
|
| 111 | + * |
|
| 112 | + * E.g.: 70 |
|
| 113 | + */ |
|
| 114 | + public function getPriority(): int { |
|
| 115 | + return 1; |
|
| 116 | + } |
|
| 117 | 117 | } |