Exemple #1
0
 $top_page_row = array(new CCol($logo, 'page_header_l'), $td_r);
 unset($logo, $page_header_r_col, $help, $support);
 $table = new CTable(NULL, 'page_header');
 $table->setCellSpacing(0);
 $table->setCellPadding(5);
 $table->addRow($top_page_row);
 $table->show();
 $menu_table = new CTable(NULL, 'menu');
 $menu_table->setCellSpacing(0);
 $menu_table->setCellPadding(5);
 $menu_table->addRow($main_menu);
 $node_form = null;
 if (ZBX_DISTRIBUTED && !defined('ZBX_HIDE_NODE_SELECTION')) {
     insert_js_function('check_all');
     $available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_LIST, PERM_RES_DATA_ARRAY);
     $available_nodes = get_tree_by_parentid($ZBX_LOCALNODEID, $available_nodes, 'masterid');
     //remove parent nodes
     if (!empty($available_nodes)) {
         $node_form = new CForm();
         $node_form->setMethod('get');
         $node_form->setAttribute('id', 'node_form');
         // +++ create Combo Box with selected nodes +++
         $combo_node_list = null;
         if (count($ZBX_VIEWED_NODES['nodes']) > 0) {
             $combo_node_list = new CComboBox('switch_node', $ZBX_VIEWED_NODES['selected'], 'submit()');
             foreach ($ZBX_VIEWED_NODES['nodes'] as $nodeid => $nodedata) {
                 $combo_node_list->addItem($nodeid, $nodedata['name']);
             }
         }
         // --- ---
         $jscript = 'javascript : ' . " var pos = getPosition('button_show_tree');" . " ShowHide('div_node_tree',IE6?'block':'table');" . ' pos.top += 20;' . " \$('div_node_tree').setStyle({top: pos.top+'px'});" . " showPopupDiv('div_node_tree','select_iframe');";
Exemple #2
0
function get_tree_by_parentid($parentid, &$tree, $parent_field, $level = 0)
{
    if (empty($tree)) {
        return $tree;
    }
    $level++;
    if ($level > 32) {
        return array();
    }
    $result = array();
    if (isset($tree[$parentid])) {
        $result[$parentid] = $tree[$parentid];
    }
    $tree_ids = array_keys($tree);
    foreach ($tree_ids as $key => $id) {
        $child = $tree[$id];
        if (bccomp($child[$parent_field], $parentid) == 0) {
            $result[$id] = $child;
            $childs = get_tree_by_parentid($id, $tree, $parent_field, $level);
            // attention recursion !!!
            $result += $childs;
        }
    }
    return $result;
}
function get_viewed_nodes($options = array())
{
    global $USER_DETAILS;
    global $ZBX_LOCALNODEID, $ZBX_AVAILABLE_NODES;
    $config = select_config();
    $def_options = array('allow_all' => 0);
    $options = zbx_array_merge($def_options, $options);
    $result = array('selected' => 0, 'nodes' => array(), 'nodeids' => array());
    if (!defined('ZBX_NOT_ALLOW_ALL_NODES')) {
        $result['nodes'][0] = array('nodeid' => 0, 'name' => S_ALL_S);
    }
    $available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_LIST, PERM_RES_DATA_ARRAY);
    $available_nodes = get_tree_by_parentid($ZBX_LOCALNODEID, $available_nodes, 'masterid');
    //remove parent nodes
    // $selected_nodeids = get_request('selected_nodes', CProfile::get('web.nodes.selected', array($USER_DETAILS['node']['nodeid'])));
    $selected_nodeids = get_request('selected_nodes', get_node_profile(array($USER_DETAILS['node']['nodeid'])));
    // +++ Fill $result['NODEIDS'], $result['NODES'] +++
    $nodes = array();
    $nodeids = array();
    foreach ($selected_nodeids as $num => $nodeid) {
        if (isset($available_nodes[$nodeid])) {
            $result['nodes'][$nodeid] = array('nodeid' => $available_nodes[$nodeid]['nodeid'], 'name' => $available_nodes[$nodeid]['name'], 'masterid' => $available_nodes[$nodeid]['masterid']);
            $nodeids[$nodeid] = $nodeid;
        }
    }
    // --- ---
    $switch_node = get_request('switch_node', CProfile::get('web.nodes.switch_node', -1));
    if (!isset($available_nodes[$switch_node]) || !uint_in_array($switch_node, $selected_nodeids)) {
        //check switch_node
        $switch_node = 0;
    }
    $result['nodeids'] = $nodeids;
    if (!defined('ZBX_NOT_ALLOW_ALL_NODES')) {
        $result['selected'] = $switch_node;
    } else {
        if (!empty($nodeids)) {
            $result['selected'] = $switch_node > 0 ? $switch_node : array_shift($nodeids);
        }
    }
    return $result;
}
function get_viewed_nodes()
{
    global $ZBX_LOCALNODEID;
    $result = array('selected' => 0, 'nodes' => array(), 'nodeids' => array());
    if (!defined('ZBX_NOT_ALLOW_ALL_NODES')) {
        $result['nodes'][0] = array('nodeid' => 0, 'name' => _('All'));
    }
    $available_nodes = get_accessible_nodes_by_user(CWebUser::$data, PERM_READ_LIST, PERM_RES_DATA_ARRAY);
    $available_nodes = get_tree_by_parentid($ZBX_LOCALNODEID, $available_nodes, 'masterid');
    // remove parent nodes
    $selected_nodeids = get_request('selected_nodes', get_node_profile(array(CWebUser::$data['node']['nodeid'])));
    // +++ Fill $result['NODEIDS'], $result['NODES'] +++
    $nodeids = array();
    foreach ($selected_nodeids as $num => $nodeid) {
        if (isset($available_nodes[$nodeid])) {
            $result['nodes'][$nodeid] = array('nodeid' => $available_nodes[$nodeid]['nodeid'], 'name' => $available_nodes[$nodeid]['name'], 'masterid' => $available_nodes[$nodeid]['masterid']);
            $nodeids[$nodeid] = $nodeid;
        }
    }
    $switch_node = get_request('switch_node', CProfile::get('web.nodes.switch_node', -1));
    if (!isset($available_nodes[$switch_node]) || !uint_in_array($switch_node, $selected_nodeids)) {
        // check switch_node
        $switch_node = 0;
    }
    $result['nodeids'] = $nodeids;
    if (!defined('ZBX_NOT_ALLOW_ALL_NODES')) {
        $result['selected'] = $switch_node;
    } elseif (!empty($nodeids)) {
        $result['selected'] = $switch_node > 0 ? $switch_node : array_shift($nodeids);
    }
    return $result;
}
Exemple #5
0
function get_tree_by_parentid($parentid, &$tree, $parent_field, $level = 0)
{
    if (empty($tree)) {
        return $tree;
    }
    $level++;
    if ($level > 32) {
        return array();
    }
    $result = array();
    if (isset($tree[$parentid])) {
        $result[$parentid] = $tree[$parentid];
    }
    foreach ($tree as $id => $child) {
        if (bccomp($child[$parent_field], $parentid) == 0) {
            $result[$id] = $child;
            $childs = get_tree_by_parentid($id, $tree, $parent_field, $level);
            // RECURSION !!!
            $result += $childs;
        }
    }
    return $result;
}