function get_oper_new_cond_form($action = null) { $tblCond = new CTable('', 'nowrap'); if (isset($_REQUEST['actionid']) && empty($action)) { $action = get_action_by_actionid($_REQUEST['actionid']); } if (isset($_REQUEST['actionid']) && !isset($_REQUEST['form_refresh'])) { $eventsource = $action['eventsource']; $evaltype = $action['evaltype']; } else { $evaltype = get_request('evaltype'); $eventsource = get_request('eventsource'); } $allowed_conditions = get_opconditions_by_eventsource($eventsource); /* init new_condition variable */ $new_opcondition = get_request('new_opcondition', array()); if (!is_array($new_opcondition)) { $new_opcondition = array(); } if (!isset($new_opcondition['conditiontype'])) { $new_opcondition['conditiontype'] = CONDITION_TYPE_EVENT_ACKNOWLEDGED; } if (!isset($new_opcondition['operator'])) { $new_opcondition['operator'] = CONDITION_OPERATOR_LIKE; } if (!isset($new_opcondition['value'])) { $new_opcondition['value'] = 0; } if (!str_in_array($new_opcondition['conditiontype'], $allowed_conditions)) { $new_opcondition['conditiontype'] = $allowed_conditions[0]; } // NEW CONDITION $rowCondition = array(); // add condition type $cmbCondType = new CComboBox('new_opcondition[conditiontype]', $new_opcondition['conditiontype'], 'submit()'); foreach ($allowed_conditions as $cond) { $cmbCondType->addItem($cond, condition_type2str($cond)); } array_push($rowCondition, $cmbCondType); // add condition operation $cmbCondOp = new CComboBox('new_opcondition[operator]'); foreach (get_operators_by_conditiontype($new_opcondition['conditiontype']) as $op) { $cmbCondOp->addItem($op, condition_operator2str($op)); } array_push($rowCondition, $cmbCondOp); // add condition value switch ($new_opcondition['conditiontype']) { case CONDITION_TYPE_EVENT_ACKNOWLEDGED: $cmbCondVal = new CComboBox('new_opcondition[value]', $new_opcondition['value']); $cmbCondVal->addItem(0, S_NOT_ACK); $cmbCondVal->addItem(1, S_ACK); $rowCondition[] = $cmbCondVal; break; } $tblCond->addRow($rowCondition); $tblConditions = new CTableInfo(); $tblConditions->addRow($tblCond); $td = new CCol(array(new CButton('add_opcondition', S_ADD), new CButton('cancel_new_opcondition', S_CANCEL))); $td->addOption('colspan', '3'); $td->addOption('style', 'text-align: right;'); $tblConditions->SetFooter($td); unset($grouped_conditions, $cond_el, $cond_buttons); // end of NEW CONDITION return $tblConditions; }
$calcTypeComboBox->addItem(ACTION_EVAL_TYPE_AND_OR, _('AND / OR')); $calcTypeComboBox->addItem(ACTION_EVAL_TYPE_AND, _('AND')); $calcTypeComboBox->addItem(ACTION_EVAL_TYPE_OR, _('OR')); $newOperationsTable->addRow(array(_('Type of calculation'), array($calcTypeComboBox, new CTextBox('preview', $grouped_opconditions, ZBX_TEXTBOX_STANDARD_SIZE, 'yes')))); } else { $operationConditionsTable->addItem(new CVar('new_operation[evaltype]', ACTION_EVAL_TYPE_AND_OR)); } if (!isset($_REQUEST['new_opcondition'])) { $operationConditionsTable->addRow(new CCol(new CSubmit('new_opcondition', _('New'), null, 'link_menu'))); } $newOperationsTable->addRow(array(_('Conditions'), new CDiv($operationConditionsTable, 'objectgroup inlineblock border_dotted ui-corner-all')), 'indent_top'); } // append new operation condition to form list if (isset($_REQUEST['new_opcondition'])) { $newOperationConditionTable = new CTable(null, 'formElementTable'); $allowedOpConditions = get_opconditions_by_eventsource($this->data['eventsource']); $new_opcondition = get_request('new_opcondition', array()); if (!is_array($new_opcondition)) { $new_opcondition = array(); } if (empty($new_opcondition)) { $new_opcondition['conditiontype'] = CONDITION_TYPE_EVENT_ACKNOWLEDGED; $new_opcondition['operator'] = CONDITION_OPERATOR_LIKE; $new_opcondition['value'] = 0; } if (!str_in_array($new_opcondition['conditiontype'], $allowedOpConditions)) { $new_opcondition['conditiontype'] = $allowedOpConditions[0]; } $rowCondition = array(); $conditionTypeComboBox = new CComboBox('new_opcondition[conditiontype]', $new_opcondition['conditiontype'], 'submit()'); foreach ($allowedOpConditions as $opcondition) {
$tblOper->addRow($tblNewOperation); $footer = array(new CButton('add_operation', $update_mode ? S_SAVE : S_ADD), new CButton('cancel_new_operation', S_CANCEL)); $right_tab->addRow(new CFormElement(S_EDIT_OPERATION, $tblOper, $footer)); } // }}} NEW OPERATION FORM // NEW OPERATION CONDITION {{{ if (isset($_REQUEST['new_opcondition'])) { $tblCond = new CTable(null, 'formElementTable'); if (isset($_REQUEST['actionid']) && !isset($_REQUEST['form_refresh'])) { $eventsource = $action['eventsource']; $evaltype = $action['evaltype']; } else { $evaltype = get_request('evaltype'); $eventsource = get_request('eventsource'); } $allowed_conditions = get_opconditions_by_eventsource($eventsource); $new_opcondition = get_request('new_opcondition', array()); if (!is_array($new_opcondition)) { $new_opcondition = array(); } if (!isset($new_opcondition['conditiontype'])) { $new_opcondition['conditiontype'] = CONDITION_TYPE_EVENT_ACKNOWLEDGED; } if (!isset($new_opcondition['operator'])) { $new_opcondition['operator'] = CONDITION_OPERATOR_LIKE; } if (!isset($new_opcondition['value'])) { $new_opcondition['value'] = 0; } if (!str_in_array($new_opcondition['conditiontype'], $allowed_conditions)) { $new_opcondition['conditiontype'] = $allowed_conditions[0];