From b72fab5212fc62634704b90b77ccd3d3b2d60fe6 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 7 Jan 2014 12:40:05 +0100 Subject: [PATCH] start update process --- .../Thelia/Config/Resources/routing/admin.xml | 5 ++ .../Controller/Admin/UpdateController.php | 71 +++++++++++++++++++ .../Core/Security/Resource/AdminResources.php | 2 + .../backOffice/default/update-notneeded.html | 6 ++ 4 files changed, 84 insertions(+) create mode 100644 core/lib/Thelia/Controller/Admin/UpdateController.php create mode 100644 templates/backOffice/default/update-notneeded.html diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index c0e54528a..d77245421 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -1122,6 +1122,11 @@ Thelia\Controller\Admin\TranslationsController::updateAction + + + Thelia\Controller\Admin\UpdateController::indexAction + + diff --git a/core/lib/Thelia/Controller/Admin/UpdateController.php b/core/lib/Thelia/Controller/Admin/UpdateController.php new file mode 100644 index 000000000..e1f408d1f --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/UpdateController.php @@ -0,0 +1,71 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Thelia\Controller\Admin\BaseAdminController; +use Thelia\Core\Security\AccessManager; +use Thelia\Core\Security\Resource\AdminResources; +use Thelia\Model\ConfigQuery; + + +/** + * Class UpdateController + * @package Thelia\Controller\Update + * @author Manuel Raynaud + */ +class UpdateController extends BaseAdminController +{ + + const UPDATE_RESOURCE = 'update'; + + protected static $version = array( + '0' => '2.0.0-beta1', + '1' => '2.0.0-beta2', + ); + + protected function isLatestVersion($version) + { + $lastEntry = array_pop(self::$version); + + return $lastEntry == $version; + } + + public function indexAction() + { + // Check current user authorization + if (null !== $this->checkAuth(AdminResources::UPDATE, array(), AccessManager::VIEW)) { + throw new NotFoundHttpException(); + } + + $currentVersion = ConfigQuery::read('thelia_version'); + + if(true === $this->isLatestVersion($currentVersion)) { + return $this->render('update-notneeded'); + } else { + return $this->render('update-index', array( + 'current_version' => $currentVersion + )); + } + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Resource/AdminResources.php b/core/lib/Thelia/Core/Security/Resource/AdminResources.php index a3e834d9d..ec2657e2b 100644 --- a/core/lib/Thelia/Core/Security/Resource/AdminResources.php +++ b/core/lib/Thelia/Core/Security/Resource/AdminResources.php @@ -103,4 +103,6 @@ final class AdminResources const STORE = "admin.configuration.store"; const TRANSLATIONS = "admin.configuration.translations"; + + const UPDATE = "admin.update"; } diff --git a/templates/backOffice/default/update-notneeded.html b/templates/backOffice/default/update-notneeded.html new file mode 100644 index 000000000..263be3d18 --- /dev/null +++ b/templates/backOffice/default/update-notneeded.html @@ -0,0 +1,6 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Update'}{/block} + +{block name="check-resource"}update{/block} +{block name="check-access"}view{/block} \ No newline at end of file