function get_condition_desc($conditiontype, $operator, $value) { return condition_type2str($conditiontype) . ' ' . condition_operator2str($operator) . ' ' . condition_value2str($conditiontype, $value); }
$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) { $conditionTypeComboBox->addItem($opcondition, condition_type2str($opcondition)); } array_push($rowCondition, $conditionTypeComboBox); $operationConditionComboBox = new CComboBox('new_opcondition[operator]'); foreach (get_operators_by_conditiontype($new_opcondition['conditiontype']) as $operationCondition) { $operationConditionComboBox->addItem($operationCondition, condition_operator2str($operationCondition)); } array_push($rowCondition, $operationConditionComboBox); if ($new_opcondition['conditiontype'] == CONDITION_TYPE_EVENT_ACKNOWLEDGED) { $operationConditionValueComboBox = new CComboBox('new_opcondition[value]', $new_opcondition['value']); $operationConditionValueComboBox->addItem(0, _('Not Ack')); $operationConditionValueComboBox->addItem(1, _('Ack')); $rowCondition[] = $operationConditionValueComboBox; } $newOperationConditionTable->addRow($rowCondition); $newOperationConditionFooter = array(new CSubmit('add_opcondition', _('Add'), null, 'link_menu'), SPACE . SPACE, new CSubmit('cancel_new_opcondition', _('Cancel'), null, 'link_menu'));
/** * Returns the HTML representation of an action condition. * * @param $conditiontype * @param $operator * @param $value * * @return array */ function get_condition_desc($conditiontype, $operator, $value) { return array(condition_type2str($conditiontype), SPACE, condition_operator2str($operator), SPACE, italic(CHtml::encode(condition_value2str($conditiontype, $value)))); }
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; }
/** * Returns the HTML representation of an action condition and action operation condition. * * @param string $conditionType * @param string $operator * @param string $value * * @return array */ function getConditionDescription($conditionType, $operator, $value) { return [condition_type2str($conditionType), SPACE, condition_operator2str($operator), SPACE, italic(CHtml::encode($value))]; }
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]; } $rowCondition = array(); $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); $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); 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; }
$allowedOpConditions = get_opconditions_by_eventsource($this->data['eventsource']); $new_opcondition = getRequest('new_opcondition', []); if (!is_array($new_opcondition)) { $new_opcondition = []; } 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]; } $condition_types = []; foreach ($allowedOpConditions as $opcondition) { $condition_types[$opcondition] = condition_type2str($opcondition); } $operators = []; foreach (get_operators_by_conditiontype($new_opcondition['conditiontype']) as $operation_condition) { $operators[$operation_condition] = condition_operator2str($operation_condition); } $rowCondition = [new CComboBox('new_opcondition[conditiontype]', $new_opcondition['conditiontype'], 'submit()', $condition_types), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), new CComboBox('new_opcondition[operator]', null, null, $operators)]; if ($new_opcondition['conditiontype'] == CONDITION_TYPE_EVENT_ACKNOWLEDGED) { $rowCondition[] = (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN); $rowCondition[] = new CComboBox('new_opcondition[value]', $new_opcondition['value'], null, [0 => _('Not Ack'), 1 => _('Ack')]); } $newOperationConditionTable->addRow(new CCol($rowCondition)); $new_operation_formlist->addRow(_('Operation condition'), (new CDiv([$newOperationConditionTable, new CHorList([(new CSubmit('add_opcondition', _('Add')))->addClass(ZBX_STYLE_BTN_LINK), (new CSubmit('cancel_new_opcondition', _('Cancel')))->addClass(ZBX_STYLE_BTN_LINK)])]))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;')); } $operationFormList->addRow(_('Operation details'), (new CDiv([$new_operation_vars, $new_operation_formlist, new CHorList([(new CSubmit('add_operation', isset($this->data['new_operation']['id']) ? _('Update') : _('Add')))->addClass(ZBX_STYLE_BTN_LINK), (new CSubmit('cancel_new_operation', _('Cancel')))->addClass(ZBX_STYLE_BTN_LINK)])]))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); }