From b6d0843e552f498fa5963b93fdb89bbfceea8021 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 4 Oct 2018 14:33:29 +0200 Subject: [PATCH 01/13] Fix dashboard edition when a bad OQL is present in dashlet 'Group By' --- application/dashlet.class.inc.php | 110 ++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 36 deletions(-) diff --git a/application/dashlet.class.inc.php b/application/dashlet.class.inc.php index 7132c8f2b..f06ec427a 100644 --- a/application/dashlet.class.inc.php +++ b/application/dashlet.class.inc.php @@ -330,31 +330,62 @@ EOF protected function GetGroupByOptions($sOql) { - $oQuery = $this->oModelReflection->GetQuery($sOql); - $sClass = $oQuery->GetClass(); $aGroupBy = array(); - foreach($this->oModelReflection->ListAttributes($sClass) as $sAttCode => $sAttType) + try { - if ($sAttType == 'AttributeLinkedSet') continue; - if (is_subclass_of($sAttType, 'AttributeLinkedSet')) continue; - if ($sAttType == 'AttributeFriendlyName') continue; - if (is_subclass_of($sAttType, 'AttributeFriendlyName')) continue; - if ($sAttType == 'AttributeExternalField') continue; - if (is_subclass_of($sAttType, 'AttributeExternalField')) continue; - if ($sAttType == 'AttributeOneWayPassword') continue; - - $sLabel = $this->oModelReflection->GetLabel($sClass, $sAttCode); - $aGroupBy[$sAttCode] = $sLabel; - - if (is_subclass_of($sAttType, 'AttributeDateTime') || $sAttType == 'AttributeDateTime') + $oQuery = $this->oModelReflection->GetQuery($sOql); + $sClass = $oQuery->GetClass(); + foreach($this->oModelReflection->ListAttributes($sClass) as $sAttCode => $sAttType) { - $aGroupBy[$sAttCode.':hour'] = Dict::Format('UI:DashletGroupBy:Prop-GroupBy:Select-Hour', $sLabel); - $aGroupBy[$sAttCode.':month'] = Dict::Format('UI:DashletGroupBy:Prop-GroupBy:Select-Month', $sLabel); - $aGroupBy[$sAttCode.':day_of_week'] = Dict::Format('UI:DashletGroupBy:Prop-GroupBy:Select-DayOfWeek', $sLabel); - $aGroupBy[$sAttCode.':day_of_month'] = Dict::Format('UI:DashletGroupBy:Prop-GroupBy:Select-DayOfMonth', $sLabel); + if ($sAttType == 'AttributeLinkedSet') + { + continue; + } + if (is_subclass_of($sAttType, 'AttributeLinkedSet')) + { + continue; + } + if ($sAttType == 'AttributeFriendlyName') + { + continue; + } + if (is_subclass_of($sAttType, 'AttributeFriendlyName')) + { + continue; + } + if ($sAttType == 'AttributeExternalField') + { + continue; + } + if (is_subclass_of($sAttType, 'AttributeExternalField')) + { + continue; + } + if ($sAttType == 'AttributeOneWayPassword') + { + continue; + } + + $sLabel = $this->oModelReflection->GetLabel($sClass, $sAttCode); + $aGroupBy[$sAttCode] = $sLabel; + + if (is_subclass_of($sAttType, 'AttributeDateTime') || $sAttType == 'AttributeDateTime') + { + $aGroupBy[$sAttCode.':hour'] = Dict::Format('UI:DashletGroupBy:Prop-GroupBy:Select-Hour', $sLabel); + $aGroupBy[$sAttCode.':month'] = Dict::Format('UI:DashletGroupBy:Prop-GroupBy:Select-Month', + $sLabel); + $aGroupBy[$sAttCode.':day_of_week'] = Dict::Format('UI:DashletGroupBy:Prop-GroupBy:Select-DayOfWeek', + $sLabel); + $aGroupBy[$sAttCode.':day_of_month'] = Dict::Format('UI:DashletGroupBy:Prop-GroupBy:Select-DayOfMonth', + $sLabel); + } } + asort($aGroupBy); + } + catch(Exception $e) + { + // Bad OQL is ignored } - asort($aGroupBy); return $aGroupBy; } @@ -1219,25 +1250,32 @@ abstract class DashletGroupBy extends Dashlet protected function GetNumericAttributes($sOql) { $aFunctionAttributes = array(); - $oQuery = $this->oModelReflection->GetQuery($sOql); - $sClass = $oQuery->GetClass(); - if (is_null($sClass)) + try { - return $aFunctionAttributes; - } - foreach($this->oModelReflection->ListAttributes($sClass) as $sAttCode => $sAttType) - { - switch ($sAttType) + $oQuery = $this->oModelReflection->GetQuery($sOql); + $sClass = $oQuery->GetClass(); + if (is_null($sClass)) { - case 'AttributeDecimal': - case 'AttributeDuration': - case 'AttributeInteger': - case 'AttributePercentage': - case 'AttributeSubItem': // TODO: Known limitation: no unit displayed (values in sec) - $sLabel = $this->oModelReflection->GetLabel($sClass, $sAttCode); - $aFunctionAttributes[$sAttCode] = $sLabel; - break; + return $aFunctionAttributes; } + foreach($this->oModelReflection->ListAttributes($sClass) as $sAttCode => $sAttType) + { + switch ($sAttType) + { + case 'AttributeDecimal': + case 'AttributeDuration': + case 'AttributeInteger': + case 'AttributePercentage': + case 'AttributeSubItem': // TODO: Known limitation: no unit displayed (values in sec) + $sLabel = $this->oModelReflection->GetLabel($sClass, $sAttCode); + $aFunctionAttributes[$sAttCode] = $sLabel; + break; + } + } + } + catch (Exception $e) + { + // Ignore bad OQL } return $aFunctionAttributes; From b84ac80aaaee96d9b75138db67b7c3b371570c1a Mon Sep 17 00:00:00 2001 From: Molkobain Date: Mon, 8 Oct 2018 13:05:45 +0200 Subject: [PATCH 02/13] =?UTF-8?q?(Cherry=20pick=20from=20develop=20ab1715e?= =?UTF-8?q?)=20N=C2=B01576=20Portal:=20Security=20hardening=20(missed=20on?= =?UTF-8?q?e=20file=20in=20previous=20commit).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../managebrickcontroller.class.inc.php | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/datamodels/2.x/itop-portal-base/portal/src/controllers/managebrickcontroller.class.inc.php b/datamodels/2.x/itop-portal-base/portal/src/controllers/managebrickcontroller.class.inc.php index ac094151e..99cd4174e 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/controllers/managebrickcontroller.class.inc.php +++ b/datamodels/2.x/itop-portal-base/portal/src/controllers/managebrickcontroller.class.inc.php @@ -577,7 +577,7 @@ class ManageBrickController extends BrickController $oAttDef = MetaModel::GetAttributeDef($sCurrentClass, $sItemAttr); if ($oAttDef->IsExternalKey()) { - $sValue = $oCurrentRow->Get($sItemAttr.'_friendlyname'); + $sValue = $oCurrentRow->GetAsHTML($sItemAttr.'_friendlyname'); // Adding a view action on the external keys if ($oCurrentRow->Get($sItemAttr) !== $oAttDef->GetNullValue()) @@ -595,13 +595,22 @@ class ManageBrickController extends BrickController } } } - elseif ($oAttDef instanceof AttributeSubItem || $oAttDef instanceof AttributeDuration) - { - $sValue = $oAttDef->GetAsHTML($oCurrentRow->Get($sItemAttr)); - } + elseif ($oAttDef instanceof AttributeImage) + { + $oOrmDoc = $oCurrentRow->Get($sItemAttr); + if (is_object($oOrmDoc) && !$oOrmDoc->IsEmpty()) + { + $sUrl = $oApp['url_generator']->generate('p_object_document_display', array('sObjectClass' => get_class($oCurrentRow), 'sObjectId' => $oCurrentRow->GetKey(), 'sObjectField' => $sItemAttr, 'cache' => 86400)); + } + else + { + $sUrl = $oAttDef->Get('default_image'); + } + $sValue = ''; + } else { - $sValue = $oAttDef->GetValueLabel($oCurrentRow->Get($sItemAttr)); + $sValue = $oAttDef->GetAsHTML($oCurrentRow->Get($sItemAttr)); } unset($oAttDef); From 4a431be0a9e0f4a510d45c00f361a2f4bcbf4383 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Thu, 2 Aug 2018 10:34:58 +0200 Subject: [PATCH 03/13] =?UTF-8?q?(Cherry=20picked=20from=20commit=20509906?= =?UTF-8?q?0)=20N=C2=B01203=20:=20Correctly=20use=20'from'=20field=20for?= =?UTF-8?q?=20test=20email=20notifications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/action.class.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/action.class.inc.php b/core/action.class.inc.php index fc5a3e3f6..55a96fcda 100644 --- a/core/action.class.inc.php +++ b/core/action.class.inc.php @@ -360,6 +360,7 @@ class ActionEmail extends ActionNotification $sTestBody .= "\n"; $oEmail->SetBody($sTestBody, 'text/html', $sStyles); $oEmail->SetRecipientTO($this->Get('test_recipient')); + $oEmail->SetRecipientFrom($sFrom); $oEmail->SetReferences($sReference); $oEmail->SetMessageId($sMessageId); } From 21d7de7d8d504acd2c9d774ce32e4acf61ae0a6c Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Tue, 9 Oct 2018 17:36:30 +0200 Subject: [PATCH 04/13] =?UTF-8?q?Use=20a=20longer=20timeout=20to=20let=20t?= =?UTF-8?q?he=20IFRAME=20load=20itself=20and=20inform=20iTop=20Hub=20of=20?= =?UTF-8?q?the=20updated=20configuration.=20(Bug=20N=C2=B01672)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- datamodels/2.x/itop-hub-connector/js/hub.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datamodels/2.x/itop-hub-connector/js/hub.js b/datamodels/2.x/itop-hub-connector/js/hub.js index cf4387d52..b5f468c3b 100644 --- a/datamodels/2.x/itop-hub-connector/js/hub.js +++ b/datamodels/2.x/itop-hub-connector/js/hub.js @@ -138,7 +138,7 @@ $(function() if (this.options.redirect_after_completion_url != '') { var sUrl = this.options.redirect_after_completion_url; - window.setTimeout(function() { window.location.href = sUrl; }, 500); + window.setTimeout(function() { window.location.href = sUrl; }, 3000); } } else From 80be4b4371b2a7367b458f17f173dfd83d81c3cc Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 9 Oct 2018 17:18:14 +0200 Subject: [PATCH 05/13] idea files improvements - use Combodo preset - JS code style (use tab for indentation, newlines in if/else statements) --- .idea/codeStyles/Project.xml | 8 ++++++++ .idea/codeStyles/codeStyleConfig.xml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index cbc60d1a0..4f6f26a5a 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -11,6 +11,14 @@