Adapt Welcome Popup API for the 3.0.x branch

This commit is contained in:
denis.flaven@combodo.com
2023-05-30 08:00:32 +02:00
parent 1e41e805a2
commit 9d6f4569ef
3 changed files with 23 additions and 25 deletions

View File

@@ -2691,33 +2691,31 @@ EOF
$oAjaxRenderController->GetMenusCount($oPage);
break;
//--------------------------------
// WelcomePopupMenu
//--------------------------------
case 'welcome_popup.acknowledge_message':
$oPage = new JsonPage();
try {
$oController = new WelcomePopupController();
$oController->AcknowledgeMessage();
$aResult = ['success' => true];
}
catch (Exception $oException) {
$aResult = [
'success' => false,
'error_message' => $oException->getMessage(),
];
}
$oPage->SetData($aResult);
break;
//--------------------------------
// WelcomePopupMenu
//--------------------------------
case 'welcome_popup_acknowledge_message':
$oPage = new JsonPage();
try {
$oController = new WelcomePopupController();
$oController->AcknowledgeMessage();
$aResult = ['success' => true];
}
catch (Exception $oException) {
$aResult = [
'success' => false,
'error_message' => $oException->getMessage(),
];
}
$oPage->SetData($aResult);
break;
default:
$oPage->p("Invalid query.");
}
default:
$oPage->p("Invalid query.");
}
$oKPI->ComputeAndReport('Data fetch and format');
$oPage->output();
} catch (Exception $e)
{
} catch (Exception $e) {
// note: transform to cope with XSS attacks
echo htmlentities($e->GetMessage(), ENT_QUOTES, 'utf-8');
IssueLog::Error($e->getMessage()."\nDebug trace:\n".$e->getTraceAsString());

View File

@@ -9,7 +9,7 @@ use utils;
* @since 3.1.0
*
*/
class WelcomePopupController extends AbstractController
class WelcomePopupController
{
/**
* Operation: welcome_popup.acknowledge_message

View File

@@ -20,7 +20,7 @@ $('.ibo-welcome-popup--indicator').click(function() {
});
$('.ibo-welcome-popup--button').click('button', function() {
const id = $(this).attr('data-message-uuid');
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', {operation: 'welcome_popup.acknowledge_message', message_uuid: id});
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', {operation: 'welcome_popup_acknowledge_message', message_uuid: id});
const escaped_id = id.replace(/\\/g, '\\\\');; // All backslashes must be doubled in a jQuery selector
$('.ibo-welcome-popup--message[data-message-uuid="'+escaped_id+'"]').remove();
if($('.ibo-welcome-popup--message').length == 0) {