diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-04-23 09:18:47 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-04-23 09:18:47 +0000 |
| commit | be2359ca3780418cc77e8449f79d8c1290bd8ee3 (patch) | |
| tree | 09aac2796f2653238253a7736f98e1e85c858d45 /frontends/php/include/hosts.inc.php | |
| parent | 9a5879720db8f0c101623e9ae3c6a7e78199571f (diff) | |
| download | zabbix-be2359ca3780418cc77e8449f79d8c1290bd8ee3.tar.gz zabbix-be2359ca3780418cc77e8449f79d8c1290bd8ee3.tar.xz zabbix-be2359ca3780418cc77e8449f79d8c1290bd8ee3.zip | |
- [DEV-159] added automatic selection first group and host in WEB monitoring (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5647 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/hosts.inc.php')
| -rw-r--r-- | frontends/php/include/hosts.inc.php | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php index ff63677a..b64af77f 100644 --- a/frontends/php/include/hosts.inc.php +++ b/frontends/php/include/hosts.inc.php @@ -698,7 +698,7 @@ require_once "include/items.inc.php"; */ function get_correct_group_and_host($a_groupid=null, $a_hostid=null, $perm=PERM_READ_WRITE, $options = array()){ if(!is_array($options)){ - fatal_error("Incorrest options for get_correct_group_and_host"); + fatal_error("Incorrect options for get_correct_group_and_host"); } global $USER_DETAILS; @@ -738,7 +738,24 @@ require_once "include/items.inc.php"; } else{ $groupid = $a_groupid; + + if(($groupid < 0) && str_in_array('always_select_first_group',$options)){ + $with_node = ' AND '.DBin_node('g.groupid', get_current_nodeid(!$only_current_node)); + $sql = 'SELECT DISTINCT g.name,g.groupid '. + ' FROM groups g, hosts_groups hg, hosts h'.$item_table. + ' WHERE hg.groupid=g.groupid '. + ' AND h.hostid=hg.hostid '. + ' AND h.hostid IN ('.$available_hosts.') '. + $with_host_status. + $with_items. + $with_node. + ' ORDER BY g.name'; +//SDI($groupid); + $groupid=($grp = DBfetch(DBselect($sql,1)))?$grp['groupid']:0; +//SDI($groupid); + } + if($groupid > 0){ $with_node = ' AND '.DBin_node('g.groupid', get_current_nodeid(!$only_current_node)); @@ -760,10 +777,10 @@ require_once "include/items.inc.php"; else{ $hostid = $a_hostid; /* is not 'All' selected */ - if(!($hostid == 0 && $allow_all_hosts == 1)) { + if(!(($hostid == 0) && ($allow_all_hosts == 1))) { $group_table = ''; $witth_group = ''; - + if($groupid != 0){ $with_node = ' AND '.DBin_node('hg.hostid', get_current_nodeid(!$only_current_node)); @@ -805,8 +822,7 @@ require_once "include/items.inc.php"; $hostid = 0; } } - if(($hostid < 0) || ($hostid == 0 && $always_select_first_host == 1)) /* incorrect host */ - { + if(($hostid < 0) || ($hostid == 0 && $always_select_first_host == 1)) /* incorrect host */{ $hostid = $first_hostid_in_group; } } @@ -884,8 +900,11 @@ require_once "include/items.inc.php"; if(!in_node($_REQUEST["groupid"])) $_REQUEST["groupid"] = 0; - $result = get_correct_group_and_host($_REQUEST["groupid"],null,$perm,$options); - $_REQUEST["groupid"] = $result["groupid"]; + if(str_in_array('always_select_first_group',$options) && ($_REQUEST['groupid'] == 0)) + $_REQUEST['groupid'] = -1; + + $result = get_correct_group_and_host($_REQUEST['groupid'],null,$perm,$options); + $_REQUEST["groupid"] = $result["groupid"]; update_profile($group_var,$_REQUEST["groupid"]); } |
