array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), "name"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})'), "eventsource"=> array(T_ZBX_INT, O_MAND, null, IN(array(EVENT_SOURCE_TRIGGERS,EVENT_SOURCE_DISCOVERY)), null), "evaltype"=> array(T_ZBX_INT, O_OPT, null, IN(array(ACTION_EVAL_TYPE_AND_OR,ACTION_EVAL_TYPE_AND,ACTION_EVAL_TYPE_OR)), 'isset({save})'), "status"=> array(T_ZBX_INT, O_OPT, null, IN(array(ACTION_STATUS_ENABLED,ACTION_STATUS_DISABLED)), 'isset({save})'), "g_actionid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, null), "conditions"=> array(null, O_OPT, null, null, null), "g_conditionid"=> array(null, O_OPT, null, null, null), "new_condition"=> array(null, O_OPT, null, null, 'isset({add_condition})'), "operations"=> array(null, O_OPT, null, null, null), "g_operationid"=> array(null, O_OPT, null, null, null), "edit_operationid"=> array(null, O_OPT, P_ACT, DB_ID, null), "new_operation"=> array(null, O_OPT, null, null, 'isset({add_operation})'), /* actions */ "group_delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "group_enable"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "group_disable"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "add_condition"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "del_condition"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "cancel_new_condition"=>array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "add_operation"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "del_operation"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "cancel_new_operation"=>array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "clone"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null), /* other */ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null), "form_refresh"=> array(T_ZBX_INT, O_OPT, null, null, null) ); check_fields($fields); validate_sort_and_sortorder(); if(isset($_REQUEST['actionid']) && !action_accessiable($_REQUEST['actionid'], PERM_READ_WRITE)) { access_deny(); } ?> SetMethod('get'); $form->AddVar('eventsource', $_REQUEST['eventsource']); $form->AddItem(new CButton('form',S_CREATE_ACTION)); show_table_header(S_CONFIGURATION_OF_ACTIONS_BIG, $form); echo SBR; if(isset($_REQUEST['form'])) { /* form */ insert_action_form(); } else { $form = new CForm(); $form->SetMethod('get'); $cmbSource = new CComboBox('eventsource',$_REQUEST['eventsource'],'submit()'); $cmbSource->AddItem(EVENT_SOURCE_TRIGGERS,S_TRIGGERS); $cmbSource->AddItem(EVENT_SOURCE_DISCOVERY,S_DISCOVERY); $form->AddItem(array(S_EVENT_SOURCE, SPACE, $cmbSource)); show_table_header(S_ACTIONS_BIG, $form); unset($form, $cmbSource); /* table */ $form = new CForm(); $form->SetName('actions'); $tblActions = new CTableInfo(S_NO_ACTIONS_DEFINED); $tblActions->SetHeader(array( array( new CCheckBox('all_items',null,'CheckAll("'.$form->GetName().'","all_items");'), make_sorting_link(S_NAME,'a.name') ), S_CONDITIONS, S_OPERATIONS, make_sorting_link(S_STATUS,'a.status') )); $db_actions = DBselect('SELECT a.* '. ' FROM actions a'. ' WHERE a.eventsource='.$_REQUEST['eventsource']. ' AND '.DBin_node('actionid'). order_by('a.name,a.status','a.actionid')); while($action_data = DBfetch($db_actions)) { if(!action_accessiable($action_data['actionid'], PERM_READ_WRITE)) continue; $conditions=array(); $db_conditions = DBselect('select * from conditions where actionid='.$action_data['actionid']. ' order by conditiontype,conditionid'); while($condition_data = DBfetch($db_conditions)) { array_push($conditions, array(get_condition_desc( $condition_data['conditiontype'], $condition_data['operator'], $condition_data['value']),BR())); } unset($db_conditions, $condition_data); $operations=array(); $db_operations = DBselect('select * from operations where actionid='.$action_data['actionid']. ' order by operationtype,operationid'); while($operation_data = DBfetch($db_operations)) array_push($operations,array(get_operation_desc(SHORT_DESCRITION, $operation_data),BR())); if($action_data['status'] == ACTION_STATUS_DISABLED) { $status= new CLink(S_DISABLED, 'actionconf.php?group_enable=1&g_actionid%5B%5D='.$action_data['actionid'].url_param('eventsource'), 'disabled'); } else { $status= new CLink(S_ENABLED, 'actionconf.php?group_disable=1&g_actionid%5B%5D='.$action_data['actionid'].url_param('eventsource'), 'enabled'); } $tblActions->AddRow(array( array( new CCheckBox( 'g_actionid[]', /* name */ null, /* checked */ null, /* action */ $action_data['actionid']), /* value */ SPACE, new CLink( $action_data['name'], 'actionconf.php?form=update&actionid='.$action_data['actionid'],'action'), ), $conditions, $operations, $status )); } $tblActions->SetFooter(new CCol(array( new CButtonQMessage('group_enable',S_ENABLE_SELECTED,S_ENABLE_SELECTED_ACTIONS_Q), SPACE, new CButtonQMessage('group_disable',S_DISABLE_SELECTED,S_DISABLE_SELECTED_ACTIONS_Q), SPACE, new CButtonQMessage('group_delete',S_DELETE_SELECTED,S_DELETE_SELECTED_ACTIONS_Q) ))); $form->AddItem($tblActions); $form->Show(); } ?>