mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-21 16:22:20 +02:00
Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts: # core/cmdbsource.class.inc.php # core/coreexception.class.inc.php # core/log.class.inc.php
This commit is contained in:
@@ -68,6 +68,8 @@ Dict::Add('EN US', 'English', 'English', array(
|
||||
Dict::Add('EN US', 'English', 'English', array(
|
||||
'Portal:Form:Caselog:Entry:Close:Tooltip' => 'Close this entry',
|
||||
'Portal:Form:Close:Warning' => 'Do you want to leave this form ? Data entered may be lost',
|
||||
'Portal:Error:ObjectCannotBeCreated' => 'Error: object cannot be created. Check associated objects and attachments before submitting again this form.',
|
||||
'Portal:Error:ObjectCannotBeUpdated' => 'Error: object cannot be updated. Check associated objects and attachments before submitting again this form.',
|
||||
));
|
||||
|
||||
// UserProfile brick
|
||||
|
||||
@@ -67,6 +67,8 @@ Dict::Add('FR FR', 'French', 'Français', array(
|
||||
Dict::Add('FR FR', 'French', 'Français', array(
|
||||
'Portal:Form:Caselog:Entry:Close:Tooltip' => 'Fermer cette entrée',
|
||||
'Portal:Form:Close:Warning' => 'Voulez-vous quitter ce formulaire ? Les données saisies seront perdues',
|
||||
'Portal:Error:ObjectCannotBeCreated' => 'Erreur: L\'objet n\'a pas été créé. Vérifiez les objets liés et les attachements avant de soumettre à nouveau le formulaire.',
|
||||
'Portal:Error:ObjectCannotBeUpdated' => 'Erreur: L\'objet n\'a pas été modifié. Vérifiez les objets liés et les attachements avant de soumettre à nouveau le formulaire.',
|
||||
));
|
||||
|
||||
// UserProfile brick
|
||||
|
||||
@@ -30,6 +30,7 @@ use DBObjectSearch;
|
||||
use DBObjectSet;
|
||||
use DBSearch;
|
||||
use FieldExpression;
|
||||
use IssueLog;
|
||||
use MetaModel;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -65,6 +66,8 @@ class BrowseBrickController extends BrickController
|
||||
*/
|
||||
public function DisplayAction(Request $oRequest, $sBrickId, $sBrowseMode = null, $sDataLoading = null)
|
||||
{
|
||||
$sPortalId = $this->getParameter('combodo.portal.instance.id');
|
||||
|
||||
/** @var \Combodo\iTop\Portal\Helper\BrowseBrickHelper $oBrowseBrickHelper */
|
||||
$oBrowseBrickHelper = $this->get('browse_brick');
|
||||
/** @var \Combodo\iTop\Portal\Helper\RequestManipulatorHelper $oRequestManipulator */
|
||||
@@ -266,8 +269,7 @@ class BrowseBrickController extends BrickController
|
||||
// Note : This could be way more simpler if we had a SetInternalParam($sParam, $value) verb
|
||||
$aQueryParams = $aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search']->GetInternalParams();
|
||||
// Note : $iSearchloopMax was initialized on the previous loop
|
||||
for ($j = 0; $j <= $iSearchLoopMax; $j++)
|
||||
{
|
||||
for ($j = 0; $j <= $iSearchLoopMax; $j++) {
|
||||
$aQueryParams['search_value_'.$j] = '%'.$aSearchValues[$j].'%';
|
||||
}
|
||||
$aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search']->SetInternalParams($aQueryParams);
|
||||
@@ -277,12 +279,11 @@ class BrowseBrickController extends BrickController
|
||||
$oQuery = $aLevelsProperties[$aLevelsPropertiesKeys[0]]['search'];
|
||||
|
||||
// Testing appropriate data loading mode if we are in auto
|
||||
if ($sDataLoading === AbstractBrick::ENUM_DATA_LOADING_AUTO)
|
||||
{
|
||||
if ($sDataLoading === AbstractBrick::ENUM_DATA_LOADING_AUTO) {
|
||||
// - Check how many records there is.
|
||||
// - Update $sDataLoading with its new value regarding the number of record and the threshold
|
||||
$oCountSet = new DBObjectSet($oQuery);
|
||||
$fThreshold = (float)MetaModel::GetModuleSetting($this->getParameter('combodo.portal.instance.id'),
|
||||
$fThreshold = (float)MetaModel::GetModuleSetting($sPortalId,
|
||||
'lazy_loading_threshold');
|
||||
$sDataLoading = ($oCountSet->Count() > $fThreshold) ? AbstractBrick::ENUM_DATA_LOADING_LAZY : AbstractBrick::ENUM_DATA_LOADING_FULL;
|
||||
unset($oCountSet);
|
||||
@@ -440,17 +441,21 @@ class BrowseBrickController extends BrickController
|
||||
}
|
||||
}
|
||||
|
||||
IssueLog::Debug('Portal BrowseBrick query', 'portal', array(
|
||||
'portalId' => $sPortalId,
|
||||
'brickId' => $sBrickId,
|
||||
'oql' => $oSet->GetFilter()->ToOQL(),
|
||||
));
|
||||
|
||||
|
||||
// Preparing response
|
||||
if ($oRequest->isXmlHttpRequest())
|
||||
{
|
||||
if ($oRequest->isXmlHttpRequest()) {
|
||||
$aData = $aData + array(
|
||||
'data' => $aItems,
|
||||
'levelsProperties' => $aLevelsProperties,
|
||||
);
|
||||
$oResponse = new JsonResponse($aData);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$aData = $aData + array(
|
||||
'oBrick' => $oBrick,
|
||||
'sBrickId' => $sBrickId,
|
||||
|
||||
@@ -42,6 +42,7 @@ use Dict;
|
||||
use Exception;
|
||||
use FieldExpression;
|
||||
use iPopupMenuExtension;
|
||||
use IssueLog;
|
||||
use JSButtonItem;
|
||||
use MetaModel;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
@@ -89,10 +90,10 @@ class ManageBrickController extends BrickController
|
||||
/** @var \Combodo\iTop\Portal\Brick\ManageBrick $oBrick */
|
||||
$oBrick = $oBrickCollection->GetBrickById($sBrickId);
|
||||
|
||||
if (is_null($sDisplayMode))
|
||||
{
|
||||
if (is_null($sDisplayMode)) {
|
||||
$sDisplayMode = $oBrick->GetDefaultDisplayMode();
|
||||
}
|
||||
|
||||
$aData = $this->GetData($oRequest, $sBrickId, $sGroupingTab, $oBrick::AreDetailsNeededForDisplayMode($sDisplayMode));
|
||||
|
||||
$aExportFields = $oBrick->GetExportFields();
|
||||
@@ -102,8 +103,7 @@ class ManageBrickController extends BrickController
|
||||
'iDefaultListLength' => $oBrick->GetDefaultListLength(),
|
||||
);
|
||||
// Preparing response
|
||||
if ($oRequest->isXmlHttpRequest())
|
||||
{
|
||||
if ($oRequest->isXmlHttpRequest()) {
|
||||
$oResponse = new JsonResponse($aData);
|
||||
}
|
||||
else
|
||||
@@ -815,30 +815,31 @@ class ManageBrickController extends BrickController
|
||||
'aColumnsDefinition' => $aColumnsDefinition,
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
IssueLog::Debug('Portal ManageBrick query', 'portal', array(
|
||||
'portalId' => $sPortalId,
|
||||
'brickId' => $sBrickId,
|
||||
'groupingTab' => $sGroupingTab,
|
||||
'oql' => $oSet->GetFilter()->ToOQL(),
|
||||
'aGroupingTabs' => $aGroupingTabs,
|
||||
));
|
||||
} else {
|
||||
$aGroupingAreasData = array();
|
||||
$sGroupingArea = null;
|
||||
}
|
||||
|
||||
// Preparing response
|
||||
if ($oRequest->isXmlHttpRequest())
|
||||
{
|
||||
if ($oRequest->isXmlHttpRequest()) {
|
||||
$aData = $aData + array(
|
||||
'data' => $aGroupingAreasData[$sGroupingArea]['aItems'],
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$aDisplayValues = array();
|
||||
$aUrls = array();
|
||||
$aColumns = array();
|
||||
$aNames = array();
|
||||
if ($bHasScope)
|
||||
{
|
||||
foreach ($aGroupingTabsValues as $aValues)
|
||||
{
|
||||
if ($bHasScope) {
|
||||
foreach ($aGroupingTabsValues as $aValues) {
|
||||
$aDisplayValues[] = array(
|
||||
'value' => $aValues['count'],
|
||||
'label' => $aValues['label'],
|
||||
|
||||
@@ -25,14 +25,12 @@ use AttributeDateTime;
|
||||
use AttributeTagSet;
|
||||
use CMDBChangeOpAttachmentAdded;
|
||||
use CMDBChangeOpAttachmentRemoved;
|
||||
use CMDBSource;
|
||||
use Combodo\iTop\Form\Field\Field;
|
||||
use Combodo\iTop\Form\Field\FileUploadField;
|
||||
use Combodo\iTop\Form\Field\LabelField;
|
||||
use Combodo\iTop\Form\Form;
|
||||
use Combodo\iTop\Form\FormManager;
|
||||
use Combodo\iTop\Portal\Helper\ApplicationHelper;
|
||||
use CoreCannotSaveObjectException;
|
||||
use DBObject;
|
||||
use DBObjectSearch;
|
||||
use DBObjectSet;
|
||||
@@ -1121,30 +1119,28 @@ class ObjectFormManager extends FormManager
|
||||
return $aData;
|
||||
}
|
||||
|
||||
// The try catch is essentially to start a MySQL transaction in order to ensure that all or none objects are persisted when creating an object with links
|
||||
try
|
||||
{
|
||||
$sObjectClass = get_class($this->oObject);
|
||||
$sObjectClass = get_class($this->oObject);
|
||||
|
||||
// Starting transaction
|
||||
CMDBSource::Query('START TRANSACTION');
|
||||
try {
|
||||
// Forcing allowed writing on the object if necessary. This is used in some particular cases.
|
||||
$bAllowWrite = ($sObjectClass === 'Person' && $this->oObject->GetKey() == UserRights::GetContactId());
|
||||
if ($bAllowWrite)
|
||||
{
|
||||
if ($bAllowWrite) {
|
||||
$this->oObject->AllowWrite(true);
|
||||
}
|
||||
|
||||
// Writing object to DB
|
||||
$bActivateTriggers = (!$this->oObject->IsNew() && $this->oObject->IsModified());
|
||||
$bIsNew = $this->oObject->IsNew();
|
||||
$bWasModified = $this->oObject->IsModified();
|
||||
$bActivateTriggers = (!$bIsNew && $bWasModified);
|
||||
try
|
||||
{
|
||||
$this->oObject->DBWrite();
|
||||
}
|
||||
catch (CoreCannotSaveObjectException $e)
|
||||
{
|
||||
throw new Exception($e->getHtmlMessage());
|
||||
catch (Exception $e) {
|
||||
if ($bIsNew) {
|
||||
throw new Exception(Dict::S('Portal:Error:ObjectCannotBeCreated'));
|
||||
}
|
||||
throw new Exception(Dict::S('Portal:Error:ObjectCannotBeUpdated'));
|
||||
}
|
||||
// Finalizing images link to object, otherwise it will be cleaned by the GC
|
||||
InlineImage::FinalizeInlineImages($this->oObject);
|
||||
@@ -1155,9 +1151,6 @@ class ObjectFormManager extends FormManager
|
||||
$this->FinalizeAttachments($aArgs['attachmentIds']);
|
||||
}
|
||||
|
||||
// Ending transaction with a commit as everything was fine
|
||||
CMDBSource::Query('COMMIT');
|
||||
|
||||
// Checking if we have to apply a stimulus
|
||||
if (isset($aArgs['applyStimulus']))
|
||||
{
|
||||
@@ -1205,14 +1198,11 @@ class ObjectFormManager extends FormManager
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// End transaction with a rollback as something failed
|
||||
CMDBSource::Query('ROLLBACK');
|
||||
$aData['valid'] = false;
|
||||
$aData['messages']['error'] += array('_main' => array($e->getMessage()));
|
||||
IssueLog::Error(__METHOD__.' at line '.__LINE__.' : Rollback during submit ('.$e->getMessage().')');
|
||||
IssueLog::Error(__METHOD__.' at line '.__LINE__.' : '.$e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
return $aData;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user