diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 7173fa8ce..d9951780e 100644 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -16,6 +16,10 @@ Thelia\Controller\Admin\HomeController::defaultAction + + Thelia\Controller\Admin\HomeController::getLatestTheliaVersion + + Thelia\Controller\Admin\HomeController::loadStatsAjaxAction diff --git a/core/lib/Thelia/Controller/Admin/HomeController.php b/core/lib/Thelia/Controller/Admin/HomeController.php index eb7a9a2ab..21391ecc3 100644 --- a/core/lib/Thelia/Controller/Admin/HomeController.php +++ b/core/lib/Thelia/Controller/Admin/HomeController.php @@ -23,6 +23,7 @@ namespace Thelia\Controller\Admin; +use Thelia\Core\HttpFoundation\Response; use Thelia\Core\Security\AccessManager; use Thelia\Model\CustomerQuery; use Thelia\Model\OrderQuery; @@ -39,6 +40,26 @@ class HomeController extends BaseAdminController return $this->render('home'); } + /** + * Get the latest available Thelia version from the Thelia web site. + * + * @return Thelia\Core\HttpFoundation\Response the response + */ + public function getLatestTheliaVersion() + { + if (null !== $response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::VIEW)) return $response; + + // get the latest version + $version = @file_get_contents("http://thelia.net/version.php"); + + if ($version === false) + $version = $this->getTranslator()->trans("Not found"); + else if (! preg_match("/^[0-9.]*$/", $version)) + $version = $this->getTranslator()->trans("Unavailable"); + + return Response::create($version); + } + public function loadStatsAjaxAction() { if (null !== $response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::VIEW)) return $response;