Compare commits

..

1 Commits
2.4.3 ... 2.4.2

Author SHA1 Message Date
Guillaume Lajarige
7c78acbe25 Creating SVN tag for iTop 2.4.2 (Forgot to create it at the time)
SVN:2.4.2[5922]
2018-06-28 08:26:18 +00:00
15 changed files with 435 additions and 971 deletions

122
.gitignore vendored
View File

@@ -1,122 +0,0 @@
/toolkit/
/conf/*
/env-*/*
# composer reserver directory, from sources, populate/update using "composer install"
vendor/*
test/vendor/*
# all datas but listing prevention
data/*
!data/.htaccess
!data/index.php
!data/web.config
# iTop extensions
extensions/*
!extensions/readme.txt
# all logs but listing prevention
log/*
!log/.htaccess
!log/index.php
!log/web.config
# Jetbrains
.idea/**
!.idea/encodings.xml
!.idea/codeStyles
!.idea/codeStyles/*
!.idea/inspectionProfiles
!.idea/inspectionProfiles/*
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
### Eclipse template
.metadata
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
.project
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

View File

@@ -1,62 +1,49 @@
<?php <?php
// Copyright (C) 2010-2016 Combodo SARL // Copyright (C) 2010-2016 Combodo SARL
// //
// This file is part of iTop. // This file is part of iTop.
// //
// iTop is free software; you can redistribute it and/or modify // iTop is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// iTop is distributed in the hope that it will be useful, // iTop is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/> // along with iTop. If not, see <http://www.gnu.org/licenses/>
/** /**
* File to include to initialize the datamodel in memory * File to include to initialize the datamodel in memory
* *
* @copyright Copyright (C) 2010-2016 Combodo SARL * @copyright Copyright (C) 2010-2016 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0 * @license http://opensource.org/licenses/AGPL-3.0
*/ */
require_once(APPROOT.'/core/cmdbobject.class.inc.php'); require_once(APPROOT.'/core/cmdbobject.class.inc.php');
require_once(APPROOT.'/application/utils.inc.php'); require_once(APPROOT.'/application/utils.inc.php');
require_once(APPROOT.'/core/contexttag.class.inc.php'); require_once(APPROOT.'/core/contexttag.class.inc.php');
session_name('itop-'.md5(APPROOT)); session_name('itop-'.md5(APPROOT));
session_start(); session_start();
$sSwitchEnv = utils::ReadParam('switch_env', null); $sSwitchEnv = utils::ReadParam('switch_env', null);
$bAllowCache = true; if (($sSwitchEnv != null) && (file_exists(APPCONF.$sSwitchEnv.'/'.ITOP_CONFIG_FILE)))
if (($sSwitchEnv != null) && (file_exists(APPCONF.$sSwitchEnv.'/'.ITOP_CONFIG_FILE)) && isset($_SESSION['itop_env']) && ($_SESSION['itop_env'] !== $sSwitchEnv)) {
{ $_SESSION['itop_env'] = $sSwitchEnv;
$_SESSION['itop_env'] = $sSwitchEnv; $sEnv = $sSwitchEnv;
$sEnv = $sSwitchEnv; // TODO: reset the credentials as well ??
$bAllowCache = false; }
// Reset the opcache since otherwise the PHP "model" files may still be cached !! else if (isset($_SESSION['itop_env']))
if (function_exists('opcache_reset')) {
{ $sEnv = $_SESSION['itop_env'];
// Zend opcode cache }
opcache_reset(); else
} {
if (function_exists('apc_clear_cache')) $sEnv = ITOP_DEFAULT_ENV;
{ $_SESSION['itop_env'] = ITOP_DEFAULT_ENV;
// APC(u) cache }
apc_clear_cache(); $sConfigFile = APPCONF.$sEnv.'/'.ITOP_CONFIG_FILE;
} MetaModel::Startup($sConfigFile, false /* $bModelOnly */, true /* $bAllowCache */, false /* $bTraceSourceFiles */, $sEnv);
// TODO: reset the credentials as well ??
}
else if (isset($_SESSION['itop_env']))
{
$sEnv = $_SESSION['itop_env'];
}
else
{
$sEnv = ITOP_DEFAULT_ENV;
$_SESSION['itop_env'] = ITOP_DEFAULT_ENV;
}
$sConfigFile = APPCONF.$sEnv.'/'.ITOP_CONFIG_FILE;
MetaModel::Startup($sConfigFile, false /* $bModelOnly */, $bAllowCache, false /* $bTraceSourceFiles */, $sEnv);

View File

@@ -1,10 +0,0 @@
{
"require": {
"php": ">=5.3.6 <7.2.0"
},
"config": {
"platform": {
"php": "5.3.6"
}
}
}

View File

@@ -210,19 +210,6 @@ class ValueSetObjects extends ValueSetDefinition
} }
} }
$oExpression = DBObjectSearch::GetPolymorphicExpression($oFilter->GetClass(), 'friendlyname');
$aFields = $oExpression->ListRequiredFields();
$sClass = $oFilter->GetClass();
foreach($aFields as $sField)
{
$aFieldItems = explode('.', $sField);
if ($aFieldItems[0] != $sClass)
{
$sOperation = 'contains';
break;
}
}
switch ($sOperation) switch ($sOperation)
{ {
case 'equals_start_with': case 'equals_start_with':

View File

@@ -54,10 +54,10 @@ class BrowseBrickController extends BrickController
// Getting current browse mode (First from router pamater, then default brick value) // Getting current browse mode (First from router pamater, then default brick value)
$sBrowseMode = (!empty($sBrowseMode)) ? $sBrowseMode : $oBrick->GetDefaultBrowseMode(); $sBrowseMode = (!empty($sBrowseMode)) ? $sBrowseMode : $oBrick->GetDefaultBrowseMode();
// Getting current dataloading mode (First from router parameter, then query parameter, then default brick value) // Getting current dataloading mode (First from router parameter, then query parameter, then default brick value)
$sDataLoading = ($sDataLoading !== null) ? $sDataLoading : $oApp['request_manipulator']->ReadParam('sDataLoading', $oBrick->GetDataLoading()); $sDataLoading = ($sDataLoading !== null) ? $sDataLoading : ( ($oRequest->query->get('sDataLoading') !== null) ? $oRequest->query->get('sDataLoading') : $oBrick->GetDataLoading() );
// Getting search value // Getting search value
$sSearchValue = $oApp['request_manipulator']->ReadParam('sSearchValue', ''); $sSearchValue = $oRequest->get('sSearchValue', null);
if (!empty($sSearchValue)) if ($sSearchValue !== null)
{ {
$sDataLoading = AbstractBrick::ENUM_DATA_LOADING_LAZY; $sDataLoading = AbstractBrick::ENUM_DATA_LOADING_LAZY;
} }
@@ -112,7 +112,7 @@ class BrowseBrickController extends BrickController
// Adding search clause // Adding search clause
// Note : For know the search is naive and looks only for the exact match. It doesn't search for words separately // Note : For know the search is naive and looks only for the exact match. It doesn't search for words separately
if (!empty($sSearchValue)) if ($sSearchValue !== null)
{ {
// - Cleaning the search value by exploding and trimming spaces // - Cleaning the search value by exploding and trimming spaces
$aSearchValues = explode(' ', $sSearchValue); $aSearchValues = explode(' ', $sSearchValue);
@@ -185,7 +185,7 @@ class BrowseBrickController extends BrickController
{ {
$aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search']->SetSelectedClasses($aLevelsClasses); $aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search']->SetSelectedClasses($aLevelsClasses);
if (!empty($sSearchValue)) if ($sSearchValue !== null)
{ {
// Note : This could be way more simpler if we had a SetInternalParam($sParam, $value) verb // Note : This could be way more simpler if we had a SetInternalParam($sParam, $value) verb
$aQueryParams = $aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search']->GetInternalParams(); $aQueryParams = $aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search']->GetInternalParams();
@@ -219,8 +219,8 @@ class BrowseBrickController extends BrickController
{ {
case BrowseBrick::ENUM_BROWSE_MODE_LIST: case BrowseBrick::ENUM_BROWSE_MODE_LIST:
// Retrieving parameters // Retrieving parameters
$iPageNumber = (int) $oApp['request_manipulator']->ReadParam('iPageNumber', 1, FILTER_SANITIZE_NUMBER_INT); $iPageNumber = (int) $oRequest->get('iPageNumber', 1);
$iListLength = (int) $oApp['request_manipulator']->ReadParam('iListLength', BrowseBrick::DEFAULT_LIST_LENGTH, FILTER_SANITIZE_NUMBER_INT); $iListLength = (int) $oRequest->get('iListLength', BrowseBrick::DEFAULT_LIST_LENGTH);
// Getting total records number // Getting total records number
$oCountSet = new DBObjectSet($oQuery); $oCountSet = new DBObjectSet($oQuery);
@@ -235,8 +235,8 @@ class BrowseBrickController extends BrickController
case BrowseBrick::ENUM_BROWSE_MODE_TREE: case BrowseBrick::ENUM_BROWSE_MODE_TREE:
case BrowseBrick::ENUM_BROWSE_MODE_MOSAIC: case BrowseBrick::ENUM_BROWSE_MODE_MOSAIC:
// Retrieving parameters // Retrieving parameters
$sLevelAlias = $oApp['request_manipulator']->ReadParam('sLevelAlias', ''); $sLevelAlias = $oRequest->get('sLevelAlias');
$sNodeId = $oApp['request_manipulator']->ReadParam('sNodeId', ''); $sNodeId = $oRequest->get('sNodeId');
// If no values for those parameters, we might be loading page in lazy mode for the first time, therefore the URL doesn't have those informations. // If no values for those parameters, we might be loading page in lazy mode for the first time, therefore the URL doesn't have those informations.
if (empty($sLevelAlias)) if (empty($sLevelAlias))
@@ -634,9 +634,8 @@ class BrowseBrickController extends BrickController
if ($aLevelsProperties[$key][$sOptionalAttribute] !== null) if ($aLevelsProperties[$key][$sOptionalAttribute] !== null)
{ {
$sPropertyName = substr($sOptionalAttribute, 0, -4); $sPropertyName = substr($sOptionalAttribute, 0, -4);
$oAttDef = MetaModel::GetAttributeDef(get_class($value), $aLevelsProperties[$key][$sOptionalAttribute]);
$tmpAttValue = $value->GetAsHTML($aLevelsProperties[$key][$sOptionalAttribute]); $tmpAttValue = $value->Get($aLevelsProperties[$key][$sOptionalAttribute]);
if($sOptionalAttribute === 'image_att') if($sOptionalAttribute === 'image_att')
{ {
if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty()) if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty())
@@ -645,7 +644,7 @@ class BrowseBrickController extends BrickController
} }
else else
{ {
$tmpAttValue = $oAttDef->Get('default_image'); $tmpAttValue = MetaModel::GetAttributeDef(get_class($value), $aLevelsProperties[$key][$sOptionalAttribute])->Get('default_image');
} }
} }
@@ -659,7 +658,7 @@ class BrowseBrickController extends BrickController
foreach ($aLevelsProperties[$key]['fields'] as $aField) foreach ($aLevelsProperties[$key]['fields'] as $aField)
{ {
$oAttDef = MetaModel::GetAttributeDef(get_class($value), $aField['code']); $oAttDef = MetaModel::GetAttributeDef(get_class($value), $aField['code']);
$aRow[$key]['fields'][$aField['code']] = $oAttDef->GetAsHTML($value->Get($aField['code'])); $aRow[$key]['fields'][$aField['code']] = $oAttDef->GetValueLabel($value->Get($aField['code']));
} }
} }
} }
@@ -727,9 +726,8 @@ class BrowseBrickController extends BrickController
if ($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute] !== null) if ($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute] !== null)
{ {
$sPropertyName = substr($sOptionalAttribute, 0, -4); $sPropertyName = substr($sOptionalAttribute, 0, -4);
$oAttDef = MetaModel::GetAttributeDef(get_class($aCurrentRowValues[0]), $aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]);
$tmpAttValue = $aCurrentRowValues[0]->GetAsHTML($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]); $tmpAttValue = $aCurrentRowValues[0]->Get($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]);
if($sOptionalAttribute === 'image_att') if($sOptionalAttribute === 'image_att')
{ {
if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty()) if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty())
@@ -738,7 +736,7 @@ class BrowseBrickController extends BrickController
} }
else else
{ {
$tmpAttValue = $oAttDef->Get('default_image'); $tmpAttValue = MetaModel::GetAttributeDef(get_class($aCurrentRowValues[0]), $aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute])->Get('default_image');
} }
} }

View File

@@ -31,7 +31,6 @@ use \AttributeDate;
use \AttributeDateTime; use \AttributeDateTime;
use \AttributeDuration; use \AttributeDuration;
use \AttributeSubItem; use \AttributeSubItem;
use \AttributeImage;
use \DBSearch; use \DBSearch;
use \DBObjectSearch; use \DBObjectSearch;
use \DBObjectSet; use \DBObjectSet;
@@ -64,9 +63,9 @@ class ManageBrickController extends BrickController
$aQueries = array(); $aQueries = array();
// Getting current dataloading mode (First from router parameter, then query parameter, then default brick value) // Getting current dataloading mode (First from router parameter, then query parameter, then default brick value)
$sDataLoading = ($sDataLoading !== null) ? $sDataLoading : $oApp['request_manipulator']->ReadParam('sDataLoading', $oBrick->GetDataLoading()); $sDataLoading = ($sDataLoading !== null) ? $sDataLoading : ( ($oRequest->get('sDataLoading') !== null) ? $oRequest->get('sDataLoading') : $oBrick->GetDataLoading() );
// Getting search value // Getting search value
$sSearchValue = $oApp['request_manipulator']->ReadParam('sSearchValue', ''); $sSearchValue = $oRequest->get('sSearchValue', null);
// Getting area columns properties // Getting area columns properties
$aColumnsAttrs = $oBrick->GetFields(); $aColumnsAttrs = $oBrick->GetFields();
@@ -202,7 +201,7 @@ class ManageBrickController extends BrickController
} }
} }
// - Retrieving the current grouping tab to display and altering the query to do so // - Retrieving the current grouping tab to display and altering the query to do so
if (empty($sGroupingTab)) if ($sGroupingTab === null)
{ {
if ($oBrick->HasGroupingTabs()) if ($oBrick->HasGroupingTabs())
{ {
@@ -282,9 +281,9 @@ class ManageBrickController extends BrickController
} }
} }
// - Retrieving the grouping areas to display // - Retrieving the grouping areas to display
$sGroupingArea = $oApp['request_manipulator']->ReadParam('sGroupingArea'); $sGroupingArea = $oRequest->get('sGroupingArea');
// - If specified or lazy loading, we trunc the $aGroupingAreasValues to keep only this one // - If specified or lazy loading, we trunc the $aGroupingAreasValues to keep only this one
if (!empty($sGroupingArea)) if ($sGroupingArea !== null)
{ {
$aGroupingAreasValues = array($sGroupingArea => $aGroupingAreasValues[$sGroupingArea]); $aGroupingAreasValues = array($sGroupingArea => $aGroupingAreasValues[$sGroupingArea]);
} }
@@ -343,8 +342,8 @@ class ManageBrickController extends BrickController
if ($sDataLoading === AbstractBrick::ENUM_DATA_LOADING_LAZY) if ($sDataLoading === AbstractBrick::ENUM_DATA_LOADING_LAZY)
{ {
// Retrieving parameters // Retrieving parameters
$iPageNumber = (int) $oApp['request_manipulator']->ReadParam('iPageNumber', 1); $iPageNumber = (int) $oRequest->get('iPageNumber', 1);
$iListLength = (int) $oApp['request_manipulator']->ReadParam('iListLength', ManageBrick::DEFAULT_LIST_LENGTH); $iListLength = (int) $oRequest->get('iListLength', ManageBrick::DEFAULT_LIST_LENGTH);
// Getting total records number // Getting total records number
$oCountSet = new DBObjectSet($oQuery); $oCountSet = new DBObjectSet($oQuery);
@@ -389,7 +388,7 @@ class ManageBrickController extends BrickController
{ {
// Set properties // Set properties
$sCurrentClass = $sKey; $sCurrentClass = $sKey;
// Defining which attribute will open the edition form) // Defining which attribute will open the edition form)
$sMainActionAttrCode = $aColumnsAttrs[0]; $sMainActionAttrCode = $aColumnsAttrs[0];
@@ -445,46 +444,36 @@ class ManageBrickController extends BrickController
} }
} }
/** @var AttributeDefinition $oAttDef */ /** @var AttributeDefinition $oAttDef */
$oAttDef = MetaModel::GetAttributeDef($sCurrentClass, $sItemAttr); $oAttDef = MetaModel::GetAttributeDef($sCurrentClass, $sItemAttr);
if ($oAttDef->IsExternalKey()) if ($oAttDef->IsExternalKey())
{ {
$sValue = $oCurrentRow->GetAsHTML($sItemAttr.'_friendlyname'); $sValue = $oCurrentRow->Get($sItemAttr . '_friendlyname');
// Adding a view action on the external keys // Adding a view action on the external keys
if ($oCurrentRow->Get($sItemAttr) !== $oAttDef->GetNullValue()) if ($oCurrentRow->Get($sItemAttr) !== $oAttDef->GetNullValue())
{
// Checking if we can view the object
if ((SecurityHelper::IsActionAllowed($oApp, UR_ACTION_READ, $oAttDef->GetTargetClass(), $oCurrentRow->Get($sItemAttr))))
{ {
// Checking if we can view the object $aActions[] = array(
if ((SecurityHelper::IsActionAllowed($oApp, UR_ACTION_READ, $oAttDef->GetTargetClass(), 'type' => ManageBrick::ENUM_ACTION_VIEW,
$oCurrentRow->Get($sItemAttr)))) 'class' => $oAttDef->GetTargetClass(),
{ 'id' => $oCurrentRow->Get($sItemAttr),
$aActions[] = array( 'opening_target' => $oBrick->GetOpeningTarget(),
'type' => ManageBrick::ENUM_ACTION_VIEW, );
'class' => $oAttDef->GetTargetClass(),
'id' => $oCurrentRow->Get($sItemAttr),
'opening_target' => $oBrick->GetOpeningTarget(),
);
}
} }
} }
elseif ($oAttDef instanceof AttributeImage) }
{ elseif ($oAttDef instanceof AttributeSubItem || $oAttDef instanceof AttributeDuration)
$oOrmDoc = $oCurrentRow->Get($sItemAttr); {
if (is_object($oOrmDoc) && !$oOrmDoc->IsEmpty()) $sValue = $oAttDef->GetAsHTML($oCurrentRow->Get($sItemAttr));
{ }
$sUrl = $oApp['url_generator']->generate('p_object_document_display', array('sObjectClass' => get_class($oCurrentRow), 'sObjectId' => $oCurrentRow->GetKey(), 'sObjectField' => $sItemAttr, 'cache' => 86400)); else
} {
else $sValue = $oAttDef->GetValueLabel($oCurrentRow->Get($sItemAttr));
{ }
$sUrl = $oAttDef->Get('default_image'); unset($oAttDef);
}
$sValue = '<img src="' . $sUrl . '" />';
}
else
{
$sValue = $oAttDef->GetAsHTML($oCurrentRow->Get($sItemAttr));
}
unset($oAttDef);
$aItemAttrs[$sItemAttr] = array( $aItemAttrs[$sItemAttr] = array(
'att_code' => $sItemAttr, 'att_code' => $sItemAttr,
@@ -512,7 +501,7 @@ class ManageBrickController extends BrickController
} }
} }
} }
// ... And item's properties // ... And item's properties
$aItems[] = array( $aItems[] = array(
'id' => $oCurrentRow->GetKey(), 'id' => $oCurrentRow->GetKey(),

View File

@@ -1,6 +1,6 @@
<?php <?php
// Copyright (C) 2010-2018 Combodo SARL // Copyright (C) 2010-2017 Combodo SARL
// //
// This file is part of iTop. // This file is part of iTop.
// //
@@ -42,7 +42,6 @@ use \ScalarExpression;
use \DBObjectSet; use \DBObjectSet;
use \cmdbAbstractObject; use \cmdbAbstractObject;
use \AttributeEnum; use \AttributeEnum;
use \AttributeImage;
use \AttributeFinalClass; use \AttributeFinalClass;
use \AttributeFriendlyName; use \AttributeFriendlyName;
use \UserRights; use \UserRights;
@@ -64,8 +63,6 @@ class ObjectController extends AbstractController
const ENUM_MODE_VIEW = 'view'; const ENUM_MODE_VIEW = 'view';
const ENUM_MODE_EDIT = 'edit'; const ENUM_MODE_EDIT = 'edit';
const ENUM_MODE_CREATE = 'create'; const ENUM_MODE_CREATE = 'create';
const DEFAULT_PAGE_NUMBER = 1;
const DEFAULT_LIST_LENGTH = 10; const DEFAULT_LIST_LENGTH = 10;
/** /**
@@ -102,8 +99,6 @@ class ObjectController extends AbstractController
$oApp->abort(404, Dict::S('UI:ObjectDoesNotExist')); $oApp->abort(404, Dict::S('UI:ObjectDoesNotExist'));
} }
$sOperation = $oApp['request_manipulator']->ReadParam('operation', '');
$aData = array('sMode' => 'view'); $aData = array('sMode' => 'view');
$aData['form'] = $this->HandleForm($oRequest, $oApp, $aData['sMode'], $sObjectClass, $sObjectId); $aData['form'] = $this->HandleForm($oRequest, $oApp, $aData['sMode'], $sObjectClass, $sObjectId);
$aData['form']['title'] = Dict::Format('Brick:Portal:Object:Form:View:Title', MetaModel::GetName($sObjectClass), $oObject->GetName()); $aData['form']['title'] = Dict::Format('Brick:Portal:Object:Form:View:Title', MetaModel::GetName($sObjectClass), $oObject->GetName());
@@ -124,7 +119,7 @@ class ObjectController extends AbstractController
if ($oRequest->isXmlHttpRequest()) if ($oRequest->isXmlHttpRequest())
{ {
// We have to check whether the 'operation' parameter is defined or not in order to know if the form is required via ajax (to be displayed as a modal dialog) or if it's a lifecycle call from a existing form. // We have to check whether the 'operation' parameter is defined or not in order to know if the form is required via ajax (to be displayed as a modal dialog) or if it's a lifecycle call from a existing form.
if (empty($sOperation)) if ($oRequest->request->get('operation') === null)
{ {
$oResponse = $oApp['twig']->render('itop-portal-base/portal/src/views/bricks/object/modal.html.twig', $aData); $oResponse = $oApp['twig']->render('itop-portal-base/portal/src/views/bricks/object/modal.html.twig', $aData);
} }
@@ -136,8 +131,8 @@ class ObjectController extends AbstractController
else else
{ {
// Adding brick if it was passed // Adding brick if it was passed
$sBrickId = $oApp['request_manipulator']->ReadParam('sBrickId', ''); $sBrickId = $oRequest->get('sBrickId');
if (!empty($sBrickId)) if ($sBrickId !== null)
{ {
$oBrick = ApplicationHelper::GetLoadedBrickFromId($oApp, $sBrickId); $oBrick = ApplicationHelper::GetLoadedBrickFromId($oApp, $sBrickId);
if ($oBrick !== null) if ($oBrick !== null)
@@ -179,8 +174,6 @@ class ObjectController extends AbstractController
$oApp->abort(404, Dict::S('UI:ObjectDoesNotExist')); $oApp->abort(404, Dict::S('UI:ObjectDoesNotExist'));
} }
$sOperation = $oApp['request_manipulator']->ReadParam('operation', '');
$aData = array('sMode' => 'edit'); $aData = array('sMode' => 'edit');
$aData['form'] = $this->HandleForm($oRequest, $oApp, $aData['sMode'], $sObjectClass, $sObjectId); $aData['form'] = $this->HandleForm($oRequest, $oApp, $aData['sMode'], $sObjectClass, $sObjectId);
$aData['form']['title'] = Dict::Format('Brick:Portal:Object:Form:Edit:Title', MetaModel::GetName($sObjectClass), $aData['form']['object_name']); $aData['form']['title'] = Dict::Format('Brick:Portal:Object:Form:Edit:Title', MetaModel::GetName($sObjectClass), $aData['form']['object_name']);
@@ -189,7 +182,7 @@ class ObjectController extends AbstractController
if ($oRequest->isXmlHttpRequest()) if ($oRequest->isXmlHttpRequest())
{ {
// We have to check whether the 'operation' parameter is defined or not in order to know if the form is required via ajax (to be displayed as a modal dialog) or if it's a lifecycle call from a existing form. // We have to check whether the 'operation' parameter is defined or not in order to know if the form is required via ajax (to be displayed as a modal dialog) or if it's a lifecycle call from a existing form.
if (empty($sOperation)) if ($oRequest->request->get('operation') === null)
{ {
$oResponse = $oApp['twig']->render('itop-portal-base/portal/src/views/bricks/object/modal.html.twig', $aData); $oResponse = $oApp['twig']->render('itop-portal-base/portal/src/views/bricks/object/modal.html.twig', $aData);
} }
@@ -201,8 +194,8 @@ class ObjectController extends AbstractController
else else
{ {
// Adding brick if it was passed // Adding brick if it was passed
$sBrickId = $oApp['request_manipulator']->ReadParam('sBrickId', ''); $sBrickId = $oRequest->get('sBrickId');
if (!empty($sBrickId)) if ($sBrickId !== null)
{ {
$oBrick = ApplicationHelper::GetLoadedBrickFromId($oApp, $sBrickId); $oBrick = ApplicationHelper::GetLoadedBrickFromId($oApp, $sBrickId);
if ($oBrick !== null) if ($oBrick !== null)
@@ -234,8 +227,6 @@ class ObjectController extends AbstractController
$oApp->abort(404, Dict::S('UI:ObjectDoesNotExist')); $oApp->abort(404, Dict::S('UI:ObjectDoesNotExist'));
} }
$sOperation = $oApp['request_manipulator']->ReadParam('operation', '');
$aData = array('sMode' => 'create'); $aData = array('sMode' => 'create');
$aData['form'] = $this->HandleForm($oRequest, $oApp, $aData['sMode'], $sObjectClass); $aData['form'] = $this->HandleForm($oRequest, $oApp, $aData['sMode'], $sObjectClass);
$aData['form']['title'] = Dict::Format('Brick:Portal:Object:Form:Create:Title', MetaModel::GetName($sObjectClass)); $aData['form']['title'] = Dict::Format('Brick:Portal:Object:Form:Create:Title', MetaModel::GetName($sObjectClass));
@@ -244,7 +235,7 @@ class ObjectController extends AbstractController
if ($oRequest->isXmlHttpRequest()) if ($oRequest->isXmlHttpRequest())
{ {
// We have to check whether the 'operation' parameter is defined or not in order to know if the form is required via ajax (to be displayed as a modal dialog) or if it's a lifecycle call from a existing form. // We have to check whether the 'operation' parameter is defined or not in order to know if the form is required via ajax (to be displayed as a modal dialog) or if it's a lifecycle call from a existing form.
if (empty($sOperation)) if ($oRequest->request->get('operation') === null)
{ {
$oResponse = $oApp['twig']->render('itop-portal-base/portal/src/views/bricks/object/modal.html.twig', $aData); $oResponse = $oApp['twig']->render('itop-portal-base/portal/src/views/bricks/object/modal.html.twig', $aData);
} }
@@ -256,8 +247,8 @@ class ObjectController extends AbstractController
else else
{ {
// Adding brick if it was passed // Adding brick if it was passed
$sBrickId = $oApp['request_manipulator']->ReadParam('sBrickId', ''); $sBrickId = $oRequest->get('sBrickId');
if (!empty($sBrickId)) if ($sBrickId !== null)
{ {
$oBrick = ApplicationHelper::GetLoadedBrickFromId($oApp, $sBrickId); $oBrick = ApplicationHelper::GetLoadedBrickFromId($oApp, $sBrickId);
if ($oBrick !== null) if ($oBrick !== null)
@@ -358,7 +349,7 @@ class ObjectController extends AbstractController
} }
// Retrieving request parameters // Retrieving request parameters
$sOperation = $oApp['request_manipulator']->ReadParam('operation', ''); $sOperation = $oRequest->request->get('operation');
// Retrieving form properties // Retrieving form properties
$aStimuliForms = ApplicationHelper::GetLoadedFormFromClass($oApp, $sObjectClass, 'apply_stimulus'); $aStimuliForms = ApplicationHelper::GetLoadedFormFromClass($oApp, $sObjectClass, 'apply_stimulus');
@@ -393,7 +384,7 @@ class ObjectController extends AbstractController
// TODO : This is a ugly patch to avoid showing a modal with a readonly form to the user as it would prevent user from finishing the transition. // TODO : This is a ugly patch to avoid showing a modal with a readonly form to the user as it would prevent user from finishing the transition.
// Instead, we apply the stimulus directly here and then go to the edited object. // Instead, we apply the stimulus directly here and then go to the edited object.
if (empty($sOperation)) if ($sOperation === null)
{ {
if (isset($aData['form']['editable_fields_count']) && $aData['form']['editable_fields_count'] === 0) if (isset($aData['form']['editable_fields_count']) && $aData['form']['editable_fields_count'] === 0)
{ {
@@ -401,7 +392,7 @@ class ObjectController extends AbstractController
$oSubRequest = $oRequest; $oSubRequest = $oRequest;
$oSubRequest->request->set('operation', 'submit'); $oSubRequest->request->set('operation', 'submit');
$oSubRequest->request->set('stimulus_code', ''); $oSubRequest->request->set('stimulus_code', null);
$aData = array('sMode' => 'apply_stimulus'); $aData = array('sMode' => 'apply_stimulus');
$aData['form'] = $this->HandleForm($oSubRequest, $oApp, $aData['sMode'], $sObjectClass, $sObjectId, $aFormProperties); $aData['form'] = $this->HandleForm($oSubRequest, $oApp, $aData['sMode'], $sObjectClass, $sObjectId, $aFormProperties);
@@ -416,7 +407,7 @@ class ObjectController extends AbstractController
if ($oRequest->isXmlHttpRequest()) if ($oRequest->isXmlHttpRequest())
{ {
// We have to check whether the 'operation' parameter is defined or not in order to know if the form is required via ajax (to be displayed as a modal dialog) or if it's a lifecycle call from a existing form. // We have to check whether the 'operation' parameter is defined or not in order to know if the form is required via ajax (to be displayed as a modal dialog) or if it's a lifecycle call from a existing form.
if (empty($sOperation)) if ($sOperation === null)
{ {
$oResponse = $oApp['twig']->render('itop-portal-base/portal/src/views/bricks/object/modal.html.twig', $aData); $oResponse = $oApp['twig']->render('itop-portal-base/portal/src/views/bricks/object/modal.html.twig', $aData);
} }
@@ -440,8 +431,9 @@ class ObjectController extends AbstractController
public static function HandleForm(Request $oRequest, Application $oApp, $sMode, $sObjectClass, $sObjectId = null, $aFormProperties = null) public static function HandleForm(Request $oRequest, Application $oApp, $sMode, $sObjectClass, $sObjectId = null, $aFormProperties = null)
{ {
$aFormData = array(); $aFormData = array();
$sOperation = $oApp['request_manipulator']->ReadParam('operation', ''); $oRequestParams = $oRequest->request;
$bModal = ($oRequest->isXmlHttpRequest() && empty($sOperation)); $sOperation = $oRequestParams->get('operation');
$bModal = ($oRequest->isXmlHttpRequest() && ($oRequest->request->get('operation') === null) );
// - Retrieve form properties // - Retrieve form properties
if ($aFormProperties === null) if ($aFormProperties === null)
@@ -450,14 +442,14 @@ class ObjectController extends AbstractController
} }
// - Create and // - Create and
if (empty($sOperation)) if ($sOperation === null)
{ {
// Retrieving action rules // Retrieving action rules
// //
// Note : The action rules must be a base64-encoded JSON object, this is just so users are tempted to changes values. // Note : The action rules must be a base64-encoded JSON object, this is just so users are tempted to changes values.
// But it would not be a security issue as it only presets values in the form. // But it would not be a security issue as it only presets values in the form.
$sActionRulesToken = $oApp['request_manipulator']->ReadParam('ar_token', ''); $sActionRulesToken = $oRequest->get('ar_token');
$aActionRules = (!empty($sActionRulesToken)) ? ContextManipulatorHelper::DecodeRulesToken($sActionRulesToken) : array(); $aActionRules = ($sActionRulesToken !== null) ? ContextManipulatorHelper::DecodeRulesToken($sActionRulesToken) : array();
// Preparing object // Preparing object
if ($sObjectId === null) if ($sObjectId === null)
@@ -560,9 +552,9 @@ class ObjectController extends AbstractController
else else
{ {
// Update / Submit / Cancel // Update / Submit / Cancel
$sFormManagerClass = $oApp['request_manipulator']->ReadParam('formmanager_class', '', FILTER_UNSAFE_RAW); $sFormManagerClass = $oRequestParams->get('formmanager_class');
$sFormManagerData = $oApp['request_manipulator']->ReadParam('formmanager_data', '', FILTER_UNSAFE_RAW); $sFormManagerData = $oRequestParams->get('formmanager_data');
if ( empty($sFormManagerClass) || empty($sFormManagerData) ) if ($sFormManagerClass === null || $sFormManagerData === null)
{ {
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameters formmanager_class and formamanager_data must be defined.'); IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameters formmanager_class and formamanager_data must be defined.');
$oApp->abort(500, 'Parameters formmanager_class and formmanager_data must be defined.'); $oApp->abort(500, 'Parameters formmanager_class and formmanager_data must be defined.');
@@ -584,13 +576,13 @@ class ObjectController extends AbstractController
{ {
case 'submit': case 'submit':
// Applying modification to object // Applying modification to object
$aFormData['validation'] = $oFormManager->OnSubmit(array('currentValues' => $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW), 'attachmentIds' => $oApp['request_manipulator']->ReadParam('attachment_ids', array(), FILTER_UNSAFE_RAW), 'formProperties' => $aFormProperties, 'applyStimulus' => $oApp['request_manipulator']->ReadParam('apply_stimulus', null))); $aFormData['validation'] = $oFormManager->OnSubmit(array('currentValues' => $oRequestParams->get('current_values'), 'attachmentIds' => $oRequest->get('attachment_ids'), 'formProperties' => $aFormProperties, 'applyStimulus' => $oRequestParams->get('apply_stimulus')));
if ($aFormData['validation']['valid'] === true) if ($aFormData['validation']['valid'] === true)
{ {
// Note : We don't use $sObjectId there as it can be null if we are creating a new one. Instead we use the id from the created object once it has been seralized // Note : We don't use $sObjectId there as it can be null if we are creating a new one. Instead we use the id from the created object once it has been seralized
// Check if stimulus has to be applied // Check if stimulus has to be applied
$sStimulusCode = $oApp['request_manipulator']->ReadParam('stimulus_code', ''); $sStimulusCode = ($oRequestParams->get('stimulus_code') !== null && $oRequestParams->get('stimulus_code') !== '') ? $oRequestParams->get('stimulus_code') : null;
if (!empty($sStimulusCode)) if ($sStimulusCode !== null)
{ {
$aFormData['validation']['redirection'] = array( $aFormData['validation']['redirection'] = array(
'url' => $oApp['url_generator']->generate('p_object_apply_stimulus', array('sObjectClass' => $sObjectClass, 'sObjectId' => $oFormManager->GetObject()->GetKey(), 'sStimulusCode' => $sStimulusCode)), 'url' => $oApp['url_generator']->generate('p_object_apply_stimulus', array('sObjectClass' => $sObjectClass, 'sObjectId' => $oFormManager->GetObject()->GetKey(), 'sStimulusCode' => $sStimulusCode)),
@@ -608,7 +600,7 @@ class ObjectController extends AbstractController
break; break;
case 'update': case 'update':
$oFormManager->OnUpdate(array('currentValues' => $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW), 'formProperties' => $aFormProperties)); $oFormManager->OnUpdate(array('currentValues' => $oRequestParams->get('current_values'), 'formProperties' => $aFormProperties));
break; break;
case 'cancel': case 'cancel':
@@ -627,11 +619,11 @@ class ObjectController extends AbstractController
// Preparing fields list regarding the operation // Preparing fields list regarding the operation
if ($sOperation === 'update') if ($sOperation === 'update')
{ {
$aRequestedFields = $oApp['request_manipulator']->ReadParam('requested_fields', array(), FILTER_UNSAFE_RAW); $aRequestedFields = $oRequestParams->get('requested_fields');
$sFormPath = $oApp['request_manipulator']->ReadParam('form_path', ''); $sFormPath = $oRequestParams->get('form_path');
// Checking if the update was on a subform, if so we need to make the rendering for that part only // Checking if the update was on a subform, if so we need to make the rendering for that part only
if ( !empty($sFormPath) && $sFormPath !== $oFormManager->GetForm()->GetId() ) if ($sFormPath !== null && $sFormPath !== $oFormManager->GetForm()->GetId())
{ {
$oSubForm = $oFormManager->GetForm()->FindSubForm($sFormPath); $oSubForm = $oFormManager->GetForm()->FindSubForm($sFormPath);
$oSubFormRenderer = new BsFormRenderer($oSubForm); $oSubFormRenderer = new BsFormRenderer($oSubForm);
@@ -716,8 +708,8 @@ class ObjectController extends AbstractController
// //
// Note : The action rules must be a base64-encoded JSON object, this is just so users are tempted to changes values. // Note : The action rules must be a base64-encoded JSON object, this is just so users are tempted to changes values.
// But it would not be a security issue as it only presets values in the form. // But it would not be a security issue as it only presets values in the form.
$sActionRulesToken = $oApp['request_manipulator']->ReadParam('ar_token', ''); $sActionRulesToken = $oRequest->get('ar_token');
$aActionRules = (!empty($sActionRulesToken)) ? ContextManipulatorHelper::DecodeRulesToken($sActionRulesToken) : array(); $aActionRules = ($sActionRulesToken !== null) ? ContextManipulatorHelper::DecodeRulesToken($sActionRulesToken) : array();
// Preparing object // Preparing object
$oApp['context_manipulator']->PrepareObject($aActionRules, $oHostObject); $oApp['context_manipulator']->PrepareObject($aActionRules, $oHostObject);
} }
@@ -725,7 +717,7 @@ class ObjectController extends AbstractController
// Updating host object with form data / values // Updating host object with form data / values
$sFormManagerClass = $aRequestContent['formmanager_class']; $sFormManagerClass = $aRequestContent['formmanager_class'];
$sFormManagerData = $aRequestContent['formmanager_data']; $sFormManagerData = $aRequestContent['formmanager_data'];
if (!empty($sFormManagerClass) && !empty($sFormManagerData)) if ($sFormManagerClass !== null && $sFormManagerData !== null)
{ {
$oFormManager = $sFormManagerClass::FromJSON($sFormManagerData); $oFormManager = $sFormManagerClass::FromJSON($sFormManagerData);
$oFormManager->SetApplication($oApp); $oFormManager->SetApplication($oApp);
@@ -837,7 +829,7 @@ class ObjectController extends AbstractController
'sTargetAttCode' => $sTargetAttCode, 'sTargetAttCode' => $sTargetAttCode,
'sHostObjectClass' => $sHostObjectClass, 'sHostObjectClass' => $sHostObjectClass,
'sHostObjectId' => $sHostObjectId, 'sHostObjectId' => $sHostObjectId,
'sActionRulesToken' => $oApp['request_manipulator']->ReadParam('ar_token', ''), 'sActionRulesToken' => $oRequest->get('ar_token')
); );
// Checking security layers // Checking security layers
@@ -860,15 +852,16 @@ class ObjectController extends AbstractController
// //
// Note : The action rules must be a base64-encoded JSON object, this is just so users are tempted to changes values. // Note : The action rules must be a base64-encoded JSON object, this is just so users are tempted to changes values.
// But it would not be a security issue as it only presets values in the form. // But it would not be a security issue as it only presets values in the form.
$aActionRules = !empty($aData['sActionRulesToken']) ? ContextManipulatorHelper::DecodeRulesToken($aData['sActionRulesToken']) : array(); $aActionRules = ($aData['sActionRulesToken'] !== null) ? ContextManipulatorHelper::DecodeRulesToken($aData['sActionRulesToken']) : array();
// Preparing object // Preparing object
$oApp['context_manipulator']->PrepareObject($aActionRules, $oHostObject); $oApp['context_manipulator']->PrepareObject($aActionRules, $oHostObject);
} }
// Updating host object with form data / values // Updating host object with form data / values
$sFormManagerClass = $oApp['request_manipulator']->ReadParam('formmanager_class', '', FILTER_UNSAFE_RAW); $oRequestParams = $oRequest->request;
$sFormManagerData = $oApp['request_manipulator']->ReadParam('formmanager_data', '', FILTER_UNSAFE_RAW); $sFormManagerClass = $oRequestParams->get('formmanager_class');
if ( !empty($sFormManagerClass) && !empty($sFormManagerData) ) $sFormManagerData = $oRequestParams->get('formmanager_data');
if ($sFormManagerClass !== null && $sFormManagerData !== null)
{ {
$oFormManager = $sFormManagerClass::FromJSON($sFormManagerData); $oFormManager = $sFormManagerClass::FromJSON($sFormManagerData);
$oFormManager->SetApplication($oApp); $oFormManager->SetApplication($oApp);
@@ -884,18 +877,18 @@ class ObjectController extends AbstractController
} }
// Updating host object // Updating host object
$oFormManager->OnUpdate(array('currentValues' => $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW))); $oFormManager->OnUpdate(array('currentValues' => $oRequestParams->get('current_values')));
$oHostObject = $oFormManager->GetObject(); $oHostObject = $oFormManager->GetObject();
} }
// Retrieving request parameters // Retrieving request parameters
$iPageNumber = $oApp['request_manipulator']->ReadParam('iPageNumber', static::DEFAULT_PAGE_NUMBER, FILTER_SANITIZE_NUMBER_INT); $iPageNumber = ($oRequest->get('iPageNumber') !== null) ? $oRequest->get('iPageNumber') : 1;
$iListLength = $oApp['request_manipulator']->ReadParam('iListLength', static::DEFAULT_LIST_LENGTH, FILTER_SANITIZE_NUMBER_INT); $iListLength = ($oRequest->get('iListLength') !== null) ? $oRequest->get('iListLength') : static::DEFAULT_LIST_LENGTH;
$bInitalPass = $oApp['request_manipulator']->HasParam('draw') ? false : true; $bInitalPass = ($oRequest->get('draw') === null) ? true : false;
$sQuery = $oApp['request_manipulator']->ReadParam('sSearchValue', ''); $sQuery = $oRequest->get('sSearchValue');
$sFormPath = $oApp['request_manipulator']->ReadParam('sFormPath', ''); $sFormPath = $oRequest->get('sFormPath');
$sFieldId = $oApp['request_manipulator']->ReadParam('sFieldId', ''); $sFieldId = $oRequest->get('sFieldId');
$aObjectIdsToIgnore = $oApp['request_manipulator']->ReadParam('aObjectIdsToIgnore', null, FILTER_UNSAFE_RAW); $aObjectIdsToIgnore = $oRequest->get('aObjectIdsToIgnore');
// Building search query // Building search query
// - Retrieving target object class from attcode // - Retrieving target object class from attcode
@@ -976,7 +969,7 @@ class ObjectController extends AbstractController
// - Adding query condition // - Adding query condition
$aInternalParams['this'] = $oHostObject; $aInternalParams['this'] = $oHostObject;
if (!empty($sQuery)) if ($sQuery !== null)
{ {
$oFullExpr = null; $oFullExpr = null;
for ($i = 0; $i < count($aAttCodes); $i++) for ($i = 0; $i < count($aAttCodes); $i++)
@@ -1351,9 +1344,9 @@ class ObjectController extends AbstractController
} }
// Retrieving ormDocument's host object // Retrieving ormDocument's host object
$sObjectClass = $oApp['request_manipulator']->ReadParam('sObjectClass', ''); $sObjectClass = $oRequest->get('sObjectClass');
$sObjectId = $oApp['request_manipulator']->ReadParam('sObjectId', ''); $sObjectId = $oRequest->get('sObjectId');
$sObjectField = $oApp['request_manipulator']->ReadParam('sObjectField', ''); $sObjectField = $oRequest->get('sObjectField');
// When reaching to an Attachment, we have to check security on its host object instead of the Attachment itself // When reaching to an Attachment, we have to check security on its host object instead of the Attachment itself
if($sObjectClass === 'Attachment') if($sObjectClass === 'Attachment')
@@ -1393,7 +1386,8 @@ class ObjectController extends AbstractController
} }
else else
{ {
$iCacheSec = $oApp['request_manipulator']->ReadParam('cache', 0, FILTER_SANITIZE_NUMBER_INT); $sCache = $oRequest->get('cache');
$iCacheSec = ($sCache !== null) ? (int) $sCache : 0;
} }
$aHeaders = array(); $aHeaders = array();
@@ -1419,7 +1413,7 @@ class ObjectController extends AbstractController
* Handles attachment add/remove on an object * Handles attachment add/remove on an object
* *
* Note: This is inspired from itop-attachment/ajax.attachment.php * Note: This is inspired from itop-attachment/ajax.attachment.php
* *
* @param Request $oRequest * @param Request $oRequest
* @param Application $oApp * @param Application $oApp
*/ */
@@ -1434,16 +1428,16 @@ class ObjectController extends AbstractController
// Retrieving sOperation from request only if it wasn't forced (determined by the route) // Retrieving sOperation from request only if it wasn't forced (determined by the route)
if ($sOperation === null) if ($sOperation === null)
{ {
$sOperation = $oApp['request_manipulator']->ReadParam('operation', null); $sOperation = $oRequest->get('operation');
} }
switch ($sOperation) switch ($sOperation)
{ {
case 'add': case 'add':
$sFieldName = $oApp['request_manipulator']->ReadParam('field_name', ''); $sFieldName = $oRequest->get('field_name');
$sObjectClass = $oApp['request_manipulator']->ReadParam('object_class', ''); $sObjectClass = $oRequest->get('object_class');
$sTempId = $oApp['request_manipulator']->ReadParam('temp_id', ''); $sTempId = $oRequest->get('temp_id');
if (empty($sObjectClass) || empty($sTempId)) if (($sObjectClass === null) || ($sTempId === null))
{ {
$aData['error'] = Dict::Format('UI:Error:2ParametersMissing', 'object_class', 'temp_id'); $aData['error'] = Dict::Format('UI:Error:2ParametersMissing', 'object_class', 'temp_id');
} }
@@ -1482,7 +1476,7 @@ class ObjectController extends AbstractController
// - Route // - Route
$aRouteParams = array( $aRouteParams = array(
'sObjectClass' => 'Attachment', 'sObjectClass' => 'Attachment',
'sObjectId' => $oApp['request_manipulator']->ReadParam('sAttachmentId', null), 'sObjectId' => $oRequest->get('sAttachmentId'),
'sObjectField' => 'contents', 'sObjectField' => 'contents',
); );
$sRedirectRoute = $oApp['url_generator']->generate('p_object_document_download', $aRouteParams); $sRedirectRoute = $oApp['url_generator']->generate('p_object_document_download', $aRouteParams);
@@ -1517,10 +1511,10 @@ class ObjectController extends AbstractController
$aData = array(); $aData = array();
// Retrieving parameters // Retrieving parameters
$sObjectClass = $oApp['request_manipulator']->ReadParam('sObjectClass', ''); $sObjectClass = $oRequest->Get('sObjectClass');
$aObjectIds = $oApp['request_manipulator']->ReadParam('aObjectIds', array(), FILTER_UNSAFE_RAW); $aObjectIds = $oRequest->Get('aObjectIds');
$aObjectAttCodes = $oApp['request_manipulator']->ReadParam('aObjectAttCodes', array(), FILTER_UNSAFE_RAW); $aObjectAttCodes = $oRequest->Get('aObjectAttCodes');
if ( empty($sObjectClass) || empty($aObjectIds) || empty($aObjectAttCodes) ) if ($sObjectClass === null || $aObjectIds === null || $aObjectAttCodes === null)
{ {
IssueLog::Info(__METHOD__ . ' at line ' . __LINE__ . ' : sObjectClass, sObjectId and aObjectAttCodes expected, "' . $sObjectClass . '", "' . $sObjectId . '" given.'); IssueLog::Info(__METHOD__ . ' at line ' . __LINE__ . ' : sObjectClass, sObjectId and aObjectAttCodes expected, "' . $sObjectClass . '", "' . $sObjectId . '" given.');
$oApp->abort(500, 'Invalid request data, some informations are missing'); $oApp->abort(500, 'Invalid request data, some informations are missing');
@@ -1588,7 +1582,7 @@ class ObjectController extends AbstractController
if ($oAttDef->IsExternalKey()) if ($oAttDef->IsExternalKey())
{ {
$aAttData['value'] = $oObject->GetAsHTML($oAttDef->GetCode() . '_friendlyname'); $aAttData['value'] = $oObject->Get($oAttDef->GetCode() . '_friendlyname');
// Checking if user can access object's external key // Checking if user can access object's external key
if (SecurityHelper::IsActionAllowed($oApp, UR_ACTION_READ, $oAttDef->GetTargetClass())) if (SecurityHelper::IsActionAllowed($oApp, UR_ACTION_READ, $oAttDef->GetTargetClass()))
@@ -1601,22 +1595,9 @@ class ObjectController extends AbstractController
// We skip it // We skip it
continue; continue;
} }
elseif ($oAttDef instanceof AttributeImage)
{
$oOrmDoc = $oObject->Get($oAttDef->GetCode());
if (is_object($oOrmDoc) && !$oOrmDoc->IsEmpty())
{
$sUrl = $oApp['url_generator']->generate('p_object_document_display', array('sObjectClass' => get_class($oObject), 'sObjectId' => $oObject->GetKey(), 'sObjectField' => $oAttDef->GetCode(), 'cache' => 86400));
}
else
{
$sUrl = $oAttDef->Get('default_image');
}
$aAttData['value'] = '<img src="' . $sUrl . '" />';
}
else else
{ {
$aAttData['value'] = $oAttDef->GetAsHTML($oObject->Get($oAttDef->GetCode())); $aAttData['value'] = $oAttDef->GetValueLabel($oObject->Get($oAttDef->GetCode()));
if ($oAttDef instanceof AttributeFriendlyName) if ($oAttDef instanceof AttributeFriendlyName)
{ {

View File

@@ -71,7 +71,7 @@ class UserProfileBrickController extends BrickController
// If this is ajax call, we are just submiting preferences or password forms // If this is ajax call, we are just submiting preferences or password forms
if ($oRequest->isXmlHttpRequest()) if ($oRequest->isXmlHttpRequest())
{ {
$aCurrentValues = $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW); $aCurrentValues = $oRequest->request->get('current_values');
$sFormType = $aCurrentValues['form_type']; $sFormType = $aCurrentValues['form_type'];
if ($sFormType === PreferencesFormManager::FORM_TYPE) if ($sFormType === PreferencesFormManager::FORM_TYPE)
{ {
@@ -120,9 +120,10 @@ class UserProfileBrickController extends BrickController
public function HandlePreferencesForm(Request $oRequest, Application $oApp, $sFormMode) public function HandlePreferencesForm(Request $oRequest, Application $oApp, $sFormMode)
{ {
$aFormData = array(); $aFormData = array();
$oRequestParams = $oRequest->request;
// Handling form // Handling form
$sOperation = $oApp['request_manipulator']->ReadParam('operation', null); $sOperation = $oRequestParams->get('operation');
// - Create // - Create
if ($sOperation === null) if ($sOperation === null)
{ {
@@ -142,8 +143,8 @@ class UserProfileBrickController extends BrickController
// - Submit // - Submit
else if ($sOperation === 'submit') else if ($sOperation === 'submit')
{ {
$sFormManagerClass = $oApp['request_manipulator']->ReadParam('formmanager_class', null, FILTER_UNSAFE_RAW); $sFormManagerClass = $oRequestParams->get('formmanager_class');
$sFormManagerData = $oApp['request_manipulator']->ReadParam('formmanager_data', null, FILTER_UNSAFE_RAW); $sFormManagerData = $oRequestParams->get('formmanager_data');
if ($sFormManagerClass === null || $sFormManagerData === null) if ($sFormManagerClass === null || $sFormManagerData === null)
{ {
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameters formmanager_class and formamanager_data must be defined.'); IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameters formmanager_class and formamanager_data must be defined.');
@@ -153,7 +154,7 @@ class UserProfileBrickController extends BrickController
// Rebuilding manager from json // Rebuilding manager from json
$oFormManager = $sFormManagerClass::FromJSON($sFormManagerData); $oFormManager = $sFormManagerClass::FromJSON($sFormManagerData);
// Applying modification to object // Applying modification to object
$aFormData['validation'] = $oFormManager->OnSubmit(array('currentValues' => $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW))); $aFormData['validation'] = $oFormManager->OnSubmit(array('currentValues' => $oRequestParams->get('current_values')));
// Reloading page only if preferences were changed // Reloading page only if preferences were changed
if (($aFormData['validation']['valid'] === true) && !empty($aFormData['validation']['messages']['success'])) if (($aFormData['validation']['valid'] === true) && !empty($aFormData['validation']['messages']['success']))
{ {
@@ -187,9 +188,10 @@ class UserProfileBrickController extends BrickController
public function HandlePasswordForm(Request $oRequest, Application $oApp) public function HandlePasswordForm(Request $oRequest, Application $oApp)
{ {
$aFormData = array(); $aFormData = array();
$oRequestParams = $oRequest->request;
// Handling form // Handling form
$sOperation = $oApp['request_manipulator']->ReadParam('operation', null); $sOperation = $oRequestParams->get('operation');
// - Create // - Create
if ($sOperation === null) if ($sOperation === null)
{ {
@@ -204,8 +206,8 @@ class UserProfileBrickController extends BrickController
// - Submit // - Submit
else if ($sOperation === 'submit') else if ($sOperation === 'submit')
{ {
$sFormManagerClass = $oApp['request_manipulator']->ReadParam('formmanager_class', null, FILTER_UNSAFE_RAW); $sFormManagerClass = $oRequestParams->get('formmanager_class');
$sFormManagerData = $oApp['request_manipulator']->ReadParam('formmanager_data', null, FILTER_UNSAFE_RAW); $sFormManagerData = $oRequestParams->get('formmanager_data');
if ($sFormManagerClass === null || $sFormManagerData === null) if ($sFormManagerClass === null || $sFormManagerData === null)
{ {
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameters formmanager_class and formamanager_data must be defined.'); IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameters formmanager_class and formamanager_data must be defined.');
@@ -215,7 +217,7 @@ class UserProfileBrickController extends BrickController
// Rebuilding manager from json // Rebuilding manager from json
$oFormManager = $sFormManagerClass::FromJSON($sFormManagerData); $oFormManager = $sFormManagerClass::FromJSON($sFormManagerData);
// Applying modification to object // Applying modification to object
$aFormData['validation'] = $oFormManager->OnSubmit(array('currentValues' => $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW))); $aFormData['validation'] = $oFormManager->OnSubmit(array('currentValues' => $oRequestParams->get('current_values')));
} }
else else
{ {
@@ -242,10 +244,11 @@ class UserProfileBrickController extends BrickController
public function HandlePictureForm(Request $oRequest, Application $oApp, $sFormMode) public function HandlePictureForm(Request $oRequest, Application $oApp, $sFormMode)
{ {
$aFormData = array(); $aFormData = array();
$oRequestParams = $oRequest->request;
$sPictureAttCode = 'picture'; $sPictureAttCode = 'picture';
// Handling form // Handling form
$sOperation = $oApp['request_manipulator']->ReadParam('operation', null); $sOperation = $oRequestParams->get('operation');
// - No operation specified // - No operation specified
if ($sOperation === null) if ($sOperation === null)
{ {

View File

@@ -1,119 +0,0 @@
<?php
/**
* Copyright (C) 2012-2018 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with iTop. If not, see <http://www.gnu.org/licenses/>
*/
namespace Combodo\iTop\Portal\Helper;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* RequestManipulatorHelper class
*
* Handle basic requests manipulation.
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.5.1
*/
class RequestManipulatorHelper
{
/** @var \Symfony\Component\HttpFoundation\RequestStack $oRequestStack */
protected $oRequestStack;
/**
* RequestManipulatorHelper constructor.
*
* @param \Symfony\Component\HttpFoundation\RequestStack $oRequestStack
*/
public function __construct(RequestStack &$oRequestStack)
{
$this->oRequestStack = $oRequestStack;
}
/**
* @return \Symfony\Component\HttpFoundation\Request
*/
public function GetCurrentRequest()
{
return $this->oRequestStack->getCurrentRequest();
}
/**
* Returns if the request has a $sKey parameter.
* This looks in the GET arguments first, then PATH and finally the POST data.
*
* @param string $sKey
*
* @return bool
*/
public function HasParam($sKey)
{
if ($this->GetCurrentRequest()->query->has($sKey))
{
return true;
}
if ($this->GetCurrentRequest()->attributes->has($sKey))
{
return true;
}
if ($this->GetCurrentRequest()->request->has($sKey))
{
return true;
}
return false;
}
/**
* Returns the $sKey parameter from the request filtered with $iFilter.
* This looks in the GET arguments first, then the PATH and finally the POST data.
*
* Note: It is inspired by the \Symfony\Component\HttpFoundation\ParameterBag::filter() function and was necessary as we sometimes have parameters that can be either in the GET/PATH/POST arguments and need to be filtered. Silex only offer the possibility to filter parameter from a single ParameterBag, so we created this helper.
*
* @param string $sKey
* @param mixed $default
* @param int $iFilter Default is FILTER_SANITIZE_STRING
*
* @return mixed|null
*
* @since 2.5.1
*/
public function ReadParam($sKey, $default = null, $iFilter = FILTER_SANITIZE_STRING)
{
if ($this->GetCurrentRequest()->query->has($sKey))
{
return $this->GetCurrentRequest()->query->filter($sKey, $default, $iFilter);
}
if ($this->GetCurrentRequest()->attributes->has($sKey))
{
return $this->GetCurrentRequest()->attributes->filter($sKey, $default, $iFilter);
}
if ($this->GetCurrentRequest()->request->has($sKey))
{
return $this->GetCurrentRequest()->request->filter($sKey, $default, $iFilter);
}
return $default;
}
}

View File

@@ -1,60 +0,0 @@
<?php
/**
* Copyright (C) 2012-2018 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with iTop. If not, see <http://www.gnu.org/licenses/>
*/
namespace Combodo\iTop\Portal\Provider;
use Silex\Application;
use Silex\ServiceProviderInterface;
use Combodo\iTop\Portal\Helper\RequestManipulatorHelper;
/**
* RequestManipulatorHelper service provider
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.4.3
*/
class RequestManipulatorServiceProvider implements ServiceProviderInterface
{
/**
* @param \Silex\Application $oApp
*/
public function register(Application $oApp)
{
$oApp['request_manipulator'] = $oApp->share(function ($oApp)
{
$oApp->flush();
$oRequestManipulatorHelper = new RequestManipulatorHelper($oApp['request_stack']);
return $oRequestManipulatorHelper;
});
}
/**
* @param \Silex\Application $oApp
*/
public function boot(Application $oApp)
{
}
}

View File

@@ -36,8 +36,6 @@ require_once __DIR__ . '/../src/providers/urlgeneratorserviceprovider.class.inc.
require_once __DIR__ . '/../src/helpers/urlgeneratorhelper.class.inc.php'; require_once __DIR__ . '/../src/helpers/urlgeneratorhelper.class.inc.php';
require_once __DIR__ . '/../src/providers/contextmanipulatorserviceprovider.class.inc.php'; require_once __DIR__ . '/../src/providers/contextmanipulatorserviceprovider.class.inc.php';
require_once __DIR__ . '/../src/helpers/contextmanipulatorhelper.class.inc.php'; require_once __DIR__ . '/../src/helpers/contextmanipulatorhelper.class.inc.php';
require_once __DIR__ . '/../src/providers/requestmanipulatorserviceprovider.class.inc.php';
require_once __DIR__ . '/../src/helpers/requestmanipulatorhelper.class.inc.php';
require_once __DIR__ . '/../src/providers/scopevalidatorserviceprovider.class.inc.php'; require_once __DIR__ . '/../src/providers/scopevalidatorserviceprovider.class.inc.php';
require_once __DIR__ . '/../src/helpers/scopevalidatorhelper.class.inc.php'; require_once __DIR__ . '/../src/helpers/scopevalidatorhelper.class.inc.php';
require_once __DIR__ . '/../src/providers/lifecyclevalidatorserviceprovider.class.inc.php'; require_once __DIR__ . '/../src/providers/lifecyclevalidatorserviceprovider.class.inc.php';
@@ -99,9 +97,6 @@ $oApp->before(function(Symfony\Component\HttpFoundation\Request $oRequest, Silex
$oApp->abort(500, Dict::S('Portal:ErrorNoContactForThisUser')); $oApp->abort(500, Dict::S('Portal:ErrorNoContactForThisUser'));
} }
// Register request manipulator now that the request has been created.
$oApp->register(new Combodo\iTop\Portal\Provider\RequestManipulatorServiceProvider());
// Enable archived data // Enable archived data
utils::InitArchiveMode(); utils::InitArchiveMode();

View File

@@ -1,7 +1,7 @@
iTop - version 2.4.3 - 10-Oct-2018 iTop - version 2.4.2 - 14-Jun-2018
Readme file Readme file
iTop 2.4.3 is the 34th release of iTop. iTop 2.4.2 is the 32nd release of iTop.
Changes since the previous version Changes since the previous version
------------------------------------------------------------------- -------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@@ -29,8 +29,6 @@ use \Combodo\iTop\Form\Field\TextField;
* Description of TextAreaField * Description of TextAreaField
* *
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com> * @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package \Combodo\iTop\Form\Field
* @since 2.3.0
*/ */
class TextAreaField extends TextField class TextAreaField extends TextField
{ {
@@ -115,7 +113,7 @@ class TextAreaField extends TextField
{ {
if ($this->GetFormat() == TextAreaField::ENUM_FORMAT_TEXT) if ($this->GetFormat() == TextAreaField::ENUM_FORMAT_TEXT)
{ {
$sValue = \Str::pure2html($this->GetCurrentValue()); $sValue = $this->GetCurrentValue();
$sValue = AttributeText::RenderWikiHtml($sValue); $sValue = AttributeText::RenderWikiHtml($sValue);
return "<div>".str_replace("\n", "<br>\n", $sValue).'</div>'; return "<div>".str_replace("\n", "<br>\n", $sValue).'</div>';
} }

View File

@@ -576,7 +576,6 @@ EOF
); );
// Target object others attributes // Target object others attributes
// TODO: Support for AttriubteImage, AttributeBlob
foreach ($this->oField->GetAttributesToDisplay(true) as $sAttCode) foreach ($this->oField->GetAttributesToDisplay(true) as $sAttCode)
{ {
if ($sAttCode !== 'id') if ($sAttCode !== 'id')
@@ -599,7 +598,7 @@ EOF
} }
else else
{ {
$aAttProperties['value'] = $oAttDef->GetAsHTML($oRemoteItem->Get($sAttCode)); $aAttProperties['value'] = $oAttDef->GetValueLabel($oRemoteItem->Get($sAttCode));
if ($oAttDef instanceof AttributeFriendlyName) if ($oAttDef instanceof AttributeFriendlyName)
{ {