mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
New type of trigger: TriggerOnPortalUpdate, called when the end-user updates a ticket from the portal.
SVN:trunk[1420]
This commit is contained in:
@@ -353,6 +353,12 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
}
|
||||
$oPage->SetCurrentTab('');
|
||||
|
||||
foreach (MetaModel::EnumPlugins('iApplicationUIExtension') as $oExtensionInstance)
|
||||
{
|
||||
$oExtensionInstance->OnDisplayRelations($this, $oPage, $bEditMode);
|
||||
}
|
||||
|
||||
// Display Notifications after the other tabs since this tab disappears in edition
|
||||
if (!$bEditMode)
|
||||
{
|
||||
// Get the actual class of the current object
|
||||
@@ -364,19 +370,16 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
$oTriggerSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObject AS T WHERE T.target_class IN ('$sClassList')"));
|
||||
if ($oTriggerSet->Count() > 0)
|
||||
{
|
||||
$oPage->SetCurrentTab(Dict::S('UI:NotificationsTab'));
|
||||
|
||||
// Display notifications regarding the object
|
||||
$iId = $this->GetKey();
|
||||
$oBlock = new DisplayBlock(DBObjectSearch::FromOQL("SELECT EventNotificationEmail AS Ev JOIN TriggerOnObject AS T ON Ev.trigger_id = T.id WHERE T.target_class IN ('$sClassList') AND Ev.object_id = $iId"), 'list', false);
|
||||
$oNotifSearch = DBObjectSearch::FromOQL("SELECT EventNotificationEmail AS Ev JOIN TriggerOnObject AS T ON Ev.trigger_id = T.id WHERE T.target_class IN ('$sClassList') AND Ev.object_id = $iId");
|
||||
$oNotifSet = new DBObjectSet($oNotifSearch);
|
||||
$sCount = ($oNotifSet->Count() > 0) ? ' ('.$oNotifSet->Count().')' : '';
|
||||
$oPage->SetCurrentTab(Dict::S('UI:NotificationsTab').$sCount);
|
||||
$oBlock = new DisplayBlock($oNotifSearch, 'list', false);
|
||||
$oBlock->Display($oPage, 'notifications', array('menu' => false));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (MetaModel::EnumPlugins('iApplicationUIExtension') as $oExtensionInstance)
|
||||
{
|
||||
$oExtensionInstance->OnDisplayRelations($this, $oPage, $bEditMode);
|
||||
}
|
||||
}
|
||||
|
||||
function GetBareProperties(WebPage $oPage, $bEditMode = false)
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -452,6 +452,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:TriggerOnPortalUpdate+' => 'Trigger on a end-user\'s update from the portal',
|
||||
));
|
||||
|
||||
//
|
||||
// Class: TriggerOnStateChange
|
||||
//
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -966,6 +966,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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user