Files
iTop/sources/Controller/Notifications/ActionController.php
Pierre Goiffon bec5e250a5 N°5472 Notification Action objects : add a last executions tab (#549)
This tab is an ajax tab (deferred on demand loading)
The tab will display the last EventNotification for this action. Number of objects displayed is based on the new `notifications.last_executions_days` config parameter (default to 61 days, can be set to 0 for no limit)
2024-02-14 10:07:24 +01:00

48 lines
1.3 KiB
PHP

<?php
/*
* @copyright Copyright (C) 2010-2024 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Controller\Notifications;
use Action;
use Combodo\iTop\Application\WebPage\AjaxPage;
use Combodo\iTop\Controller\AbstractController;
use CoreException;
use CoreUnexpectedValue;
use Dict;
use MetaModel;
use utils;
/**
* @internal
* @since 3.2.0 N°5472 creation
*/
class ActionController extends AbstractController {
public const ROUTE_NAMESPACE = 'notifications.action';
/**
* @throws CoreException if cannot load the Action object
* @throws CoreUnexpectedValue if `actionid` parameter is invalid
* @since 3.2.0 N°5472 creation
*/
public function OperationLastExecutionsTab()
{
$sActionId = utils::ReadParam('action_id', null, false);
$sCannotLoadActionErrorMessage = __METHOD__ . ': invalid action_id parameter';
if (utils::IsNullOrEmptyString($sActionId)) {
throw new CoreUnexpectedValue($sCannotLoadActionErrorMessage);
}
$oAction = MetaModel::GetObject(Action::class, $sActionId, false);
if (is_null($oAction)) {
throw new CoreException($sCannotLoadActionErrorMessage);
}
$oPage = new AjaxPage(Dict::S('Action:last_executions_tab'));
$oAction->GetLastExecutionsTabContent($oPage);
return $oPage;
}
}