Commit c9b73a02 authored by Tino Goratsch's avatar Tino Goratsch

added an alert message when the currently used ACP3 CMS is outdated

refs #62
parent 67a57117
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Modules\ACP3\System\Event\Listener;
use ACP3\Core\ACL;
use ACP3\Core\Controller\AreaEnum;
use ACP3\Core\Http\RequestInterface;
use ACP3\Core\View;
use ACP3\Modules\ACP3\System\Helper\UpdateCheck;
class RenderUpdateCheckAlertOnLayoutContentBeforeListener
{
/**
* @var UpdateCheck
*/
private $updateCheck;
/**
* @var View
*/
private $view;
/**
* @var RequestInterface
*/
private $request;
/**
* @var ACL
*/
private $acl;
/**
* RenderUpdateCheckAlertOnLayoutContentBeforeListener constructor.
* @param ACL $acl
* @param RequestInterface $request
* @param View $view
* @param UpdateCheck $updateCheck
*/
public function __construct(
ACL $acl,
RequestInterface $request,
View $view,
UpdateCheck $updateCheck
) {
$this->updateCheck = $updateCheck;
$this->view = $view;
$this->request = $request;
$this->acl = $acl;
}
public function renderUpdateCheckAlert()
{
$update = $this->updateCheck->checkForNewVersion();
if ($this->canRenderUpdateAlert($update['is_latest'])) {
$this->view->assign('update', $update);
$this->view->displayTemplate('System/Partials/alert_update_check.tpl');
}
}
/**
* @param bool $isLatestVersion
* @return bool
*/
private function canRenderUpdateAlert($isLatestVersion)
{
return $isLatestVersion === false
&& $this->request->getArea() === AreaEnum::AREA_ADMIN
&& $this->request->getFullPath() !== 'acp/system/maintenance/update_check/'
&& $this->acl->hasPermission('admin/system/maintenance/update_check');
}
}
<div class="alert alert-sm alert-warning text-center">
<small>
{if $update.is_latest}
{lang t="system|acp3_up_to_date"}
{else}
{lang t="system|acp3_not_up_to_date" args=['%link_start%' => "<a href=\"`$update.url`\" target=\"_blank\">",'%link_end%' => '</a>']}
{/if}
</small>
</div>
...@@ -36,3 +36,13 @@ services: ...@@ -36,3 +36,13 @@ services:
- '@core.view' - '@core.view'
tags: tags:
- { name: core.eventListener, event: layout.content_before, method: renderCookieConsent } - { name: core.eventListener, event: layout.content_before, method: renderCookieConsent }
system.event.listener.render_update_check_alert_on_layout_content_before_listener:
class: ACP3\Modules\ACP3\System\Event\Listener\RenderUpdateCheckAlertOnLayoutContentBeforeListener
arguments:
- '@core.acl'
- '@core.http.request'
- '@core.view'
- '@system.helpers.update_check'
tags:
- { name: core.eventListener, event: layout.content_before, method: renderUpdateCheckAlert }
...@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ...@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added the possibility to duplicate downloads via the admin data grid - Added the possibility to duplicate downloads via the admin data grid
- Added the possibility to quickly enable/disable downloads - Added the possibility to quickly enable/disable downloads
- Added the possibility to sort downloads by date or with an custom order - Added the possibility to sort downloads by date or with an custom order
- [#62](https://github.com/ACP3/cms/issues/62) Added an alert message when the currently used ACP3 CMS is outdated
### Changed ### Changed
- Updated `giggsey/locale` library to version 1.3 to take advantage of the new functionality for the localized country list - Updated `giggsey/locale` library to version 1.3 to take advantage of the new functionality for the localized country list
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment