N°2060 - Fix session messages and SCSS compilation services being cached

This commit is contained in:
Molkobain
2020-01-16 11:28:25 +01:00
parent a6fe564a95
commit 53adb37f43
6 changed files with 184 additions and 56 deletions

View File

@@ -48,6 +48,9 @@ $oListsCompat = new Lists($oModuleDesign);
$oListsCompat->Process($container);
// Generating CSS files
// Note: We do this here as it is not user dependent and therefore can be cached for everyone.
// A dedicated listener 'CssFromSassCompiler' exists to compile files again when by-passing HTTP cache.
// This is to keep developers comfort when tuning the SCSS files.
$aImportPaths = array($_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_PATH'].'css/');
$aPortalConf = $container->getParameter('combodo.portal.instance.conf');
foreach ($aPortalConf['properties']['themes'] as $sKey => $value)
@@ -68,43 +71,4 @@ foreach ($aPortalConf['properties']['themes'] as $sKey => $value)
$aPortalConf['properties']['themes'][$sKey] = $aValues;
}
}
$container->setParameter('combodo.portal.instance.conf', $aPortalConf);
//TODO: The following needs to be refactored
// Session messages
// Note: We keep this system instead of following the Symfony system to make it simpler for extension developers to use them accross the admin. console and the portal.
$aAllMessages = array();
if ((array_key_exists('obj_messages', $_SESSION)) && (!empty($_SESSION['obj_messages'])))
{
foreach ($_SESSION['obj_messages'] as $sMessageKey => $aMessageObjectData)
{
$aObjectMessages = array();
$aRanks = array();
foreach ($aMessageObjectData as $sMessageId => $aMessageData)
{
$sMsgClass = 'alert alert-dismissible alert-';
switch ($aMessageData['severity'])
{
case 'info':
$sMsgClass .= 'info';
break;
case 'error':
$sMsgClass .= 'danger';
break;
case 'ok':
default:
$sMsgClass .= 'success';
break;
}
$aObjectMessages[] = array('css_classes' => $sMsgClass, 'message' => $aMessageData['message']);
$aRanks[] = $aMessageData['rank'];
}
//unset($_SESSION['obj_messages'][$sMessageKey]);
array_multisort($aRanks, $aObjectMessages);
foreach ($aObjectMessages as $aObjectMessage)
{
$aAllMessages[] = $aObjectMessage;
}
}
}
$container->setParameter('combodo.current_user.session_messages', $aAllMessages);
$container->setParameter('combodo.portal.instance.conf', $aPortalConf);

View File

@@ -0,0 +1,21 @@
# Copyright (C) 2010-2020 Combodo SARL
#
# This file is part of iTop.
#
# iTop is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iTop is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with iTop. If not, see <http://www.gnu.org/licenses/>
p_session_message_add:
path: '/session-message/add'
defaults:
_controller: 'Combodo\iTop\Portal\Controller\SessionMessageController::AddMessageAction'

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2010-2018 Combodo SARL
# Copyright (C) 2010-2020 Combodo SARL
#
# This file is part of iTop.
#
@@ -74,6 +74,8 @@ services:
tags: [{ name: 'kernel.event_listener', event: 'kernel.request', priority: 400 }]
Combodo\iTop\Portal\EventListener\ApplicationContextSetPluginPropertyClass:
tags: [{ name: 'kernel.event_listener', event: 'kernel.request', priority: 300 }]
Combodo\iTop\Portal\EventListener\CssFromSassCompiler:
tags: [{ name: 'kernel.event_listener', event: 'kernel.request', priority: 200 }]
# Add more service definitions when explicit configuration is needed
# Please note that last definitions always *replace* previous ones
@@ -141,4 +143,7 @@ services:
public: true
brick_controller_helper:
alias: Combodo\iTop\Portal\Helper\BrickControllerHelper
public: true
session_message_helper:
alias: Combodo\iTop\Portal\Helper\SessionMessageHelper
public: true