// append slide table $slideTable = new CTableInfo(_('No slides defined.'), 'formElementTable'); $slideTable->setAttribute('style', 'min-width: 500px;'); $slideTable->setAttribute('id', 'slideTable'); $slideTable->setHeader(array(new CCol(SPACE, null, null, '15'), new CCol(SPACE, null, null, '15'), new CCol(_('Screen'), null, null, '140'), new CCol(_('Delay'), null, null, '70'), new CCol(_('Action'), null, null, '50'))); $i = 1; foreach ($this->data['slides'] as $step => $slides) { $name = ''; if (!empty($slides['screenid'])) { $screen = get_screen_by_screenid($slides['screenid']); if (!empty($screen['name'])) { $name = $screen['name']; } } $delay = new CNumericBox('slides[' . $step . '][delay]', !empty($slides['delay']) ? $slides['delay'] : '', 5, 'no', true, false); $delay->setAttribute('placeholder', _('default')); $removeButton = new CButton('remove_' . $step, _('Remove'), 'javascript: removeSlide(this);', 'link_menu'); $removeButton->setAttribute('remove_slide', $step); $row = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), new CSpan($i++ . ':', 'rowNum', 'current_slide_' . $step), $name, $delay, $removeButton), 'sortable', 'slides_' . $step); $slideTable->addRow($row); } $addButtonColumn = new CCol(empty($this->data['work_slide']) ? new CButton('add', _('Add'), 'return PopUp("popup.php?srctbl=screens&srcfld1=screenid&dstfrm=' . $slideForm->getName() . '&multiselect=1", 450, 450)', 'link_menu') : null, null, 5); $addButtonColumn->setAttribute('style', 'vertical-align: middle;'); $slideTable->addRow(new CRow($addButtonColumn, null, 'screenListFooter')); $slideFormList->addRow(_('Slides'), new CDiv($slideTable, 'objectgroup inlineblock border_dotted ui-corner-all')); // append tabs to form $slideTab = new CTabView(); $slideTab->addTab('slideTab', _('Slide'), $slideFormList); $slideForm->addItem($slideTab); // append buttons to form if (empty($this->data['slideshowid'])) {
} $ev_select = new CComboBox('show_events', $_REQUEST['show_events']); $ev_select->addItem(EVENTS_OPTION_NOEVENT, S_HIDE_ALL); $ev_select->addItem(EVENTS_OPTION_ALL, S_SHOW_ALL . SPACE . '(' . $config['event_expire'] . SPACE . ($config['event_expire'] > 1 ? S_DAYS : S_DAY) . ')'); if ($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) . ')'); } $filterForm->addRow(S_EVENTS, $ev_select); $severity_select = new CComboBox('show_severity', $show_severity); $cb_items = array(-1 => S_ALL_S, TRIGGER_SEVERITY_NOT_CLASSIFIED => S_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION => S_INFORMATION, TRIGGER_SEVERITY_WARNING => S_WARNING, TRIGGER_SEVERITY_AVERAGE => S_AVERAGE, TRIGGER_SEVERITY_HIGH => S_HIGH, TRIGGER_SEVERITY_DISASTER => S_DISASTER); $severity_select->addItems($cb_items); $filterForm->addRow(S_MIN_SEVERITY, $severity_select); $action = 'javascrip: this.checked ? $("status_change_days").enable() : $("status_change_days").disable()'; $sts_change_days_cb = new CNumericBox('status_change_days', $_REQUEST['status_change_days'], 4); if (!$_REQUEST['status_change']) { $sts_change_days_cb->setAttribute('disabled', 'disabled'); } $sts_change_days_cb->addStyle('vertical-align: middle;'); $cbd = new CCheckBox('status_change', $_REQUEST['status_change'], $action, 1); $cbd->addStyle('vertical-align: middle;'); $spand = new CSpan(S_DAYS_SMALL); $spand->addStyle('vertical-align: middle;'); $filterForm->addRow(S_AGE_LESS_THAN, array($cbd, $sts_change_days_cb, $spand)); $filterForm->addRow(S_SHOW_DETAILS, new CCheckBox('show_details', $_REQUEST['show_details'], null, 1)); $filterForm->addRow(S_FILTER_BY_NAME, new CTextBox('txt_select', $_REQUEST['txt_select'], 40)); $filterForm->addItemToBottomRow(new CButton('filter_set', S_FILTER)); $filterForm->addItemToBottomRow(new CButton('filter_rst', S_RESET)); $trigg_wdgt->addFlicker($filterForm, CProfile::get('web.tr_status.filter.state', 0)); /*************** FILTER END ******************/ if ($_REQUEST['fullscreen']) { $triggerInfo = new CTriggersInfo($_REQUEST['groupid'], $_REQUEST['hostid']);
$languageComboBox->attr('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 ? array($languageComboBox, SPACE, new CSpan($languageError, 'red wrap')) : $languageComboBox); // append themes to form list $themes = array_merge(array(THEME_DEFAULT => _('System default')), Z::getThemes()); $themeComboBox = new CComboBox('theme', $this->data['theme'], null, $themes); $userFormList->addRow(_('Theme'), $themeComboBox); // append auto-login & auto-logout to form list $autologoutCheckBox = new CCheckBox('autologout_visible', isset($this->data['autologout']) ? 'yes' : 'no'); if (isset($this->data['autologout'])) { $autologoutTextBox = new CNumericBox('autologout', $this->data['autologout'], 4); } else { $autologoutTextBox = new CNumericBox('autologout', 900, 4); $autologoutTextBox->setAttribute('disabled', 'disabled'); } if ($this->data['alias'] != ZBX_GUEST_USER) { $userFormList->addRow(_('Auto-login'), new CCheckBox('autologin', $this->data['autologin'], null, 1)); $userFormList->addRow(_('Auto-logout (min 90 seconds)'), array($autologoutCheckBox, $autologoutTextBox)); } $userFormList->addRow(_('Refresh (in seconds)'), new CNumericBox('refresh', $this->data['refresh'], 4)); $userFormList->addRow(_('Rows per page'), new CNumericBox('rows_per_page', $this->data['rows_per_page'], 6)); $userFormList->addRow(_('URL (after login)'), new CTextBox('url', $this->data['url'], ZBX_TEXTBOX_STANDARD_SIZE)); /* * Media tab */ if (uint_in_array(CWebUser::$data['type'], array(USER_TYPE_ZABBIX_ADMIN, USER_TYPE_SUPER_ADMIN))) { $userMediaFormList = new CFormList('userMediaFormList'); $userForm->addVar('user_medias', $this->data['user_medias']); $mediaTableInfo = new CTableInfo(_('No media found.'));
$filterForm->addRow(_('Acknowledge status'), new CComboBox('ack_status', $filter['ackStatus'], null, array(ZBX_ACK_STS_ANY => _('Any'), ZBX_ACK_STS_WITH_UNACK => _('With unacknowledged events'), ZBX_ACK_STS_WITH_LAST_UNACK => _('With last event unacknowledged')))); } // events if (!$overview) { $eventsComboBox = new CComboBox('show_events', $filter['showEvents'], null, array(EVENTS_OPTION_NOEVENT => _('Hide all'), EVENTS_OPTION_ALL => _n('Show all (%1$s day)', 'Show all (%1$s days)', $config['event_expire']))); if ($config['event_ack_enable']) { $eventsComboBox->addItem(EVENTS_OPTION_NOT_ACK, _n('Show unacknowledged (%1$s day)', 'Show unacknowledged (%1$s days)', $config['event_expire'])); } $filterForm->addRow(_('Events'), $eventsComboBox); } // min severity $filterForm->addRow(_('Minimum trigger severity'), new CComboBox('show_severity', $filter['showSeverity'], null, array(TRIGGER_SEVERITY_NOT_CLASSIFIED => getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), TRIGGER_SEVERITY_INFORMATION => getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), TRIGGER_SEVERITY_WARNING => getSeverityCaption(TRIGGER_SEVERITY_WARNING), TRIGGER_SEVERITY_AVERAGE => getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), TRIGGER_SEVERITY_HIGH => getSeverityCaption(TRIGGER_SEVERITY_HIGH), TRIGGER_SEVERITY_DISASTER => getSeverityCaption(TRIGGER_SEVERITY_DISASTER)))); // age less than $statusChangeDays = new CNumericBox('status_change_days', $filter['statusChangeDays'], 3, false, false, false); if (!$filter['statusChange']) { $statusChangeDays->setAttribute('disabled', 'disabled'); } $statusChangeDays->addStyle('vertical-align: middle;'); $statusChangeCheckBox = new CCheckBox('status_change', $filter['statusChange'], 'javascript: this.checked ? $("status_change_days").enable() : $("status_change_days").disable()', 1); $statusChangeCheckBox->addStyle('vertical-align: middle;'); $daysSpan = new CSpan(_('days')); $daysSpan->addStyle('vertical-align: middle;'); $filterForm->addRow(_('Age less than'), array($statusChangeCheckBox, $statusChangeDays, SPACE, $daysSpan)); // name $filterForm->addRow(_('Filter by name'), new CTextBox('txt_select', $filter['txtSelect'], 40)); // application $filterForm->addRow(_('Filter by application'), array(new CTextBox('application', $filter['application'], 40), new CButton('application_name', _('Select'), 'return PopUp("popup.php?srctbl=applications&srcfld1=name&real_hosts=1&dstfld1=application&with_applications=1' . '&dstfrm=' . $filterForm->getName() . '");', 'filter-button'))); // inventory filter $inventoryFilters = $filter['inventory']; if (!$inventoryFilters) { $inventoryFilters = array(array('field' => '', 'value' => ''));
$day = ''; $hours = ''; $minutes = ''; } $servicesForm->addVar('new_service_time[to]', $year . $month . $day . $hours . $minutes); $calendarIcon->addAction('onclick', "javascript: var pos = getPosition(this); pos.top -= 203; pos.left += 16; CLNDR['downtime_till'].clndr.clndrshow(pos.top, pos.left); CLNDR['downtime_since'].clndr.clndrhide();"); $downtimeTillDay = new CNumericBox('downtime_till_day', $day, 2); $downtimeTillDay->setAttribute('placeholder', _('dd')); $downtimeTillMonth = new CNumericBox('downtime_till_month', $month, 2); $downtimeTillMonth->setAttribute('placeholder', _('mm')); $downtimeTillYear = new CNumericBox('downtime_till_year', $year, 4); $downtimeTillYear->setAttribute('placeholder', _('yyyy')); $downtimeTillHour = new CNumericBox('downtime_till_hour', $hours, 2); $downtimeTillHour->setAttribute('placeholder', _('hh')); $downtimeTillMinute = new CNumericBox('downtime_till_minute', $minutes, 2); $downtimeTillMinute->setAttribute('placeholder', _('mm')); $timeCalendarTable->addRow(array(_('Till'), new CCol(array($downtimeTillDay, '/', $downtimeTillMonth, '/', $downtimeTillYear, SPACE, $downtimeTillHour, ':', $downtimeTillMinute, $calendarIcon)))); zbx_add_post_js('create_calendar(null, ["downtime_till_day", "downtime_till_month", "downtime_till_year", "downtime_till_hour", "downtime_till_minute"], "downtime_till", "new_service_time_to");'); $serviceTimeTable->addRow($timeCalendarTable); } else { $weekFromComboBox = new CComboBox('new_service_time[from_week]', isset($_REQUEST['new_service_time']['from_week']) ? $_REQUEST['new_service_time']['from_week'] : 0); $weekToComboBox = new CComboBox('new_service_time[to_week]', isset($_REQUEST['new_service_time']['from_week']) ? $_REQUEST['new_service_time']['to_week'] : 0); for ($dow = 0; $dow < 7; $dow++) { $weekFromComboBox->addItem($dow, getDayOfWeekCaption($dow)); $weekToComboBox->addItem($dow, getDayOfWeekCaption($dow)); } $timeFromHourTextBox = new CTextBox('new_service_time[from_hour]', isset($_REQUEST['new_service_time']['from_hour']) ? $_REQUEST['new_service_time']['from_hour'] : '', 2, 'no', 2); $timeFromHourTextBox->setAttribute('placeholder', _('hh')); $timeFromMinuteTextBox = new CTextBox('new_service_time[from_minute]', isset($_REQUEST['new_service_time']['from_minute']) ? $_REQUEST['new_service_time']['from_minute'] : '', 2, 'no', 2); $timeFromMinuteTextBox->setAttribute('placeholder', _('mm')); $timeToHourTextBox = new CTextBox('new_service_time[to_hour]', isset($_REQUEST['new_service_time']['to_hour']) ? $_REQUEST['new_service_time']['to_hour'] : '', 2, 'no', 2);
$histortTab = new CTable(null, 'formElementTable'); $histortTab->addRow(array(new CLabel(_('Enable internal housekeeping'), 'hk_history_mode'), new CCheckBox('hk_history_mode', $this->data['config']['hk_history_mode'], null, 1))); $houseKeeperHistoryGlobal = new CCheckBox('hk_history_global', $this->data['config']['hk_history_global'], null, 1); $houseKeeperHistoryModeGlobal = new CNumericBox('hk_history', $this->data['config']['hk_history'], 5); if (!$this->data['config']['hk_history_global']) { $houseKeeperHistoryModeGlobal->setAttribute('disabled', 'disabled'); } $histortTab->addRow(array(new CLabel(_('Override item history period'), 'hk_history_global'), $houseKeeperHistoryGlobal)); $histortTab->addRow(array(new CLabel(_('Data storage period (in days)'), 'hk_history'), $houseKeeperHistoryModeGlobal)); $histortTab->addClass('border_dotted objectgroup element-row'); $houseKeeperTab->addRow(_('History'), new CDiv($histortTab)); // trend $trendTab = new CTable(null, 'formElementTable'); $trendTab->addRow(array(new CLabel(_('Enable internal housekeeping'), 'hk_trends_mode'), new CCheckBox('hk_trends_mode', $this->data['config']['hk_trends_mode'], null, 1))); $houseKeeperTrendGlobal = new CCheckBox('hk_trends_global', $this->data['config']['hk_trends_global'], null, 1); $houseKeeperTrendModeGlobal = new CNumericBox('hk_trends', $this->data['config']['hk_trends'], 5); if (!$this->data['config']['hk_trends_global']) { $houseKeeperTrendModeGlobal->setAttribute('disabled', 'disabled'); } $trendTab->addRow(array(new CLabel(_('Override item trend period'), 'hk_trends_global'), $houseKeeperTrendGlobal)); $trendTab->addRow(array(new CLabel(_('Data storage period (in days)'), 'hk_trends'), $houseKeeperTrendModeGlobal)); $trendTab->addClass('border_dotted objectgroup element-row'); $houseKeeperTab->addRow(_('Trends'), new CDiv($trendTab)); $houseKeeperView = new CTabView(); $houseKeeperView->addTab('houseKeeper', _('Housekeeping'), $houseKeeperTab); $houseKeeperForm = new CForm(); $houseKeeperForm->setName('houseKeeperForm'); $houseKeeperForm->addVar('form_refresh', $this->data['form_refresh'] + 1); $houseKeeperForm->addItem($houseKeeperView); $houseKeeperForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), new CButton('resetDefaults', _('Reset defaults')))); return $houseKeeperForm;
function insert_graph_form() { $frmGraph = new CFormTable(S_GRAPH, null, 'post'); $frmGraph->SetName('frm_graph'); $frmGraph->SetHelp("web.graphs.graph.php"); $frmGraph->SetMethod('post'); $items = get_request('items', array()); if (isset($_REQUEST['graphid'])) { $frmGraph->addVar('graphid', $_REQUEST['graphid']); $result = DBselect('SELECT * FROM graphs WHERE graphid=' . $_REQUEST['graphid']); $row = DBfetch($result); $frmGraph->SetTitle(S_GRAPH . ' "' . $row['name'] . '"'); } if (isset($_REQUEST['graphid']) && !isset($_REQUEST['form_refresh'])) { $name = $row['name']; $width = $row['width']; $height = $row['height']; $ymin_type = $row["ymin_type"]; $ymax_type = $row["ymax_type"]; $yaxismin = $row['yaxismin']; $yaxismax = $row['yaxismax']; $ymin_itemid = $row["ymin_itemid"]; $ymax_itemid = $row["ymax_itemid"]; $showworkperiod = $row['show_work_period']; $showtriggers = $row['show_triggers']; $graphtype = $row['graphtype']; $legend = $row['show_legend']; $graph3d = $row['show_3d']; $percent_left = $row['percent_left']; $percent_right = $row['percent_right']; $db_items = DBselect('SELECT * FROM graphs_items WHERE graphid=' . $_REQUEST['graphid']); while ($item = DBfetch($db_items)) { array_push($items, array('itemid' => $item['itemid'], 'drawtype' => $item['drawtype'], 'sortorder' => $item['sortorder'], 'color' => $item['color'], 'yaxisside' => $item['yaxisside'], 'calc_fnc' => $item['calc_fnc'], 'type' => $item['type'], 'periods_cnt' => $item['periods_cnt'])); } } else { $name = get_request('name', ''); $graphtype = get_request('graphtype', GRAPH_TYPE_NORMAL); if ($graphtype == GRAPH_TYPE_PIE || $graphtype == GRAPH_TYPE_EXPLODED) { $width = get_request('width', 400); $height = get_request('height', 300); } else { $width = get_request('width', 900); $height = get_request('height', 200); } $ymin_type = get_request("ymin_type", GRAPH_YAXIS_TYPE_CALCULATED); $ymax_type = get_request("ymax_type", GRAPH_YAXIS_TYPE_CALCULATED); $yaxismin = get_request("yaxismin", 0.0); $yaxismax = get_request("yaxismax", 100.0); $ymin_itemid = get_request("ymin_itemid", 0); $ymax_itemid = get_request("ymax_itemid", 0); $showworkperiod = get_request('showworkperiod', 0); $showtriggers = get_request('showtriggers', 0); $legend = get_request('legend', 0); $graph3d = get_request('graph3d', 0); $visible = get_request('visible'); $percent_left = 0; $percent_right = 0; if (isset($visible['percent_left'])) { $percent_left = get_request('percent_left', 0); } if (isset($visible['percent_right'])) { $percent_right = get_request('percent_right', 0); } } /* reinit $_REQUEST */ $_REQUEST['items'] = $items; $_REQUEST['name'] = $name; $_REQUEST['width'] = $width; $_REQUEST['height'] = $height; $_REQUEST['ymin_type'] = $ymin_type; $_REQUEST['ymax_type'] = $ymax_type; $_REQUEST['yaxismin'] = $yaxismin; $_REQUEST['yaxismax'] = $yaxismax; $_REQUEST['ymin_itemid'] = $ymin_itemid; $_REQUEST['ymax_itemid'] = $ymax_itemid; $_REQUEST['showworkperiod'] = $showworkperiod; $_REQUEST['showtriggers'] = $showtriggers; $_REQUEST['graphtype'] = $graphtype; $_REQUEST['legend'] = $legend; $_REQUEST['graph3d'] = $graph3d; $_REQUEST['percent_left'] = $percent_left; $_REQUEST['percent_right'] = $percent_right; /********************/ if ($graphtype != GRAPH_TYPE_NORMAL) { foreach ($items as $gid => $gitem) { if ($gitem['type'] != GRAPH_ITEM_AGGREGATED) { continue; } unset($items[$gid]); } } asort_by_key($items, 'sortorder'); $group_gid = get_request('group_gid', array()); $frmGraph->addVar('ymin_itemid', $ymin_itemid); $frmGraph->addVar('ymax_itemid', $ymax_itemid); $frmGraph->addRow(S_NAME, new CTextBox('name', $name, 32)); $g_width = new CNumericBox('width', $width, 5); $g_width->setAttribute('onblur', 'javascript: submit();'); $frmGraph->addRow(S_WIDTH, $g_width); $g_height = new CNumericBox('height', $height, 5); $g_height->setAttribute('onblur', 'javascript: submit();'); $frmGraph->addRow(S_HEIGHT, $g_height); $cmbGType = new CComboBox('graphtype', $graphtype, 'graphs.submit(this)'); $cmbGType->addItem(GRAPH_TYPE_NORMAL, S_NORMAL); $cmbGType->addItem(GRAPH_TYPE_STACKED, S_STACKED); $cmbGType->addItem(GRAPH_TYPE_PIE, S_PIE); $cmbGType->addItem(GRAPH_TYPE_EXPLODED, S_EXPLODED); zbx_add_post_js('graphs.graphtype = ' . $graphtype . ";\n"); $frmGraph->addRow(S_GRAPH_TYPE, $cmbGType); if ($graphtype == GRAPH_TYPE_NORMAL || $graphtype == GRAPH_TYPE_STACKED) { $frmGraph->addRow(S_SHOW_WORKING_TIME, new CCheckBox('showworkperiod', $showworkperiod, null, 1)); $frmGraph->addRow(S_SHOW_TRIGGERS, new CCheckBox('showtriggers', $showtriggers, null, 1)); if ($graphtype == GRAPH_TYPE_NORMAL) { $percent_left = sprintf("%2.2f", $percent_left); $percent_right = sprintf("%2.2f", $percent_right); $pr_left_input = new CTextBox('percent_left', $percent_left, '5'); $pr_left_chkbx = new CCheckBox('visible[percent_left]', 1, "javascript: ShowHide('percent_left');", 1); if ($percent_left == 0) { $pr_left_input->setAttribute('style', 'display: none;'); $pr_left_chkbx->SetChecked(0); } $pr_right_input = new CTextBox('percent_right', $percent_right, '5'); $pr_right_chkbx = new CCheckBox('visible[percent_right]', 1, "javascript: ShowHide('percent_right');", 1); if ($percent_right == 0) { $pr_right_input->setAttribute('style', 'display: none;'); $pr_right_chkbx->SetChecked(0); } $frmGraph->addRow(S_PERCENTILE_LINE . ' (' . S_LEFT . ')', array($pr_left_chkbx, $pr_left_input)); $frmGraph->addRow(S_PERCENTILE_LINE . ' (' . S_RIGHT . ')', array($pr_right_chkbx, $pr_right_input)); } $yaxis_min = array(); $cmbYType = new CComboBox('ymin_type', $ymin_type, 'javascript: submit();'); $cmbYType->addItem(GRAPH_YAXIS_TYPE_CALCULATED, S_CALCULATED); $cmbYType->addItem(GRAPH_YAXIS_TYPE_FIXED, S_FIXED); $cmbYType->addItem(GRAPH_YAXIS_TYPE_ITEM_VALUE, S_ITEM); $yaxis_min[] = $cmbYType; if ($ymin_type == GRAPH_YAXIS_TYPE_FIXED) { $yaxis_min[] = new CTextBox("yaxismin", $yaxismin, 9); } else { if ($ymin_type == GRAPH_YAXIS_TYPE_ITEM_VALUE) { $frmGraph->addVar('yaxismin', $yaxismin); $ymin_name = ''; if ($ymin_itemid > 0) { $min_host = get_host_by_itemid($ymin_itemid); $min_item = get_item_by_itemid($ymin_itemid); $ymin_name = $min_host['host'] . ':' . item_description($min_item); } $yaxis_min[] = new CTextBox("ymin_name", $ymin_name, 80, 'yes'); $yaxis_min[] = new CButton('yaxis_min', S_SELECT, 'javascript: ' . "return PopUp('popup.php?dstfrm=" . $frmGraph->getName() . "&dstfld1=ymin_itemid" . "&dstfld2=ymin_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');"); } else { $frmGraph->addVar('yaxismin', $yaxismin); } } $frmGraph->addRow(S_YAXIS_MIN_VALUE, $yaxis_min); $yaxis_max = array(); $cmbYType = new CComboBox("ymax_type", $ymax_type, "submit()"); $cmbYType->addItem(GRAPH_YAXIS_TYPE_CALCULATED, S_CALCULATED); $cmbYType->addItem(GRAPH_YAXIS_TYPE_FIXED, S_FIXED); $cmbYType->addItem(GRAPH_YAXIS_TYPE_ITEM_VALUE, S_ITEM); $yaxis_max[] = $cmbYType; if ($ymax_type == GRAPH_YAXIS_TYPE_FIXED) { $yaxis_max[] = new CTextBox("yaxismax", $yaxismax, 9); } else { if ($ymax_type == GRAPH_YAXIS_TYPE_ITEM_VALUE) { $frmGraph->addVar('yaxismax', $yaxismax); $ymax_name = ''; if ($ymax_itemid > 0) { $max_host = get_host_by_itemid($ymax_itemid); $max_item = get_item_by_itemid($ymax_itemid); $ymax_name = $max_host['host'] . ':' . item_description($max_item); } $yaxis_max[] = new CTextBox("ymax_name", $ymax_name, 80, 'yes'); $yaxis_max[] = new CButton('yaxis_max', S_SELECT, 'javascript: ' . "return PopUp('popup.php?dstfrm=" . $frmGraph->getName() . "&dstfld1=ymax_itemid" . "&dstfld2=ymax_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');"); } else { $frmGraph->addVar('yaxismax', $yaxismax); } } $frmGraph->addRow(S_YAXIS_MAX_VALUE, $yaxis_max); } else { $frmGraph->addRow(S_3D_VIEW, new CCheckBox('graph3d', $graph3d, 'javascript: graphs.submit(this);', 1)); $frmGraph->addRow(S_LEGEND, new CCheckBox('legend', $legend, 'javascript: graphs.submit(this);', 1)); } $only_hostid = null; $monitored_hosts = null; if (count($items)) { $frmGraph->addVar('items', $items); $items_table = new CTableInfo(); foreach ($items as $gid => $gitem) { if ($graphtype == GRAPH_TYPE_STACKED && $gitem['type'] == GRAPH_ITEM_AGGREGATED) { continue; } $host = get_host_by_itemid($gitem['itemid']); $item = get_item_by_itemid($gitem['itemid']); if ($host['status'] == HOST_STATUS_TEMPLATE) { $only_hostid = $host['hostid']; } else { $monitored_hosts = 1; } if ($gitem['type'] == GRAPH_ITEM_AGGREGATED) { $color = '-'; } else { $color = new CColorCell(null, $gitem['color']); } $do_up = new CLink(S_UP, '#', 'action'); $do_up->OnClick("return create_var('" . $frmGraph->GetName() . "','move_up'," . $gid . ", true);"); $do_down = new CLink(S_DOWN, '#', 'action'); $do_down->OnClick("return create_var('" . $frmGraph->GetName() . "','move_down'," . $gid . ", true);"); $description = new CLink($host['host'] . ': ' . item_description($item), '#', 'action'); $description->OnClick('return PopUp("popup_gitem.php?list_name=items&dstfrm=' . $frmGraph->GetName() . url_param($only_hostid, false, 'only_hostid') . url_param($monitored_hosts, false, 'monitored_hosts') . url_param($graphtype, false, 'graphtype') . url_param($gitem, false) . url_param($gid, false, 'gid') . url_param(get_request('graphid', 0), false, 'graphid') . '",550,400,"graph_item_form");'); if ($graphtype == GRAPH_TYPE_PIE || $graphtype == GRAPH_TYPE_EXPLODED) { $items_table->addRow(array(new CCheckBox('group_gid[' . $gid . ']', isset($group_gid[$gid])), $gitem['sortorder'], $description, graph_item_calc_fnc2str($gitem["calc_fnc"], $gitem["type"]), graph_item_type2str($gitem['type'], $gitem["periods_cnt"]), $color, array($do_up, SPACE . "|" . SPACE, $do_down))); } else { $items_table->addRow(array(new CCheckBox('group_gid[' . $gid . ']', isset($group_gid[$gid])), $gitem['sortorder'], $description, graph_item_calc_fnc2str($gitem["calc_fnc"], $gitem["type"]), graph_item_type2str($gitem['type'], $gitem["periods_cnt"]), graph_item_drawtype2str($gitem["drawtype"], $gitem["type"]), $color, array($do_up, SPACE . "|" . SPACE, $do_down))); } } $dedlete_button = new CButton('delete_item', S_DELETE_SELECTED); } else { $items_table = $dedlete_button = null; } $frmGraph->addRow(S_ITEMS, array($items_table, new CButton('add_item', S_ADD, "return PopUp('popup_gitem.php?dstfrm=" . $frmGraph->GetName() . url_param($only_hostid, false, 'only_hostid') . url_param($monitored_hosts, false, 'monitored_hosts') . url_param($graphtype, false, 'graphtype') . "',550,400,'graph_item_form');"), $dedlete_button)); unset($items_table, $dedlete_button); $frmGraph->addItemToBottomRow(new CButton("save", S_SAVE)); if (isset($_REQUEST["graphid"])) { $frmGraph->addItemToBottomRow(SPACE); $frmGraph->addItemToBottomRow(new CButton("clone", S_CLONE)); $frmGraph->addItemToBottomRow(SPACE); $frmGraph->addItemToBottomRow(new CButtonDelete(S_DELETE_GRAPH_Q, url_param("graphid") . url_param('groupid') . url_param("hostid"))); } $frmGraph->addItemToBottomRow(SPACE); $frmGraph->addItemToBottomRow(new CButtonCancel(url_param('groupid') . url_param("hostid"))); $frmGraph->show(); }
function getUserForm($userid, $profile = 0) { global $ZBX_LOCALES; global $USER_DETAILS; $config = select_config(); $frm_title = S_USER; if (isset($userid)) { /* if(bccomp($userid,$USER_DETAILS['userid'])==0) $profile = 1;*/ $options = array('userids' => $userid, 'output' => API_OUTPUT_EXTEND); if ($profile) { $options['nodeids'] = id2nodeid($userid); } $users = CUser::get($options); $user = reset($users); $frm_title = S_USER . ' "' . $user['alias'] . '"'; } if (isset($userid) && (!isset($_REQUEST['form_refresh']) || isset($_REQUEST['register']))) { $alias = $user['alias']; $name = $user['name']; $surname = $user['surname']; $password = null; $password1 = null; $password2 = null; $url = $user['url']; $autologin = $user['autologin']; $autologout = $user['autologout']; $lang = $user['lang']; $theme = $user['theme']; $refresh = $user['refresh']; $rows_per_page = $user['rows_per_page']; $user_type = $user['type']; if ($autologout > 0) { $_REQUEST['autologout'] = $autologout; } $user_groups = array(); $user_medias = array(); $options = array('userids' => $userid, 'output' => API_OUTPUT_SHORTEN); $user_groups = CUserGroup::get($options); $user_groups = zbx_objectValues($user_groups, 'usrgrpid'); $user_groups = zbx_toHash($user_groups); $db_medias = DBselect('SELECT m.* FROM media m WHERE m.userid=' . $userid); while ($db_media = DBfetch($db_medias)) { $user_medias[] = array('mediaid' => $db_media['mediaid'], 'mediatypeid' => $db_media['mediatypeid'], 'period' => $db_media['period'], 'sendto' => $db_media['sendto'], 'severity' => $db_media['severity'], 'active' => $db_media['active']); } $messages = getMessageSettings(); } else { $alias = get_request('alias', ''); $name = get_request('name', ''); $surname = get_request('surname', ''); $password = null; $password1 = get_request('password1', ''); $password2 = get_request('password2', ''); $url = get_request('url', ''); $autologin = get_request('autologin', 0); $autologout = get_request('autologout', 90); $lang = get_request('lang', 'en_gb'); $theme = get_request('theme', 'default.css'); $refresh = get_request('refresh', 30); $rows_per_page = get_request('rows_per_page', 50); $user_type = get_request('user_type', USER_TYPE_ZABBIX_USER); $user_groups = get_request('user_groups', array()); $change_password = get_request('change_password', null); $user_medias = get_request('user_medias', array()); $messages = get_request('messages', array()); if (!isset($messages['enabled'])) { $messages['enabled'] = 0; } if (!isset($messages['sounds.recovery'])) { $messages['sounds.recovery'] = 0; } if (!isset($messages['triggers.recovery'])) { $messages['triggers.recovery'] = 0; } if (!isset($messages['triggers.severities'])) { $messages['triggers.severities'] = array(); } $pMsgs = getMessageSettings(); $messages = array_merge($pMsgs, $messages); } if ($autologin || !isset($_REQUEST['autologout'])) { $autologout = 0; } else { if (isset($_REQUEST['autologout']) && $autologout < 90) { $autologout = 90; } } $perm_details = get_request('perm_details', 0); $media_types = array(); $media_type_ids = array(); foreach ($user_medias as $one_media) { $media_type_ids[$one_media['mediatypeid']] = 1; } if (count($media_type_ids) > 0) { $sql = 'SELECT mt.mediatypeid, mt.description ' . ' FROM media_type mt ' . ' WHERE mt.mediatypeid IN (' . implode(',', array_keys($media_type_ids)) . ')'; $db_media_types = DBselect($sql); while ($db_media_type = DBfetch($db_media_types)) { $media_types[$db_media_type['mediatypeid']] = $db_media_type['description']; } } $frmUser = new CFormTable($frm_title); $frmUser->setName('user_form'); $frmUser->setHelp('web.users.php'); $frmUser->addVar('config', get_request('config', 0)); if (isset($userid)) { $frmUser->addVar('userid', $userid); } if ($profile == 0) { $frmUser->addRow(S_ALIAS, new CTextBox('alias', $alias, 40)); $frmUser->addRow(S_NAME, new CTextBox('name', $name, 40)); $frmUser->addRow(S_SURNAME, new CTextBox('surname', $surname, 40)); } $auth_type = isset($userid) ? get_user_system_auth($userid) : $config['authentication_type']; if (ZBX_AUTH_INTERNAL == $auth_type) { if (!isset($userid) || isset($change_password)) { $frmUser->addRow(S_PASSWORD, new CPassBox('password1', $password1, 20)); $frmUser->addRow(S_PASSWORD_ONCE_AGAIN, new CPassBox('password2', $password2, 20)); if (isset($change_password)) { $frmUser->addVar('change_password', $change_password); } } else { $passwd_but = new CButton('change_password', S_CHANGE_PASSWORD); if ($alias == ZBX_GUEST_USER) { $passwd_but->setAttribute('disabled', 'disabled'); } $frmUser->addRow(S_PASSWORD, $passwd_but); } } if ($profile == 0) { $frmUser->addVar('user_groups', $user_groups); if (isset($userid) && bccomp($USER_DETAILS['userid'], $userid) == 0) { $frmUser->addVar('user_type', $user_type); } else { $cmbUserType = new CComboBox('user_type', $user_type, $perm_details ? 'submit();' : null); $cmbUserType->addItem(USER_TYPE_ZABBIX_USER, user_type2str(USER_TYPE_ZABBIX_USER)); $cmbUserType->addItem(USER_TYPE_ZABBIX_ADMIN, user_type2str(USER_TYPE_ZABBIX_ADMIN)); $cmbUserType->addItem(USER_TYPE_SUPER_ADMIN, user_type2str(USER_TYPE_SUPER_ADMIN)); $frmUser->addRow(S_USER_TYPE, $cmbUserType); } $lstGroups = new CListBox('user_groups_to_del[]', null, 10); $lstGroups->attributes['style'] = 'width: 320px'; $options = array('usrgrpids' => $user_groups, 'output' => API_OUTPUT_EXTEND); $groups = CUserGroup::get($options); order_result($groups, 'name'); foreach ($groups as $num => $group) { $lstGroups->addItem($group['usrgrpid'], $group['name']); } $frmUser->addRow(S_GROUPS, array($lstGroups, BR(), new CButton('add_group', S_ADD, 'return PopUp("popup_usrgrp.php?dstfrm=' . $frmUser->getName() . '&list_name=user_groups_to_del[]&var_name=user_groups",450, 450);'), SPACE, count($user_groups) > 0 ? new CButton('del_user_group', S_DELETE_SELECTED) : null)); } $cmbLang = new CComboBox('lang', $lang); foreach ($ZBX_LOCALES as $loc_id => $loc_name) { $cmbLang->addItem($loc_id, $loc_name); } $frmUser->addRow(S_LANGUAGE, $cmbLang); $cmbTheme = new CComboBox('theme', $theme); $cmbTheme->addItem(ZBX_DEFAULT_CSS, S_SYSTEM_DEFAULT); $cmbTheme->addItem('css_ob.css', S_ORIGINAL_BLUE); $cmbTheme->addItem('css_bb.css', S_BLACK_AND_BLUE); $cmbTheme->addItem('css_od.css', S_DARK_ORANGE); $frmUser->addRow(S_THEME, $cmbTheme); $script = "javascript:\n\t\t\tvar autologout_visible = document.getElementById('autologout_visible');\n\t\t\tvar autologout = document.getElementById('autologout');\n\t\t\tif(this.checked){\n\t\t\t\tif(autologout_visible.checked){\n\t\t\t\t\tautologout_visible.checked = false;\n\t\t\t\t\tautologout_visible.onclick();\n\t\t\t\t}\n\t\t\t\tautologout_visible.disabled = true;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tautologout_visible.disabled = false;\n\t\t\t}"; $chkbx_autologin = new CCheckBox("autologin", $autologin, $script, 1); $chkbx_autologin->setAttribute('autocomplete', 'off'); $frmUser->addRow(S_AUTO_LOGIN, $chkbx_autologin); $script = "javascript: var autologout = document.getElementById('autologout');\n\t\t\t\t\tif(this.checked) autologout.disabled = false;\n\t\t\t\t\telse autologout.disabled = true;"; $autologoutCheckBox = new CCheckBox('autologout_visible', $autologout == 0 ? 'no' : 'yes', $script); $autologoutTextBox = new CNumericBox("autologout", $autologout == 0 ? '90' : $autologout, 4); // if autologout is disabled if ($autologout == 0) { $autologoutTextBox->setAttribute('disabled', 'disabled'); } if ($autologin != 0) { $autologoutCheckBox->setAttribute('disabled', 'disabled'); } $frmUser->addRow(S_AUTO_LOGOUT, array($autologoutCheckBox, $autologoutTextBox)); $frmUser->addRow(S_SCREEN_REFRESH, new CNumericBox('refresh', $refresh, 4)); $frmUser->addRow(S_ROWS_PER_PAGE, new CNumericBox('rows_per_page', $rows_per_page, 6)); $frmUser->addRow(S_URL_AFTER_LOGIN, new CTextBox("url", $url, 50)); //view Media Settings for users above "User" +++ if (uint_in_array($USER_DETAILS['type'], array(USER_TYPE_ZABBIX_ADMIN, USER_TYPE_SUPER_ADMIN))) { $frmUser->addVar('user_medias', $user_medias); $media_table = new CTableInfo(S_NO_MEDIA_DEFINED); foreach ($user_medias as $id => $one_media) { if (!isset($one_media['active']) || $one_media['active'] == 0) { $status = new CLink(S_ENABLED, '#', 'enabled'); $status->onClick('return create_var("' . $frmUser->getName() . '","disable_media",' . $id . ', true);'); } else { $status = new CLink(S_DISABLED, '#', 'disabled'); $status->onClick('return create_var("' . $frmUser->getName() . '","enable_media",' . $id . ', true);'); } $media_url = '?dstfrm=' . $frmUser->getName() . '&media=' . $id . '&mediatypeid=' . $one_media['mediatypeid'] . '&sendto=' . urlencode($one_media['sendto']) . '&period=' . $one_media['period'] . '&severity=' . $one_media['severity'] . '&active=' . $one_media['active']; $media_table->addRow(array(new CCheckBox('user_medias_to_del[' . $id . ']', null, null, $id), new CSpan($media_types[$one_media['mediatypeid']], 'nowrap'), new CSpan($one_media['sendto'], 'nowrap'), new CSpan($one_media['period'], 'nowrap'), media_severity2str($one_media['severity']), $status, new CButton('edit_media', S_EDIT, 'javascript: return PopUp("popup_media.php' . $media_url . '",550,400);'))); } $frmUser->addRow(S_MEDIA, array($media_table, new CButton('add_media', S_ADD, 'javascript: return PopUp("popup_media.php?dstfrm=' . $frmUser->getName() . '",550,400);'), SPACE, count($user_medias) > 0 ? new CButton('del_user_media', S_DELETE_SELECTED) : null)); } if (0 == $profile) { $frmUser->addVar('perm_details', $perm_details); $link = new CSpan($perm_details ? S_HIDE : S_SHOW, 'link'); $link->onClick("return create_var('" . $frmUser->getName() . "','perm_details'," . ($perm_details ? 0 : 1) . ", true);"); $resources_list = array(S_RIGHTS_OF_RESOURCES, SPACE . '(', $link, ')'); $frmUser->addSpanRow($resources_list, 'right_header'); if ($perm_details) { $group_ids = array_values($user_groups); if (count($group_ids) == 0) { $group_ids = array(-1); } $db_rights = DBselect('SELECT * FROM rights r WHERE ' . DBcondition('r.groupid', $group_ids)); $tmp_perm = array(); while ($db_right = DBfetch($db_rights)) { if (isset($tmp_perm[$db_right['id']])) { $tmp_perm[$db_right['id']] = min($tmp_perm[$db_right['id']], $db_right['permission']); } else { $tmp_perm[$db_right['id']] = $db_right['permission']; } } $user_rights = array(); foreach ($tmp_perm as $id => $perm) { array_push($user_rights, array('id' => $id, 'permission' => $perm)); } //SDI($user_rights); //SDI($user_type); $frmUser->addSpanRow(get_rights_of_elements_table($user_rights, $user_type)); } } if ($profile) { $msgVisibility = array('1' => array('messages[timeout]', 'messages[sounds.repeat]', 'messages[sounds.recovery]', 'messages[triggers.recovery]', 'timeout_row', 'repeat_row', 'triggers_row')); $frmUser->addRow(S_GUI_MESSAGING, new CCheckBox('messages[enabled]', $messages['enabled'], null, 1)); $newRow = $frmUser->addRow(S_MESSAGE_TIMEOUT . SPACE . '(' . S_SECONDS_SMALL . ')', new CNumericBox("messages[timeout]", $messages['timeout'], 5)); $newRow->setAttribute('id', 'timeout_row'); $repeatSound = new CComboBox('messages[sounds.repeat]', $messages['sounds.repeat'], 'javascript: if(IE) submit();'); $repeatSound->setAttribute('id', 'messages[sounds.repeat]'); $repeatSound->addItem(1, S_ONCE); $repeatSound->addItem(10, '10 ' . S_SECONDS); $repeatSound->addItem(-1, S_MESSAGE_TIMEOUT); $newRow = $frmUser->addRow(S_PLAY_SOUND, $repeatSound); $newRow->setAttribute('id', 'repeat_row'); // trigger sounds $severities = array(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER); $zbxSounds = getSounds(); $triggers = new CTable('', 'invisible'); $soundList = new CComboBox('messages[sounds.recovery]', $messages['sounds.recovery']); foreach ($zbxSounds as $filename => $file) { $soundList->addItem($file, $filename); } $resolved = array(new CCheckBox('messages[triggers.recovery]', $messages['triggers.recovery'], null, 1), S_RECOVERY, $soundList, new CButton('start', S_PLAY, "javascript: testUserSound('messages[sounds.recovery]');", false), new CButton('stop', S_STOP, 'javascript: AudioList.stopAll();', false)); $triggers->addRow($resolved); foreach ($severities as $snum => $severity) { $soundList = new CComboBox('messages[sounds.' . $severity . ']', $messages['sounds.' . $severity]); foreach ($zbxSounds as $filename => $file) { $soundList->addItem($file, $filename); } $triggers->addRow(array(new CCheckBox('messages[triggers.severities][' . $severity . ']', isset($messages['triggers.severities'][$severity]), null, 1), getSeverityCaption($severity), $soundList, new CButton('start', S_PLAY, "javascript: testUserSound('messages[sounds." . $severity . "]');", false), new CButton('stop', S_STOP, 'javascript: AudioList.stopAll();', false))); zbx_subarray_push($msgVisibility, 1, 'messages[triggers.severities][' . $severity . ']'); zbx_subarray_push($msgVisibility, 1, 'messages[sounds.' . $severity . ']'); } $newRow = $frmUser->addRow(S_TRIGGER_SEVERITY, $triggers); $newRow->setAttribute('id', 'triggers_row'); zbx_add_post_js("var userMessageSwitcher = new CViewSwitcher('messages[enabled]', 'click', " . zbx_jsvalue($msgVisibility, true) . ");"); } $frmUser->addItemToBottomRow(new CButton('save', S_SAVE)); if (isset($userid) && $profile == 0) { $frmUser->addItemToBottomRow(SPACE); $delete_b = new CButtonDelete(S_DELETE_SELECTED_USER_Q, url_param("form") . url_param("config") . url_param("userid")); if (bccomp($USER_DETAILS['userid'], $userid) == 0) { $delete_b->setAttribute('disabled', 'disabled'); } $frmUser->addItemToBottomRow($delete_b); } $frmUser->addItemToBottomRow(SPACE); $frmUser->addItemToBottomRow(new CButtonCancel(url_param("config"))); return $frmUser; }
$month = ''; $day = ''; $hours = ''; $minutes = ''; } $maintenanceForm->addVar('active_till', $year . $month . $day . $hours . $minutes); $maintenanceTillDay = new CNumericBox('mntc_till_day', $day, 2); $maintenanceTillDay->setAttribute('placeholder', _('dd')); $maintenanceTillMonth = new CNumericBox('mntc_till_month', $month, 2); $maintenanceTillMonth->setAttribute('placeholder', _('mm')); $maintenanceTillYear = new CNumericBox('mntc_till_year', $year, 4); $maintenanceTillYear->setAttribute('placeholder', _('yyyy')); $maintenanceTillHour = new CNumericBox('mntc_till_hour', $hours, 2); $maintenanceTillHour->setAttribute('placeholder', _('hh')); $maintenanceTillMinute = new CNumericBox('mntc_till_minute', $minutes, 2); $maintenanceTillMinute->setAttribute('placeholder', _('mm')); $maintenanceFormList->addRow(_('Active till'), array($maintenanceTillDay, '/', $maintenanceTillMonth, '/', $maintenanceTillYear, SPACE, $maintenanceTillHour, ':', $maintenanceTillMinute, $calendarIcon)); zbx_add_post_js('create_calendar(null, ["mntc_till_day", "mntc_till_month", "mntc_till_year", "mntc_till_hour", "mntc_till_minute"], "mntc_active_till", "active_till");'); $maintenanceFormList->addRow(_('Description'), new CTextArea('description', $this->data['description'])); /* * Maintenance period tab */ $maintenancePeriodFormList = new CFormList('maintenancePeriodFormList'); $maintenancePeriodTable = new CTableInfo(_('No maintenance period defined.')); $maintenancePeriodTable->setHeader(array(new CCheckBox('all_periods', null, 'checkAll("' . $maintenanceForm->getName() . '", "all_periods", "g_timeperiodid");'), _('Period type'), _('Schedule'), _('Period'), _('Action'))); foreach ($this->data['timeperiods'] as $id => $timeperiod) { $maintenancePeriodTable->addRow(array(new CCheckBox('g_timeperiodid[]', 'no', null, $id), timeperiod_type2str($timeperiod['timeperiod_type']), new CCol(shedule2str($timeperiod), 'wraptext'), zbx_date2age(0, $timeperiod['period']), new CSubmit('edit_timeperiodid[' . $id . ']', _('Edit'), null, 'link_menu'))); if (isset($timeperiod['timeperiodid'])) { $maintenanceForm->addVar('timeperiods[' . $id . '][timeperiodid]', $timeperiod['timeperiodid']); } $maintenanceForm->addVar('timeperiods[' . $id . '][timeperiod_type]', $timeperiod['timeperiod_type']);