Example #1
0
 /**
  * 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));
     }
 }
Example #2
0
 /**
  * @param array $options['objectOptions'] 	an array of parameters to be added to the request URL
  *
  * @see jQuery.multiSelect()
  */
 public function __construct(array $options = [])
 {
     parent::__construct('div', true);
     $this->addClass('multiselect');
     $this->setId(zbx_formatDomId($options['name']));
     // url
     $url = new CUrl('jsrpc.php');
     $url->setArgument('type', PAGE_TYPE_TEXT_RETURN_JSON);
     $url->setArgument('method', 'multiselect.get');
     $url->setArgument('objectName', $options['objectName']);
     if (!empty($options['objectOptions'])) {
         foreach ($options['objectOptions'] as $optionName => $optionvalue) {
             $url->setArgument($optionName, $optionvalue);
         }
     }
     $params = ['url' => $url->getUrl(), 'name' => $options['name'], 'labels' => ['No matches found' => _('No matches found'), 'More matches found...' => _('More matches found...'), 'type here to search' => _('type here to search'), 'new' => _('new'), 'Select' => _('Select')]];
     if (array_key_exists('data', $options)) {
         $params['data'] = zbx_cleanHashes($options['data']);
     }
     foreach (['ignored', 'defaultValue', 'disabled', 'selectedLimit', 'addNew'] as $option) {
         if (array_key_exists($option, $options)) {
             $params[$option] = $options[$option];
         }
     }
     if (array_key_exists('popup', $options)) {
         foreach (['parameters', 'width', 'height'] as $option) {
             if (array_key_exists($option, $options['popup'])) {
                 $params['popup'][$option] = $options['popup'][$option];
             }
         }
     }
     zbx_add_post_js('jQuery("#' . $this->getAttribute('id') . '").multiSelect(' . CJs::encodeJson($params) . ');');
 }
function local_generateHeader($data)
{
    // only needed for zbx_construct_menu
    global $page;
    header('Content-Type: text/html; charset=UTF-8');
    // construct menu
    $main_menu = [];
    $sub_menus = [];
    zbx_construct_menu($main_menu, $sub_menus, $page, $data['controller']['action']);
    $pageHeader = new CView('layout.htmlpage.header', ['javascript' => ['files' => $data['javascript']['files']], 'page' => ['title' => $data['page']['title']], 'user' => ['lang' => CWebUser::$data['lang'], 'theme' => CWebUser::$data['theme']]]);
    echo $pageHeader->getOutput();
    if ($data['fullscreen'] == 0) {
        global $ZBX_SERVER_NAME;
        $pageMenu = new CView('layout.htmlpage.menu', ['server_name' => isset($ZBX_SERVER_NAME) ? $ZBX_SERVER_NAME : '', 'menu' => ['main_menu' => $main_menu, 'sub_menus' => $sub_menus, 'selected' => $page['menu']], 'user' => ['is_guest' => CWebUser::isGuest(), 'alias' => CWebUser::$data['alias'], 'name' => CWebUser::$data['name'], 'surname' => CWebUser::$data['surname']]]);
        echo $pageMenu->getOutput();
    }
    echo '<div class="' . ZBX_STYLE_ARTICLE . '">';
    // should be replaced with addPostJS() at some point
    zbx_add_post_js('initMessages({});');
    // if a user logs in after several unsuccessful attempts, display a warning
    if ($failedAttempts = CProfile::get('web.login.attempt.failed', 0)) {
        $attempt_ip = CProfile::get('web.login.attempt.ip', '');
        $attempt_date = CProfile::get('web.login.attempt.clock', 0);
        $error_msg = _n('%4$s failed login attempt logged. Last failed attempt was from %1$s on %2$s at %3$s.', '%4$s failed login attempts logged. Last failed attempt was from %1$s on %2$s at %3$s.', $attempt_ip, zbx_date2str(DATE_FORMAT, $attempt_date), zbx_date2str(TIME_FORMAT, $attempt_date), $failedAttempts);
        error($error_msg);
        CProfile::update('web.login.attempt.failed', 0, PROFILE_TYPE_INT);
    }
    show_messages();
}
 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);
 }
Example #5
0
function add_doll_objects($ref_tab, $pmid = 'mainpage')
{
    $upd_script = array();
    foreach ($ref_tab as $id => $doll) {
        $upd_script[$doll['id']] = format_doll_init($doll);
    }
    zbx_add_post_js('initPMaster(' . zbx_jsvalue($pmid) . ',' . zbx_jsvalue($upd_script) . ');');
}
Example #6
0
 public function useJQueryStyle()
 {
     $this->setAttribute('class', $this->getAttribute('class') . ' jqueryinputset');
     if (!defined('ZBX_JQUERY_INPUTSET')) {
         define('ZBX_JQUERY_INPUTSET', true);
         zbx_add_post_js('setTimeout(function() { jQuery("div.jqueryinputset").buttonset(); }, 10);');
     }
     return $this;
 }
 public function useJQueryStyle($class = '')
 {
     $this->jQuery = true;
     $this->attr('class', 'jqueryinput ' . $this->getAttribute('class') . ' ' . $class);
     if (!defined('ZBX_JQUERY_INPUT')) {
         define('ZBX_JQUERY_INPUT', true);
         zbx_add_post_js('jQuery("input.jqueryinput").button();');
     }
     return $this;
 }
Example #8
0
 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);
 }
 public function __construct(&$form, $name, $value = null, $size = 10)
 {
     zbx_add_post_js('if (IE7) $$("select option[disabled]").each(function(e) { e.setStyle({color: "gray"}); });');
     $this->form =& $form;
     $this->name = $name . '_tweenbox';
     $this->varname = $name;
     $this->value = zbx_toHash($value);
     $this->id_l = $this->varname . '_left';
     $this->id_r = $this->varname . '_right';
     $this->lbox = new CListBox($this->id_l, null, $size);
     $this->rbox = new CListBox($this->id_r, null, $size);
     $this->lbox->setAttribute('style', 'width: 280px;');
     $this->rbox->setAttribute('style', 'width: 280px;');
 }
Example #10
0
 /**
  * @param array $options['objectOptions'] 	an array of parameters to be added to the request URL
  *
  * @see jQuery.multiSelect()
  */
 public function __construct(array $options = array())
 {
     parent::__construct('div', 'yes');
     $this->addClass('multiselect');
     $this->attr('id', zbx_formatDomId($options['name']));
     // url
     $url = new Curl('jsrpc.php');
     $url->setArgument('type', PAGE_TYPE_TEXT_RETURN_JSON);
     $url->setArgument('method', 'multiselect.get');
     $url->setArgument('objectName', $options['objectName']);
     if (!empty($options['objectOptions'])) {
         foreach ($options['objectOptions'] as $optionName => $optionvalue) {
             $url->setArgument($optionName, $optionvalue);
         }
     }
     $params = array('id' => $this->getAttribute('id'), 'url' => $url->getUrl(), 'name' => $options['name'], 'labels' => array('No matches found' => _('No matches found'), 'More matches found...' => _('More matches found...'), 'type here to search' => _('type here to search'), 'new' => _('new'), 'Select' => _('Select')), 'data' => empty($options['data']) ? array() : zbx_cleanHashes($options['data']), 'ignored' => isset($options['ignored']) ? $options['ignored'] : null, 'defaultValue' => isset($options['defaultValue']) ? $options['defaultValue'] : null, 'disabled' => isset($options['disabled']) ? $options['disabled'] : false, 'selectedLimit' => isset($options['selectedLimit']) ? $options['selectedLimit'] : null, 'addNew' => isset($options['addNew']) ? $options['addNew'] : false, 'popup' => array('parameters' => isset($options['popup']['parameters']) ? $options['popup']['parameters'] : null, 'width' => isset($options['popup']['width']) ? $options['popup']['width'] : null, 'height' => isset($options['popup']['height']) ? $options['popup']['height'] : null, 'buttonClass' => isset($options['popup']['buttonClass']) ? $options['popup']['buttonClass'] : null));
     zbx_add_post_js('jQuery("#' . $this->getAttribute('id') . '").multiSelect(' . CJs::encodeJson($params) . ')');
 }
 /**
  * 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=' . HISTORY_GRAPH . '&itemids[]=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'] . $this->getProfileUrlParams();
     }
     if ($resourceid && $this->mode != SCREEN_MODE_EDIT) {
         if ($this->mode == SCREEN_MODE_PREVIEW) {
             $timeControlData['loadSBox'] = 1;
         }
     }
     $timeControlData['src'] = $resourceid ? 'chart.php?itemids[]=' . $resourceid . '&' . $this->screenitem['url'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'] : 'chart3.php?';
     $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() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ')';
     } else {
         if ($this->mode == SCREEN_MODE_SLIDESHOW) {
             insert_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');');
         } else {
             zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($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=' . HISTORY_GRAPH . '&itemids[]=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow']);
         }
         $item->setAttribute('id', $containerid);
         return $this->getOutput($item);
     }
 }
Example #12
0
function insert_show_color_picker_javascript()
{
    global $SHOW_COLOR_PICKER_SCRIPT_ISERTTED;
    if ($SHOW_COLOR_PICKER_SCRIPT_ISERTTED) {
        return;
    }
    $SHOW_COLOR_PICKER_SCRIPT_ISERTTED = true;
    $table = '';
    $table .= '<table cellspacing="0" cellpadding="1">';
    $table .= '<tr>';
    /* gray colors */
    foreach (array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'b', 'C', 'D', 'E', 'F') as $c) {
        $color = $c . $c . $c . $c . $c . $c;
        $table .= '<td>' . unpack_object(new CColorCell(null, $color, 'set_color(\\\'' . $color . '\\\')')) . '</td>';
    }
    $table .= '</tr>';
    /* other colors */
    $colors = array(array('r' => 0, 'g' => 0, 'b' => 1), array('r' => 0, 'g' => 1, 'b' => 0), array('r' => 1, 'g' => 0, 'b' => 0), array('r' => 0, 'g' => 1, 'b' => 1), array('r' => 1, 'g' => 0, 'b' => 1), array('r' => 1, 'g' => 1, 'b' => 0));
    $brigs = array(array(0 => '0', 1 => '3'), array(0 => '0', 1 => '4'), array(0 => '0', 1 => '5'), array(0 => '0', 1 => '6'), array(0 => '0', 1 => '7'), array(0 => '0', 1 => '8'), array(0 => '0', 1 => '9'), array(0 => '0', 1 => 'A'), array(0 => '0', 1 => 'B'), array(0 => '0', 1 => 'C'), array(0 => '0', 1 => 'D'), array(0 => '0', 1 => 'E'), array(0 => '3', 1 => 'F'), array(0 => '6', 1 => 'F'), array(0 => '9', 1 => 'F'), array(0 => 'C', 1 => 'F'));
    foreach ($colors as $c) {
        $table .= '<tr>';
        foreach ($brigs as $br) {
            $r = $br[$c['r']];
            $g = $br[$c['g']];
            $b = $br[$c['b']];
            $color = $r . $r . $g . $g . $b . $b;
            $table .= '<td>' . unpack_object(new CColorCell(null, $color, 'set_color(\\\'' . $color . '\\\')')) . '</td>';
        }
        $table .= '</tr>';
    }
    $table .= '</table>';
    $cancel = '<span onclick="javascript:hide_color_picker();" class="link">' . S_CANCEL . '</span>';
    $script = 'var color_picker = null;
				var curr_lbl = null;
				var curr_txt = null;' . "\n";
    $script .= "var color_table = '" . $table . $cancel . "'\n";
    insert_js($script);
    print '<script type="text/javascript" src="js/color_picker.js"></script>';
    zbx_add_post_js('create_color_picker();');
}
        $applications = zbx_objectValues($item['applications'], 'name');
        $applications = implode(', ', $applications);
        if (empty($applications)) {
            $applications = '-';
        }
    } else {
        $applications = '-';
    }
    $itemTable->addRow(array(new CCheckBox('group_itemid[' . $item['itemid'] . ']', null, null, $item['itemid']), $description, $item['key_'], $item['delay'], $item['history'], in_array($item['value_type'], array(ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_TEXT)) ? '' : $item['trends'], item_type2str($item['type']), new CCol($applications, 'wraptext'), $status));
}
// create go buttons
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected item prototypes?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('disable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected item prototypes?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('delete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected item prototypes?'));
$goComboBox->addItem($goOption);
$goButton = new CSubmit('goButton', _('Go') . ' (0)');
$goButton->setAttribute('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "group_itemid";');
zbx_add_post_js('chkbxRange.prefix = "' . $this->data['parent_discoveryid'] . '";');
zbx_add_post_js('cookie.prefix = "' . $this->data['parent_discoveryid'] . '";');
// append table to form
$itemForm->addItem(array($this->data['paging'], $itemTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton))));
// append form to widget
$itemsWidget->addItem($itemForm);
return $itemsWidget;
Example #14
0
            $row = new CRow(array(SPACE, $config['event_ack_enable'] ? $ack_cb_col : null, $status, $clock, zbx_date2age($row_event['clock']), zbx_date2age($next_clock, $row_event['clock']), $config['event_ack_enable'] ? $ack : NULL, is_show_all_nodes() ? SPACE : null, $empty_col), 'odd_row');
            $row->setAttribute('data-parentid', $trigger['triggerid']);
            $row->addStyle('display: none;');
            $table->addRow($row);
            if ($i > $config['event_show_max']) {
                break;
            }
        }
    }
}
//----- GO ------
$footer = null;
if ($config['event_ack_enable']) {
    $goBox = new CComboBox('go');
    $goBox->addItem('bulkacknowledge', S_BULK_ACKNOWLEDGE);
    // goButton name is necessary!!!
    $goButton = new CButton('goButton', S_GO . ' (0)');
    $goButton->setAttribute('id', 'goButton');
    $show_event_col ? zbx_add_post_js('chkbxRange.pageGoName = "events";') : zbx_add_post_js('chkbxRange.pageGoName = "triggers";');
    $footer = get_table_header(array($goBox, $goButton));
}
//----
$table = array($paging, $table, $paging, $footer);
$m_form->addItem($table);
$trigg_wdgt->addItem($m_form);
$trigg_wdgt->show();
zbx_add_post_js('blink.init();');
zbx_add_post_js("var switcher = new CSwitcher('{$switcherName}');");
$jsmenu = new CPUMenu(null, 170);
$jsmenu->InsertJavaScript();
include_once 'include/page_footer.php';
Example #15
0
if (isset($_REQUEST["form"])) {
    insert_map_form();
} else {
    $form = new CForm();
    $form->setName('frm_maps');
    $numrows = new CSpan(null, 'info');
    $numrows->setAttribute('name', 'numrows');
    $header = get_table_header(array(S_MAPS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
    show_table_header($header);
    $table = new CTableInfo(S_NO_MAPS_DEFINED);
    $table->SetHeader(array(new CCheckBox('all_maps', NULL, "checkAll('" . $form->getName() . "','all_maps','maps');"), make_sorting_link(S_NAME, 'sm.name'), make_sorting_link(S_WIDTH, 'sm.width'), make_sorting_link(S_HEIGHT, 'sm.height'), S_MAP));
    $result = DBselect('SELECT sm.sysmapid,sm.name,sm.width,sm.height ' . ' FROM sysmaps sm' . ' WHERE ' . DBin_node('sm.sysmapid') . order_by('sm.name,sm.width,sm.height', 'sm.sysmapid'));
    while ($row = DBfetch($result)) {
        if (!sysmap_accessible($row["sysmapid"], PERM_READ_WRITE)) {
            continue;
        }
        $table->AddRow(array(new CCheckBox('maps[' . $row['sysmapid'] . ']', NULL, NULL, $row['sysmapid']), new CLink($row["name"], "sysmaps.php?form=update" . "&sysmapid=" . $row["sysmapid"] . "#form", 'action'), $row["width"], $row["height"], new CLink(S_EDIT, "sysmap.php?sysmapid=" . $row["sysmapid"])));
    }
    //----- GO ------
    $goBox = new CComboBox('go');
    $goBox->addItem('delete', S_DELETE_SELECTED);
    // goButton name is necessary!!!
    $goButton = new CButton('goButton', S_GO . ' (0)');
    $goButton->setAttribute('id', 'goButton');
    zbx_add_post_js('chkbxRange.pageGoName = "maps";');
    $table->setFooter(new CCol(array($goBox, $goButton)));
    $form->addItem($table);
    $form->show();
    zbx_add_post_js('insert_in_element("numrows","' . $table->getNumRows() . '");');
}
include_once "include/page_footer.php";
     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();
     $operationConditionsTable = new CTable(_('No conditions defined.'), 'formElementTable');
            if ($hosts) {
                $hosts[] = ', ';
            }
            $hosts[] = new CLink($host['name'], 'hosts.php?form=update&hostid=' . $host['hostid'], $style);
        }
    }
    $lastAccess = '-';
    if (isset($proxy['lastaccess'])) {
        $lastAccess = $proxy['lastaccess'] == 0 ? '-' : zbx_date2age($proxy['lastaccess']);
    }
    $proxyTable->addRow(array(new CCheckBox('hosts[' . $proxy['proxyid'] . ']', null, null, $proxy['proxyid']), isset($proxy['host']) ? new CLink($proxy['host'], 'proxies.php?form=update&proxyid=' . $proxy['proxyid']) : '', isset($proxy['status']) && $proxy['status'] == HOST_STATUS_PROXY_ACTIVE ? _('Active') : _('Passive'), $lastAccess, isset($proxy['host']) ? count($proxy['hosts']) : '', isset($proxy['item_count']) ? $proxy['item_count'] : 0, isset($proxy['perf']) ? $proxy['perf'] : '-', new CCol(empty($hosts) ? '-' : $hosts, 'wraptext')));
}
// create go buttons
$goComboBox = new CComboBox('action');
$goOption = new CComboItem('proxy.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable hosts monitored by selected proxies?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('proxy.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable hosts monitored by selected proxies?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('proxy.massdelete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected proxies?'));
$goComboBox->addItem($goOption);
$goButton = new CSubmit('goButton', _('Go') . ' (0)');
$goButton->setAttribute('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "hosts";');
// append table to form
$proxyForm->addItem(array($this->data['paging'], $proxyTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton))));
// append form to widget
$proxyWidget->addItem($proxyForm);
return $proxyWidget;
Example #18
0
/**
 * Create DIV with latest problem triggers.
 *
 * If no sortfield and sortorder are defined, the sort indicater in the column name will not be displayed.
 *
 * @param array  $filter['screenid']
 * @param array  $filter['groupids']
 * @param array  $filter['hostids']
 * @param array  $filter['maintenance']
 * @param int    $filter['extAck']
 * @param int    $filter['severity']
 * @param int    $filter['limit']
 * @param string $filter['sortfield']
 * @param string $filter['sortorder']
 * @param string $filter['backUrl']
 *
 * @return CDiv
 */
function make_latest_issues(array $filter = array())
{
    // hide the sort indicator if no sortfield and sortorder are given
    $showSortIndicator = isset($filter['sortfield']) || isset($filter['sortorder']);
    if (!isset($filter['sortfield'])) {
        $filter['sortfield'] = 'lastchange';
    }
    if (!isset($filter['sortorder'])) {
        $filter['sortorder'] = ZBX_SORT_DOWN;
    }
    $options = array('groupids' => $filter['groupids'], 'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null, 'monitored' => true, 'maintenance' => $filter['maintenance'], 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE));
    $triggers = API::Trigger()->get(array_merge($options, array('withLastEventUnacknowledged' => isset($filter['extAck']) && $filter['extAck'] == EXTACK_OPTION_UNACK ? true : null, 'skipDependent' => true, 'output' => array('triggerid', 'state', 'error', 'url', 'expression', 'description', 'priority', 'lastchange'), 'selectHosts' => array('hostid', 'name'), 'selectLastEvent' => array('eventid', 'acknowledged', 'objectid', 'clock', 'ns'), 'sortfield' => $filter['sortfield'], 'sortorder' => $filter['sortorder'], 'limit' => isset($filter['limit']) ? $filter['limit'] : DEFAULT_LATEST_ISSUES_CNT)));
    // don't use withLastEventUnacknowledged and skipDependent because of performance issues
    $triggersTotalCount = API::Trigger()->get(array_merge($options, array('countOutput' => true)));
    // get acknowledges
    $eventIds = array();
    foreach ($triggers as $trigger) {
        if ($trigger['lastEvent']) {
            $eventIds[] = $trigger['lastEvent']['eventid'];
        }
    }
    if ($eventIds) {
        $eventAcknowledges = API::Event()->get(array('eventids' => $eventIds, 'select_acknowledges' => API_OUTPUT_EXTEND, 'preservekeys' => true));
    }
    foreach ($triggers as $tnum => $trigger) {
        // if trigger is lost (broken expression) we skip it
        if (empty($trigger['hosts'])) {
            unset($triggers[$tnum]);
            continue;
        }
        $host = reset($trigger['hosts']);
        $trigger['hostid'] = $host['hostid'];
        $trigger['hostname'] = $host['name'];
        if ($trigger['lastEvent']) {
            $trigger['lastEvent']['acknowledges'] = isset($eventAcknowledges[$trigger['lastEvent']['eventid']]) ? $eventAcknowledges[$trigger['lastEvent']['eventid']]['acknowledges'] : null;
        }
        $triggers[$tnum] = $trigger;
    }
    $hostIds = zbx_objectValues($triggers, 'hostid');
    // get hosts
    $hosts = API::Host()->get(array('hostids' => $hostIds, 'output' => array('hostid', 'name', 'status', 'maintenance_status', 'maintenance_type', 'maintenanceid'), 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
    // actions
    $actions = getEventActionsStatHints($eventIds);
    // ack params
    $ackParams = isset($filter['screenid']) ? array('screenid' => $filter['screenid']) : array();
    $config = select_config();
    // indicator of sort field
    if ($showSortIndicator) {
        $sortDiv = new CDiv(SPACE, $filter['sortorder'] === ZBX_SORT_DOWN ? 'icon_sortdown default_cursor' : 'icon_sortup default_cursor');
        $sortDiv->addStyle('float: left');
        $hostHeaderDiv = new CDiv(array(_('Host'), SPACE));
        $hostHeaderDiv->addStyle('float: left');
        $issueHeaderDiv = new CDiv(array(_('Issue'), SPACE));
        $issueHeaderDiv->addStyle('float: left');
        $lastChangeHeaderDiv = new CDiv(array(_('Time'), SPACE));
        $lastChangeHeaderDiv->addStyle('float: left');
    }
    $table = new CTableInfo(_('No events found.'));
    $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, $showSortIndicator && $filter['sortfield'] === 'hostname' ? array($hostHeaderDiv, $sortDiv) : _('Host'), $showSortIndicator && $filter['sortfield'] === 'priority' ? array($issueHeaderDiv, $sortDiv) : _('Issue'), $showSortIndicator && $filter['sortfield'] === 'lastchange' ? array($lastChangeHeaderDiv, $sortDiv) : _('Last change'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')));
    $scripts = API::Script()->getScriptsByHosts($hostIds);
    // triggers
    foreach ($triggers as $trigger) {
        $host = $hosts[$trigger['hostid']];
        $hostName = new CSpan($host['name'], 'link_menu');
        $hostName->setMenuPopup(getMenuPopupHost($host, $scripts[$host['hostid']]));
        // add maintenance icon with hint if host is in maintenance
        $maintenanceIcon = null;
        if ($host['maintenance_status']) {
            $maintenanceIcon = new CDiv(null, 'icon-maintenance-abs');
            // get maintenance
            $maintenances = API::Maintenance()->get(array('maintenanceids' => $host['maintenanceid'], 'output' => API_OUTPUT_EXTEND, 'limit' => 1));
            if ($maintenance = reset($maintenances)) {
                $hint = $maintenance['name'] . ' [' . ($host['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
                if (isset($maintenance['description'])) {
                    // double quotes mandatory
                    $hint .= "\n" . $maintenance['description'];
                }
                $maintenanceIcon->setHint($hint);
                $maintenanceIcon->addClass('pointer');
            }
            $hostName->addClass('left-to-icon-maintenance-abs');
        }
        $hostDiv = new CDiv(array($hostName, $maintenanceIcon), 'maintenance-abs-cont');
        // unknown triggers
        $unknown = SPACE;
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = new CDiv(SPACE, 'status_icon iconunknown');
            $unknown->setHint($trigger['error'], '', 'on');
        }
        // trigger has events
        if ($trigger['lastEvent']) {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['lastEvent']['clock'], 'ns' => $trigger['lastEvent']['ns'])));
            // ack
            $ack = getEventAckState($trigger['lastEvent'], empty($filter['backUrl']) ? true : $filter['backUrl'], true, $ackParams);
        } else {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['lastchange'], 'ns' => '999999999')));
            // ack
            $ack = new CSpan(_('No events'), 'unknown');
        }
        // description
        if (!zbx_empty($trigger['url'])) {
            $description = new CLink($description, resolveTriggerUrl($trigger), null, null, true);
        } else {
            $description = new CSpan($description, 'pointer');
        }
        $description = new CCol($description, getSeverityStyle($trigger['priority']));
        if ($trigger['lastEvent']) {
            $description->setHint(make_popup_eventlist($trigger['triggerid'], $trigger['lastEvent']['eventid']), '', '', false);
        }
        // clock
        $clock = new CLink(zbx_date2str(_('d M Y H:i:s'), $trigger['lastchange']), 'events.php?triggerid=' . $trigger['triggerid'] . '&source=0&show_unknown=1&nav_time=' . $trigger['lastchange']);
        // actions
        $actionHint = $trigger['lastEvent'] && isset($actions[$trigger['lastEvent']['eventid']]) ? $actions[$trigger['lastEvent']['eventid']] : SPACE;
        $table->addRow(array(get_node_name_by_elid($trigger['triggerid']), $hostDiv, $description, $clock, zbx_date2age($trigger['lastchange']), $unknown, $ack, $actionHint));
    }
    // initialize blinking
    zbx_add_post_js('jqBlink.blink();');
    $script = new CJSScript(get_js("jQuery('#hat_lastiss_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')"));
    $infoDiv = new CDiv(_n('%1$d of %2$d issue is shown', '%1$d of %2$d issues are shown', count($triggers), $triggersTotalCount));
    $infoDiv->addStyle('text-align: right; padding-right: 3px;');
    return new CDiv(array($table, $infoDiv, $script));
}
$discoveryWidget->addHeaderRowNumber();
// create form
$discoveryForm = new CForm();
$discoveryForm->setName('druleForm');
// create table
$discoveryTable = new CTableInfo(_('No discovery rules found.'));
$discoveryTable->setHeader(array(new CCheckBox('all_drules', null, "checkAll('" . $discoveryForm->getName() . "', 'all_drules', 'g_druleid');"), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('IP range'), _('Delay'), _('Checks'), _('Status')));
foreach ($data['drules'] as $drule) {
    array_push($drule['description'], new CLink($drule['name'], '?form=update&druleid=' . $drule['druleid']));
    $status = new CCol(new CLink(discovery_status2str($drule['status']), '?g_druleid[]=' . $drule['druleid'] . '&action=' . ($drule['status'] == DRULE_STATUS_ACTIVE ? 'drule.massdisable' : 'drule.massenable'), discovery_status2style($drule['status'])));
    $discoveryTable->addRow(array(new CCheckBox('g_druleid[' . $drule['druleid'] . ']', null, null, $drule['druleid']), $drule['description'], $drule['iprange'], $drule['delay'], !empty($drule['checks']) ? implode(', ', $drule['checks']) : '', $status));
}
// create go buttons
$goComboBox = new CComboBox('action');
$goOption = new CComboItem('drule.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected discovery rules?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('drule.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected discovery rules?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('drule.massdelete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected discovery rules?'));
$goComboBox->addItem($goOption);
$goButton = new CSubmit('goButton', _('Go') . ' (0)');
$goButton->setAttribute('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "g_druleid";');
// append table to form
$discoveryForm->addItem(array($this->data['paging'], $discoveryTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton))));
// append form to widget
$discoveryWidget->addItem($discoveryForm);
return $discoveryWidget;
 /**
  * Insert javascript to clean all screen items.
  *
  * @static
  */
 public static function insertScreenCleanJs()
 {
     zbx_add_post_js('window.flickerfreeScreen.cleanAll();');
 }
Example #21
0
/**
 * 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[] = '&nbsp;&nbsp;';
        }
        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[] = '&nbsp;&nbsp;';
            $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;
}
Example #22
0
    $search_div = null;
    if ($page['file'] != 'index.php' && CWebUser::$data['userid'] > 0) {
        $searchForm = new CView('general.search');
        $search_div = $searchForm->render();
    }
    $sub_menu_table->addRow(array($menu_divs, $search_div));
    $page_menu->addItem($sub_menu_table);
    $page_menu->show();
}
// create history
if (isset($page['hist_arg']) && CWebUser::$data['alias'] != ZBX_GUEST_USER && $page['type'] == PAGE_TYPE_HTML && !defined('ZBX_PAGE_NO_MENU')) {
    $table = new CTable(null, 'history left');
    $table->addRow(new CRow(array(new CCol(_('History') . ':', 'caption'), get_user_history())));
    $table->show();
} elseif ($page['type'] == PAGE_TYPE_HTML && !defined('ZBX_PAGE_NO_MENU')) {
    echo SBR;
}
// unset multiple variables
unset($ZBX_MENU, $table, $top_page_row, $menu_table, $node_form, $main_menu_row, $db_nodes, $node_data, $sub_menu_table, $sub_menu_rows);
if ($page['type'] == PAGE_TYPE_HTML && $showGuiMessaging) {
    zbx_add_post_js('var msglistid = initMessages({});');
}
// if a user logs in after several unsuccessful attempts, display a warning
if ($failedAttempts = CProfile::get('web.login.attempt.failed', 0)) {
    $attempip = CProfile::get('web.login.attempt.ip', '');
    $attempdate = CProfile::get('web.login.attempt.clock', 0);
    $error_msg = _n('%4$s failed login attempt logged. Last failed attempt was from %1$s on %2$s at %3$s.', '%4$s failed login attempts logged. Last failed attempt was from %1$s on %2$s at %3$s.', $attempip, zbx_date2str(_('d M Y'), $attempdate), zbx_date2str(_('H:i'), $attempdate), $failedAttempts);
    error($error_msg);
    CProfile::update('web.login.attempt.failed', 0, PROFILE_TYPE_INT);
}
show_messages();
Example #23
0
} else {
    $table = new CTableInfo(S_NO_MEDIA_TYPES_DEFINED);
    $table->setHeader(array(make_sorting_link(S_TYPE, 'mt.type'), make_sorting_link(S_DESCRIPTION, 'mt.description'), S_DETAILS));
    $result = DBselect('SELECT mt.* ' . ' FROM media_type mt' . ' WHERE ' . DBin_node('mt.mediatypeid') . order_by('mt.type,mt.description'));
    while ($row = DBfetch($result)) {
        switch ($row['type']) {
            case MEDIA_TYPE_EMAIL:
                $details = S_SMTP_SERVER . ": '" . $row['smtp_server'] . "', " . S_SMTP_HELO . ": '" . $row['smtp_helo'] . "', " . S_SMTP_EMAIL . ": '" . $row['smtp_email'] . "'";
                break;
            case MEDIA_TYPE_EXEC:
                $details = S_SCRIPT_NAME . ": '" . $row['exec_path'] . "'";
                break;
            case MEDIA_TYPE_SMS:
                $details = S_GSM_MODEM . ": '" . $row['gsm_modem'] . "'";
                break;
            case MEDIA_TYPE_JABBER:
                $details = S_JABBER_IDENTIFIER . ": '" . $row['username'] . "'";
                break;
            default:
                $details = '';
        }
        $table->addRow(array(media_type2str($row['type']), new CLink($row["description"], "?&form=update&mediatypeid=" . $row["mediatypeid"], 'action'), $details));
        $row_count++;
    }
    $table->show();
}
zbx_add_post_js('insert_in_element("numrows","' . $row_count . '");');
?>

<?php 
include_once "include/page_footer.php";
        }
        array_pop($actionLinks);
    } else {
        $actionLinks = '-';
    }
    $actionColumn = new CCol($actionLinks);
    $actionColumn->setAttribute('style', 'white-space: normal;');
    $statusLink = 'media_types.php?go=' . ($mediaType['status'] == MEDIA_TYPE_STATUS_DISABLED ? 'activate' : 'disable') . '&mediatypeids' . SQUAREBRACKETS . '=' . $mediaType['mediatypeid'];
    $status = MEDIA_TYPE_STATUS_ACTIVE == $mediaType['status'] ? new CLink(_('Enabled'), $statusLink, 'enabled') : new CLink(_('Disabled'), $statusLink, 'disabled');
    // append row
    $mediaTypeTable->addRow(array(new CCheckBox('mediatypeids[' . $mediaType['mediatypeid'] . ']', null, null, $mediaType['mediatypeid']), $this->data['displayNodes'] ? $mediaType['nodename'] : null, new CLink($mediaType['description'], '?form=edit&mediatypeid=' . $mediaType['mediatypeid']), media_type2str($mediaType['typeid']), $status, $actionColumn, $details));
}
// create go button
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected media types?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('disable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected media types?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('delete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected media types?'));
$goComboBox->addItem($goOption);
$goButton = new CSubmit('goButton', _('Go') . ' (0)');
$goButton->setAttribute('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "mediatypeids";');
// append table to form
$mediaTypeForm->addItem(array($this->data['paging'], $mediaTypeTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton))));
// append form to widget
$mediaTypeWidget->addItem($mediaTypeForm);
return $mediaTypeWidget;
    }
    if ($user['type'] == USER_TYPE_SUPER_ADMIN) {
        $userTypeStyle = 'disabled';
    }
    // gui access style
    $guiAccessStyle = 'green';
    if ($user['gui_access'] == GROUP_GUI_ACCESS_INTERNAL) {
        $guiAccessStyle = 'orange';
    }
    if ($user['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
        $guiAccessStyle = 'disabled';
    }
    // append user to table
    $usersTable->addRow(array(new CCheckBox('group_userid[' . $userId . ']', null, null, $userId), new CLink($user['alias'], 'users.php?form=update&userid=' . $userId), $user['name'], $user['surname'], user_type2str($user['type']), $usersGroups, $online, $blocked, new CSpan(user_auth_type2str($user['gui_access']), $guiAccessStyle), $user['debug_mode'] == GROUP_DEBUG_MODE_ENABLED ? new CSpan(_('Enabled'), 'orange') : new CSpan(_('Disabled'), 'green'), $user['users_status'] == 1 ? new CSpan(_('Disabled'), 'red') : new CSpan(_('Enabled'), 'green')));
}
// append Go buttons
$goComboBox = new CComboBox('action');
$goOption = new CComboItem('user.massunblock', _('Unblock selected'));
$goOption->setAttribute('confirm', _('Unblock selected users?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('user.massdelete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected users?'));
$goComboBox->addItem($goOption);
$goButton = new CSubmit('goButton', _('Go') . ' (0)');
$goButton->setAttribute('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "group_userid";');
// append table to form
$usersForm->addItem(array($this->data['paging'], $usersTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton))));
// append form to widget
$usersWidget->addItem($usersForm);
return $usersWidget;
Example #26
0
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;
}
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
zbx_add_post_js('jqBlink.blink();');
$overviewWidget = new CWidget();
$typeComboBox = new CComboBox('type', $this->data['type'], 'submit()');
$typeComboBox->addItem(SHOW_TRIGGERS, _('Triggers'));
$typeComboBox->addItem(SHOW_DATA, _('Data'));
$headerForm = new CForm('get');
$headerForm->addItem(array(_('Group'), SPACE, $this->data['pageFilter']->getGroupsCB(true)));
$headerForm->addItem(array(SPACE, _('Application'), SPACE, $this->data['pageFilter']->getApplicationsCB(true)));
$headerForm->addItem(array(SPACE, _('Type'), SPACE, $typeComboBox));
$overviewWidget->addHeader(_('Overview'), $headerForm);
$hintTable = new CTableInfo();
$hintTable->setAttribute('style', 'width: 200px');
if ($this->data['type'] == SHOW_TRIGGERS) {
    $hintTable->addRow(array(new CCol(SPACE, 'normal'), _('OK')));
}
for ($i = 0; $i < TRIGGER_SEVERITY_COUNT; $i++) {
Example #28
0
                    $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';
            $hostTemplates[] = ', ';
        }
        if ($hostTemplates) {
            array_pop($hostTemplates);
        }
    }
    // status
    $status = new CLink(item_status2str($hostPrototype['status']), '?group_hostid=' . $hostPrototype['hostid'] . '&parent_discoveryid=' . $discoveryRule['itemid'] . '&go=' . ($hostPrototype['status'] ? 'activate' : 'disable'), itemIndicatorStyle($hostPrototype['status']));
    $hostTable->addRow(array(new CCheckBox('group_hostid[' . $hostPrototype['hostid'] . ']', null, null, $hostPrototype['hostid']), $name, new CCol($hostTemplates, 'wraptext'), $status));
}
// create go buttons
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Activate selected'));
$goOption->setAttribute('confirm', _('Enable selected host prototypes?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('disable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected host prototypes?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('delete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected host prototypes?'));
$goComboBox->addItem($goOption);
$goButton = new CSubmit('goButton', _('Go') . ' (0)');
$goButton->setAttribute('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "group_hostid";');
zbx_add_post_js('chkbxRange.prefix = "' . $discoveryRule['itemid'] . '";');
zbx_add_post_js('cookie.prefix = "' . $discoveryRule['itemid'] . '";');
// append table to form
$itemForm->addItem(array($this->data['paging'], $hostTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton))));
// append form to widget
$itemsWidget->addItem($itemForm);
return $itemsWidget;
// create table
$maintenanceTable = new CTableInfo(_('No maintenance periods found.'));
$maintenanceTable->setHeader(array(new CCheckBox('all_maintenances', null, "checkAll('" . $maintenanceForm->getName() . "', 'all_maintenances', 'maintenanceids');"), $this->data['displayNodes'] ? _('Node') : null, make_sorting_header(_('Name'), 'name'), make_sorting_header(_('Type'), 'maintenance_type'), _('State'), _('Description')));
foreach ($this->data['maintenances'] as $maintenance) {
    $maintenanceid = $maintenance['maintenanceid'];
    switch ($maintenance['status']) {
        case MAINTENANCE_STATUS_EXPIRED:
            $maintenanceStatus = new CSpan(_x('Expired', 'maintenance status'), 'red');
            break;
        case MAINTENANCE_STATUS_APPROACH:
            $maintenanceStatus = new CSpan(_x('Approaching', 'maintenance status'), 'blue');
            break;
        case MAINTENANCE_STATUS_ACTIVE:
            $maintenanceStatus = new CSpan(_x('Active', 'maintenance status'), 'green');
            break;
    }
    $maintenanceTable->addRow(array(new CCheckBox('maintenanceids[' . $maintenanceid . ']', null, null, $maintenanceid), $this->data['displayNodes'] ? $maintenance['nodename'] : null, new CLink($maintenance['name'], 'maintenance.php?form=update&maintenanceid=' . $maintenanceid), $maintenance['maintenance_type'] ? _('No data collection') : _('With data collection'), $maintenanceStatus, $maintenance['description']));
}
// create go button
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('delete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected maintenance periods?'));
$goComboBox->addItem($goOption);
$goButton = new CSubmit('goButton', _('Go') . ' (0)');
$goButton->setAttribute('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "maintenanceids";');
// append table to form
$maintenanceForm->addItem(array($this->data['paging'], $maintenanceTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton))));
// append form to widget
$maintenanceWidget->addItem($maintenanceForm);
return $maintenanceWidget;