mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°6167 - Introduce API for the content of the Welcome Popup (#505)
* API for the content of the Welcome Popup * Apply suggestions from code review * N°7410 - Refactor code to match conventions * N°7410 - Refactor to new design * N°7410 - Review adjustments * N°7410 - Review adjustments * N°7410 - Update translations * N°7410 - Update setup complied file * Update sources/Application/WelcomePopup/Provider/DefaultProvider.php --------- Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
This commit is contained in:
45
sources/Controller/WelcomePopupController.php
Normal file
45
sources/Controller/WelcomePopupController.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace Combodo\iTop\Controller;
|
||||
|
||||
use Combodo\iTop\Application\WebPage\JsonPage;
|
||||
use Combodo\iTop\Application\WelcomePopup\WelcomePopupService;
|
||||
use Exception;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* Simple controller to acknowledge (via Ajax) welcome popup messages
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class WelcomePopupController extends AbstractController
|
||||
{
|
||||
/** @inheritDoc */
|
||||
const ROUTE_NAMESPACE = "welcome_popup";
|
||||
|
||||
/**
|
||||
* Acknowledge a specific message for the current user
|
||||
* @return \Combodo\iTop\Application\WebPage\JsonPage
|
||||
*/
|
||||
public function OperationAcknowledgeMessage(): JsonPage
|
||||
{
|
||||
$oPage = new JsonPage();
|
||||
$oPage->SetOutputDataOnly(true);
|
||||
|
||||
try {
|
||||
$oService = WelcomePopupService::GetInstance();
|
||||
$sMessageUUID = utils::ReadPostedParam('message_uuid', '', false, utils::ENUM_SANITIZATION_FILTER_RAW_DATA);
|
||||
$oService->AcknowledgeMessage($sMessageUUID);
|
||||
|
||||
$aResult = ['success' => true];
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
$aResult = [
|
||||
'success' => false,
|
||||
'error_message' => $oException->getMessage(),
|
||||
];
|
||||
}
|
||||
|
||||
$oPage->SetData($aResult);
|
||||
return $oPage;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user