123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <?php
- // Copyright (C) 2010 Combodo SARL
- //
- // This program is free software; you can redistribute it and/or modify
- // it under the terms of the GNU General Public License as published by
- // the Free Software Foundation; version 3 of the License.
- //
- // This program 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 General Public License for more details.
- //
- // You should have received a copy of the GNU General Public License
- // along with this program; if not, write to the Free Software
- // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- /**
- * Persistent class Trigger and derived
- * User defined triggers, that may be used in conjunction with user defined actions
- *
- * @author Erwan Taloc <erwan.taloc@combodo.com>
- * @author Romain Quetiez <romain.quetiez@combodo.com>
- * @author Denis Flaven <denis.flaven@combodo.com>
- * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
- */
- /**
- * A user defined trigger, to customize the application
- * A trigger will activate an action
- *
- * @package iTopORM
- */
- class Trigger extends cmdbAbstractObject
- {
- public static function Init()
- {
- $aParams = array
- (
- "category" => "core/cmdb",
- "key_type" => "autoincrement",
- "key_label" => "",
- "name_attcode" => "description",
- "state_attcode" => "",
- "reconc_keys" => array(),
- "db_table" => "priv_trigger",
- "db_key_field" => "id",
- "db_finalclass_field" => "realclass",
- "display_template" => "",
- );
- MetaModel::Init_Params($aParams);
- //MetaModel::Init_InheritAttributes();
- MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
- MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("linked_actions", array("linked_class"=>"lnkTriggerAction", "ext_key_to_me"=>"trigger_id", "ext_key_to_remote"=>"action_id", "allowed_values"=>null, "count_min"=>1, "count_max"=>0, "depends_on"=>array())));
- // Display lists
- MetaModel::Init_SetZListItems('details', array('finalclass', 'description')); // Attributes to be displayed for the complete details
- MetaModel::Init_SetZListItems('list', array('finalclass', 'description')); // Attributes to be displayed for a list
- // Search criteria
- // MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
- // MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
- }
- public function DoActivate($aContextArgs)
- {
- // Find the related
- $oLinkedActions = $this->Get('linked_actions');
- while ($oLink = $oLinkedActions->Fetch())
- {
- $iActionId = $oLink->Get('action_id');
- $oAction = MetaModel::GetObject('Action', $iActionId);
- if ($oAction->IsActive())
- {
- $oAction->DoExecute($this, $aContextArgs);
- }
- }
- }
- }
- class TriggerOnObject extends Trigger
- {
- public static function Init()
- {
- $aParams = array
- (
- "category" => "core/cmdb",
- "key_type" => "autoincrement",
- "key_label" => "",
- "name_attcode" => "",
- "state_attcode" => "",
- "reconc_keys" => array(),
- "db_table" => "priv_trigger_onobject",
- "db_key_field" => "id",
- "db_finalclass_field" => "",
- "display_template" => "",
- );
- MetaModel::Init_Params($aParams);
- MetaModel::Init_InheritAttributes();
- MetaModel::Init_AddAttribute(new AttributeClass("target_class", array("class_category"=>"bizmodel", "more_values"=>null, "sql"=>"target_class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
- // Display lists
- MetaModel::Init_SetZListItems('details', array('description', 'target_class')); // 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
- // MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
- // MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
- }
- }
- class TriggerOnStateChange extends TriggerOnObject
- {
- public static function Init()
- {
- $aParams = array
- (
- "category" => "core/cmdb",
- "key_type" => "autoincrement",
- "key_label" => "",
- "name_attcode" => "",
- "state_attcode" => "",
- "reconc_keys" => array(),
- "db_table" => "priv_trigger_onstatechange",
- "db_key_field" => "id",
- "db_finalclass_field" => "",
- "display_template" => "",
- );
- MetaModel::Init_Params($aParams);
- MetaModel::Init_InheritAttributes();
- MetaModel::Init_AddAttribute(new AttributeString("state", array("allowed_values"=>null, "sql"=>"state", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
- // Display lists
- MetaModel::Init_SetZListItems('details', array('description', 'target_class', 'state')); // Attributes to be displayed for the complete details
- MetaModel::Init_SetZListItems('list', array('finalclass', 'target_class', 'state', 'description')); // Attributes to be displayed for a list
- // Search criteria
- // MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
- // MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
- }
- }
- class TriggerOnStateEnter extends TriggerOnStateChange
- {
- public static function Init()
- {
- $aParams = array
- (
- "category" => "core/cmdb",
- "key_type" => "autoincrement",
- "key_label" => "",
- "name_attcode" => "",
- "state_attcode" => "",
- "reconc_keys" => array(),
- "db_table" => "priv_trigger_onstateenter",
- "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', 'state')); // Attributes to be displayed for the complete details
- MetaModel::Init_SetZListItems('list', array('target_class', 'state', 'description')); // Attributes to be displayed for a list
- // Search criteria
- // MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
- // MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
- }
- }
- class TriggerOnStateLeave extends TriggerOnStateChange
- {
- public static function Init()
- {
- $aParams = array
- (
- "category" => "core/cmdb",
- "key_type" => "autoincrement",
- "key_label" => "",
- "name_attcode" => "",
- "state_attcode" => "",
- "reconc_keys" => array(),
- "db_table" => "priv_trigger_onstateleave",
- "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', 'state')); // Attributes to be displayed for the complete details
- MetaModel::Init_SetZListItems('list', array('target_class', 'state', 'description')); // Attributes to be displayed for a list
- // Search criteria
- // MetaModel::Init_SetZListItems('standard_search', array('')); // Criteria of the std search form
- // MetaModel::Init_SetZListItems('advanced_search', array('')); // Criteria of the advanced search form
- }
- }
- class TriggerOnObjectCreate extends TriggerOnObject
- {
- public static function Init()
- {
- $aParams = array
- (
- "category" => "core/cmdb",
- "key_type" => "autoincrement",
- "key_label" => "",
- "name_attcode" => "",
- "state_attcode" => "",
- "reconc_keys" => array(),
- "db_table" => "priv_trigger_onobjcreate",
- "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')); // 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
- // MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
- // MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
- }
- }
- class lnkTriggerAction extends cmdbAbstractObject
- {
- public static function Init()
- {
- $aParams = array
- (
- "category" => "core/cmdb",
- "key_type" => "autoincrement",
- "key_label" => "Link ID",
- "name_attcode" => "",
- "state_attcode" => "",
- "reconc_keys" => array(""),
- "db_table" => "priv_link_action_trigger",
- "db_key_field" => "link_id",
- "db_finalclass_field" => "",
- "display_template" => "",
- );
- MetaModel::Init_Params($aParams);
- MetaModel::Init_AddAttribute(new AttributeExternalKey("action_id", array("targetclass"=>"Action", "jointype"=> '', "allowed_values"=>null, "sql"=>"action_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
- MetaModel::Init_AddAttribute(new AttributeExternalField("action_name", array("allowed_values"=>null, "extkey_attcode"=> 'action_id', "target_attcode"=>"name")));
- MetaModel::Init_AddAttribute(new AttributeExternalKey("trigger_id", array("targetclass"=>"Trigger", "jointype"=> '', "allowed_values"=>null, "sql"=>"trigger_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
- MetaModel::Init_AddAttribute(new AttributeExternalField("trigger_name", array("allowed_values"=>null, "extkey_attcode"=> 'trigger_id', "target_attcode"=>"description")));
- MetaModel::Init_AddAttribute(new AttributeInteger("order", array("allowed_values"=>null, "sql"=>"order", "default_value"=>0, "is_null_allowed"=>true, "depends_on"=>array())));
- // Display lists
- MetaModel::Init_SetZListItems('details', array('action_id', 'trigger_id', 'order')); // Attributes to be displayed for a list
- MetaModel::Init_SetZListItems('list', array('action_name', 'trigger_name', 'order')); // Attributes to be displayed for a list
- // Search criteria
- MetaModel::Init_SetZListItems('standard_search', array('action_id', 'trigger_id', 'order')); // Criteria of the std search form
- MetaModel::Init_SetZListItems('advanced_search', array('action_id', 'trigger_id', 'order')); // Criteria of the advanced search form
- }
- }
- ?>
|