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})'), 'esc_period'=> array(T_ZBX_INT, O_OPT, null, BETWEEN(60,999999), 'isset({save})&&isset({escalation})'), 'escalation'=> array(T_ZBX_INT, O_OPT, null, IN("0,1"), null), 'status'=> array(T_ZBX_INT, O_OPT, null, IN(array(ACTION_STATUS_ENABLED,ACTION_STATUS_DISABLED)), 'isset({save})'), 'def_shortdata'=> array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), 'def_longdata'=> array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), 'recovery_msg'=> array(T_ZBX_INT, O_OPT, null, null, null), 'r_shortdata'=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({recovery_msg})&&isset({save})'), 'r_longdata'=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({recovery_msg})&&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, 'isset({save})'), '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})'), 'opconditions'=> array(null, O_OPT, null, null, null), 'g_opconditionid'=> array(null, O_OPT, null, null, null), 'new_opcondition'=> array(null, O_OPT, null, null, 'isset({add_opcondition})'), /* 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), 'add_opcondition'=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), 'del_opcondition'=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null), 'cancel_new_opcondition'=>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), //ajax 'favobj'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, NULL), 'favid'=> array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), 'state'=> array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj}) && ("filter"=={favobj})'), ); check_fields($fields); validate_sort_and_sortorder('a.name',ZBX_SORT_UP); //SDI($_REQUEST); /* AJAX */ if(isset($_REQUEST['favobj'])){ if('filter' == $_REQUEST['favobj']){ update_profile('web.audit.filter.state',$_REQUEST['state']); } } if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){ exit(); } //-------- if(isset($_REQUEST['actionid']) && !action_accessible($_REQUEST['actionid'], PERM_READ_WRITE)){ access_deny(); } ?> $new_operation['esc_step_to']) { $from = $new_operation['esc_step_to']; $new_operation['esc_step_to'] = $new_operation['esc_step_from']; $new_operation['esc_step_from'] = $from; } if(!isset($new_operation['id'])){ if(!str_in_array($new_operation,$_REQUEST['operations'])) array_push($_REQUEST['operations'],$new_operation); } else{ $id = $new_operation['id']; unset($new_operation['id']); $_REQUEST['operations'][$id] = $new_operation; } unset($_REQUEST['new_operation']); } } else if(inarr_isset(array('del_operation','g_operationid'))){ $_REQUEST['operations'] = get_request('operations',array()); foreach($_REQUEST['g_operationid'] as $val){ unset($_REQUEST['operations'][$val]); } } else if(inarr_isset(array('edit_operationid'))){ $_REQUEST['edit_operationid'] = array_keys($_REQUEST['edit_operationid']); $edit_operationid = $_REQUEST['edit_operationid'] =array_pop($_REQUEST['edit_operationid']); $_REQUEST['operations'] = get_request('operations',array()); if(isset($_REQUEST['operations'][$edit_operationid])){ $_REQUEST['new_operation'] = $_REQUEST['operations'][$edit_operationid]; $_REQUEST['new_operation']['id'] = $edit_operationid; } } /* GROUP ACTIONS */ else if(isset($_REQUEST['group_enable'])&&isset($_REQUEST['g_actionid'])){ if(!count($nodes = get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY))) access_deny(); $query = 'select distinct actionid from actions'. ' where '.DBin_node('actionid',$nodes). ' and actionid in ('.implode(',',$_REQUEST['g_actionid']).') '; $result=DBselect($query); $actionids = array(); DBstart(); while($row=DBfetch($result)){ $res = update_action_status($row['actionid'],0); if($res) $actionids[] = $row['actionid']; } $result = DBend(); if($result && isset($res)){ show_messages($result, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ACTION, ' Actions ['.implode(',',$actionids).'] enabled'); } } else if(isset($_REQUEST['group_disable'])&&isset($_REQUEST['g_actionid'])){ if(!count($nodes = get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY))) access_deny(); $query = 'select distinct actionid from actions'. ' where '.DBin_node('actionid',$nodes). ' and actionid in ('.implode(',',$_REQUEST['g_actionid']).') '; $result=DBselect($query); $actionids = array(); Dbstart(); while($row=DBfetch($result)){ $res = update_action_status($row['actionid'],1); if($res) $actionids[] = $row['actionid']; } $result = DBend(); if($result && isset($res)){ show_messages($result, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ACTION, ' Actions ['.implode(',',$actionids).'] disabled'); } } else if(isset($_REQUEST['group_delete'])&&isset($_REQUEST['g_actionid'])){ if(!count($nodes = get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY))) access_deny(); $result=DBselect('select distinct actionid from actions'. ' where '.DBin_node('actionid',$nodes). ' and actionid in ('.implode(',',$_REQUEST['g_actionid']).') ' ); $actionids = array(); DBstart(); while($row=DBfetch($result)){ $del_res = delete_action($row['actionid']); if($del_res) $actionids[] = $row['actionid']; } $result = DBend(); if($result && isset($del_res)){ show_messages(TRUE, S_ACTIONS_DELETED, S_CANNOT_DELETE_ACTIONS); add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_ACTION, ' Actions ['.implode(',',$actionids).'] deleted'); } } ?> SetMethod('get'); $form->AddVar('eventsource', $_REQUEST['eventsource']); $form->AddItem(new CButton('form',S_CREATE_ACTION)); show_table_header(S_CONFIGURATION_OF_ACTIONS_BIG, $form); if(isset($_REQUEST['form'])){ /* form */ // insert_action_form(); //* NEW Form $frmAction = new CForm('actionconf.php','post'); $frmAction->SetName(S_ACTION); $frmAction->AddVar('form',get_request('form',1)); $from_rfr = get_request('form_refresh',0); $frmAction->AddVar('form_refresh',$from_rfr+1); $action = null; if(isset($_REQUEST['actionid'])){ $action = get_action_by_actionid($_REQUEST['actionid']); $frmAction->AddVar('actionid',$_REQUEST['actionid']); } $left_tab = new CTable(); $left_tab->SetCellPadding(3); $left_tab->SetCellSpacing(3); $left_tab->AddOption('border',0); $left_tab->AddRow(create_hat( S_ACTION, get_act_action_form($action),//null, null, 'hat_action', get_profile('web.actionconf.hats.hat_action.state',1) )); $left_tab->AddRow(create_hat( S_ACTION_CONDITIONS, get_act_condition_form($action),//null, null, 'hat_conditions', get_profile('web.actionconf.hats.hat_conditions.state',1) )); if(isset($_REQUEST['new_condition'])){ $left_tab->AddRow(create_hat( S_NEW_CONDITION, get_act_new_cond_form($action),//null, null, 'hat_new_cond', get_profile('web.actionconf.hats.hat_new_cond.state',1) )); } $right_tab = new CTable(); $right_tab->SetCellPadding(3); $right_tab->SetCellSpacing(3); $right_tab->AddOption('border',0); $right_tab->AddRow(create_hat( S_ACTION_OPERATIONS, get_act_operations_form($action),//null, null, 'hat_operations', get_profile('web.actionconf.hats.hat_operations.state',1) )); if(isset($_REQUEST['new_operation'])){ $right_tab->AddRow(create_hat( S_EDIT_OPERATION, get_act_new_oper_form($action),//null, null, 'hat_new_oper', get_profile('web.actionconf.hats.hat_new_oper.state',1) )); } if(isset($_REQUEST['new_opcondition'])){ $right_tab->AddRow(create_hat( S_NEW.SPACE.S_OPERATION_CONDITION, get_oper_new_cond_form($action),//null, null, 'hat_new_oper_cond', get_profile('web.actionconf.hats.hat_new_oper_cond.state',1) )); } $td_l = new CCol($left_tab); $td_l->AddOption('valign','top'); $td_r = new CCol($right_tab); $td_r->AddOption('valign','top'); $outer_table = new CTable(); $outer_table->AddOption('border',0); $outer_table->SetCellPadding(1); $outer_table->SetCellSpacing(1); $outer_table->AddRow(array($td_l,$td_r)); $frmAction->Additem($outer_table); show_messages(); $frmAction->Show(); //*/ } 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_accessible($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['.$action_data['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(); } ?>