diff options
author | Lukas Reschke <lukas@owncloud.com> | 2016-03-04 13:56:13 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2016-03-04 14:37:35 +0100 |
commit | e3a0a69c7375154b7205511e919363b709ca3831 (patch) | |
tree | 916ff010b45d25a122ef4878bc5b245178349dad /apps/updatenotification/controller/admincontroller.php | |
parent | 8be6054e5ce8aeffd6e305317e57e2747f7909ea (diff) | |
download | nextcloud-server-e3a0a69c7375154b7205511e919363b709ca3831.tar.gz nextcloud-server-e3a0a69c7375154b7205511e919363b709ca3831.zip |
Add release channel selection back
Allows to select the release channels again and also shows the last check date
Diffstat (limited to 'apps/updatenotification/controller/admincontroller.php')
-rw-r--r-- | apps/updatenotification/controller/admincontroller.php | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/apps/updatenotification/controller/admincontroller.php b/apps/updatenotification/controller/admincontroller.php index 505ea01edd9..cb0c6409d7e 100644 --- a/apps/updatenotification/controller/admincontroller.php +++ b/apps/updatenotification/controller/admincontroller.php @@ -21,12 +21,15 @@ namespace OCA\UpdateNotification\Controller; +use OCA\UpdateNotification\UpdateChecker; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; use OCP\IConfig; +use OCP\IDateTimeFormatter; +use OCP\IL10N; use OCP\IRequest; use OCP\Security\ISecureRandom; @@ -39,6 +42,12 @@ class AdminController extends Controller { private $config; /** @var ITimeFactory */ private $timeFactory; + /** @var UpdateChecker */ + private $updateChecker; + /** @var IL10N */ + private $l10n; + /** @var IDateTimeFormatter */ + private $dateTimeFormatter; /** * @param string $appName @@ -47,25 +56,70 @@ class AdminController extends Controller { * @param ISecureRandom $secureRandom * @param IConfig $config * @param ITimeFactory $timeFactory + * @param IL10N $l10n + * @param UpdateChecker $updateChecker + * @param IDateTimeFormatter $dateTimeFormatter */ public function __construct($appName, IRequest $request, IJobList $jobList, ISecureRandom $secureRandom, IConfig $config, - ITimeFactory $timeFactory) { + ITimeFactory $timeFactory, + IL10N $l10n, + UpdateChecker $updateChecker, + IDateTimeFormatter $dateTimeFormatter) { parent::__construct($appName, $request); $this->jobList = $jobList; $this->secureRandom = $secureRandom; $this->config = $config; $this->timeFactory = $timeFactory; + $this->l10n = $l10n; + $this->updateChecker = $updateChecker; + $this->dateTimeFormatter = $dateTimeFormatter; } /** * @return TemplateResponse */ public function displayPanel() { - return new TemplateResponse($this->appName, 'admin', [], ''); + $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime( + $this->config->getAppValue('core', 'lastupdatedat') + ); + + $channels = [ + 'daily', + 'beta', + 'stable', + 'production', + ]; + $currentChannel = \OCP\Util::getChannel(); + + // Remove the currently used channel from the channels list + if(($key = array_search($currentChannel, $channels)) !== false) { + unset($channels[$key]); + } + + $params = [ + 'isNewVersionAvailable' => ($this->updateChecker->getUpdateState() === []) ? false : true, + 'lastChecked' => $lastUpdateCheck, + 'currentChannel' => $currentChannel, + 'channels' => $channels, + ]; + + return new TemplateResponse($this->appName, 'admin', $params, ''); + } + + /** + * @UseSession + * + * @param string $channel + * @return DataResponse + */ + public function setChannel($channel) { + \OCP\Util::setChannel($channel); + $this->config->setAppValue('core', 'lastupdatedat', 0); + return new DataResponse(['status' => 'success', 'data' => ['message' => $this->l10n->t('Updated channel')]]); } /** |