// append host in maintenance checkbox to form list $maintenanceCheckBox = new CCheckBox('maintenance', $this->data['maintenance'], null, '1'); if (!$this->data['isFilterEnable']) { $maintenanceCheckBox->setAttribute('disabled', 'disabled'); } $dashconfFormList->addRow(_('Hosts'), array($maintenanceCheckBox, _('Show hosts in maintenance'))); // append trigger severities to form list $severities = array(); foreach ($this->data['severities'] as $severity) { $serverityCheckBox = new CCheckBox('trgSeverity[' . $severity . ']', isset($this->data['severity'][$severity]), '', 1); $serverityCheckBox->setEnabled($this->data['isFilterEnable']); $severities[] = array($serverityCheckBox, getSeverityCaption($severity)); $severities[] = BR(); } array_pop($severities); $dashconfFormList->addRow(_('Triggers with severity'), $severities); // append problem display to form list $extAckComboBox = new CComboBox('extAck', $this->data['extAck']); $extAckComboBox->addItems(array(EXTACK_OPTION_ALL => _('All'), EXTACK_OPTION_BOTH => _('Separated'), EXTACK_OPTION_UNACK => _('Unacknowledged only'))); $extAckComboBox->setEnabled($this->data['isFilterEnable'] && $this->data['config']['event_ack_enable']); if (!$this->data['config']['event_ack_enable']) { $extAckComboBox->setAttribute('title', _('Event acknowledging disabled')); } $dashconfFormList->addRow(_('Problem display'), $extAckComboBox); // create tab $dashconfTab = new CTabView(); $dashconfTab->addTab('dashconfTab', _('Filter'), $dashconfFormList); $dashconfForm->addItem($dashconfTab); $dashconfForm->addItem(makeFormFooter(new CSubmit('update', _('Update')), new CButtonCancel())); $dashconfWidget->addItem($dashconfForm); return $dashconfWidget;
$openState = CProfile::get('web.latest.toggle_other', null, $host['hostid']); $toggle = new CDiv(null, 'app-list-toggle icon-plus-9x9'); if ($openState) { $toggle->addClass('icon-minus-9x9'); } $toggle->setAttribute('data-app-id', '0_' . $host['hostid']); $toggle->setAttribute('data-open-state', $openState); $hostName = null; if (!$singleHostSelected) { $hostName = new CSpan($host['name'], 'link_menu menu-host' . ($host['status'] == HOST_STATUS_NOT_MONITORED ? ' not-monitored' : '')); $hostName->setMenuPopup(CMenuPopupHelper::getHost($host, $hostScripts[$host['hostid']])); } // add toggle row $table->addRow(array($toggle, '', $hostName, new CCol(array(bold('- ' . 'other' . ' -'), ' (' . _n('%1$s Item', '%1$s Items', $dbHost['item_cnt']) . ')'), null, $filter['showDetails'] ? 10 : 5)), 'odd_row'); // add toggle sub rows foreach ($appRows as $row) { $row->setAttribute('parent_app_id', '0_' . $host['hostid']); $row->addClass('odd_row'); if (!$openState) { $row->addClass('hidden'); } $table->addRow($row); } } $goBox = new CComboBox('graphtype', GRAPH_TYPE_STACKED, null, array(GRAPH_TYPE_STACKED => _('Display stacked graph'), GRAPH_TYPE_NORMAL => _('Display graph'))); $goBox->setAttribute('id', 'action'); $goButton = new CSubmit('goButton', _('Go') . ' (0)'); $form->addItem(array($table, get_table_header(array($goBox, $goButton)))); $latestWidget->addItem($form); $latestWidget->show(); require_once dirname(__FILE__) . '/include/page_footer.php';
} $_REQUEST['alias'] = get_request('alias', CProfile::get('web.auditlogs.filter.alias', '')); $_REQUEST['action'] = get_request('action', CProfile::get('web.auditlogs.filter.action', -1)); $_REQUEST['resourcetype'] = get_request('resourcetype', CProfile::get('web.auditlogs.filter.resourcetype', -1)); if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) { CProfile::update('web.auditlogs.filter.alias', $_REQUEST['alias'], PROFILE_TYPE_STR); CProfile::update('web.auditlogs.filter.action', $_REQUEST['action'], PROFILE_TYPE_INT); CProfile::update('web.auditlogs.filter.resourcetype', $_REQUEST['resourcetype'], PROFILE_TYPE_INT); } // -------------- $audit_wdgt = new CWidget(); // HEADER $frmForm = new CForm(); $frmForm->setMethod('get'); $cmbConf = new CComboBox('config', 'auditlogs.php'); $cmbConf->setAttribute('onchange', 'javascript: redirect(this.options[this.selectedIndex].value);'); $cmbConf->addItem('auditlogs.php', S_LOGS); $cmbConf->addItem('auditacts.php', S_ACTIONS); $frmForm->addItem($cmbConf); $audit_wdgt->addPageHeader(S_AUDIT_LOGS_BIG, $frmForm); $numrows = new CDiv(); $numrows->setAttribute('name', 'numrows'); $audit_wdgt->addHeader(S_LOGS_BIG); $audit_wdgt->addHeader($numrows); //-------- /************************* FILTER **************************/ /***********************************************************/ $filterForm = new CFormTable(); $filterForm->setAttribute('name', 'zbx_filter'); $filterForm->setAttribute('id', 'zbx_filter'); $row = new CRow(array(new CCol(S_USER, 'form_row_l'), new CCol(array(new CTextBox('alias', $_REQUEST['alias'], 32), new CButton('btn1', S_SELECT, "return PopUp('popup.php?" . "dstfrm=" . $filterForm->GetName() . "&dstfld1=alias&srctbl=users&srcfld1=alias&real_hosts=1');", 'T')), 'form_row_r')));
if (EVENTS_OPTION_NOEVENT) { $ev_select->addItem(EVENTS_OPTION_NOEVENT, S_HIDE_ALL); } if (EVENTS_OPTION_ALL) { $ev_select->addItem(EVENTS_OPTION_ALL, S_SHOW_ALL . SPACE . '(' . $config['event_expire'] . SPACE . ($config['event_expire'] > 1 ? S_DAYS : S_DAY) . ')'); } if (EVENTS_OPTION_NOT_ACK && $config['event_ack_enable']) { $ev_select->addItem(EVENTS_OPTION_NOT_ACK, S_SHOW_UNACKNOWLEDGED . SPACE . '(' . $config['event_expire'] . SPACE . ($config['event_expire'] > 1 ? S_DAYS : S_DAY) . ')'); } if (EVENTS_OPTION_ONLYTRUE_NOTACK && $config['event_ack_enable']) { $ev_select->addItem(EVENTS_OPTION_ONLYTRUE_NOTACK, S_SHOW_PROBLEM_UNACKNOWLEDGED . SPACE . '(' . $config['event_expire'] . SPACE . ($config['event_expire'] > 1 ? S_DAYS : S_DAY) . ')'); } //------- JP ------- if ($show_triggers == TRIGGERS_OPTION_NOFALSEFORB) { $ev_select->addItem(EVENTS_OPTION_NOFALSEFORB, ' - ', 'yes'); $ev_select->setAttribute('disabled', 'disabled'); $ev_status = new CComboBox('show_events_status', $show_events_status, 'javascript: submit();'); $ev_status->addItem(EVENTS_NOFALSEFORB_STATUS_ALL, S_SHOW_ALL); $ev_status->addItem(EVENTS_NOFALSEFORB_STATUS_FALSE, S_SHOW_ONLY_FALSE); $ev_status->addItem(EVENTS_NOFALSEFORB_STATUS_TRUE, S_SHOW_ONLY_TRUE); } //--- $filterForm->addRow(S_TRIGGERS, $tr_select); // JP if ($show_triggers == TRIGGERS_OPTION_NOFALSEFORB) { $filterForm->addRow(S_STATUS, $ev_status); $filterForm->addVar('show_events', $show_events); } else { $filterForm->addRow(S_EVENTS, $ev_select); $filterForm->addVar('show_events_status', $show_events_status); }
$widget = (new CWidget())->setTitle(_('Dashboard')); // create form $form = (new CForm())->setName('dashconf')->setId('dashform')->addVar('filterEnable', $this->data['isFilterEnable']); // create form list $form_list = new CFormList('dashconfFormList'); // append filter status to form list if ($this->data['isFilterEnable']) { $filterStatusSpan = (new CSpan(_('Enabled')))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(ZBX_STYLE_GREEN)->onClick("create_var('" . $form->getName() . "', 'filterEnable', 0, true);")->setAttribute('tabindex', 0); } else { $filterStatusSpan = (new CSpan(_('Disabled')))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(ZBX_STYLE_RED)->onClick("\$('dashform').enable(); create_var('" . $form->getName() . "', 'filterEnable', 1, true);")->setAttribute('tabindex', 0); } $form_list->addRow(_('Dashboard filter'), $filterStatusSpan); // append host groups to form list $hostGroupsComboBox = new CComboBox('grpswitch', $this->data['grpswitch'], 'submit()', [0 => _('All'), 1 => _('Selected')]); if (!$this->data['isFilterEnable']) { $hostGroupsComboBox->setAttribute('disabled', 'disabled'); } $form_list->addRow(_('Host groups'), $hostGroupsComboBox); if ($this->data['grpswitch']) { $form_list->addRow(_('Show selected groups'), (new CMultiSelect(['name' => 'groupids[]', 'objectName' => 'hostGroup', 'data' => $this->data['groups'], 'disabled' => !$this->data['isFilterEnable'], 'popup' => ['parameters' => 'srctbl=host_groups&dstfrm=' . $form->getName() . '&dstfld1=groupids_' . '&srcfld1=groupid&multiselect=1']]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH)); $form_list->addRow(_('Hide selected groups'), (new CMultiSelect(['name' => 'hidegroupids[]', 'objectName' => 'hostGroup', 'data' => $this->data['hideGroups'], 'disabled' => !$this->data['isFilterEnable'], 'popup' => ['parameters' => 'srctbl=host_groups&dstfrm=' . $form->getName() . '&dstfld1=hidegroupids_' . '&srcfld1=groupid&multiselect=1']]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH)); } // append host in maintenance checkbox to form list $maintenanceCheckBox = (new CCheckBox('maintenance'))->setChecked($this->data['maintenance'] == 1); if (!$this->data['isFilterEnable']) { $maintenanceCheckBox->setAttribute('disabled', 'disabled'); } $form_list->addRow(_('Hosts'), new CLabel([$maintenanceCheckBox, _('Show hosts in maintenance')], 'maintenance')); // append trigger severities to form list $severities = []; foreach ($this->data['severities'] as $severity) {
function getItemFilterForm(&$items) { $filter_groupId = $_REQUEST['filter_groupid']; $filter_hostId = $_REQUEST['filter_hostid']; $filter_application = $_REQUEST['filter_application']; $filter_name = $_REQUEST['filter_name']; $filter_type = $_REQUEST['filter_type']; $filter_key = $_REQUEST['filter_key']; $filter_snmp_community = $_REQUEST['filter_snmp_community']; $filter_snmpv3_securityname = $_REQUEST['filter_snmpv3_securityname']; $filter_snmp_oid = $_REQUEST['filter_snmp_oid']; $filter_port = $_REQUEST['filter_port']; $filter_value_type = $_REQUEST['filter_value_type']; $filter_data_type = $_REQUEST['filter_data_type']; $filter_delay = $_REQUEST['filter_delay']; $filter_history = $_REQUEST['filter_history']; $filter_trends = $_REQUEST['filter_trends']; $filter_status = $_REQUEST['filter_status']; $filter_state = $_REQUEST['filter_state']; $filter_templated_items = $_REQUEST['filter_templated_items']; $filter_with_triggers = $_REQUEST['filter_with_triggers']; $subfilter_hosts = $_REQUEST['subfilter_hosts']; $subfilter_apps = $_REQUEST['subfilter_apps']; $subfilter_types = $_REQUEST['subfilter_types']; $subfilter_value_types = $_REQUEST['subfilter_value_types']; $subfilter_status = $_REQUEST['subfilter_status']; $subfilter_state = $_REQUEST['subfilter_state']; $subfilter_templated_items = $_REQUEST['subfilter_templated_items']; $subfilter_with_triggers = $_REQUEST['subfilter_with_triggers']; $subfilter_history = $_REQUEST['subfilter_history']; $subfilter_trends = $_REQUEST['subfilter_trends']; $subfilter_interval = $_REQUEST['subfilter_interval']; $form = new CForm('get'); $form->setAttribute('name', 'zbx_filter'); $form->setAttribute('id', 'zbx_filter'); $form->addVar('subfilter_hosts', $subfilter_hosts); $form->addVar('subfilter_apps', $subfilter_apps); $form->addVar('subfilter_types', $subfilter_types); $form->addVar('subfilter_value_types', $subfilter_value_types); $form->addVar('subfilter_status', $subfilter_status); $form->addVar('subfilter_state', $subfilter_state); $form->addVar('subfilter_templated_items', $subfilter_templated_items); $form->addVar('subfilter_with_triggers', $subfilter_with_triggers); $form->addVar('subfilter_history', $subfilter_history); $form->addVar('subfilter_trends', $subfilter_trends); $form->addVar('subfilter_interval', $subfilter_interval); // type select $fTypeVisibility = array(); $cmbType = new CComboBox('filter_type', $filter_type); $cmbType->setAttribute('id', 'filter_type'); $cmbType->addItem(-1, _('all')); foreach (array('filter_delay_label', 'filter_delay') as $vItem) { zbx_subarray_push($fTypeVisibility, -1, $vItem); } $itemTypes = item_type2str(); unset($itemTypes[ITEM_TYPE_HTTPTEST]); // httptest items are only for internal zabbix logic $cmbType->addItems($itemTypes); foreach ($itemTypes as $typeNum => $typeLabel) { if ($typeNum != ITEM_TYPE_TRAPPER) { zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay_label'); zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay'); } switch ($typeNum) { case ITEM_TYPE_SNMPV1: case ITEM_TYPE_SNMPV2C: $snmp_types = array('filter_snmp_community_label', 'filter_snmp_community', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_port_label', 'filter_port'); foreach ($snmp_types as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; case ITEM_TYPE_SNMPV3: foreach (array('filter_snmpv3_securityname_label', 'filter_snmpv3_securityname', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_port_label', 'filter_port') as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; } } zbx_add_post_js("var filterTypeSwitcher = new CViewSwitcher('filter_type', 'change', " . zbx_jsvalue($fTypeVisibility, true) . ');'); // type of information select $fVTypeVisibility = array(); $cmbValType = new CComboBox('filter_value_type', $filter_value_type); $cmbValType->addItem(-1, _('all')); $cmbValType->addItem(ITEM_VALUE_TYPE_UINT64, _('Numeric (unsigned)')); $cmbValType->addItem(ITEM_VALUE_TYPE_FLOAT, _('Numeric (float)')); $cmbValType->addItem(ITEM_VALUE_TYPE_STR, _('Character')); $cmbValType->addItem(ITEM_VALUE_TYPE_LOG, _('Log')); $cmbValType->addItem(ITEM_VALUE_TYPE_TEXT, _('Text')); foreach (array('filter_data_type_label', 'filter_data_type') as $vItem) { zbx_subarray_push($fVTypeVisibility, ITEM_VALUE_TYPE_UINT64, $vItem); } zbx_add_post_js("var filterValueTypeSwitcher = new CViewSwitcher('filter_value_type', 'change', " . zbx_jsvalue($fVTypeVisibility, true) . ');'); // status select $cmbStatus = new CComboBox('filter_status', $filter_status); $cmbStatus->addItem(-1, _('all')); foreach (array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED) as $status) { $cmbStatus->addItem($status, item_status2str($status)); } // state select $cmbState = new CComboBox('filter_state', $filter_state); $cmbState->addItem(-1, _('all')); foreach (array(ITEM_STATE_NORMAL, ITEM_STATE_NOTSUPPORTED) as $state) { $cmbState->addItem($state, itemState($state)); } // update interval $updateIntervalLabel = new CSpan(array(bold(_('Update interval')), SPACE . _('(in sec)') . NAME_DELIMITER)); $updateIntervalLabel->setAttribute('id', 'filter_delay_label'); $updateIntervalInput = new CNumericBox('filter_delay', $filter_delay, 5, false, true); $updateIntervalInput->setEnabled('no'); // data type $dataTypeLabel = new CSpan(bold(_('Data type') . NAME_DELIMITER)); $dataTypeLabel->setAttribute('id', 'filter_data_type_label'); $dataTypeInput = new CComboBox('filter_data_type', $filter_data_type); $dataTypeInput->addItem(-1, _('all')); $dataTypeInput->addItems(item_data_type2str()); $dataTypeInput->setEnabled('no'); // filter table $table = new CTable('', 'filter'); $table->setCellPadding(0); $table->setCellSpacing(0); // SNMP community $snmpCommunityLabel = new CSpan(array(bold(_('SNMP community')), SPACE . _('like') . NAME_DELIMITER)); $snmpCommunityLabel->setAttribute('id', 'filter_snmp_community_label'); $snmpCommunityField = new CTextBox('filter_snmp_community', $filter_snmp_community, ZBX_TEXTBOX_FILTER_SIZE); $snmpCommunityField->setEnabled('no'); // SNMPv3 security name $snmpSecurityLabel = new CSpan(array(bold(_('Security name')), SPACE . _('like') . NAME_DELIMITER)); $snmpSecurityLabel->setAttribute('id', 'filter_snmpv3_securityname_label'); $snmpSecurityField = new CTextBox('filter_snmpv3_securityname', $filter_snmpv3_securityname, ZBX_TEXTBOX_FILTER_SIZE); $snmpSecurityField->setEnabled('no'); // SNMP OID $snmpOidLabel = new CSpan(array(bold(_('SNMP OID')), SPACE . _('like') . NAME_DELIMITER)); $snmpOidLabel->setAttribute('id', 'filter_snmp_oid_label'); $snmpOidField = new CTextBox('filter_snmp_oid', $filter_snmp_oid, ZBX_TEXTBOX_FILTER_SIZE); $snmpOidField->setEnabled('no'); // port $portLabel = new CSpan(array(bold(_('Port')), SPACE . _('like') . NAME_DELIMITER)); $portLabel->setAttribute('id', 'filter_port_label'); $portField = new CNumericBox('filter_port', $filter_port, 5, false, true); $portField->setEnabled('no'); // row 1 $groupFilter = null; if (!empty($filter_groupId)) { $getHostInfo = API::HostGroup()->get(array('groupids' => $filter_groupId, 'output' => array('name'))); $getHostInfo = reset($getHostInfo); if (!empty($getHostInfo)) { $groupFilter[] = array('id' => $getHostInfo['groupid'], 'name' => $getHostInfo['name']); } } $table->addRow(array(new CCol(bold(_('Host group') . NAME_DELIMITER), 'label col1'), new CCol(array(new CMultiSelect(array('name' => 'filter_groupid', 'selectedLimit' => 1, 'objectName' => 'hostGroup', 'objectOptions' => array('editable' => true), 'data' => $groupFilter, 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $form->getName() . '&dstfld1=filter_groupid' . '&srcfld1=groupid&writeonly=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button')))), 'col1'), new CCol(bold(_('Type') . NAME_DELIMITER), 'label col2'), new CCol($cmbType, 'col2'), new CCol(bold(_('Type of information') . NAME_DELIMITER), 'label col3'), new CCol($cmbValType, 'col3'), new CCol(bold(_('State') . NAME_DELIMITER), 'label'), new CCol($cmbState, 'col4')), 'item-list-row'); // row 2 $hostFilterData = null; if (!empty($filter_hostId)) { $getHostInfo = API::Host()->get(array('hostids' => $filter_hostId, 'templated_hosts' => true, 'output' => array('name'))); $getHostInfo = reset($getHostInfo); if (!empty($getHostInfo)) { $hostFilterData[] = array('id' => $getHostInfo['hostid'], 'name' => $getHostInfo['name']); } } $table->addRow(array(new CCol(bold(_('Host') . NAME_DELIMITER), 'label'), new CCol(array(new CMultiSelect(array('name' => 'filter_hostid', 'selectedLimit' => 1, 'objectName' => 'hosts', 'objectOptions' => array('editable' => true, 'templated_hosts' => true), 'data' => $hostFilterData, 'popup' => array('parameters' => 'srctbl=host_templates&dstfrm=' . $form->getName() . '&dstfld1=filter_hostid' . '&srcfld1=hostid&writeonly=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button')))), 'col1'), new CCol($updateIntervalLabel, 'label'), new CCol($updateIntervalInput), new CCol($dataTypeLabel, 'label'), new CCol($dataTypeInput), new CCol(bold(_('Status') . NAME_DELIMITER), 'label col4'), new CCol($cmbStatus, 'col4')), 'item-list-row'); // row 3 $table->addRow(array(new CCol(bold(_('Application') . NAME_DELIMITER), 'label'), new CCol(array(new CTextBox('filter_application', $filter_application, ZBX_TEXTBOX_FILTER_SIZE), new CButton('btn_app', _('Select'), 'return PopUp("popup.php?srctbl=applications&srcfld1=name' . '&dstfrm=' . $form->getName() . '&dstfld1=filter_application' . '&with_applications=1' . '" + (jQuery("input[name=\'filter_hostid\']").length > 0 ? "&hostid="+jQuery("input[name=\'filter_hostid\']").val() : "")' . ', 550, 450, "application");', 'filter-select-button')), 'col1'), new CCol(array($snmpCommunityLabel, $snmpSecurityLabel), 'label'), new CCol(array($snmpCommunityField, $snmpSecurityField)), new CCol(array(bold(_('History')), SPACE . _('(in days)') . NAME_DELIMITER), 'label'), new CCol(new CNumericBox('filter_history', $filter_history, 8, false, true)), new CCol(bold(_('Triggers') . NAME_DELIMITER), 'label'), new CCol(new CComboBox('filter_with_triggers', $filter_with_triggers, null, array(-1 => _('all'), 1 => _('With triggers'), 0 => _('Without triggers'))))), 'item-list-row'); // row 4 $table->addRow(array(new CCol(array(bold(_('Name')), SPACE . _('like') . NAME_DELIMITER), 'label'), new CCol(new CTextBox('filter_name', $filter_name, ZBX_TEXTBOX_FILTER_SIZE), 'col1'), new CCol($snmpOidLabel, 'label'), new CCol($snmpOidField), new CCol(array(bold(_('Trends')), SPACE . _('(in days)') . NAME_DELIMITER), 'label'), new CCol(new CNumericBox('filter_trends', $filter_trends, 8, false, true)), new CCol(bold(_('Template') . NAME_DELIMITER), 'label'), new CCol(new CComboBox('filter_templated_items', $filter_templated_items, null, array(-1 => _('all'), 1 => _('Templated items'), 0 => _('Not Templated items'))))), 'item-list-row'); // row 5 $table->addRow(array(new CCol(array(bold(_('Key')), SPACE . _('like') . NAME_DELIMITER), 'label'), new CCol(new CTextBox('filter_key', $filter_key, ZBX_TEXTBOX_FILTER_SIZE), 'col1'), new CCol($portLabel, 'label'), new CCol($portField), new CCol(null, 'label'), new CCol(), new CCol(null, 'label'), new CCol()), 'item-list-row'); $filter = new CSubmit('filter_set', _('Filter'), 'chkbxRange.clearSelectedOnFilterChange();'); $filter->useJQueryStyle('main'); $reset = new CSubmit('filter_rst', _('Reset'), 'chkbxRange.clearSelectedOnFilterChange();'); $reset->useJQueryStyle(); $div_buttons = new CDiv(array($filter, SPACE, $reset)); $div_buttons->setAttribute('style', 'padding: 4px 0px;'); $footer = new CCol($div_buttons, 'controls', 8); $table->addRow($footer); $form->addItem($table); // subfilters $table_subfilter = new CTable(null, 'filter sub-filter'); // array contains subfilters and number of items in each $item_params = array('hosts' => array(), 'applications' => array(), 'types' => array(), 'value_types' => array(), 'status' => array(), 'state' => array(), 'templated_items' => array(), 'with_triggers' => array(), 'history' => array(), 'trends' => array(), 'interval' => array()); // generate array with values for subfilters of selected items foreach ($items as $item) { // hosts if (zbx_empty($filter_hostId)) { $host = reset($item['hosts']); if (!isset($item_params['hosts'][$host['hostid']])) { $item_params['hosts'][$host['hostid']] = array('name' => $host['name'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_hosts') { continue; } $show_item &= $value; } if ($show_item) { $host = reset($item['hosts']); $item_params['hosts'][$host['hostid']]['count']++; } } // applications if (!empty($item['applications'])) { foreach ($item['applications'] as $application) { if (!isset($item_params['applications'][$application['name']])) { $item_params['applications'][$application['name']] = array('name' => $application['name'], 'count' => 0); } } } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_apps') { continue; } $show_item &= $value; } $sel_app = false; if ($show_item) { // if any of item applications are selected foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps)) { $sel_app = true; break; } } foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps) || !$sel_app) { $item_params['applications'][$app['name']]['count']++; } } } // types if ($filter_type == -1) { if (!isset($item_params['types'][$item['type']])) { $item_params['types'][$item['type']] = array('name' => item_type2str($item['type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['types'][$item['type']]['count']++; } } // value types if ($filter_value_type == -1) { if (!isset($item_params['value_types'][$item['value_type']])) { $item_params['value_types'][$item['value_type']] = array('name' => itemValueTypeString($item['value_type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_value_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['value_types'][$item['value_type']]['count']++; } } // status if ($filter_status == -1) { if (!isset($item_params['status'][$item['status']])) { $item_params['status'][$item['status']] = array('name' => item_status2str($item['status']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_status') { continue; } $show_item &= $value; } if ($show_item) { $item_params['status'][$item['status']]['count']++; } } // state if ($filter_state == -1) { if (!isset($item_params['state'][$item['state']])) { $item_params['state'][$item['state']] = array('name' => itemState($item['state']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_state') { continue; } $show_item &= $value; } if ($show_item) { $item_params['state'][$item['state']]['count']++; } } // template if ($filter_templated_items == -1) { if ($item['templateid'] == 0 && !isset($item_params['templated_items'][0])) { $item_params['templated_items'][0] = array('name' => _('Not Templated items'), 'count' => 0); } elseif ($item['templateid'] > 0 && !isset($item_params['templated_items'][1])) { $item_params['templated_items'][1] = array('name' => _('Templated items'), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_templated_items') { continue; } $show_item &= $value; } if ($show_item) { if ($item['templateid'] == 0) { $item_params['templated_items'][0]['count']++; } else { $item_params['templated_items'][1]['count']++; } } } // with triggers if ($filter_with_triggers == -1) { if (count($item['triggers']) == 0 && !isset($item_params['with_triggers'][0])) { $item_params['with_triggers'][0] = array('name' => _('Without triggers'), 'count' => 0); } elseif (count($item['triggers']) > 0 && !isset($item_params['with_triggers'][1])) { $item_params['with_triggers'][1] = array('name' => _('With triggers'), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_with_triggers') { continue; } $show_item &= $value; } if ($show_item) { if (count($item['triggers']) == 0) { $item_params['with_triggers'][0]['count']++; } else { $item_params['with_triggers'][1]['count']++; } } } // trends if (zbx_empty($filter_trends)) { if (!isset($item_params['trends'][$item['trends']])) { $item_params['trends'][$item['trends']] = array('name' => $item['trends'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_trends') { continue; } $show_item &= $value; } if ($show_item) { $item_params['trends'][$item['trends']]['count']++; } } // history if (zbx_empty($filter_history)) { if (!isset($item_params['history'][$item['history']])) { $item_params['history'][$item['history']] = array('name' => $item['history'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_history') { continue; } $show_item &= $value; } if ($show_item) { $item_params['history'][$item['history']]['count']++; } } // interval if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER) { if (!isset($item_params['interval'][$item['delay']])) { $item_params['interval'][$item['delay']] = array('name' => $item['delay'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_interval') { continue; } $show_item &= $value; } if ($show_item) { $item_params['interval'][$item['delay']]['count']++; } } } // output if (zbx_empty($filter_hostId) && count($item_params['hosts']) > 1) { $hosts_output = prepareSubfilterOutput($item_params['hosts'], $subfilter_hosts, 'subfilter_hosts'); $table_subfilter->addRow(array(_('Hosts'), $hosts_output)); } if (!empty($item_params['applications']) && count($item_params['applications']) > 1) { $application_output = prepareSubfilterOutput($item_params['applications'], $subfilter_apps, 'subfilter_apps'); $table_subfilter->addRow(array(_('Applications'), $application_output)); } if ($filter_type == -1 && count($item_params['types']) > 1) { $type_output = prepareSubfilterOutput($item_params['types'], $subfilter_types, 'subfilter_types'); $table_subfilter->addRow(array(_('Types'), $type_output)); } if ($filter_value_type == -1 && count($item_params['value_types']) > 1) { $value_types_output = prepareSubfilterOutput($item_params['value_types'], $subfilter_value_types, 'subfilter_value_types'); $table_subfilter->addRow(array(_('Type of information'), $value_types_output)); } if ($filter_status == -1 && count($item_params['status']) > 1) { $status_output = prepareSubfilterOutput($item_params['status'], $subfilter_status, 'subfilter_status'); $table_subfilter->addRow(array(_('Status'), $status_output)); } if ($filter_state == -1 && count($item_params['state']) > 1) { $state_output = prepareSubfilterOutput($item_params['state'], $subfilter_state, 'subfilter_state'); $table_subfilter->addRow(array(_('State'), $state_output)); } if ($filter_templated_items == -1 && count($item_params['templated_items']) > 1) { $templated_items_output = prepareSubfilterOutput($item_params['templated_items'], $subfilter_templated_items, 'subfilter_templated_items'); $table_subfilter->addRow(array(_('Template'), $templated_items_output)); } if ($filter_with_triggers == -1 && count($item_params['with_triggers']) > 1) { $with_triggers_output = prepareSubfilterOutput($item_params['with_triggers'], $subfilter_with_triggers, 'subfilter_with_triggers'); $table_subfilter->addRow(array(_('With triggers'), $with_triggers_output)); } if (zbx_empty($filter_history) && count($item_params['history']) > 1) { $history_output = prepareSubfilterOutput($item_params['history'], $subfilter_history, 'subfilter_history'); $table_subfilter->addRow(array(_('History'), $history_output)); } if (zbx_empty($filter_trends) && count($item_params['trends']) > 1) { $trends_output = prepareSubfilterOutput($item_params['trends'], $subfilter_trends, 'subfilter_trends'); $table_subfilter->addRow(array(_('Trends'), $trends_output)); } if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER && count($item_params['interval']) > 1) { $interval_output = prepareSubfilterOutput($item_params['interval'], $subfilter_interval, 'subfilter_interval'); $table_subfilter->addRow(array(_('Interval'), $interval_output)); } $form->addItem(new CDiv(_('Subfilter [affects only filtered data!]'), 'thin_header')); $form->addItem($table_subfilter); return $form; }
$customLabelImage->addClass('hidden'); } $sysmapList->addRow(_('Image label type'), array($labelTypeImage, BR(), $customLabelImage)); // append icon label to sysmap unset($labelTypes[MAP_LABEL_TYPE_CUSTOM]); $sysmapList->addRow(_('Icon label type'), new CComboBox('label_type', $this->data['label_type'], null, $labelTypes)); // append icon label location to sysmap $cmbLocation = new CComboBox('label_location', $this->data['label_location']); $cmbLocation->addItems(array(0 => _('Bottom'), 1 => _('Left'), 2 => _('Right'), 3 => _('Top'))); $sysmapList->addRow(_('Icon label location'), $cmbLocation); // append show unack to sysmap $selectShowUnack = new CComboBox('show_unack', $this->data['show_unack']); $selectShowUnack->addItems(array(EXTACK_OPTION_ALL => _('All'), EXTACK_OPTION_BOTH => _('Separated'), EXTACK_OPTION_UNACK => _('Unacknowledged only'))); $selectShowUnack->setEnabled($config['event_ack_enable']); if (!$config['event_ack_enable']) { $selectShowUnack->setAttribute('title', _('Acknowledging disabled')); } $sysmapList->addRow(_('Problem display'), $selectShowUnack); // create url table $urlTable = new CTable(_('No URLs defined.'), 'formElementTable'); $urlTable->setAttribute('style', 'min-width: 500px;'); $urlTable->setHeader(array(_('Name'), _('URL'), _('Element'), SPACE)); if (empty($this->data['urls'])) { $this->data['urls'][] = array('name' => '', 'url' => '', 'elementtype' => 0); } $i = 0; foreach ($this->data['urls'] as $url) { $urlLabel = new CTextBox('urls[' . $i . '][name]', $url['name'], 32); $urlLink = new CTextBox('urls[' . $i . '][url]', $url['url'], 32); $urlEtype = new CCombobox('urls[' . $i . '][elementtype]', $url['elementtype']); $urlEtype->addItems(sysmap_element_types());
// disable node selection if we show objects from only one host or LLD rule if (hasRequest('only_hostid') || hasRequest('parent_discoveryid')) { $nodeComboBox->setEnabled('disabled'); } $frmTitle->addItem(array(SPACE, _('Node'), SPACE, $nodeComboBox, SPACE)); } /* * Only host id */ if (isset($onlyHostid)) { $only_hosts = API::Host()->get(array('hostids' => $hostid, 'templated_hosts' => true, 'output' => array('hostid', 'host'), 'limit' => 1)); $host = reset($only_hosts); $cmbHosts = new CComboBox('hostid', $hostid); $cmbHosts->addItem($hostid, $host['host']); $cmbHosts->setEnabled('disabled'); $cmbHosts->setAttribute('title', _('You can not switch hosts for current selection.')); $frmTitle->addItem(array(SPACE, _('Host'), SPACE, $cmbHosts)); } else { if (str_in_array($srctbl, array('triggers', 'items', 'applications', 'graphs', 'templates', 'hosts', 'host_templates'))) { $frmTitle->addItem(array(_('Group'), SPACE, $pageFilter->getGroupsCB())); } if (str_in_array($srctbl, array('help_items'))) { $itemtype = get_request('itemtype', 0); $cmbTypes = new CComboBox('itemtype', $itemtype, 'javascript: submit();'); foreach ($allowed_item_types as $type) { $cmbTypes->addItem($type, item_type2str($type)); } $frmTitle->addItem(array(_('Type'), SPACE, $cmbTypes)); } if (str_in_array($srctbl, array('triggers', 'items', 'applications', 'graphs'))) { $frmTitle->addItem(array(SPACE, _('Host'), SPACE, $pageFilter->getHostsCB()));
$customLabelImageTextArea->addClass('hidden'); } $sysmapList->addRow(_('Image label type'), array($labelTypeImageComboBox, BR(), $customLabelImageTextArea)); // append icon label to form list unset($this->data['labelTypes'][MAP_LABEL_TYPE_CUSTOM]); $sysmapList->addRow(_('Icon label type'), new CComboBox('label_type', $this->data['sysmap']['label_type'], null, $this->data['labelTypes'])); // append icon label location to form list $locationComboBox = new CComboBox('label_location', $this->data['sysmap']['label_location']); $locationComboBox->addItems(array(0 => _('Bottom'), 1 => _('Left'), 2 => _('Right'), 3 => _('Top'))); $sysmapList->addRow(_('Icon label location'), $locationComboBox); // append show unack to form list $showUnackComboBox = new CComboBox('show_unack', $this->data['sysmap']['show_unack']); $showUnackComboBox->addItems(array(EXTACK_OPTION_ALL => _('All'), EXTACK_OPTION_BOTH => _('Separated'), EXTACK_OPTION_UNACK => _('Unacknowledged only'))); $showUnackComboBox->setEnabled($this->data['config']['event_ack_enable']); if (!$this->data['config']['event_ack_enable']) { $showUnackComboBox->setAttribute('title', _('Acknowledging disabled')); } $sysmapList->addRow(_('Problem display'), $showUnackComboBox); // append severity min to form list $sysmapList->addRow(_('Minimum trigger severity'), new CSeverity(array('name' => 'severity_min', 'value' => $this->data['sysmap']['severity_min']))); // create url table $urlTable = new CTable(_('No URLs defined.'), 'formElementTable'); $urlTable->setAttribute('style', 'min-width: 500px;'); $urlTable->setHeader(array(_('Name'), _('URL'), _('Element'), SPACE)); if (empty($this->data['sysmap']['urls'])) { $this->data['sysmap']['urls'][] = array('name' => '', 'url' => '', 'elementtype' => 0); } $i = 0; foreach ($this->data['sysmap']['urls'] as $url) { $urlLabel = new CTextBox('urls[' . $i . '][name]', $url['name'], 32); $urlLink = new CTextBox('urls[' . $i . '][url]', $url['url'], 32);
$iconsComboBox->addItems($this->data['iconList']); $iconPreviewImage = new CImg('imgstore.php?iconid=' . $mapping['iconid'] . '&width=' . ZBX_ICON_PREVIEW_WIDTH . '&height=' . ZBX_ICON_PREVIEW_HEIGHT, _('Preview'), null, null, 'pointer preview'); $iconPreviewImage->setAttribute('data-image-full', 'imgstore.php?iconid=' . $mapping['iconid']); $row = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), $numSpan, $profileLinksComboBox, $expressionTextBox, $iconsComboBox, $iconPreviewImage, new CButton('remove', _('Remove'), '', 'link_menu removeMapping')), 'sortable'); $row->setAttribute('id', 'iconmapidRow_' . $i); $iconMapTable->addRow($row); $i++; } // hidden row for js reset($this->data['iconList']); $firstIconId = key($this->data['iconList']); $numSpan = new CSpan('0:'); $numSpan->addClass('rowNum'); $profileLinksComboBox = new CComboBox('iconmap[mappings][#{iconmappingid}][inventory_link]'); $profileLinksComboBox->addItems($this->data['inventoryList']); $profileLinksComboBox->setAttribute('disabled', 'disabled'); $expressionTextBox = new CTextBox('iconmap[mappings][#{iconmappingid}][expression]'); $expressionTextBox->setAttribute('maxlength', 64); $expressionTextBox->setAttribute('disabled', 'disabled'); $iconsComboBox = new CComboBox('iconmap[mappings][#{iconmappingid}][iconid]', $firstIconId); $iconsComboBox->addClass('mappingIcon'); $iconsComboBox->addItems($this->data['iconList']); $iconsComboBox->setAttribute('disabled', 'disabled'); $iconPreviewImage = new CImg('imgstore.php?iconid=' . $firstIconId . '&width=' . ZBX_ICON_PREVIEW_WIDTH . '&height=' . ZBX_ICON_PREVIEW_HEIGHT, _('Preview'), null, null, 'pointer preview'); $iconPreviewImage->setAttribute('data-image-full', 'imgstore.php?iconid=' . $firstIconId); // row template $hiddenRowTemplate = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), $numSpan, $profileLinksComboBox, $expressionTextBox, $iconsComboBox, $iconPreviewImage, new CButton('remove', _('Remove'), '', 'link_menu removeMapping')), 'hidden'); $hiddenRowTemplate->setAttribute('id', 'rowTpl'); $iconMapTable->addRow($hiddenRowTemplate); // add row button $iconMapTable->addRow(new CCol(new CButton('addMapping', _('Add'), '', 'link_menu'), null, 7));
$dbItem = reset($dbItems); if ($dbItem['templateid']) { $template = get_realhost_by_itemid($dbItem['templateid']); $itemName = $template['host'] . NAME_DELIMITER . $dbItem['name_expanded']; } else { $itemName = $dbItem['name_expanded']; } $ctb = new CTextBox('item', $itemName, 80); $ctb->setAttribute('id', 'item'); $ctb->setAttribute('disabled', 'disabled'); $script = "javascript: return PopUp('popup.php?dstfrm=" . $frmTRLog->getName() . "&dstfld1=itemid&dstfld2=item&srctbl=items&srcfld1=itemid&srcfld2=name',800,450);"; $cbtn = new CSubmit('select_item', _('Select'), $script); $frmTRLog->addRow(_('Item'), array($ctb, $cbtn)); $frmTRLog->addVar('itemid', $itemid); $exp_select = new CComboBox('expr_type'); $exp_select->setAttribute('id', 'expr_type'); $exp_select->addItem(REGEXP_INCLUDE, _('Include')); $exp_select->addItem(REGEXP_EXCLUDE, _('Exclude')); $ctb = new CTextBox('expression', '', 80); $ctb->setAttribute('id', 'logexpr'); $cb = new CButton('add_exp', _('Add'), 'javascript: add_logexpr();'); $cbAdd = new CButton('add_key_and', _('AND'), 'javascript: add_keyword_and();'); $cbOr = new CButton('add_key_or', _('OR'), 'javascript: add_keyword_or();'); $cbIregexp = new CCheckBox('iregexp', 'no', null, 1); $frmTRLog->addRow(_('Expression'), array($ctb, BR(), $cbIregexp, 'iregexp', SPACE, $cbAdd, SPACE, $cbOr, SPACE, $exp_select, SPACE, $cb)); $keyTable = new CTableInfo(null); $keyTable->setAttribute('id', 'key_list'); $keyTable->setHeader(array(_('Keyword'), _('Type'), _('Action'))); $table = new CTableInfo(null); $table->setAttribute('id', 'exp_list'); $table->setHeader(array(_('Expression'), _('Type'), _('Position'), _('Action')));
$hostid = 0; } $available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_LIST); $available_hosts = empty($pageFilter->hosts) ? array() : array_keys($pageFilter->hosts); if (isset($only_hostid)) { $hostid = $_REQUEST['hostid'] = $only_hostid; $options = array('hostids' => $hostid, 'templated_hosts' => 1, 'output' => array('hostid', 'host'), 'limit' => 1); $only_hosts = CHost::get($options); $host = reset($only_hosts); if (empty($host)) { access_deny(); } $cmbHosts = new CComboBox('hostid', $hostid); $cmbHosts->addItem($hostid, get_node_name_by_elid($hostid, null, ': ') . $host['host']); $cmbHosts->setEnabled('disabled'); $cmbHosts->setAttribute('title', S_CANNOT_SWITCH_HOSTS); $frmTitle->addItem(array(SPACE, S_HOST, SPACE, $cmbHosts)); } else { if (str_in_array($srctbl, array('hosts', 'host_group', 'triggers', 'items', 'simple_graph', 'applications', 'screens', 'slides', 'graphs', 'sysmaps', 'plain_text', 'screens2', 'overview', 'host_group_scr'))) { if (ZBX_DISTRIBUTED) { $cmbNode = new CComboBox('nodeid', $nodeid, 'submit()'); $db_nodes = DBselect('SELECT * FROM nodes WHERE ' . DBcondition('nodeid', $available_nodes)); while ($node_data = DBfetch($db_nodes)) { $cmbNode->addItem($node_data['nodeid'], $node_data['name']); if (bccomp($nodeid, $node_data['nodeid']) == 0) { $ok = true; } } $frmTitle->addItem(array(SPACE, S_NODE, SPACE, $cmbNode, SPACE)); } }
function insert_map_form() { $frm_title = 'New system map'; if (isset($_REQUEST['sysmapid'])) { $options = array('sysmapids' => $_REQUEST['sysmapid'], 'output' => API_OUTPUT_EXTEND); $sysmaps = CMap::get($options); $row = reset($sysmaps); $frm_title = 'System map: "' . $row['name'] . '"'; } if (isset($_REQUEST['sysmapid']) && !isset($_REQUEST['form_refresh'])) { $name = $row['name']; $width = $row['width']; $height = $row['height']; $backgroundid = $row['backgroundid']; $label_type = $row['label_type']; $label_location = $row['label_location']; $highlight = $row['highlight']; $markelements = $row['markelements']; $expandproblem = $row['expandproblem']; $show_unack = $row['show_unack']; } else { $name = get_request('name', ''); $width = get_request('width', 800); $height = get_request('height', 600); $backgroundid = get_request('backgroundid', 0); $label_type = get_request('label_type', 0); $label_location = get_request('label_location', 0); $highlight = get_request('highlight', 0); $markelements = get_request('markelements', 0); $expandproblem = get_request('expandproblem', 0); $show_unack = get_request('show_unack', 0); } $frmMap = new CFormTable($frm_title, 'sysmaps.php'); $frmMap->setHelp('web.sysmaps.map.php'); if (isset($_REQUEST['sysmapid'])) { $frmMap->addVar('sysmapid', $_REQUEST['sysmapid']); } $frmMap->addRow(S_NAME, new CTextBox('name', $name, 32)); $frmMap->addRow(S_WIDTH, new CNumericBox('width', $width, 5)); $frmMap->addRow(S_HEIGHT, new CNumericBox('height', $height, 5)); $cmbImg = new CComboBox('backgroundid', $backgroundid); $cmbImg->addItem(0, S_NO_IMAGE . '...'); $result = DBselect('SELECT * FROM images WHERE imagetype=2 AND ' . DBin_node('imageid') . ' order by name'); while ($row = DBfetch($result)) { $cmbImg->addItem($row['imageid'], get_node_name_by_elid($row['imageid'], null, ': ') . $row['name']); } $frmMap->addRow(S_BACKGROUND_IMAGE, $cmbImg); $frmMap->addRow(S_ICON_HIGHLIGHTING, new CCheckBox('highlight', $highlight, null, 1)); $frmMap->addRow(S_MARK_ELEMENTS_ON_TRIGGER_STATUS_CHANGE, new CCheckBox('markelements', $markelements, null, 1)); $frmMap->addRow(S_EXPAND_SINGLE_PROBLEM, new CCheckBox('expandproblem', $expandproblem, null, 1)); $cmbLabel = new CComboBox('label_type', $label_type); $cmbLabel->addItem(0, S_LABEL); $cmbLabel->addItem(1, S_IP_ADDRESS); $cmbLabel->addItem(2, S_ELEMENT_NAME); $cmbLabel->addItem(3, S_STATUS_ONLY); $cmbLabel->addItem(4, S_NOTHING); $frmMap->addRow(S_ICON_LABEL_TYPE, $cmbLabel); $cmbLocation = new CComboBox('label_location', $label_location); $cmbLocation->addItem(0, S_BOTTOM); $cmbLocation->addItem(1, S_LEFT); $cmbLocation->addItem(2, S_RIGHT); $cmbLocation->addItem(3, S_TOP); $frmMap->addRow(S_ICON_LABEL_LOCATION, $cmbLocation); $config = select_config(); $cb = new CComboBox('show_unack', $show_unack); $cb->addItems(array(EXTACK_OPTION_ALL => S_O_ALL, EXTACK_OPTION_BOTH => S_O_SEPARATED, EXTACK_OPTION_UNACK => S_O_UNACKNOWLEDGED_ONLY)); $cb->setEnabled($config['event_ack_enable']); if (!$config['event_ack_enable']) { $cb->setAttribute('title', S_EVENT_ACKNOWLEDGING_DISABLED); } $frmMap->addRow(S_PROBLEM_DISPLAY, $cb); $frmMap->addItemToBottomRow(new CButton('save', S_SAVE)); if (isset($_REQUEST['sysmapid'])) { $frmMap->addItemToBottomRow(SPACE); $frmMap->addItemToBottomRow(new CButtonDelete(S_DELETE_SYSTEM_MAP_Q, url_param('form') . url_param('sysmapid'))); } $frmMap->addItemToBottomRow(SPACE); $frmMap->addItemToBottomRow(new CButtonCancel()); return $frmMap; }
$allLocalesAvailable = true; foreach (getLocales() as $localeId => $locale) { if ($locale['display']) { // checking if this locale exists in the system. The only way of doing it is to try and set one // trying to set only the LC_MONETARY locale to avoid changing LC_NUMERIC $localeExists = setlocale(LC_MONETARY, zbx_locale_variants($localeId)) || $localeId == 'en_GB'; $languageComboBox->addItem($localeId, $locale['name'], $localeId == $this->data['lang'] ? true : null, $localeExists); $allLocalesAvailable &= $localeExists; } } // restoring original locale setlocale(LC_MONETARY, zbx_locale_variants(CWebUser::$data['lang'])); $languageError = ''; if (!function_exists('bindtextdomain')) { $languageError = 'Translations are unavailable because the PHP gettext module is missing.'; $languageComboBox->setAttribute('disabled', 'disabled'); } elseif (!$allLocalesAvailable) { $languageError = _('You are not able to choose some of the languages, because locales for them are not installed on the web server.'); } $userFormList->addRow(_('Language'), $languageError ? [$languageComboBox, SPACE, (new CSpan($languageError))->addClass('red')->addClass('wrap')] : $languageComboBox); // append themes to form list $themes = array_merge([THEME_DEFAULT => _('System default')], Z::getThemes()); $userFormList->addRow(_('Theme'), new CComboBox('theme', $this->data['theme'], null, $themes)); // append auto-login & auto-logout to form list $autologoutCheckBox = (new CCheckBox('autologout_visible'))->setChecked(isset($this->data['autologout'])); if (isset($this->data['autologout'])) { $autologoutTextBox = (new CNumericBox('autologout', $this->data['autologout'], 4))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH); } else { $autologoutTextBox = (new CNumericBox('autologout', 900, 4))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH)->setAttribute('disabled', 'disabled'); } if ($this->data['alias'] != ZBX_GUEST_USER) {
$labelSpan->setAttribute('data-formulaid', $label); $conditionTable->addRow(array($labelSpan, get_condition_desc($condition['conditiontype'], $condition['operator'], $condition['value']), array(new CButton('remove', _('Remove'), 'javascript: removeCondition(' . $i . ');', 'link_menu'), new CVar('conditions[' . $i . ']', $condition)), new CVar('conditions[' . $i . '][formulaid]', $label)), null, 'conditions_' . $i); $i++; } $formula = new CTextBox('formula', $this->data['action']['filter']['formula'], ZBX_TEXTBOX_STANDARD_SIZE); $formula->attr('id', 'formula'); $formula->attr('placeholder', 'A or (B and C) …'); if ($this->data['action']['filter']['evaltype'] != CONDITION_EVAL_TYPE_EXPRESSION) { $formula->addClass('hidden'); } $calculationTypeComboBox = new CComboBox('evaltype', $this->data['action']['filter']['evaltype'], 'processTypeOfCalculation()'); $calculationTypeComboBox->addItem(CONDITION_EVAL_TYPE_AND_OR, _('And/Or')); $calculationTypeComboBox->addItem(CONDITION_EVAL_TYPE_AND, _('And')); $calculationTypeComboBox->addItem(CONDITION_EVAL_TYPE_OR, _('Or')); $calculationTypeComboBox->addItem(CONDITION_EVAL_TYPE_EXPRESSION, _('Custom expression')); $calculationTypeComboBox->setAttribute('id', 'evaltype'); $conditionFormList->addRow(_('Type of calculation'), array($calculationTypeComboBox, new CSpan('', $this->data['action']['filter']['evaltype'] == CONDITION_EVAL_TYPE_EXPRESSION ? 'hidden' : '', 'conditionLabel'), $formula), false, 'conditionRow'); $conditionFormList->addRow(_('Conditions'), new CDiv($conditionTable, 'objectgroup inlineblock border_dotted ui-corner-all')); // append new condition to form list $conditionTypeComboBox = new CComboBox('new_condition[conditiontype]', $this->data['new_condition']['conditiontype'], 'submit()'); foreach ($this->data['allowedConditions'] as $key => $condition) { $this->data['allowedConditions'][$key] = array('name' => condition_type2str($condition), 'type' => $condition); } order_result($this->data['allowedConditions'], 'name'); foreach ($this->data['allowedConditions'] as $condition) { $conditionTypeComboBox->addItem($condition['type'], $condition['name']); } $conditionOperatorsComboBox = new CComboBox('new_condition[operator]', $this->data['new_condition']['operator']); foreach (get_operators_by_conditiontype($this->data['new_condition']['conditiontype']) as $operator) { $conditionOperatorsComboBox->addItem($operator, condition_operator2str($operator)); }
$map_tab->addRow(_('Minimum trigger severity'), new CSeverity(['name' => 'severity_min', 'value' => (int) $data['sysmap']['severity_min']])); // Create url table. $url_table = (new CTable())->setAttribute('style', 'width: 100%;')->setHeader([_('Name'), _('URL'), _('Element'), _('Action')]); if (empty($data['sysmap']['urls'])) { $data['sysmap']['urls'][] = ['name' => '', 'url' => '', 'elementtype' => 0]; } $i = 0; foreach ($data['sysmap']['urls'] as $url) { $url_table->addRow((new CRow([(new CTextBox('urls[' . $i . '][name]', $url['name']))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH), (new CTextBox('urls[' . $i . '][url]', $url['url']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH), new CComboBox('urls[' . $i . '][elementtype]', $url['elementtype'], null, sysmap_element_types()), (new CCol((new CButton(null, _('Remove')))->onClick('$("urlEntry_' . $i . '").remove();')->addClass(ZBX_STYLE_BTN_LINK)))->addClass(ZBX_STYLE_NOWRAP)]))->setId('urlEntry_' . $i)); $i++; } // Append empty template row to url table. $template_url_label = (new CTextBox('urls[#{id}][name]', ''))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)->setAttribute('disabled', 'disabled'); $template_url_link = (new CTextBox('urls[#{id}][url]', ''))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('disabled', 'disabled'); $template_url_etype = new CComboBox('urls[#{id}][elementtype]', null, null, sysmap_element_types()); $template_url_etype->setAttribute('disabled', 'disabled'); $template_remove_button = (new CButton(null, _('Remove')))->onClick('$("entry_#{id}").remove();')->addClass(ZBX_STYLE_BTN_LINK); $template_url_row = (new CRow([$template_url_label, $template_url_link, $template_url_etype, (new CCol($template_remove_button))->addClass(ZBX_STYLE_NOWRAP)]))->addStyle('display: none')->setId('urlEntryTpl'); $url_table->addRow($template_url_row); // Append "add" button to url table. $add_button = (new CButton(null, _('Add')))->onClick('cloneRow("urlEntryTpl", ' . $i . ')')->addClass(ZBX_STYLE_BTN_LINK); $add_button_column = (new CCol($add_button))->setColSpan(4); $url_table->addRow($add_button_column); // Append url table to form list. $map_tab->addRow(_('URLs'), (new CDiv($url_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); $tabs->addTab('sysmap_tab', _('Map'), $map_tab); // User group sharing table. $user_group_shares_table = (new CTable())->setHeader([_('User groups'), _('Permissions'), _('Action')])->setAttribute('style', 'width: 100%;'); $add_user_group_btn = [(new CButton(null, _('Add')))->onClick('return PopUp("popup.php?dstfrm=' . $form->getName() . '&srctbl=usrgrp&srcfld1=usrgrpid&srcfld2=name&multiselect=1")')->addClass(ZBX_STYLE_BTN_LINK)]; $user_group_shares_table->addRow((new CRow((new CCol($add_user_group_btn))->setColSpan(3)))->setId('user_group_list_footer')); $user_groups = [];
/* * IPMI */ $ipmiList = new CFormList('ipmilist'); // normal hosts if (!$isDiscovered) { $cmbIPMIAuthtype = new CComboBox('ipmi_authtype', $ipmi_authtype); $cmbIPMIAuthtype->addItems(ipmiAuthTypes()); $cmbIPMIAuthtype->addClass('openView'); $cmbIPMIAuthtype->setAttribute('size', 7); $cmbIPMIAuthtype->addStyle('width: 170px;'); $ipmiList->addRow(_('Authentication algorithm'), $cmbIPMIAuthtype); $cmbIPMIPrivilege = new CComboBox('ipmi_privilege', $ipmi_privilege); $cmbIPMIPrivilege->addItems(ipmiPrivileges()); $cmbIPMIPrivilege->addClass('openView'); $cmbIPMIPrivilege->setAttribute('size', 5); $cmbIPMIPrivilege->addStyle('width: 170px;'); $ipmiList->addRow(_('Privilege level'), $cmbIPMIPrivilege); } else { $cmbIPMIAuthtype = new CTextBox('ipmi_authtype_name', ipmiAuthTypes($dbHost['ipmi_authtype']), ZBX_TEXTBOX_SMALL_SIZE, true); $ipmiList->addRow(_('Authentication algorithm'), $cmbIPMIAuthtype); $cmbIPMIPrivilege = new CTextBox('ipmi_privilege_name', ipmiPrivileges($dbHost['ipmi_privilege']), ZBX_TEXTBOX_SMALL_SIZE, true); $ipmiList->addRow(_('Privilege level'), $cmbIPMIPrivilege); } $ipmiList->addRow(_('Username'), new CTextBox('ipmi_username', $ipmi_username, ZBX_TEXTBOX_SMALL_SIZE, $isDiscovered)); $ipmiList->addRow(_('Password'), new CTextBox('ipmi_password', $ipmi_password, ZBX_TEXTBOX_SMALL_SIZE, $isDiscovered)); $divTabs->addTab('ipmiTab', _('IPMI'), $ipmiList); /* * Macros */ if (empty($macros)) {
$urlEtype = new CComboBox('urls[' . $i . '][elementtype]', $url['elementtype']); $urlEtype->addItems(sysmap_element_types()); $removeButton = new CSpan(_('Remove'), 'link_menu'); $removeButton->addAction('onclick', '$("urlEntry_' . $i . '").remove();'); $urlRow = new CRow(array($urlLabel, $urlLink, $urlEtype, $removeButton)); $urlRow->setAttribute('id', 'urlEntry_' . $i); $urlTable->addRow($urlRow); $i++; } // append empty template row to url table $templateUrlLabel = new CTextBox('urls[#{id}][name]', '', 32); $templateUrlLabel->setAttribute('disabled', 'disabled'); $templateUrlLink = new CTextBox('urls[#{id}][url]', '', 32); $templateUrlLink->setAttribute('disabled', 'disabled'); $templateUrlEtype = new CComboBox('urls[#{id}][elementtype]'); $templateUrlEtype->setAttribute('disabled', 'disabled'); $templateUrlEtype->addItems(sysmap_element_types()); $templateRemoveButton = new CSpan(_('Remove'), 'link_menu'); $templateRemoveButton->addAction('onclick', '$("entry_#{id}").remove();'); $templateUrlRow = new CRow(array($templateUrlLabel, $templateUrlLink, $templateUrlEtype, $templateRemoveButton)); $templateUrlRow->addStyle('display: none'); $templateUrlRow->setAttribute('id', 'urlEntryTpl'); $urlTable->addRow($templateUrlRow); // append "add" button to url table $addButton = new CSpan(_('Add'), 'link_menu'); $addButton->addAction('onclick', 'cloneRow("urlEntryTpl", ' . $i . ')'); $addButtonColumn = new CCol($addButton); $addButtonColumn->setColSpan(4); $urlTable->addRow($addButtonColumn); // append url table to form list $sysmapList->addRow(_('URLs'), new CDiv($urlTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
// SPACE added to extend CB width in Chrome $cbMain = new CCheckBox('maintenance', $maintenance, null, '1'); if (!$filterEnable) { $cbMain->setAttribute('disabled', 'disabled'); } $dashForm->addRow(S_HOSTS, array($cbMain, S_SHOW_HOSTS_IN_MAINTENANCE)); // Trigger $severity = zbx_toHash($severity); $trgSeverities = array(); $severities = array(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER); foreach ($severities as $snum => $sever) { $cb = new CCheckBox('trgSeverity[' . $sever . ']', isset($severity[$sever]), '', 1); $cb->setEnabled($filterEnable); $trgSeverities[] = array($cb, getSeverityCaption($sever)); $trgSeverities[] = BR(); } array_pop($trgSeverities); $dashForm->addRow(S_TRIGGERS_WITH_SEVERITY, $trgSeverities); $config = select_config(); $cb = new CComboBox('extAck', $extAck); $cb->addItems(array(EXTACK_OPTION_ALL => S_O_ALL, EXTACK_OPTION_BOTH => S_O_SEPARATED, EXTACK_OPTION_UNACK => S_O_UNACKNOWLEDGED_ONLY)); $cb->setEnabled($filterEnable && $config['event_ack_enable']); if (!$config['event_ack_enable']) { $cb->setAttribute('title', S_EVENT_ACKNOWLEDGING_DISABLED); } $dashForm->addRow(S_PROBLEM_DISPLAY, $cb); //----- $dashForm->addItemToBottomRow(new CButton('save', S_SAVE)); $dashboard_wdgt->addItem($dashForm); $dashboard_wdgt->show(); include_once 'include/page_footer.php';
$dashList->addRow(_('Hosts'), array($cbMain, _('Show hosts in maintenance'))); // Trigger $severity = zbx_toHash($severity); $trgSeverities = array(); $severities = array(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER); foreach ($severities as $snum => $sever) { $cb = new CCheckBox('trgSeverity[' . $sever . ']', isset($severity[$sever]), '', 1); $cb->setEnabled($filterEnable); $trgSeverities[] = array($cb, getSeverityCaption($sever)); $trgSeverities[] = BR(); } array_pop($trgSeverities); $dashList->addRow(_('Triggers with severity'), $trgSeverities); $config = select_config(); $cb = new CComboBox('extAck', $extAck); $cb->addItems(array(EXTACK_OPTION_ALL => _('All'), EXTACK_OPTION_BOTH => _('Separated'), EXTACK_OPTION_UNACK => _('Unacknowledged only'))); $cb->setEnabled($filterEnable && $config['event_ack_enable']); if (!$config['event_ack_enable']) { $cb->setAttribute('title', _('Event acknowledging disabled')); } $dashList->addRow(_('Problem display'), $cb); //----- $divTabs->addTab('dashFilterTab', _('Filter'), $dashList); $dashForm->addItem($divTabs); // Footer $main = array(new CSubmit('save', _('Save'))); $others = array(); $dashForm->addItem(makeFormFooter($main, $others)); $dashboard_wdgt->addItem($dashForm); $dashboard_wdgt->show(); require_once dirname(__FILE__) . '/include/page_footer.php';