Fix for Trac #434: new class of Trigger: TriggerOnPortalUpdate

SVN:1.1[1442]
This commit is contained in:
Denis Flaven
2011-08-09 14:46:16 +00:00
parent 05c709056b
commit b732673b65
4 changed files with 47 additions and 0 deletions

View File

@@ -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
{

View File

@@ -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
//

View File

@@ -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',

View File

@@ -907,6 +907,14 @@ function AddComment($oP, $id)
$iChangeId = $oMyChange->DBInsert();
$oRequest->DBUpdateTracked($oMyChange);
$oP->p("<h1>".Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oRequest)), $oRequest->GetName())."</h1>\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
{