diff --git a/core/trigger.class.inc.php b/core/trigger.class.inc.php index 604e42780..77bfae61f 100644 --- a/core/trigger.class.inc.php +++ b/core/trigger.class.inc.php @@ -105,6 +105,34 @@ abstract class TriggerOnObject extends Trigger // MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form } } +/** + * To trigger notifications when a ticket is updated from the portal + */ +class TriggerOnPortalUpdate extends TriggerOnObject +{ + public static function Init() + { + $aParams = array + ( + "category" => "core/cmdb", + "key_type" => "autoincrement", + "name_attcode" => "description", + "state_attcode" => "", + "reconc_keys" => array(), + "db_table" => "priv_trigger_onportalupdate", + "db_key_field" => "id", + "db_finalclass_field" => "", + "display_template" => "", + ); + MetaModel::Init_Params($aParams); + MetaModel::Init_InheritAttributes(); + + // Display lists + MetaModel::Init_SetZListItems('details', array('description', 'target_class', 'action_list')); // Attributes to be displayed for the complete details + MetaModel::Init_SetZListItems('list', array('finalclass', 'target_class', 'description')); // Attributes to be displayed for a list + // Search criteria + } +} abstract class TriggerOnStateChange extends TriggerOnObject { diff --git a/dictionaries/dictionary.itop.core.php b/dictionaries/dictionary.itop.core.php index 0c3f5eff8..ca6ea136b 100644 --- a/dictionaries/dictionary.itop.core.php +++ b/dictionaries/dictionary.itop.core.php @@ -436,6 +436,15 @@ Dict::Add('EN US', 'English', 'English', array( 'Class:TriggerOnObject/Attribute:target_class+' => '', )); +// +// Class: TriggerOnPortalUpdate +// + +Dict::Add('EN US', 'English', 'English', array( + 'Class:TriggerOnPortalUpdate' => 'Trigger (when updated from the portal)', + +)); + // // Class: TriggerOnStateChange // diff --git a/dictionaries/fr.dictionary.itop.core.php b/dictionaries/fr.dictionary.itop.core.php index ce78cab02..467f6a76a 100644 --- a/dictionaries/fr.dictionary.itop.core.php +++ b/dictionaries/fr.dictionary.itop.core.php @@ -48,6 +48,8 @@ Dict::Add('FR FR', 'French', 'Français', array( 'Class:ActionEmail/Attribute:importance/Value:low+' => '', 'Class:ActionEmail/Attribute:importance/Value:normal' => 'Normale', 'Class:ActionEmail/Attribute:importance/Value:normal+' => '', + 'Class:TriggerOnPortalUdpate' => 'Déclencheur sur mise à jour depuis le portail', + 'Class:TriggerOnPortalUdpate+' => '', 'Class:TriggerOnStateEnter' => 'Déclencheur sur un objet entrant dans un état', 'Class:TriggerOnStateEnter+' => '', 'Class:TriggerOnStateLeave' => 'Déclencheur sur un objet quitant un état', diff --git a/portal/index.php b/portal/index.php index 6c13d7af0..6e4a5de35 100644 --- a/portal/index.php +++ b/portal/index.php @@ -907,6 +907,14 @@ function AddComment($oP, $id) $iChangeId = $oMyChange->DBInsert(); $oRequest->DBUpdateTracked($oMyChange); $oP->p("

".Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oRequest)), $oRequest->GetName())."

\n"); + + // If there is any trigger for the Portal Update, then activate them + $sOQL = "SELECT TriggerOnPortalUpdate WHERE target_class ='UserRequest'"; + $oSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL)); + while($oTrigger = $oSet->Fetch()) + { + $oTrigger->DoActivate($oRequest->ToArgs('this')); + } } else {