mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°6043 - Booking: Add prerequisites in iTop core - CRUD extensibility (#520)
This commit is contained in:
@@ -398,24 +398,31 @@ JS;
|
||||
{
|
||||
IssueLog::Trace(__CLASS__.'::'.__METHOD__.' Object not created (see $aErrors)', $sClass, array(
|
||||
'$sTransactionId' => $sTransactionId,
|
||||
'$aErrors' => $aErrors,
|
||||
'$sUser' => UserRights::GetUser(),
|
||||
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
|
||||
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
|
||||
'$aErrors' => $aErrors,
|
||||
'$sUser' => UserRights::GetUser(),
|
||||
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
|
||||
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
|
||||
));
|
||||
|
||||
throw new CoreCannotSaveObjectException(array('id' => $oObj->GetKey(), 'class' => $sClass, 'issues' => $aErrors));
|
||||
}
|
||||
|
||||
$oObj->DBInsertNoReload();// No need to reload
|
||||
// Transactions are now handled in DBInsert
|
||||
$oObj->SetContextSection('temporary_objects', [
|
||||
'finalize' => [
|
||||
'transaction_id' => $sTransactionId,
|
||||
],
|
||||
]);
|
||||
$oObj->DBInsertNoReload();
|
||||
|
||||
|
||||
IssueLog::Trace(__CLASS__.'::'.__METHOD__.' Object created', $sClass, array(
|
||||
'$id' => $oObj->GetKey(),
|
||||
'$id' => $oObj->GetKey(),
|
||||
'$sTransactionId' => $sTransactionId,
|
||||
'$aErrors' => $aErrors,
|
||||
'$sUser' => UserRights::GetUser(),
|
||||
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
|
||||
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
|
||||
'$aErrors' => $aErrors,
|
||||
'$sUser' => UserRights::GetUser(),
|
||||
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
|
||||
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
|
||||
));
|
||||
|
||||
utils::RemoveTransaction($sTransactionId);
|
||||
@@ -596,23 +603,28 @@ JS;
|
||||
else
|
||||
{
|
||||
IssueLog::Trace(__CLASS__.'::'.__METHOD__.' Object updated', $sClass, array(
|
||||
'$id' => $id,
|
||||
'$id' => $id,
|
||||
'$sTransactionId' => $sTransactionId,
|
||||
'$aErrors' => $aErrors,
|
||||
'IsModified' => $oObj->IsModified(),
|
||||
'$sUser' => UserRights::GetUser(),
|
||||
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
|
||||
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
|
||||
'$aErrors' => $aErrors,
|
||||
'IsModified' => $oObj->IsModified(),
|
||||
'$sUser' => UserRights::GetUser(),
|
||||
'HTTP_REFERER' => @$_SERVER['HTTP_REFERER'],
|
||||
'REQUEST_URI' => @$_SERVER['REQUEST_URI'],
|
||||
));
|
||||
|
||||
try
|
||||
{
|
||||
if (!empty($aErrors))
|
||||
{
|
||||
try {
|
||||
if (!empty($aErrors)) {
|
||||
throw new CoreCannotSaveObjectException(array('id' => $oObj->GetKey(), 'class' => $sClass, 'issues' => $aErrors));
|
||||
}
|
||||
|
||||
// Transactions are now handled in DBUpdate
|
||||
$oObj->SetContextSection('temporary_objects', [
|
||||
'finalize' => [
|
||||
'transaction_id' => $sTransactionId,
|
||||
],
|
||||
]);
|
||||
$oObj->DBUpdate();
|
||||
|
||||
$sMessage = Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());
|
||||
$sSeverity = 'ok';
|
||||
if ($this->IsHandlingXmlHttpRequest()) {
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2023 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Controller\TemporaryObjects;
|
||||
|
||||
use Combodo\iTop\Controller\AbstractController;
|
||||
use Combodo\iTop\Service\TemporaryObjects\TemporaryObjectManager;
|
||||
use JsonPage;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* TemporaryObjectController.
|
||||
*
|
||||
* Temporary object endpoints.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
class TemporaryObjectController extends AbstractController
|
||||
{
|
||||
public const ROUTE_NAMESPACE = 'temporary_object';
|
||||
|
||||
/** @var \Combodo\iTop\Service\TemporaryObjects\TemporaryObjectManager Temporary object manager */
|
||||
private TemporaryObjectManager $oTemporaryObjectManager;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Retrieve controller dependencies
|
||||
$this->oTemporaryObjectManager = TemporaryObjectManager::GetInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* OperationWatchDog.
|
||||
*
|
||||
* Watchdog for delaying expiration date of temporary objects linked to the provided temporary id.
|
||||
*
|
||||
* @return JsonPage
|
||||
*/
|
||||
public function OperationWatchDog(): JsonPage
|
||||
{
|
||||
$oPage = new JsonPage();
|
||||
|
||||
// Retrieve temp id
|
||||
$sTempId = utils::ReadParam('temp_id', '', false, utils::ENUM_SANITIZATION_FILTER_STRING);
|
||||
|
||||
// Delay temporary objects expiration
|
||||
$bResult = $this->oTemporaryObjectManager->ExtendTemporaryObjectsLifetime($sTempId);
|
||||
|
||||
return $oPage->SetData([
|
||||
'success' => $bResult,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* OperationGarbage.
|
||||
*
|
||||
* Garbage temporary objects based on expiration date.
|
||||
*
|
||||
* @return JsonPage
|
||||
*/
|
||||
public function OperationGarbage(): JsonPage
|
||||
{
|
||||
$oPage = new JsonPage();
|
||||
|
||||
// Garbage expired temporary objects
|
||||
$bResult = $this->oTemporaryObjectManager->GarbageExpiredTemporaryObjects();
|
||||
|
||||
return $oPage->SetData([
|
||||
'success' => $bResult,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user