public function getOnActionJS() { if (count($this->items) <= 0) { return NULL; } return 'return show_popup_menu(event,' . zbx_jsvalue($this->items) . ',' . zbx_jsvalue($this->width) . ');'; }
/** * Process screen. * * @return CDiv (screen inside container) */ public function get() { $this->dataId = 'graph_full'; $containerId = 'graph_container'; // time control $graphDims = getGraphDims($this->graphid); if ($graphDims['graphtype'] == GRAPH_TYPE_PIE || $graphDims['graphtype'] == GRAPH_TYPE_EXPLODED) { $loadSBox = 0; $src = 'chart6.php'; } else { $loadSBox = 1; $src = 'chart2.php'; } $src .= '?graphid=' . $this->graphid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'] . $this->getProfileUrlParams(); $this->timeline['starttime'] = date(TIMESTAMP_FORMAT, get_min_itemclock_by_graphid($this->graphid)); $timeControlData = array('id' => $this->getDataId(), 'containerid' => $containerId, 'src' => $src, 'objDims' => $graphDims, 'loadSBox' => $loadSBox, 'loadImage' => 1, 'dynamic' => 1, 'periodFixed' => CProfile::get($this->profileIdx . '.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD); // output if ($this->mode == SCREEN_MODE_JS) { $timeControlData['dynamic'] = 0; $timeControlData['loadSBox'] = 0; return 'timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ')'; } else { if ($this->mode == SCREEN_MODE_SLIDESHOW) { insert_js('timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');'); } else { zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');'); } return $this->getOutput(new CDiv(null, 'center', $containerId), true, array('graphid' => $this->graphid)); } }
public function toString($destroy = true) { if (count($this->tabs) == 1) { $this->setAttribute('class', 'min-width ui-tabs ui-widget ui-widget-content ui-corner-all widget'); $header = reset($this->headers); $header = new CDiv($header); $header->addClass('ui-corner-all ui-widget-header header'); $header->setAttribute('id', 'tab_' . key($this->headers)); $this->addItem($header); $tab = reset($this->tabs); $tab->addClass('ui-tabs ui-tabs-panel ui-widget ui-widget-content ui-corner-all widget'); $this->addItem($tab); } else { $headersList = new CList(); foreach ($this->headers as $id => $header) { $tabLink = new CLink($header, '#' . $id, null, null, false); $tabLink->setAttribute('id', 'tab_' . $id); $headersList->addItem($tabLink); } $this->addItem($headersList); $this->addItem($this->tabs); $options = array(); if (!is_null($this->selectedTab)) { $options['selected'] = $this->selectedTab; } if ($this->rememberTab) { $options['cookie'] = array(); } zbx_add_post_js('jQuery("#' . $this->id . '").tabs(' . zbx_jsvalue($options, true) . ').show();'); } return parent::toString($destroy); }
function make_refresh_menu($pmid, $dollid, $cur_interval, $params = null, &$menu, &$submenu) { $menu['menu_' . $dollid][] = array(S_REFRESH, null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader'))); $intervals = array('10', '30', '60', '120', '600', '900'); foreach ($intervals as $key => $value) { $menu['menu_' . $dollid][] = array(S_EVERY . SPACE . $value . SPACE . S_SECONDS_SMALL, 'javascript: setRefreshRate(' . zbx_jsvalue($pmid) . ',' . zbx_jsvalue($dollid) . ',' . $value . ',' . zbx_jsvalue($params) . ');' . 'void(0);', null, array('outer' => $value == $cur_interval ? 'pum_b_submenu' : 'pum_o_submenu', 'inner' => array('pum_i_submenu'))); } $submenu['menu_' . $dollid][] = array(); }
public function setMessage($value = null) { if (is_null($value)) { $value = _('Are you sure you want perform this action?'); } // if message will contain single quotes, it will break everything, so it must be escaped $this->msg = zbx_jsvalue($value, false, false); $this->setAction(null); return $this; }
public function setMessage($value = null) { if (is_null($value)) { $value = _('Are you sure you want perform this action?'); } if (!is_string($value)) { return $this->error(_s('Incorrect value for setMessage(): "%s".', $value)); } // if message will contain single quotes, it will break everything, so it must be escaped $this->msg = zbx_jsvalue($value, false, false); $this->setAction(null); }
public function toString($destroy = true) { if (!isset($this->attributes['checked'])) { foreach ($this->object_name as $obj_name) { if (empty($obj_name)) { continue; } zbx_add_post_js('visibility_status_changeds(false, ' . zbx_jsvalue($obj_name) . ', ' . zbx_jsvalue($this->replace_to) . ');'); } } return parent::toString($destroy); }
/** * Process screen. * * @return CDiv (screen inside container) */ public function get() { $this->dataId = 'graph_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid']; $resourceid = !empty($this->screenitem['real_resourceid']) ? $this->screenitem['real_resourceid'] : $this->screenitem['resourceid']; $containerid = 'graph_container_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid']; $graphDims = getGraphDims(); $graphDims['graphHeight'] = $this->screenitem['height']; $graphDims['width'] = $this->screenitem['width']; // get time control $timeControlData = array('id' => $this->getDataId(), 'containerid' => $containerid, 'objDims' => $graphDims, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.screens.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD); // host feature if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) { $newitemid = get_same_item_for_host($resourceid, $this->hostid); $resourceid = !empty($newitemid) ? $newitemid : ''; } if ($this->mode == SCREEN_MODE_PREVIEW && !empty($resourceid)) { $this->action = 'history.php?action=showgraph&itemid=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'] . $this->getProfileUrlParams(); } if (!zbx_empty($resourceid) && $this->mode != SCREEN_MODE_EDIT) { if ($this->mode == SCREEN_MODE_PREVIEW) { $timeControlData['loadSBox'] = 1; } } $timeControlData['src'] = zbx_empty($resourceid) ? 'chart3.php?' : 'chart.php?itemid=' . $resourceid . '&' . $this->screenitem['url'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height']; $timeControlData['src'] .= $this->mode == SCREEN_MODE_EDIT ? '&period=3600&stime=' . date(TIMESTAMP_FORMAT, time()) : '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow']; $timeControlData['src'] .= $this->getProfileUrlParams(); // output if ($this->mode == SCREEN_MODE_JS) { return 'timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ')'; } else { if ($this->mode == SCREEN_MODE_SLIDESHOW) { insert_js('timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');'); } else { zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');'); } if ($this->mode == SCREEN_MODE_EDIT || $this->mode == SCREEN_MODE_SLIDESHOW) { $item = new CDiv(); } elseif ($this->mode == SCREEN_MODE_PREVIEW) { $item = new CLink(null, 'history.php?action=showgraph&itemid=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow']); } $item->setAttribute('id', $containerid); return $this->getOutput($item); } }
function get_js_sizeable_graph($dom_graph_id, $url) { return new CScript(' <script language="JavaScript" type="text/javascript"> <!-- A_SBOX["' . $dom_graph_id . '"] = new Object; A_SBOX["' . $dom_graph_id . '"].shiftT = 17; A_SBOX["' . $dom_graph_id . '"].shiftL = 10; var ZBX_G_WIDTH; if(window.innerWidth) ZBX_G_WIDTH=window.innerWidth; else ZBX_G_WIDTH=document.body.clientWidth; ZBX_G_WIDTH-= 80; insert_sizeable_graph(' . zbx_jsvalue($dom_graph_id) . ',' . zbx_jsvalue($url) . '); --> </script>'); }
include_once 'include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('dstfrm' => array(T_ZBX_STR, O_MAND, P_SYS, NOT_EMPTY, null), 'config' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1,2,3'), NULL), 'gid' => array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0, 65535), null), 'list_name' => array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY, 'isset({save})&&isset({gid})'), 'caption' => array(T_ZBX_STR, O_OPT, null, null, null), 'itemid' => array(T_ZBX_INT, O_OPT, null, DB_ID . '({}!=0)', 'isset({save})'), 'color' => array(T_ZBX_CLR, O_OPT, null, null, 'isset({save})'), 'calc_fnc' => array(T_ZBX_INT, O_OPT, null, IN('0,1,2,4,7,9'), 'isset({save})'), 'axisside' => array(T_ZBX_INT, O_OPT, null, IN(GRAPH_YAXIS_SIDE_LEFT . ',' . GRAPH_YAXIS_SIDE_RIGHT), null), 'add' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form_refresh' => array(T_ZBX_STR, O_OPT, null, null, null)); check_fields($fields); $_REQUEST['caption'] = get_request('caption', ''); $_REQUEST['axisside'] = get_request('axisside', GRAPH_YAXIS_SIDE_LEFT); if (zbx_empty($_REQUEST['caption']) && isset($_REQUEST['itemid']) && $_REQUEST['itemid'] > 0) { $_REQUEST['caption'] = item_description(get_item_by_itemid($_REQUEST['itemid'])); } insert_js_function('add_bitem'); insert_js_function('update_bitem'); if (isset($_REQUEST['save']) && !isset($_REQUEST['gid'])) { insert_js("add_bitem('" . $_REQUEST['dstfrm'] . "'," . zbx_jsvalue($_REQUEST['caption']) . ",'" . $_REQUEST['itemid'] . "','" . $_REQUEST['color'] . "'," . $_REQUEST['calc_fnc'] . "," . $_REQUEST['axisside'] . ");\n"); } if (isset($_REQUEST['save']) && isset($_REQUEST['gid'])) { insert_js("update_bitem('" . $_REQUEST['dstfrm'] . "','" . $_REQUEST['list_name'] . "','" . $_REQUEST['gid'] . "'," . zbx_jsvalue($_REQUEST['caption']) . ",'" . $_REQUEST['itemid'] . "','" . $_REQUEST['color'] . "'," . $_REQUEST['calc_fnc'] . "," . $_REQUEST['axisside'] . ");\n"); } else { echo SBR; $frmGItem = new CFormTable(S_NEW_ITEM_FOR_THE_GRAPH); $frmGItem->setName('graph_item'); $frmGItem->setHelp('web.graph.item.php'); $frmGItem->addVar('dstfrm', $_REQUEST['dstfrm']); $config = get_request('config', 1); $gid = get_request('gid', null); $list_name = get_request('list_name', null); $caption = get_request('caption', ''); $itemid = get_request('itemid', 0); $color = get_request('color', '009900'); $calc_fnc = get_request('calc_fnc', 2); $axisside = get_request('axisside', GRAPH_YAXIS_SIDE_LEFT); $description = '';
/** * Insert javascript to create scroll in time control. * * @static * * @param array $options * @param array $options['timeline'] * @param string $options['profileIdx'] */ public static function insertScreenScrollJs(array $options = array()) { $options['timeline'] = empty($options['timeline']) ? '' : $options['timeline']; $options['profileIdx'] = empty($options['profileIdx']) ? '' : $options['profileIdx']; $timeControlData = array('id' => 'scrollbar', 'loadScroll' => 1, 'mainObject' => 1, 'periodFixed' => CProfile::get($options['profileIdx'] . '.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD); zbx_add_post_js('timeControl.addObject("scrollbar", ' . zbx_jsvalue($options['timeline']) . ', ' . zbx_jsvalue($timeControlData) . ');'); }
* Graph in */ $graphInScreen = new CScreenBase(array('resourcetype' => SCREEN_RESOURCE_GRAPH, 'mode' => SCREEN_MODE_PREVIEW, 'dataId' => 'graph_in', 'profileIdx' => 'web.httptest', 'profileIdx2' => get_request('httptestid'), 'period' => get_request('period'), 'stime' => get_request('stime'))); $graphInScreen->timeline['starttime'] = date(TIMESTAMP_FORMAT, get_min_itemclock_by_itemid($itemIds)); $src = 'chart3.php?height=150' . '&name=' . $httpTest['name'] . '&http_item_type=' . HTTPSTEP_ITEM_TYPE_IN . '&httptestid=' . $httpTest['httptestid'] . '&graphtype=' . GRAPH_TYPE_STACKED . '&period=' . $graphInScreen->timeline['period'] . '&stime=' . $graphInScreen->timeline['stime'] . '&profileIdx=' . $graphInScreen->profileIdx . '&profileIdx2=' . $graphInScreen->profileIdx2; $graphInContainer = new CDiv(new CLink(null, $src), 'flickerfreescreen', 'flickerfreescreen_graph_in'); $graphInContainer->setAttribute('style', 'position: relative'); $graphInContainer->setAttribute('data-timestamp', time()); $graphTable->addRow(array(bold(_('Speed')), $graphInContainer)); $timeControlData = array('id' => 'graph_in', 'containerid' => 'flickerfreescreen_graph_in', 'src' => $src, 'objDims' => $graphDims, 'loadSBox' => 1, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.httptest.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD); zbx_add_post_js('timeControl.addObject("graph_in", ' . zbx_jsvalue($graphInScreen->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');'); $graphInScreen->insertFlickerfreeJs(); /* * Graph time */ $graphTimeScreen = new CScreenBase(array('resourcetype' => SCREEN_RESOURCE_GRAPH, 'mode' => SCREEN_MODE_PREVIEW, 'dataId' => 'graph_time', 'profileIdx' => 'web.httptest', 'profileIdx2' => get_request('httptestid'), 'period' => get_request('period'), 'stime' => get_request('stime'))); $src = 'chart3.php?height=150' . '&name=' . $httpTest['name'] . '&http_item_type=' . HTTPSTEP_ITEM_TYPE_TIME . '&httptestid=' . $httpTest['httptestid'] . '&graphtype=' . GRAPH_TYPE_STACKED . '&period=' . $graphTimeScreen->timeline['period'] . '&stime=' . $graphTimeScreen->timeline['stime'] . '&profileIdx=' . $graphTimeScreen->profileIdx . '&profileIdx2=' . $graphTimeScreen->profileIdx2; $graphTimeContainer = new CDiv(new CLink(null, $src), 'flickerfreescreen', 'flickerfreescreen_graph_time'); $graphTimeContainer->setAttribute('style', 'position: relative'); $graphTimeContainer->setAttribute('data-timestamp', time()); $graphTable->addRow(array(bold(_('Response time')), $graphTimeContainer)); $timeControlData = array('id' => 'graph_time', 'containerid' => 'flickerfreescreen_graph_time', 'src' => $src, 'objDims' => $graphDims, 'loadSBox' => 1, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.httptest.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD); zbx_add_post_js('timeControl.addObject("graph_time", ' . zbx_jsvalue($graphInScreen->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');'); $graphTimeScreen->insertFlickerfreeJs(); // scroll CScreenBuilder::insertScreenScrollJs(array('timeline' => $graphInScreen->timeline)); CScreenBuilder::insertScreenRefreshTimeJs(); CScreenBuilder::insertProcessObjectsJs(); $graphsWidget->addItem($graphTable); $graphsWidget->show(); require_once dirname(__FILE__) . '/include/page_footer.php';
$hosts_list = array(); foreach ($trigger['hosts'] as $num => $trigger_host) { $menus = ''; $host_nodeid = id2nodeid($trigger_host['hostid']); if (isset($scripts_by_hosts[$trigger_host['hostid']])) { foreach ($scripts_by_hosts[$trigger_host['hostid']] as $id => $script) { $script_nodeid = id2nodeid($script['scriptid']); if (bccomp($host_nodeid, $script_nodeid) == 0) { $menus .= "['" . $script['name'] . "',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $trigger_host['hostid'] . "&scriptid=" . $script['scriptid'] . "','" . S_TOOLS . "',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; } } } if (!empty($scripts_by_hosts)) { $menus = "[" . zbx_jsvalue(S_TOOLS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus; } $menus .= "[" . zbx_jsvalue(S_LINKS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],"; $menus .= "['" . S_LATEST_DATA . "',\"javascript: redirect('latest.php?hostid=" . $trigger_host['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; $menus = rtrim($menus, ','); $menus = 'show_popup_menu(event,[' . $menus . '],180);'; $maint_span = null; if ($trigger_host['maintenance_status']) { $text = $trigger_host['maintenance_type'] ? S_NO_DATA_MAINTENANCE : S_NORMAL_MAINTENANCE; $text = ' [' . $text . ']'; $maint_span = new CSpan($text, 'orange pointer'); $maintenanceOptions = array('maintenanceids' => $trigger_host['maintenanceid'], 'output' => API_OUTPUT_EXTEND); $maintenances = CMaintenance::get($maintenanceOptions); $maintenance = reset($maintenances); $maint_hint = new CSpan($maintenance['name'] . ($maintenance['description'] == '' ? '' : ': ' . $maintenance['description'])); $maint_span->setHint($maint_hint); } $hosts_span = new CSpan($trigger_host['host'], 'link_menu');
break; case OPERATION_TYPE_TEMPLATE_ADD: case OPERATION_TYPE_TEMPLATE_REMOVE: if (!isset($this->data['new_operation']['optemplate'])) { $this->data['new_operation']['optemplate'] = array(); } $templateList = new CTable(); $templateList->setAttribute('id', 'opTemplateList'); $templateList->addRow(new CRow(new CCol(array(new CMultiSelect(array('name' => 'discoveryTemplates', 'objectName' => 'templates', 'objectOptions' => array('editable' => true))), new CButton('add', _('Add'), 'return addDiscoveryTemplates();', 'link_menu')), null, 2), null, 'opTemplateListFooter')); // load templates $templateIds = isset($this->data['new_operation']['optemplate']) ? zbx_objectValues($this->data['new_operation']['optemplate'], 'templateid') : array(); if ($templateIds) { $templates = API::Template()->get(array('templateids' => $templateIds, 'output' => array('templateid', 'name'))); order_result($templates, 'name'); $jsInsert = ''; $jsInsert .= 'addPopupValues(' . zbx_jsvalue(array('object' => 'dsc_templateid', 'values' => $templates)) . ');'; zbx_add_post_js($jsInsert); } $caption = OPERATION_TYPE_TEMPLATE_ADD == $this->data['new_operation']['operationtype'] ? _('Link with templates') : _('Unlink from templates'); $newOperationsTable->addRow(array($caption, new CDiv($templateList, 'objectgroup inlineblock border_dotted ui-corner-all'))); break; } // append operation conditions to form list if ($this->data['eventsource'] == 0) { if (!isset($this->data['new_operation']['opconditions'])) { $this->data['new_operation']['opconditions'] = array(); } else { zbx_rksort($this->data['new_operation']['opconditions']); } $allowed_opconditions = get_opconditions_by_eventsource($this->data['eventsource']); $grouped_opconditions = array();
$ack = new CLink(S_YES, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file']); } else { $ack = new CLink(S_NO, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file'], 'on'); } } $description = expand_trigger_description_by_data(zbx_array_merge($trigger, array('clock' => $event['clock'])), ZBX_FLAG_EVENT); $tr_desc = new CSpan($description, 'pointer'); $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " new Array({'triggerid': '" . $trigger['triggerid'] . "', 'lastchange': '" . $event['clock'] . "'})," . zbx_jsvalue($items, true) . ");"); // Duration $tr_event = $event + $trigger; if ($next_event = get_next_event($tr_event, $events, $_REQUEST['hide_unknown'])) { $event['duration'] = zbx_date2age($tr_event['clock'], $next_event['clock']); } else { $event['duration'] = zbx_date2age($tr_event['clock']); } $table->addRow(array(new CLink(zbx_date2str(S_EVENTS_ACTION_TIME_FORMAT, $event['clock']), 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid'], 'action'), is_show_all_nodes() ? get_node_name_by_elid($event['objectid']) : null, $_REQUEST['hostid'] == 0 ? $host['host'] : null, new CSpan($tr_desc, 'link_menu'), new CCol(trigger_value2str($event['value']), get_trigger_value_style($event['value'])), new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority'], $event['value'])), $event['duration'], $config['event_ack_enable'] ? $ack : NULL, $actions)); } } $table = array($paging, $table, $paging); $jsmenu = new CPUMenu(null, 170); $jsmenu->InsertJavaScript(); } $events_wdgt->addItem($table); // NAV BAR $timeline = array('period' => $effectiveperiod, 'starttime' => date('YmdHis', $starttime), 'usertime' => date('YmdHis', $till)); $dom_graph_id = 'scroll_events_id'; $objData = array('id' => 'timeline_1', 'loadSBox' => 0, 'loadImage' => 0, 'loadScroll' => 1, 'dynamic' => 0, 'mainObject' => 1); zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');'); zbx_add_post_js('timeControl.processObjects();'); $events_wdgt->show(); include_once 'include/page_footer.php';
function make_refresh_menu($pmid, $dollid, $cur_interval, $params = null, &$menu, &$submenu, $menu_type = 1) { if ($menu_type == 1) { $intervals = array('10' => 10, '30' => 30, '60' => 60, '120' => 120, '600' => 600, '900' => 900); $title = _('Refresh time in seconds'); } elseif ($menu_type == 2) { $intervals = array('x0.25' => 0.25, 'x0.5' => 0.5, 'x1' => 1, 'x1.5' => 1.5, 'x2' => 2, 'x3' => 3, 'x4' => 4, 'x5' => 5); $title = _('Refresh time multiplier'); } $menu['menu_' . $dollid][] = array($title, null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader'))); foreach ($intervals as $key => $value) { $menu['menu_' . $dollid][] = array($key, 'javascript: setRefreshRate(' . zbx_jsvalue($pmid) . ', ' . zbx_jsvalue($dollid) . ', ' . $value . ', ' . zbx_jsvalue($params) . ');' . 'void(0);', null, array('outer' => $value == $cur_interval ? 'pum_b_submenu' : 'pum_o_submenu', 'inner' => array('pum_i_submenu'))); } $submenu['menu_' . $dollid][] = array(); }
} else { $statusCaption = _('Monitored'); $statusClass = 'enabled'; } $statusScript = 'return Confirm(' . zbx_jsvalue(_('Disable host?')) . ');'; $statusUrl = 'hosts.php?hosts' . SQUAREBRACKETS . '=' . $host['hostid'] . '&go=disable' . url_param('groupid'); break; case HOST_STATUS_NOT_MONITORED: $statusCaption = _('Not monitored'); $statusUrl = 'hosts.php?hosts' . SQUAREBRACKETS . '=' . $host['hostid'] . '&go=activate' . url_param('groupid'); $statusScript = 'return Confirm(' . zbx_jsvalue(_('Enable host?')) . ');'; $statusClass = 'disabled'; break; default: $statusCaption = _('Unknown'); $statusScript = 'return Confirm(' . zbx_jsvalue(_('Disable host?')) . ');'; $statusUrl = 'hosts.php?hosts' . SQUAREBRACKETS . '=' . $host['hostid'] . '&go=disable' . url_param('groupid'); $statusClass = 'unknown'; } $status = new CLink($statusCaption, $statusUrl, $statusClass, $statusScript); if (empty($host['parentTemplates'])) { $hostTemplates = '-'; } else { $hostTemplates = array(); order_result($host['parentTemplates'], 'name'); foreach ($host['parentTemplates'] as $template) { $caption = array(); $caption[] = new CLink(CHtml::encode($template['name']), 'templates.php?form=update&templateid=' . $template['templateid'], 'unknown'); if (!empty($templates[$template['templateid']]['parentTemplates'])) { order_result($templates[$template['templateid']]['parentTemplates'], 'name'); $caption[] = ' (';
$dashboardWidget = new CWidget('dashboard_wdgt'); $dashboardWidget->setClass('header'); $dashboardWidget->addHeader(_('PERSONAL DASHBOARD'), array(new CIcon(_s('Configure (Filter %s)', $dashconf['filterEnable'] ? _('Enabled') : _('Disabled')), $dashconf['filterEnable'] ? 'iconconfig_hl' : 'iconconfig', "document.location = 'dashconf.php';"), SPACE, get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen'])))); // js menu arrays $menu = array(); $submenu = array(); make_graph_menu($menu, $submenu); make_sysmap_menu($menu, $submenu); make_screen_menu($menu, $submenu); make_refresh_menu('mainpage', 'hat_syssum', CProfile::get('web.dashboard.rf_rate.hat_syssum', 60), null, $menu, $submenu); make_refresh_menu('mainpage', 'hat_hoststat', CProfile::get('web.dashboard.rf_rate.hat_hoststat', 60), null, $menu, $submenu); make_refresh_menu('mainpage', 'hat_stszbx', CProfile::get('web.dashboard.rf_rate.hat_stszbx', 60), null, $menu, $submenu); make_refresh_menu('mainpage', 'hat_lastiss', CProfile::get('web.dashboard.rf_rate.hat_lastiss', 60), null, $menu, $submenu); make_refresh_menu('mainpage', 'hat_webovr', CProfile::get('web.dashboard.rf_rate.hat_webovr', 60), null, $menu, $submenu); make_refresh_menu('mainpage', 'hat_dscvry', CProfile::get('web.dashboard.rf_rate.hat_dscvry', 60), null, $menu, $submenu); insert_js('var page_menu=' . zbx_jsvalue($menu) . ";\n" . 'var page_submenu=' . zbx_jsvalue($submenu) . ";\n"); /* * Left column */ $leftColumn = array(); // favorite graphs $graph_menu = get_icon('menu', array('menu' => 'graphs')); $fav_grph = new CUIWidget('hat_favgrph', make_favorite_graphs(), CProfile::get('web.dashboard.hats.hat_favgrph.state', 1)); $fav_grph->setHeader(_('Favourite graphs'), array($graph_menu)); $fav_grph->setFooter(new CLink(_('Graphs') . ' »', 'charts.php', 'highlight'), true); $leftColumn[] = $fav_grph; // favorite screens $screen_menu = get_icon('menu', array('menu' => 'screens')); $fav_scr = new CUIWidget('hat_favscr', make_favorite_screens(), CProfile::get('web.dashboard.hats.hat_favscr.state', 1)); $fav_scr->setHeader(_('Favourite screens'), array($screen_menu)); $fav_scr->setFooter(new CLink(_('Screens') . ' »', 'screens.php', 'highlight'), true);
function pager($items, $itemsPerPage, $currentPage, $urlParams = array(), $removeUrlParams = array()) { $startPage = 1; $pagesCount = floor($items / $itemsPerPage) + 1; $endPage = $pagesCount; $url = new Curl(); $pageLine = array(); if (is_array($urlParams) && $urlParams) { foreach ($urlParams as $key => $value) { $url->setArgument($key, $value); } } $removeUrlParams = array_merge($removeUrlParams, array('go', 'form', 'delete', 'cancel')); foreach ($removeUrlParams as $param) { $url->removeArgument($param); } if ($startPage > 1) { $url->setArgument('page', 1); $pageLine[] = new CLink('<< ' . _x('First', 'page navigation'), $url->getUrl(), null, null, true); $pageLine[] = ' '; } if ($currentPage > 1) { $url->setArgument('page', $currentPage - 1); $pageLine[] = new CLink('< ' . _x('Previous', 'page navigation'), $url->getUrl(), null, null, true); $pageLine[] = ' | '; } for ($p = $startPage; $p <= $pagesCount; $p++) { if ($p > $endPage) { break; } if ($p == $currentPage) { $pagespan = new CSpan($p, 'bold textcolorstyles'); } else { $url->setArgument('page', $p); $pagespan = new CLink($p, $url->getUrl(), null, null, true); } $pageLine[] = $pagespan; $pageLine[] = ' | '; } array_pop($pageLine); if ($currentPage < $pagesCount) { $pageLine[] = ' | '; $url->setArgument('page', $currentPage + 1); $pageLine[] = new CLink(_x('Next', 'page navigation') . ' >', $url->getUrl(), null, null, true); } if ($p < $pagesCount) { $pageLine[] = ' '; $url->setArgument('page', $pagesCount); $pageLine[] = new CLink(_x('Last', 'page navigation') . ' >>', $url->getUrl(), null, null, true); } $table = new CTable(null, 'paging'); $table->addRow(new CCol($pageLine)); $pageView = array(); $pageView[] = _('Displaying') . SPACE; if ($items > $itemsPerPage) { $pageView[] = new CSpan($itemsPerPage * $currentPage, 'info'); $pageView[] = SPACE . _('to') . SPACE; } $to = min($itemsPerPage * $currentPage + $itemsPerPage, $items); $pageView[] = new CSpan($to, 'info'); $pageView[] = SPACE . _('of') . SPACE; $pageView[] = new CSpan($items, 'info'); $pageView[] = SPACE . _('found'); $pageView = new CSpan($pageView); zbx_add_post_js('insertInElement("numrows", ' . zbx_jsvalue($pageView->toString()) . ', "div");'); return $table; }
/** * Adds a hint box to the elemt. * * @param string|array|CTag $text hint content * @param string $spanClass wrap the content in a span element and assign a this class to the span * @param bool $byClick if set to true, it will be possible to "freeze" the hint box via a mouse * click * * @return bool */ public function setHint($text, $spanClass = '', $byClick = true) { if (empty($text)) { return false; } encodeValues($text); $text = unpack_object($text); $this->addAction('onmouseover', 'hintBox.HintWraper(event, this, ' . zbx_jsvalue($text) . ', "' . $spanClass . '");'); if ($byClick) { $this->addAction('onclick', 'hintBox.showStaticHint(event, this, ' . zbx_jsvalue($text) . ', "' . $spanClass . '");'); } return true; }
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; }
} // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('dstfrm' => array(T_ZBX_STR, O_MAND, P_SYS, NOT_EMPTY, NULL), 'media' => array(T_ZBX_INT, O_OPT, P_SYS, NULL, NULL), 'mediatypeid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({add})'), 'sendto' => array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({add})'), 'period' => array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({add})'), 'active' => array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({add})'), 'severity' => array(T_ZBX_INT, O_OPT, NULL, NOT_EMPTY, NULL), 'add' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, NULL, NULL), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), 'form_refresh' => array(T_ZBX_STR, O_OPT, NULL, NULL, NULL)); check_fields($fields); insert_js_function('add_media'); if (isset($_REQUEST['add'])) { if (!validate_period($_REQUEST['period'])) { error(S_INCORRECT_TIME_PERIOD); } else { $severity = 0; $_REQUEST['severity'] = get_request('severity', array()); foreach ($_REQUEST['severity'] as $id) { $severity |= 1 << $id; } echo '<script language="JavaScript" type="text/javascript"><!-- add_media("' . $_REQUEST['dstfrm'] . '",' . $_REQUEST['media'] . ',' . zbx_jsvalue($_REQUEST['mediatypeid']) . ',"' . $_REQUEST['sendto'] . '","' . $_REQUEST['period'] . '",' . $_REQUEST['active'] . ',' . $severity . ');' . "\n" . '--></script>'; } } echo SBR; if (isset($_REQUEST['media']) && !isset($_REQUEST['form_refresh'])) { $rq_severity = get_request('severity', 63); $severity = array(); for ($i = 0; $i < 6; $i++) { if ($rq_severity & 1 << $i) { $severity[$i] = $i; } } } else { $severity = get_request('severity', array(0, 1, 2, 3, 4, 5)); } $media = get_request('media', -1);
if (isset($_REQUEST['save'])) { $result = true; if ((!isset($_REQUEST['stepid']) || isset($_REQUEST['stepid']) && $_REQUEST['name'] !== $_REQUEST['old_name']) && isset($_REQUEST['steps_names'])) { foreach ($_REQUEST['steps_names'] as $name) { if ($name === $_REQUEST['name']) { show_error_message(_s('Step with name "%1$s" already exists.', $name)); $result = false; } } } } if (isset($_REQUEST['save']) && $result) { if (!isset($_REQUEST['stepid'])) { insert_js('add_httpstep(' . zbx_jsvalue($_REQUEST['dstfrm']) . ',' . zbx_jsvalue($_REQUEST['name']) . ',' . zbx_jsvalue($_REQUEST['timeout']) . ',' . zbx_jsvalue($_REQUEST['url']) . ',' . zbx_jsvalue($_REQUEST['posts']) . ',' . zbx_jsvalue($_REQUEST['variables']) . ',' . zbx_jsvalue($_REQUEST['required']) . ',' . zbx_jsvalue($_REQUEST['status_codes']) . ");\n"); } else { insert_js('update_httpstep(' . zbx_jsvalue($_REQUEST['dstfrm']) . ',' . zbx_jsvalue($_REQUEST['list_name']) . ',' . zbx_jsvalue($_REQUEST['stepid']) . ',' . zbx_jsvalue($_REQUEST['name']) . ',' . zbx_jsvalue($_REQUEST['timeout']) . ',' . zbx_jsvalue($_REQUEST['url']) . ',' . zbx_jsvalue($_REQUEST['posts']) . ',' . zbx_jsvalue($_REQUEST['variables']) . ',' . zbx_jsvalue($_REQUEST['required']) . ',' . zbx_jsvalue($_REQUEST['status_codes']) . ");\n"); } } else { $httpPopupForm = new CForm(); $httpPopupForm->addVar('dstfrm', get_request('dstfrm', null)); $httpPopupForm->addVar('stepid', get_request('stepid', null)); $httpPopupForm->addVar('list_name', get_request('list_name', null)); $httpPopupForm->addVar('templated', get_request('templated', null)); $httpPopupForm->addVar('old_name', get_request('old_name', null)); $httpPopupForm->addVar('steps_names', get_request('steps_names', null)); $httpPopupFormList = new CFormList('httpPopupFormList'); $httpPopupFormList->addRow(_('Name'), new CTextBox('name', get_request('name', ''), ZBX_TEXTBOX_STANDARD_SIZE, get_request('templated', null), 64)); $httpPopupFormList->addRow(_('URL'), new CTextBox('url', get_request('url', ''), ZBX_TEXTBOX_STANDARD_SIZE)); $httpPopupFormList->addRow(_('Post'), new CTextArea('posts', get_request('posts', ''))); $httpPopupFormList->addRow(_('Variables'), new CTextArea('variables', get_request('variables', ''))); $httpPopupFormList->addRow(_('Timeout'), new CNumericBox('timeout', get_request('timeout', 15), 5));
function make_latest_issues($params = array()) { global $USER_DETAILS; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY); $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array()); $scripts_by_hosts = get_accessible_scripts_by_hosts($available_hosts); $config = select_config(); $sql_select = ''; $sql_from = ''; $sql_where = ''; $limit = 20; if (!empty($params)) { if (isset($params['limit'])) { $limit = $params['limit']; } if (isset($params['groupid']) && $params['groupid'] > 0) { $sql_select .= ',g.name '; $sql_from .= ',groups g '; $sql_where .= ' AND g.groupid=hg.groupid ' . ' AND hg.groupid=' . $params['groupid']; } if (isset($params['hostid']) && $params['hostid'] > 0) { $sql_where .= ' AND h.hostid=' . $params['hostid']; } } $table = new CTableInfo(); $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, isset($params['groupid']) && $params['groupid'] > 0 ? S_GROUP : null, S_HOST, S_ISSUE, S_LAST_CHANGE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS)); $sql = 'SELECT DISTINCT t.triggerid,t.status,t.description,t.expression,t.priority,t.lastchange,t.value,h.host,h.hostid ' . $sql_select . ' FROM triggers t,hosts h,items i,functions f,hosts_groups hg ' . $sql_from . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.value=' . TRIGGER_VALUE_TRUE . $sql_where . ' ORDER BY t.lastchange DESC'; $result = DBselect($sql, $limit); while ($row = DBfetch($result)) { // Check for dependencies if (trigger_dependent($row["triggerid"])) { continue; } $host = null; $menus = ''; $host_nodeid = id2nodeid($row['hostid']); foreach ($scripts_by_hosts[$row['hostid']] as $id => $script) { $script_nodeid = id2nodeid($script['scriptid']); if (bccomp($host_nodeid, $script_nodeid) == 0) { $menus .= "['" . $script['name'] . "',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $row['hostid'] . "&scriptid=" . $script['scriptid'] . "','" . S_TOOLS . "',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; } } $menus .= "[" . zbx_jsvalue(S_LINKS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],"; $menus .= "['" . S_LATEST_DATA . "',\"javascript: redirect('latest.php?groupid=0&hostid=" . $row['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; $menus = rtrim($menus, ','); $menus = "show_popup_menu(event,[[" . zbx_jsvalue(S_TOOLS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus . "],180);"; $host = new CSpan($row['host'], 'link'); $host->setAttribute('onclick', 'javascript: ' . $menus); $host->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $event_sql = 'SELECT DISTINCT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged, t.type, t.url ' . ' FROM events e, triggers t ' . ' WHERE e.object=' . EVENT_SOURCE_TRIGGERS . ' AND e.objectid=' . $row['triggerid'] . ' AND t.triggerid=e.objectid ' . ' AND e.value=' . TRIGGER_VALUE_TRUE . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC'; $res_events = DBSelect($event_sql, 1); while ($row_event = DBfetch($res_events)) { $ack = NULL; if ($config['event_ack_enable']) { if ($row_event['acknowledged'] == 1) { $ack_info = make_acktab_by_eventid($row_event['eventid']); $ack_info->setAttribute('style', 'width: auto;'); $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row_event['eventid'], 'action'); $ack->setHint($ack_info); } else { $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row_event['eventid'], 'on'); } } // $description = expand_trigger_description($row['triggerid']); $description = expand_trigger_description_by_data(array_merge($row, array('clock' => $row_event['clock'])), ZBX_FLAG_EVENT); //actions $actions = get_event_actions_stat_hints($row_event['eventid']); $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'events.php?triggerid=' . $row['triggerid'] . '&source=0&show_unknown=1&nav_time=' . $row_event['clock'], 'action'); if ($row_event['url']) { $description = new CLink($description, $row_event['url'], 'action', null, true); } else { $description = new CSpan($description, 'pointer'); } $description = new CCol($description, get_severity_style($row["priority"])); $description->setHint(make_popup_eventlist($row_event['eventid'], $row['type'])); $table->addRow(array(get_node_name_by_elid($row['triggerid']), $host, $description, $clock, zbx_date2age($row_event['clock']), $ack, $actions)); } unset($row, $description, $actions, $alerts, $hint); } $table->setFooter(new CCol(S_UPDATED . ': ' . date("H:i:s", time()))); return $table; }
} }); } function selectUniquenessCriteriaDefault() { jQuery('#uniqueness_criteria_ip').attr('checked', 'checked'); } jQuery(document).ready(function() { addPopupValues(<?php echo zbx_jsvalue(array_values($this->data['drule']['dchecks'])); ?> ); jQuery("input:radio[name='uniqueness_criteria'][value=<?php echo zbx_jsvalue($this->data['drule']['uniqueness_criteria']); ?> ]").attr('checked', 'checked'); jQuery('#newCheck').click(showNewCheckForm); jQuery('#clone').click(function() { jQuery('#druleid, #delete, #clone').remove(); jQuery('#cancel').addClass('ui-corner-left'); jQuery('#form').val('clone'); jQuery('#name').focus(); }); }); (function($) { $.fn.serializeJSON = function() { var json = {};
function get_user_actionmenu($userid) { $usr_grp_all_in = array(); $usr_grp_gui_in = array(); $usr_grp_status_in = array(); $sql = 'SELECT DISTINCT g.name, g.usrgrpid, g.gui_access, g.users_status ' . ' FROM users_groups ug, usrgrp g ' . ' WHERE ug.userid=' . $userid . ' AND g.usrgrpid=ug.usrgrpid ' . ' AND ' . DBin_node('g.usrgrpid', get_current_nodeid(false)); $res = DBselect($sql); while ($group = DBFetch($res)) { $group['name'] = htmlspecialchars($group['name']); $gui_access = $group['gui_access']; $users_status = $group['users_status']; unset($group['gui_access']); unset($group['users_status']); $usr_grp_all_in[] = $group; if ($gui_access != GROUP_GUI_ACCESS_SYSTEM) { $usr_grp_gui_in[] = $group; } if ($users_status == GROUP_STATUS_DISABLED) { $usr_grp_status_in[] = $group; } } $action = new CSpan(S_SELECT); $script = new CScript("javascript: create_user_menu(event," . $userid . "," . zbx_jsvalue($usr_grp_all_in) . "," . zbx_jsvalue($usr_grp_gui_in) . "," . zbx_jsvalue($usr_grp_status_in) . ");"); $action->AddAction('onclick', $script); $action->AddOption('onmouseover', 'javascript: this.style.cursor = "pointer";'); return $action; }
/** * Returns paging line. * * @param array $items list of items * * @return CTable */ function getPagingLine(&$items) { global $page; $config = select_config(); $searchLimit = ''; if ($config['search_limit'] < count($items)) { array_pop($items); $searchLimit = '+'; } $rowsPerPage = CWebUser::$data['rows_per_page']; $itemsCount = count($items); $pagesCount = $itemsCount > 0 ? ceil($itemsCount / $rowsPerPage) : 1; $currentPage = getPageNumber(); if ($currentPage < 1) { $currentPage = 1; } if ($itemsCount < ($currentPage - 1) * $rowsPerPage) { $currentPage = $pagesCount; } $start = ($currentPage - 1) * $rowsPerPage; CProfile::update('web.paging.lastpage', $page['file'], PROFILE_TYPE_STR); CProfile::update('web.paging.page', $currentPage, PROFILE_TYPE_INT); // trim array with items to contain items for current page $items = array_slice($items, $start, $rowsPerPage, true); // viewed pages (better to use not odd) $pagingNavRange = 11; $endPage = $currentPage + floor($pagingNavRange / 2); if ($endPage < $pagingNavRange) { $endPage = $pagingNavRange; } if ($endPage > $pagesCount) { $endPage = $pagesCount; } $startPage = $endPage > $pagingNavRange ? $endPage - $pagingNavRange + 1 : 1; $pageLine = array(); $table = null; if ($pagesCount > 1) { $url = CUrlFactory::getContextUrl(); if ($startPage > 1) { $url->setArgument('page', 1); $pageLine[] = new CLink('<< ' . _x('First', 'page navigation'), $url->getUrl(), null, null, true); $pageLine[] = ' '; } if ($currentPage > 1) { $url->setArgument('page', $currentPage - 1); $pageLine[] = new CLink('< ' . _x('Previous', 'page navigation'), $url->getUrl(), null, null, true); $pageLine[] = ' | '; } for ($p = $startPage; $p <= $pagesCount; $p++) { if ($p > $endPage) { break; } if ($p == $currentPage) { $pagespan = new CSpan($p, 'bold textcolorstyles'); } else { $url->setArgument('page', $p); $pagespan = new CLink($p, $url->getUrl(), null, null, true); } $pageLine[] = $pagespan; $pageLine[] = ' | '; } array_pop($pageLine); if ($currentPage < $pagesCount) { $pageLine[] = ' | '; $url->setArgument('page', $currentPage + 1); $pageLine[] = new CLink(_x('Next', 'page navigation') . ' >', $url->getUrl(), null, null, true); } if ($p < $pagesCount) { $pageLine[] = ' '; $url->setArgument('page', $pagesCount); $pageLine[] = new CLink(_x('Last', 'page navigation') . ' >>', $url->getUrl(), null, null, true); } $table = new CTable(null, 'paging'); $table->addRow(new CCol($pageLine)); } $viewFromPage = ($currentPage - 1) * $rowsPerPage + 1; $viewTillPage = $currentPage * $rowsPerPage; if ($viewTillPage > $itemsCount) { $viewTillPage = $itemsCount; } $pageView = array(); $pageView[] = _('Displaying') . SPACE; if ($itemsCount > 0) { $pageView[] = new CSpan($viewFromPage, 'info'); $pageView[] = SPACE . _('to') . SPACE; } $pageView[] = new CSpan($viewTillPage, 'info'); $pageView[] = SPACE . _('of') . SPACE; $pageView[] = new CSpan($itemsCount, 'info'); $pageView[] = $searchLimit; $pageView[] = SPACE . _('found'); $pageView = new CSpan($pageView); zbx_add_post_js('insertInElement("numrows", ' . zbx_jsvalue($pageView->toString()) . ', "div");'); return $table; }
var form = window.opener.document.forms[formname]; if(!form){ close_window(); return false; } add_var_to_opener_obj(form,list_name + '[' + stepid + '][name]',name); add_var_to_opener_obj(form,list_name + '[' + stepid + '][timeout]',timeout); add_var_to_opener_obj(form,list_name + '[' + stepid + '][url]',url); add_var_to_opener_obj(form,list_name + '[' + stepid + '][posts]',posts); add_var_to_opener_obj(form,list_name + '[' + stepid + '][required]',required); add_var_to_opener_obj(form,list_name + '[' + stepid + '][status_codes]',status_codes); form.submit(); close_window(); return true; } <?php echo "update_httpstep(" . zbx_jsvalue($_REQUEST['dstfrm']) . "," . zbx_jsvalue($_REQUEST['list_name']) . "," . zbx_jsvalue($_REQUEST['stepid']) . "," . zbx_jsvalue($_REQUEST['name']) . "," . zbx_jsvalue($_REQUEST['timeout']) . "," . zbx_jsvalue($_REQUEST['url']) . "," . zbx_jsvalue($_REQUEST['posts']) . "," . zbx_jsvalue($_REQUEST['required']) . "," . zbx_jsvalue($_REQUEST['status_codes']) . ");\n"; ?> --> </script> <?php } else { echo SBR; insert_httpstep_form(); } include_once "include/page_footer.php";
} $sub_menu_item = new CLink($sub_page['menu_text'], $sub_page['menu_url'], $sub_page['class'] . ' nowrap'); if ($sub_page['selected']) { $sub_menu_item = new CSpan($sub_menu_item, 'active nowrap'); } $sub_menu_row[] = $sub_menu_item; $sub_menu_row[] = new CSpan(SPACE . ' | ' . SPACE, 'divider'); } $sub_menu_div = new CDiv($sub_menu_row); $sub_menu_div->setAttribute('id', 'sub_' . $label); $sub_menu_div->addAction('onmouseover', 'javascript: MMenu.submenu_mouseOver();'); $sub_menu_div->addAction('onmouseout', 'javascript: MMenu.mouseOut();'); if (isset($page['menu']) && $page['menu'] == $label) { $menu_selected = true; $sub_menu_div->setAttribute('style', 'display: block;'); insert_js('MMenu.def_label = ' . zbx_jsvalue($label)); } else { $sub_menu_div->setAttribute('style', 'display: none;'); } $menu_divs[] = $sub_menu_div; } $sub_menu_div = new CDiv(SPACE); $sub_menu_div->setAttribute('id', 'sub_empty'); $sub_menu_div->setAttribute('style', 'display: ' . ($menu_selected ? 'none;' : 'block;')); $menu_divs[] = $sub_menu_div; $search_form = new CForm('search.php'); $search_form->setMethod('get'); $search_form->setAttribute('class', 'thin'); $search_form->addItem(new CDiv(array(S_SEARCH_BIG . ': ', new CTextBox('search', '', 15)))); $search_div = new CDiv($search_form); $search_div->setAttribute('id', 'zbx_search');
// create table $servicesParentTable = new CTableInfo(); $servicesParentTable->setHeader(array(_('Service'), _('Status calculation'), _('Trigger'))); $prefix = null; // root $description = new CLink(_('root'), '#', null, 'javascript: jQuery(\'#parent_name\', window.opener.document).val(' . zbx_jsvalue(_('root')) . '); jQuery(\'#parentname\', window.opener.document).val(' . zbx_jsvalue(_('root')) . '); jQuery(\'#parentid\', window.opener.document).val(' . zbx_jsvalue(0) . '); self.close(); return false;'); $servicesParentTable->addRow(array(array($prefix, $description), _('Note'), '-')); // others foreach ($this->data['db_pservices'] as $db_service) { $description = new CSpan($db_service['name'], 'link'); $description->setAttribute('onclick', 'javascript: jQuery(\'#parent_name\', window.opener.document).val(' . zbx_jsvalue($db_service['name']) . '); jQuery(\'#parentname\', window.opener.document).val(' . zbx_jsvalue($db_service['name']) . '); jQuery(\'#parentid\', window.opener.document).val(' . zbx_jsvalue($db_service['serviceid']) . '); self.close(); return false;'); $servicesParentTable->addRow(array(array($prefix, $description), serviceAlgorythm($db_service['algorithm']), $db_service['trigger'])); } $column = new CCol(new CButton('cancel', _('Cancel'), 'javascript: self.close();')); $column->setAttribute('style', 'text-align:right;'); $servicesParentTable->setFooter($column); // append table to form $servicesParentForm->addItem($servicesParentTable); // append form to widget $servicesParentWidget->addItem($servicesParentForm); return $servicesParentWidget;