summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/config.inc.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-08-13 08:22:32 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-08-13 08:22:32 +0000
commitabaab90a1c9d3367f1ef636557cfe8e661716749 (patch)
tree3e266e5523a635c45a7e7ef6d4571e7323f26065 /frontends/php/include/config.inc.php
parent8901654871973b4267f106a97183001189189c82 (diff)
downloadzabbix-abaab90a1c9d3367f1ef636557cfe8e661716749.tar.gz
zabbix-abaab90a1c9d3367f1ef636557cfe8e661716749.tar.xz
zabbix-abaab90a1c9d3367f1ef636557cfe8e661716749.zip
- merger rev. 4546:4547 of branches/1.4.j [developed data monitoring of multiple nodes]
git-svn-id: svn://svn.zabbix.com/trunk@4549 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/config.inc.php')
-rw-r--r--frontends/php/include/config.inc.php108
1 files changed, 94 insertions, 14 deletions
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index b60bacbb..46472344 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -176,41 +176,124 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!!
function init_nodes()
{
/* Init CURRENT NODE ID */
- global $USER_DETAILS;
- global $ZBX_LOCALNODEID, $ZBX_LOCMASTERID;
- global $ZBX_CURNODEID, $ZBX_CURMASTERID;
+ global $_REQUEST,
+ $USER_DETAILS,
+ $ZBX_LOCALNODEID, $ZBX_LOCMASTERID,
+ $ZBX_CURRENT_NODEID, $ZBX_CURRENT_SUBNODES, $ZBX_CURMASTERID,
+ $ZBX_NODES,
+ $ZBX_WITH_SUBNODES;
+
+ $ZBX_CURRENT_SUBNODES = array();
+ $ZBX_NODES = array();
if(!defined('ZBX_PAGE_NO_AUTHERIZATION') && ZBX_DISTRIBUTED)
{
- $ZBX_CURNODEID = get_cookie('zbx_current_nodeid', $ZBX_LOCALNODEID); // Selected node
+ $ZBX_CURRENT_NODEID = get_cookie('zbx_current_nodeid', $ZBX_LOCALNODEID); // Selected node
+ $ZBX_WITH_SUBNODES = get_cookie('zbx_with_subnodes', false); // Show elements from subnodes
+
if(isset($_REQUEST['switch_node']))
{
if($node_data = DBfetch(DBselect("select * from nodes where nodeid=".$_REQUEST['switch_node'])))
{
- $ZBX_CURNODEID = $_REQUEST['switch_node'];
+ $ZBX_CURRENT_NODEID = $_REQUEST['switch_node'];
}
unset($node_data);
}
- if($node_data = DBfetch(DBselect("select * from nodes where nodeid=".$ZBX_CURNODEID)))
+ if(isset($_REQUEST['show_subnodes']))
+ {
+ $ZBX_WITH_SUBNODES = !empty($_REQUEST['show_subnodes']);
+ }
+
+ if($node_data = DBfetch(DBselect("select * from nodes where nodeid=".$ZBX_CURRENT_NODEID)))
{
$ZBX_CURMASTERID = $node_data['masterid'];
}
- if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST,null,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)) <= 0)
+ $ZBX_NODES = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_LIST, null, PERM_RES_DATA_ARRAY);
+
+ if ( !isset($ZBX_NODES[$ZBX_CURRENT_NODEID]) )
{
$denyed_page_requested = true;
- $ZBX_CURNODEID = $ZBX_LOCALNODEID;
+ $ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID;
$ZBX_CURMASTERID = $ZBX_LOCMASTERID;
}
+
+ foreach ( $ZBX_NODES as $nodeid => $node_data )
+ {
+ for ( $curr_node = &$node_data;
+ $curr_node['masterid'] != 0 &&
+ $curr_node['masterid'] != $ZBX_CURRENT_NODEID;
+ $curr_node = &$ZBX_NODES[$curr_node['masterid']]
+ );
+
+ if ( $curr_node['masterid'] == $ZBX_CURRENT_NODEID )
+ {
+ $ZBX_CURRENT_SUBNODES[$nodeid] = $nodeid;
+ }
+ }
- zbx_set_post_cookie('zbx_current_nodeid',$ZBX_CURNODEID);
+ zbx_set_post_cookie('zbx_current_nodeid',$ZBX_CURRENT_NODEID);
+ zbx_set_post_cookie('zbx_with_subnodes',$ZBX_WITH_SUBNODES);
}
else
{
- $ZBX_CURNODEID = $ZBX_LOCALNODEID;
+ $ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID;
$ZBX_CURMASTERID = $ZBX_LOCMASTERID;
+ $ZBX_WITH_SUBNODES = false;
+ }
+
+ $ZBX_CURRENT_SUBNODES[$ZBX_CURRENT_NODEID] = $ZBX_CURRENT_NODEID;
+
+ if ( count($ZBX_CURRENT_SUBNODES) < 2 && !defined('ZBX_DISABLE_SUBNODES') )
+ define('ZBX_DISABLE_SUBNODES', 1);
+ }
+
+ function get_current_nodeid( $forse_with_subnodes = null, $perm = null )
+ {
+ global $ZBX_CURRENT_NODEID, $ZBX_CURRENT_SUBNODES, $ZBX_WITH_SUBNODES;
+
+ if ( !isset($ZBX_CURRENT_NODEID) ) init_nodes();
+
+ $result = ( is_show_subnodes($forse_with_subnodes) ? $ZBX_CURRENT_SUBNODES : $ZBX_CURRENT_NODEID );
+
+ if ( !is_null($perm) )
+ {
+ global $USER_DETAILS;
+
+ $result = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_ONLY, null, null, $result);
}
+
+ return $result;
+ }
+
+ function get_node_name_by_elid($id_val, $forse_with_subnodes = null)
+ {
+ global $ZBX_NODES;
+
+ if ( ! is_show_subnodes($forse_with_subnodes) )
+ return null;
+
+ $nodeid = id2nodeid($id_val);
+
+ if ( !isset($ZBX_NODES[$nodeid]) )
+ return null;
+
+ return '['.$ZBX_NODES[$nodeid]['name'].'] ';
+ }
+
+ function is_show_subnodes($forse_with_subnodes = null)
+ {
+ global $ZBX_WITH_SUBNODES;
+
+ if ( is_null($forse_with_subnodes) )
+ {
+ if ( defined('ZBX_DISABLE_SUBNODES') )
+ $forse_with_subnodes = false;
+ else
+ $forse_with_subnodes = $ZBX_WITH_SUBNODES;
+ }
+ return $forse_with_subnodes;
}
function access_deny()
@@ -924,8 +1007,6 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!!
function update_config($event_history,$alert_history,$refresh_unsupported,$work_period,$alert_usrgrpid)
{
- global $ZBX_CURNODEID;
-
$update = array();
if(!is_null($event_history))
@@ -965,8 +1046,7 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!!
}
return DBexecute('update config set '.implode(',',$update).
- ' where '.DBid2nodeid('configid')."=".$ZBX_CURNODEID);
-
+ ' where '.DBin_node('configid', get_current_nodeid(false)));
}
function &get_table_header($col1, $col2=SPACE)