summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-08-20 14:46:11 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-08-20 14:46:11 +0000
commit469d17e7d448ec1833abb72add88d1d1f61c4a06 (patch)
tree4a21e42405a82385c87981d5f2199e388a964272 /frontends/php
parent155fa1457186f7ffa453ba7bf68ae0c22387746b (diff)
downloadzabbix-master.tar.gz
zabbix-master.tar.xz
zabbix-master.zip
- [DEV-199] performance improvements of js scripts in hosts screen (Artem)HEADmaster
- [DEV-137] many small fixes (Artem) git-svn-id: svn://svn.zabbix.com/trunk@5932 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/charts.php6
-rw-r--r--frontends/php/dashboard.php48
-rw-r--r--frontends/php/events.php4
-rw-r--r--frontends/php/graphs.php33
-rw-r--r--frontends/php/hosts.php59
-rw-r--r--frontends/php/httpmon.php4
-rw-r--r--frontends/php/include/actions.inc.php8
-rw-r--r--frontends/php/include/classes/ccombobox.inc.php45
-rw-r--r--frontends/php/include/events.inc.php3
-rw-r--r--frontends/php/include/forms.inc.php28
-rw-r--r--frontends/php/include/hosts.inc.php171
-rw-r--r--frontends/php/include/import.inc.php10
-rw-r--r--frontends/php/include/js.inc.php42
-rw-r--r--frontends/php/include/maps.inc.php2
-rw-r--r--frontends/php/include/page_header.php4
-rw-r--r--frontends/php/include/perm.inc.php4
-rw-r--r--frontends/php/include/screens.inc.php6
-rw-r--r--frontends/php/include/users.inc.php48
-rw-r--r--frontends/php/items.php14
-rw-r--r--frontends/php/js/ajax_req.js143
-rw-r--r--frontends/php/js/chkbxrange.js22
-rw-r--r--frontends/php/js/common.js559
-rw-r--r--frontends/php/js/dashboard.js69
-rw-r--r--frontends/php/js/json.js105
-rw-r--r--frontends/php/js/menu.js37
-rw-r--r--frontends/php/js/menu_scripts.js226
-rw-r--r--frontends/php/js/tree.js2
-rw-r--r--frontends/php/js/users.js103
-rw-r--r--frontends/php/latest.php4
-rw-r--r--frontends/php/overview.php4
-rw-r--r--frontends/php/popup.php11
-rw-r--r--frontends/php/screens.php4
-rw-r--r--frontends/php/scripts.php2
-rw-r--r--frontends/php/tr_status.php4
-rw-r--r--frontends/php/triggers.php8
-rw-r--r--frontends/php/users.php4
36 files changed, 892 insertions, 954 deletions
diff --git a/frontends/php/charts.php b/frontends/php/charts.php
index ad447b6c..44905738 100644
--- a/frontends/php/charts.php
+++ b/frontends/php/charts.php
@@ -133,7 +133,7 @@ include_once 'include/page_header.php';
$h1 = array();
$available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST);
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST,PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST);
$available_graphs = get_accessible_graphs(PERM_READ_LIST, PERM_RES_IDS_ARRAY, get_current_nodeid());
@@ -168,7 +168,7 @@ include_once 'include/page_header.php';
if($_REQUEST['groupid'] == 0){
$sql = 'SELECT COUNT(DISTINCT g.groupid) as grpcount, MAX(g.groupid) as groupid'.
' FROM groups g, hosts_groups hg, hosts h, items i, graphs_items gi '.
- ' WHERE g.groupid in ('.$available_groups.') '.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND hg.groupid=g.groupid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND h.hostid=i.hostid '.
@@ -231,7 +231,7 @@ include_once 'include/page_header.php';
$result=DBselect('SELECT DISTINCT g.groupid, g.name '.
' FROM groups g, hosts_groups hg, hosts h, items i, graphs_items gi '.
- ' WHERE g.groupid in ('.$available_groups.') '.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND hg.groupid=g.groupid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND h.hostid=i.hostid '.
diff --git a/frontends/php/dashboard.php b/frontends/php/dashboard.php
index d23964f6..b28da721 100644
--- a/frontends/php/dashboard.php
+++ b/frontends/php/dashboard.php
@@ -18,19 +18,19 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-require_once "include/config.inc.php";
-require_once "include/hosts.inc.php";
-require_once "include/triggers.inc.php";
-require_once "include/items.inc.php";
-require_once "include/actions.inc.php";
-require_once "include/discovery.inc.php";
-require_once "include/html.inc.php";
-require_once "include/blocks.inc.php";
+require_once('include/config.inc.php');
+require_once('include/hosts.inc.php');
+require_once('include/triggers.inc.php');
+require_once('include/items.inc.php');
+require_once('include/actions.inc.php');
+require_once('include/discovery.inc.php');
+require_once('include/html.inc.php');
+require_once('include/blocks.inc.php');
$page["title"] = "S_DASHBOARD";
$page["file"] = "dashboard.php";
$page['hist_arg'] = array();
-$page['scripts'] = array('updater.js','dashboard.js','showhint.js');
+$page['scripts'] = array('updater.js','menu_scripts.js','showhint.js');
$page['type'] = detect_page_type(PAGE_TYPE_HTML);
@@ -168,20 +168,6 @@ include_once "include/page_header.php";
}
}
- if(isset($_REQUEST['output'])){
- if('json2' == $_REQUEST['output']){
- echo 'try{'.
- 'json.callBack("sdt"); '.
- 'json.removeScript("'.$_REQUEST['jsscriptid'].'");'.
- ' }catch(e){ '.
- 'alert("Warning: incorrect JSON return.");'.
- 'json.removeScript("'.$_REQUEST['jsscriptid'].'");'.
- ' }';
- }
- }
-
-
-
if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){
exit();
}
@@ -227,7 +213,7 @@ include_once "include/page_header.php";
// --------------
$graph_menu = new CDiv(SPACE,'iconmenu');
- $graph_menu->AddAction('onclick','javascript: create_menu(event,"graphs");');
+ $graph_menu->AddAction('onclick','javascript: create_dashboard_menu(event,"graphs");');
$graph_menu->AddOption('title',S_MENU);
$left_tab->AddRow(create_hat(
@@ -239,7 +225,7 @@ include_once "include/page_header.php";
));
$screen_menu = new CDiv(SPACE,'iconmenu');
- $screen_menu->AddAction('onclick','javascript: create_menu(event,"screens");');
+ $screen_menu->AddAction('onclick','javascript: create_dashboard_menu(event,"screens");');
$screen_menu->AddOption('title',S_MENU);
$left_tab->AddRow(create_hat(
@@ -252,7 +238,7 @@ include_once "include/page_header.php";
$sysmap_menu = new CDiv(SPACE,'iconmenu');
- $sysmap_menu->AddAction('onclick','javascript: create_menu(event,"sysmaps");');
+ $sysmap_menu->AddAction('onclick','javascript: create_dashboard_menu(event,"sysmaps");');
$sysmap_menu->AddOption('title',S_MENU);
$left_tab->AddRow(create_hat(
@@ -293,7 +279,7 @@ include_once "include/page_header.php";
);
$refresh_menu = new CDiv(SPACE,'iconmenu');
- $refresh_menu->AddAction('onclick','javascript: create_menu(event,"hat_syssum");');
+ $refresh_menu->AddAction('onclick','javascript: create_dashboard_menu(event,"hat_syssum");');
$refresh_menu->AddOption('title',S_MENU);
$right_tab->AddRow(create_hat(
@@ -305,7 +291,7 @@ include_once "include/page_header.php";
));
$refresh_menu = new CDiv(SPACE,'iconmenu');
- $refresh_menu->AddAction('onclick','javascript: create_menu(event,"hat_stszbx");');
+ $refresh_menu->AddAction('onclick','javascript: create_dashboard_menu(event,"hat_stszbx");');
$refresh_menu->AddOption('title',S_MENU);
$right_tab->AddRow(create_hat(
@@ -317,7 +303,7 @@ include_once "include/page_header.php";
));
$refresh_menu = new CDiv(SPACE,'iconmenu');
- $refresh_menu->AddAction('onclick','javascript: create_menu(event,"hat_lastiss");');
+ $refresh_menu->AddAction('onclick','javascript: create_dashboard_menu(event,"hat_lastiss");');
$refresh_menu->AddOption('title',S_MENU);
$right_tab->AddRow(create_hat(S_LATEST_ISSUES,
@@ -328,7 +314,7 @@ include_once "include/page_header.php";
));
$refresh_menu = new CDiv(SPACE,'iconmenu');
- $refresh_menu->AddAction('onclick','javascript: create_menu(event,"hat_webovr");');
+ $refresh_menu->AddAction('onclick','javascript: create_dashboard_menu(event,"hat_webovr");');
$refresh_menu->AddOption('title',S_MENU);
$right_tab->AddRow(create_hat(
@@ -346,7 +332,7 @@ include_once "include/page_header.php";
$refresh_tab[] = array( 'id' => 'hat_dscvry','interval' => get_profile('web.dahsboard.rf_rate.hat_dscvry',60));
$refresh_menu = new CDiv(SPACE,'iconmenu');
- $refresh_menu->AddAction('onclick','javascript: create_menu(event,"hat_dscvry");');
+ $refresh_menu->AddAction('onclick','javascript: create_dashboard_menu(event,"hat_dscvry");');
$refresh_menu->AddOption('title',S_MENU);
$right_tab->AddRow(create_hat(
diff --git a/frontends/php/events.php b/frontends/php/events.php
index 2c782527..cc57609a 100644
--- a/frontends/php/events.php
+++ b/frontends/php/events.php
@@ -144,7 +144,7 @@ include_once "include/page_header.php";
if(EVENT_SOURCE_TRIGGERS == $source){
$available_groups= get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY);
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY);
$available_triggers = get_accessible_triggers(PERM_READ_ONLY, PERM_RES_DATA_ARRAY, get_current_nodeid());
@@ -183,7 +183,7 @@ include_once "include/page_header.php";
$result=DBselect('SELECT DISTINCT g.groupid,g.name '.
' FROM groups g, hosts_groups hg, hosts h, items i '.
- ' WHERE g.groupid in ('.$available_groups.') '.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND hg.groupid=g.groupid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND h.hostid=i.hostid '.
diff --git a/frontends/php/graphs.php b/frontends/php/graphs.php
index 885493a1..3ed64e3f 100644
--- a/frontends/php/graphs.php
+++ b/frontends/php/graphs.php
@@ -19,12 +19,12 @@
**/
?>
<?php
- require_once "include/config.inc.php";
- require_once "include/hosts.inc.php";
- require_once "include/graphs.inc.php";
- require_once "include/forms.inc.php";
- require_once "include/classes/chart.inc.php";
- require_once "include/classes/pie.inc.php";
+ require_once('include/config.inc.php');
+ require_once('include/hosts.inc.php');
+ require_once('include/graphs.inc.php');
+ require_once('include/forms.inc.php');
+ require_once('include/classes/chart.inc.php');
+ require_once('include/classes/pie.inc.php');
$page["title"] = "S_CONFIGURATION_OF_GRAPHS";
@@ -87,8 +87,7 @@ include_once "include/page_header.php";
validate_sort_and_sortorder('g.name',ZBX_SORT_UP);
$options = array('allow_all_hosts','only_current_node','always_select_first_host');//'with_monitored_items',
- validate_group_with_host(PERM_READ_WRITE,$options,'web.last.conf.groupid', 'web.last.conf.hostid');
-//SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']);
+ validate_group_with_host(PERM_READ_WRITE,$options,'web.last.conf.groupid', 'web.last.conf.hostid');
?>
<?php
@@ -97,7 +96,7 @@ include_once "include/page_header.php";
$_REQUEST['graph3d'] = get_request('graph3d', 0);
$_REQUEST['legend'] = get_request('legend', 0);
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE);
$available_graphs = get_accessible_graphs(PERM_READ_WRITE,PERM_RES_IDS_ARRAY);
// ---- <ACTIONS> ----
@@ -206,7 +205,7 @@ include_once "include/page_header.php";
$sql = 'SELECT distinct h.hostid '.
' FROM hosts h, hosts_groups hg'.
' WHERE h.hostid=hg.hostid '.
- ' AND hg.groupid IN ('.implode(',',$_REQUEST['copy_targetid']).')'.
+ ' AND '.DBcondition('hg.groupid',$_REQUEST['copy_targetid']).
' AND '.DBcondition('h.hostid',$available_hosts);
$db_hosts = DBselect($sql);
while($db_host = DBfetch($db_hosts)){
@@ -310,8 +309,8 @@ include_once "include/page_header.php";
$r_form = new CForm();
$r_form->SetMethod('get');
- $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
- $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()");
+ $cmbGroup = new CComboBox('groupid',$_REQUEST['groupid'],'submit()');
+ $cmbHosts = new CComboBox('hostid',$_REQUEST['hostid'],'submit()');
$cmbGroup->AddItem(0,S_ALL_SMALL);
@@ -322,17 +321,17 @@ include_once "include/page_header.php";
' ORDER BY g.name';
$result=DBselect($sql);
while($row=DBfetch($result)){
- $cmbGroup->AddItem($row["groupid"],$row["name"]);
+ $cmbGroup->AddItem($row['groupid'],$row['name']);
}
$r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
- if($_REQUEST["groupid"] > 0){
+ if($_REQUEST['groupid'] > 0){
$sql='SELECT DISTINCT h.hostid,h.host '.
' FROM hosts h, hosts_groups hg '.
- ' WHERE hg.groupid='.$_REQUEST["groupid"].
+ ' WHERE hg.groupid='.$_REQUEST['groupid'].
' AND hg.hostid=h.hostid '.
' AND '.DBcondition('h.hostid',$available_hosts).
- ' AND h.status IN ('.HOST_STATUS_MONITORED.','.HOST_STATUS_TEMPLATE.') '.
+ ' AND h.status IN ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.','.HOST_STATUS_TEMPLATE.') '.
' ORDER BY h.host';
}
else{
@@ -340,7 +339,7 @@ include_once "include/page_header.php";
$sql='SELECT DISTINCT h.hostid,h.host '.
' FROM hosts h '.
' WHERE '.DBcondition('h.hostid',$available_hosts).
- ' AND h.status IN ('.HOST_STATUS_MONITORED.','.HOST_STATUS_TEMPLATE.') '.
+ ' AND h.status IN ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.','.HOST_STATUS_TEMPLATE.') '.
' ORDER BY h.host';
}
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php
index 94fb19ec..308ff631 100644
--- a/frontends/php/hosts.php
+++ b/frontends/php/hosts.php
@@ -19,19 +19,20 @@
**/
?>
<?php
- require_once 'include/config.inc.php';
- require_once 'include/hosts.inc.php';
- require_once 'include/forms.inc.php';
+ require_once('include/config.inc.php');
+ require_once('include/hosts.inc.php');
+ require_once('include/forms.inc.php');
$page['title'] = "S_HOSTS";
$page['file'] = 'hosts.php';
$page['hist_arg'] = array('groupid','config','hostid');
-
-include_once 'include/page_header.php';
+ $page['scripts'] = array('menu_scripts.js');
+
+include_once('include/page_header.php');
$_REQUEST['config'] = get_request('config',get_profile('web.hosts.config',0));
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE);
if(isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0 && !uint_in_array($_REQUEST['hostid'], $available_hosts)) {
access_deny();
}
@@ -127,7 +128,7 @@ include_once 'include/page_header.php';
if($_REQUEST['config']==4)
validate_group_with_host(PERM_READ_WRITE,array('always_select_first_host','only_current_node'),'web.last.conf.groupid', 'web.last.conf.hostid');
else if($_REQUEST['config']==0 || $_REQUEST['config']==3)
- validate_group(PERM_READ_WRITE,array(),'web.last.conf.groupid');
+ validate_group(PERM_READ_WRITE,array('real_hosts'),'web.last.conf.groupid');
update_profile('web.hosts.config',$_REQUEST['config'], PROFILE_TYPE_INT);
?>
@@ -954,7 +955,7 @@ include_once 'include/page_header.php';
else
$status_filter = ' AND h.status IN ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.') ';
- $cmbGroups = new CComboBox("groupid",get_request("groupid",0),"submit()");
+ $cmbGroups = new CComboBox('groupid',get_request('groupid',0),'submit()');
$cmbGroups->AddItem(0,S_ALL_SMALL);
$result=DBselect('SELECT DISTINCT g.groupid,g.name '.
@@ -1012,7 +1013,6 @@ include_once 'include/page_header.php';
$sql.= ' WHERE hg.groupid='.$_REQUEST['groupid'].
' AND hg.hostid=h.hostid '.
' AND';
-
}
else{
$sql.= ' hosts h WHERE ';
@@ -1095,7 +1095,7 @@ include_once 'include/page_header.php';
}
- $show = host_js_menu($row["hostid"]);
+ $show = host_js_menu($row['hostid']);
$templates_linked = array();
foreach($templates as $templateid => $temp){
@@ -1112,6 +1112,11 @@ include_once 'include/page_header.php';
$available,
$error,
$show));
+
+ $jsmenu = new CPUMenu(null,270);
+ $jsmenu->InsertJavaScript();
+
+ set_hosts_jsmenu_array();
}
$footerButtons = array(
@@ -1161,7 +1166,7 @@ include_once 'include/page_header.php';
$db_groups=DBselect('SELECT g.groupid,g.name '.
' FROM groups g'.
- ' WHERE g.groupid in ('.$available_groups.')'.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
order_by('g.name'));
while($db_group=DBfetch($db_groups)){
$db_hosts = DBselect('SELECT DISTINCT h.host, h.status'.
@@ -1384,27 +1389,27 @@ include_once 'include/page_header.php';
$table = new CTableInfo(S_NO_PROXIES_DEFINED);
$table->setHeader(array(
- array( new CCheckBox("all_hosts",NULL,
- "CheckAll('".$form->GetName()."','all_hosts');"),
- SPACE,
- make_sorting_link(S_NAME,'g.name')),
- S_LASTSEEN_AGE,
- ' # ',
- S_MEMBERS));
-
- $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE);
+ array(new CCheckBox("all_hosts",NULL,"CheckAll('".$form->GetName()."','all_hosts');"),
+ SPACE,
+ make_sorting_link(S_NAME,'g.name')),
+ S_LASTSEEN_AGE,
+ ' # ',
+ S_MEMBERS
+ ));
- $db_proxies=DBselect('select hostid,host,lastaccess from hosts'.
- ' where status in ('.HOST_STATUS_PROXY.') and '.DBin_node('hostid').
- order_by('host'));
- while($db_proxy=DBfetch($db_proxies))
- {
+ $db_proxies=DBselect('SELECT hostid,host,lastaccess '.
+ ' FROM hosts'.
+ ' WHERE status IN ('.HOST_STATUS_PROXY.') '.
+ ' AND '.DBin_node('hostid').
+ order_by('host'));
+
+ while($db_proxy=DBfetch($db_proxies)){
$db_hosts = DBselect('SELECT DISTINCT host,status'.
' FROM hosts'.
' WHERE proxy_hostid='.$db_proxy['hostid'].
' AND '.DBcondition('hostid',$available_hosts).
- ' and status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.')'.
- ' order by host'
+ ' AND status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.')'.
+ ' ORDER BY host'
);
$hosts = array();
diff --git a/frontends/php/httpmon.php b/frontends/php/httpmon.php
index bdd8f560..1884596b 100644
--- a/frontends/php/httpmon.php
+++ b/frontends/php/httpmon.php
@@ -114,13 +114,13 @@ include_once "include/page_header.php";
$cmbGroup = new CComboBox("groupid",null,"submit();");
$cmbGroup->AddItem(0,S_ALL_SMALL);
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST,PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST);
$available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST);
//\ ([hg]{1,2}\.hostid)\ [inIN]+\ \(.\.\$[a-z_]+\..\)\
// '.DBcondition('$1',$available_hosts)
$result=DBselect('SELECT DISTINCT g.groupid,g.name '.
' FROM groups g, hosts_groups hg, hosts h, applications a, httptest ht '.
- ' WHERE g.groupid in ('.$available_groups.') '.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND hg.groupid=g.groupid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND h.hostid=a.hostid '.
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php
index 401f68d5..2a895fc8 100644
--- a/frontends/php/include/actions.inc.php
+++ b/frontends/php/include/actions.inc.php
@@ -30,7 +30,7 @@ function action_accessible($actionid,$perm){
if (DBselect('select actionid from actions where actionid='.$actionid.' and '.DBin_node('actionid'))){
$result = true;
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY);
$available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY);
$db_result = DBselect('SELECT * FROM conditions WHERE actionid='.$actionid);
@@ -72,7 +72,7 @@ function check_permission_for_action_conditions($conditions){
$result = true;
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY);
$available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY);
foreach($conditions as $ac_data){
@@ -711,7 +711,7 @@ function validate_condition($conditiontype, $value)
break;
case CONDITION_TYPE_HOST_TEMPLATE:
if(!uint_in_array($value,
- get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY)))
+ get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY)))
{
error(S_INCORRECT_GROUP);
return false;
@@ -727,7 +727,7 @@ function validate_condition($conditiontype, $value)
break;
case CONDITION_TYPE_HOST:
if(!uint_in_array($value,
- get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY)))
+ get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY)))
{
error(S_INCORRECT_HOST);
return false;
diff --git a/frontends/php/include/classes/ccombobox.inc.php b/frontends/php/include/classes/ccombobox.inc.php
index 99d4ef7f..af79fbc6 100644
--- a/frontends/php/include/classes/ccombobox.inc.php
+++ b/frontends/php/include/classes/ccombobox.inc.php
@@ -21,11 +21,9 @@
<?php
require_once("include/classes/ctag.inc.php");
- class CComboItem extends CTag
- {
+ class CComboItem extends CTag{
/* public */
- function CComboItem($value,$caption=NULL,$selected=NULL, $enabled=NULL)
- {
+ function CComboItem($value,$caption=NULL,$selected=NULL, $enabled=NULL){
parent::CTag('option','yes');
$this->tag_body_start = "";
$this->options['value'] = $value;
@@ -36,20 +34,20 @@
$this->SetEnabled($enabled);
}
- function SetValue($value)
- {
+
+ function SetValue($value){
return $this->options['value'] = $value;
}
- function GetValue()
- {
+
+ function GetValue(){
return $this->GetOption('value');
}
- function SetCaption($value=NULL)
- {
+
+ function SetCaption($value=NULL){
$this->AddItem(nbsp($value));
}
- function SetSelected($value='yes')
- {
+
+ function SetSelected($value='yes'){
if((is_string($value) && ($value == 'yes' || $value == 'selected' || $value=='on'))
|| (is_int($value) && $value<>0))
return $this->options['selected'] = 'selected';
@@ -58,14 +56,12 @@
}
}
- class CComboBox extends CTag
- {
+ class CComboBox extends CTag{
/* private */
//var $value;
/* public */
- function CComboBox($name='combobox',$value=NULL,$action=NULL)
- {
+ function CComboBox($name='combobox',$value=NULL,$action=NULL){
parent::CTag('select','yes');
$this->tag_end = '';
@@ -78,16 +74,16 @@
$this->value = $value;
$this->SetAction($action);
}
- function SetAction($value='submit()', $event='onchange')
- {
+
+ function SetAction($value='submit()', $event='onchange'){
$this->AddOption($event,$value);
}
- function SetValue($value=NULL)
- {
+
+ function SetValue($value=NULL){
$this->value = $value;
}
- function AddItem($value, $caption='', $selected=NULL, $enabled='yes')
- {
+
+ function AddItem($value, $caption='', $selected=NULL, $enabled='yes'){
// if($enabled=='no') return; /* disable item method 1 */
if(strtolower(get_class($value))=='ccomboitem'){
parent::AddItem($value);
@@ -118,8 +114,7 @@
$this->SetValue($value);
}
- function SetSize($value)
- {
+ function SetSize($value){
$this->options['size'] = $value;
}
}
@@ -157,6 +152,8 @@
class CTweenBox{
function ctweenbox(&$form,$name,$value=null,$size=10){
+ insert_javascript_for_twinbox();
+
$this->form = &$form;
$this->name = $name.'_tweenbox';
$this->varname = $name;
diff --git a/frontends/php/include/events.inc.php b/frontends/php/include/events.inc.php
index d860f480..26e4972e 100644
--- a/frontends/php/include/events.inc.php
+++ b/frontends/php/include/events.inc.php
@@ -346,8 +346,7 @@ function get_history_of_triggers_events($start,$num, $groupid=0, $hostid=0){
$sql_from = $sql_cond = '';
- $available_groups= get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST,PERM_RES_IDS_ARRAY);
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST,PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST);
$available_triggers = get_accessible_triggers(PERM_READ_ONLY, PERM_RES_DATA_ARRAY, get_current_nodeid());
if($hostid > 0){
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 7e6b0c3d..ff179ac6 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -894,7 +894,7 @@
if($perm_details){
$group_ids = array_keys($user_groups);
if(count($group_ids) == 0) $group_ids = array(-1);
- $db_rights = DBselect('SELECT * FROM rights r WHERE r.groupid IN ('.implode(',',$group_ids).')');
+ $db_rights = DBselect('SELECT * FROM rights r WHERE '.DBcondition('r.groupid',$group_ids));
$tmp_perm = array();
while($db_right = DBfetch($db_rights)){
@@ -1792,12 +1792,13 @@
$cmbGroups = new CComboBox("add_groupid",$add_groupid);
- $groups=DBselect("SELECT DISTINCT groupid,name FROM groups ".
- "where groupid in (".get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY).") ".
- " order by name");
- while($group=DBfetch($groups))
- {
- $cmbGroups->AddItem(
+ $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY);
+ $groups=DBselect('SELECT DISTINCT groupid,name '.
+ ' FROM groups '.
+ ' WHERE '.DBcondition('groupid',$available_groups).
+ ' order by name');
+ while($group=DBfetch($groups)){
+ $cmbGroups->AddItem(
$group["groupid"],
get_node_name_by_elid($group["groupid"]).$group["name"]
);
@@ -4050,10 +4051,11 @@
$frmHost->AddRow(S_NAME,S_ORIGINAL);
+ $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST);
$grp_tb = new CTweenBox($frmHost,'groups',$groups,6);
$db_groups=DBselect('SELECT DISTINCT groupid,name '.
' FROM groups '.
- ' WHERE groupid IN ('.get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST).') '.
+ ' WHERE '.DBcondition('groupid',$available_groups).
' ORDER BY name');
while($db_group=DBfetch($db_groups)){
@@ -4237,10 +4239,11 @@
$ip = $db_host['ip'];
// add groups
+ $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST);
$db_groups=DBselect('SELECT DISTINCT groupid '.
' FROM hosts_groups '.
' WHERE hostid='.$_REQUEST['hostid'].
- ' AND groupid in ('.get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST).') ');
+ ' AND '.DBcondition('groupid',$available_groups));
while($db_group=DBfetch($db_groups)){
if(uint_in_array($db_group['groupid'],$groups)) continue;
$groups[$db_group['groupid']] = $db_group['groupid'];
@@ -4284,10 +4287,11 @@
$frmHost->AddRow(S_NAME,new CTextBox('host',$host,20));
+ $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST);
$grp_tb = new CTweenBox($frmHost,'groups',$groups,10);
$db_groups=DBselect('SELECT DISTINCT groupid,name '.
' FROM groups '.
- ' WHERE groupid IN ('.get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST).') '.
+ ' WHERE '.DBcondition('groupid',$available_groups).
' ORDER BY name');
while($db_group=DBfetch($db_groups)){
@@ -4935,7 +4939,7 @@
$cmbType = new CComboBox("elementtype",$elementtype,"submit()");
$available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY);
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY);
$available_triggers = get_accessible_triggers(PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
$db_hosts = DBselect('SELECT DISTINCT n.name as node_name,h.hostid,h.host '.
@@ -5041,7 +5045,7 @@
$group_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name '.
' FROM groups g '.
' LEFT JOIN nodes n on n.nodeid='.DBid2nodeid('g.groupid').
- ' WHERE g.groupid in ('.$available_groups.') '.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND g.groupid='.$elementid.
' ORDER BY node_name,g.name'));
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index 86506f08..f16e2148 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -673,61 +673,18 @@ require_once "include/httptest.inc.php";
return $result;
}
- /*
- * Function: validate_group_with_templates
- *
- * Description:
- * Check available groups and host(template) by user permission
- * and check current group an host(template) relations
- *
- * Author:
- * Aly
- *
- * Comments:
- *
- */
- function validate_group_with_templates($perm, $options = array(),$group_var=null,$host_var=null){
- if(is_null($group_var)) $group_var = "web.latest.groupid";
- if(is_null($host_var)) $host_var = "web.latest.hostid";
-
- $_REQUEST["groupid"] = get_request("groupid", -1 );
- $_REQUEST["hostid"] = get_request("hostid", get_profile($host_var,0));
-
- if($_REQUEST["groupid"] == -1){
- $_REQUEST["groupid"] = get_profile($group_var,0);
-
- if(!in_node($_REQUEST["groupid"])) $_REQUEST["groupid"] = 0;
-
- if ($_REQUEST["hostid"] > 0 && !DBfetch(DBselect('SELECT groupid FROM hosts_groups '.
- ' WHERE hostid='.$_REQUEST["hostid"].' and groupid='.$_REQUEST["groupid"]))){
- $_REQUEST["groupid"] = 0;
- }
- }
-
- if(str_in_array("always_select_first_host",$options) && $_REQUEST["hostid"] == 0 && $_REQUEST["groupid"] != 0)
- $_REQUEST["hostid"] = -1;
-
- $result = get_correct_group_and_host($_REQUEST["groupid"],$_REQUEST["hostid"], $perm, $options);
-
- $_REQUEST["groupid"] = $result["groupid"];
- $_REQUEST["hostid"] = $result["hostid"];
-
- update_profile($host_var,$_REQUEST["hostid"]);
- update_profile($group_var,$_REQUEST["groupid"]);
- }
-
- /*
- * Function: get_correct_group_and_host
- *
- * Description:
- * Retrive correct relations for group and host
- *
- * Author:
- * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
- *
- * Comments:
- *
- */
+/*
+ * Function: get_correct_group_and_host
+ *
+ * Description:
+ * Retrive correct relations for group and host
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments:
+ *
+ */
function get_correct_group_and_host($a_groupid=null, $a_hostid=null, $perm=PERM_READ_WRITE, $options = array()){
if(!is_array($options)){
fatal_error("Incorrect options for get_correct_group_and_host");
@@ -790,19 +747,24 @@ require_once "include/httptest.inc.php";
if($groupid > 0){
$with_node = ' AND '.DBin_node('g.groupid', get_current_nodeid(!$only_current_node));
-
$sql = 'SELECT DISTINCT g.groupid '.
' FROM groups g, hosts_groups hg, hosts h'.$item_table.
' WHERE hg.groupid=g.groupid '.
' AND h.hostid=hg.hostid '.
' AND '.DBcondition('h.hostid',$available_hosts).
- ' AND g.groupid='.$groupid.
+// ' AND g.groupid='.$groupid.
$with_host_status.
$with_items.
$with_node;
- if(!DBfetch(DBselect($sql))){
- $groupid = 0;
+ if(!DBfetch(DBselect($sql.' AND g.groupid='.$groupid))){
+ if($db_group = DBfetch(DBselect($sql,1))){
+ $groupid = $db_group['groupid'];
+ }
+ else{
+ $groupid = 0;
+ }
}
+
}
}
@@ -880,7 +842,7 @@ require_once "include/httptest.inc.php";
"correct" => ($group_correct && $host_correct)?1:0
);
}
-
+
/*
* Function: validate_group_with_host
*
@@ -943,7 +905,7 @@ require_once "include/httptest.inc.php";
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'];
@@ -1334,62 +1296,41 @@ require_once "include/httptest.inc.php";
return $result;
}
-
- function host_js_menu($hostid, $link_text = S_SELECT){
- $add_to = array();
- $delete_from = array();
-
- $popup_menu_actions = array(
- array(S_SHOW, null, null, array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader'))),
- array(S_ITEMS, 'items.php?hostid='.$hostid, array('tw'=>'')),
- array(S_TRIGGERS, 'triggers.php?hostid='.$hostid, array('tw'=>'')),
- array(S_GRAPHS, 'graphs.php?hostid='.$hostid, array('tw'=>'')),
- );
-
- $db_groups = DBselect('SELECT g.groupid, g.name '.
- ' FROM groups g '.
- ' LEFT JOIN hosts_groups hg on g.groupid=hg.groupid and hg.hostid='.$hostid.
- ' WHERE hostid is NULL '.
- ' ORDER BY g.name,g.groupid');
- while($group_data = DBfetch($db_groups)){
- $add_to[] = array($group_data['name'], '?'.
- url_param($group_data['groupid'], false, 'add_to_group').
- url_param($hostid, false, 'hostid')
- );
- }
-
+ function set_hosts_jsmenu_array($hostids = array()){
+ $menu_all = array();
+
$db_groups = DBselect('SELECT g.groupid, g.name '.
+ ' FROM groups g '.
+ ' ORDER BY g.name,g.groupid');
+
+ while($group=DBfetch($db_groups)){
+ $group['name'] = htmlspecialchars($group['name']);
+
+ $menu_all[] = $group;
+ }
+ insert_js('var menu_hstgrp_all='.zbx_jsvalue($menu_all).";\n");
+ }
+
+ function host_js_menu($hostid,$link_text = S_SELECT){
+ $hst_grp_all_in = array();
+
+ $db_groups = DBselect('SELECT g.groupid, g.name '.
' FROM groups g, hosts_groups hg '.
' WHERE g.groupid=hg.groupid '.
' AND hg.hostid='.$hostid.
- ' ORDER BY g.name,g.groupid');
-
- while($group_data = DBfetch($db_groups)){
- $delete_from[] = array($group_data['name'], '?'.
- url_param($group_data['groupid'], false, 'delete_from_group').
- url_param($hostid, false, 'hostid')
- );
- }
-
- if(count($add_to) > 0 || count($delete_from) > 0){
- $popup_menu_actions[] = array(S_GROUPS, null, null,
- array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')));
- }
-
- if(count($add_to) > 0){
- $popup_menu_actions[] = array_merge(array(S_ADD_TO_GROUP, null, null,
- array('outer' => 'pum_o_submenu', 'inner'=>array('pum_i_submenu'))), $add_to);
- }
-
- if(count($delete_from) > 0){
- $popup_menu_actions[] = array_merge(array(S_DELETE_FROM_GROUP, null, null,
- array('outer' => 'pum_o_submenu', 'inner'=>array('pum_i_submenu'))), $delete_from);
- }
-
- $mnuActions = new CPUMenu($popup_menu_actions);
-
- $show = new CLink($link_text, '#', 'action', $mnuActions->GetOnActionJS());
-
- return $show;
+ ' ORDER BY g.name');
+
+ while($group = DBfetch($db_groups)){
+ $group['name'] = htmlspecialchars($group['name']);
+ $hst_grp_all_in[] = $group;
+ }
+
+ $action = new CSpan($link_text);
+ $script = new CScript('javascript: create_host_menu(event,'.$hostid.','.zbx_jsvalue($hst_grp_all_in).');');
+
+ $action->AddAction('onclick',$script);
+ $action->AddOption('onmouseover','javascript: this.style.cursor = "pointer";');
+
+ return $action;
}
-?>
+?> \ No newline at end of file
diff --git a/frontends/php/include/import.inc.php b/frontends/php/include/import.inc.php
index f906b67f..7f7a6544 100644
--- a/frontends/php/include/import.inc.php
+++ b/frontends/php/include/import.inc.php
@@ -34,9 +34,9 @@
$this->trigger = array('exist' => 0, 'missed' => 0);
$this->graph = array('exist' => 0, 'missed' => 0);
- $this->available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY);
+ $this->available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_WRITE);
- $this->available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY);
+ $this->available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_WRITE);
$this->available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY);
}
@@ -78,9 +78,9 @@
$data['groups'] = array();
$data['skip'] = false;
- if($host_data = DBfetch(DBselect('select hostid from hosts'.
- ' where host='.zbx_dbstr($data['name']).
- ' and '.DBin_node('hostid',get_current_nodeid(false)))))
+ if($host_data = DBfetch(DBselect('SELECT hostid FROM hosts'.
+ ' WHERE host='.zbx_dbstr($data['name']).
+ ' AND '.DBin_node('hostid',get_current_nodeid(false)))))
{ /* exist */
if($this->host['exist']==1) /* skip */{
$data['skip'] = true;
diff --git a/frontends/php/include/js.inc.php b/frontends/php/include/js.inc.php
index fcbfd365..79d04b35 100644
--- a/frontends/php/include/js.inc.php
+++ b/frontends/php/include/js.inc.php
@@ -150,6 +150,48 @@ function inseret_javascript_for_editable_combobox(){
insert_js($js);
}
+function insert_javascript_for_twinbox(){
+ global $page;
+ if(defined('SHOW_TWINBOX_SCRIPT_INSERTTED') || (PAGE_TYPE_HTML != $page['type'])) return;
+ define('SHOW_TWINBOX_SCRIPT_INSERTTED', 1);
+
+ $js = 'function moveListBoxSelectedItem(formname,objname,from,to,action){
+ var result = true
+
+ from = $(from);
+ to = $(to);
+
+ for(i = 0; i < from.options.length; i++) {
+ if(from.options[i].selected == true) {
+/*
+ var temp = document.createElement("option");
+ temp.setAttribute("value",from.options[i].value);
+
+ var caption = IE?from.options[i].innerText:from.options[i].textContent;
+ temp.appendChild(document.createTextNode(caption));
+*/
+ var temp = from.options[i].cloneNode(true);
+
+ if(action.toLowerCase() == "add"){
+ result &= create_var(formname, objname+"["+from.options[i].value+"]", from.options[i].value, false);
+ }
+ else if(action.toLowerCase() == "rmv"){
+ result &= remove_element(objname+"["+from.options[i].value+"]","input");
+ }
+
+ from.removeChild(from.options[i]);
+
+ to.appendChild(temp);
+ i--;
+ }
+ }
+
+ return result;
+ }';
+
+ insert_js($js);
+}
+
function insert_showhint_javascript(){
global $page;
if(defined('SHOW_HINT_SCRIPT_INSERTTED') || (PAGE_TYPE_HTML != $page['type'])) return;
diff --git a/frontends/php/include/maps.inc.php b/frontends/php/include/maps.inc.php
index eb1e6a17..61c2863b 100644
--- a/frontends/php/include/maps.inc.php
+++ b/frontends/php/include/maps.inc.php
@@ -103,7 +103,7 @@
}
break;
case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
- $available_groups = get_accessible_groups_by_user($USER_DETAILS,$perm,PERM_RES_IDS_ARRAY);
+ $available_groups = get_accessible_groups_by_user($USER_DETAILS,$perm);
if(!uint_in_array($se_data['elementid'],$available_groups)){
$result = false;
}
diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php
index c8c25a16..d497519e 100644
--- a/frontends/php/include/page_header.php
+++ b/frontends/php/include/page_header.php
@@ -422,9 +422,9 @@ COpt::profiling_start("page");
}
}
?>
-
- <script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/prototype.js"></script>
+ <script type="text/javascript" src="js/common.js"></script>
+ <script type="text/javascript" src="js/ajax_req.js"></script>
<script type="text/javascript" src="js/url.js"></script>
<script type="text/javascript" src="js/chkbxrange.js"></script>
<?php
diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php
index 9c3ee565..354ee113 100644
--- a/frontends/php/include/perm.inc.php
+++ b/frontends/php/include/perm.inc.php
@@ -267,7 +267,7 @@ function get_accessible_hosts_by_user(&$user_data,$perm,$perm_res=null,$nodeid=n
// global $DB;
static $available_hosts;
- if(is_null($perm_res)) $perm_res = PERM_RES_STRING_LINE;
+ if(is_null($perm_res)) $perm_res = PERM_RES_IDS_ARRAY;//PERM_RES_STRING_LINE;
if($perm == PERM_READ_LIST) $perm = PERM_READ_ONLY;
$result = array();
@@ -366,7 +366,7 @@ function get_accessible_groups_by_user($user_data,$perm,$perm_res=null,$nodeid=n
global $ZBX_LOCALNODEID;
if(is_null($nodeid)) $nodeid = get_current_nodeid();
- if(is_null($perm_res)) $perm_res = PERM_RES_STRING_LINE;
+ if(is_null($perm_res)) $perm_res = PERM_RES_IDS_ARRAY;//PERM_RES_STRING_LINE;
$result = array();
diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php
index af018a4a..7df7ec0b 100644
--- a/frontends/php/include/screens.inc.php
+++ b/frontends/php/include/screens.inc.php
@@ -622,10 +622,11 @@
$id=0;
if($resourceid > 0){
+ $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY);
$result=DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name '.
' FROM hosts_groups hg,hosts h,groups g '.
' LEFT JOIN nodes n ON n.nodeid='.DBid2nodeid('g.groupid').
- ' WHERE g.groupid IN ('.get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY).')'.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND g.groupid=hg.groupid '.
' AND hg.hostid=h.hostid '.
' AND h.status='.HOST_STATUS_MONITORED.
@@ -681,11 +682,12 @@
$caption = '';
$id=0;
+ $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY);
if(remove_nodes_from_id($resourceid) > 0){
$result=DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name '.
' FROM hosts_groups hg, groups g '.
' LEFT JOIN nodes n ON n.nodeid='.DBid2nodeid('g.groupid').
- ' WHERE g.groupid in ('.get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY).')'.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND g.groupid='.$resourceid);
while($row=DBfetch($result)){
diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php
index 9ccadc72..2cd898ce 100644
--- a/frontends/php/include/users.inc.php
+++ b/frontends/php/include/users.inc.php
@@ -314,9 +314,12 @@
function update_user_group($usrgrpid,$name,$users_status,$gui_access,$users=array(),$rights=array()){
global $USER_DETAILS;
- if(DBfetch(DBselect('SELECT * FROM usrgrp WHERE name='.zbx_dbstr($name).
- ' and usrgrpid<>'.$usrgrpid.' and '.DBin_node('usrgrpid', get_current_nodeid(false)))))
- {
+ $sql = 'SELECT * '.
+ ' FROM usrgrp '.
+ ' WHERE name='.zbx_dbstr($name).
+ ' AND usrgrpid<>'.$usrgrpid.
+ ' AND '.DBin_node('usrgrpid', get_current_nodeid(false));
+ if(DBfetch(DBselect($sql))){
error("Group '$name' already exists");
return 0;
}
@@ -358,7 +361,7 @@
return $result;
}
- function delete_user_group($usrgrpid){
+ function delete_user_group($usrgrpid){
$result = DBexecute("delete from rights where groupid=$usrgrpid");
if(!$result) return $result;
@@ -371,7 +374,7 @@
return $result;
}
- function get_group_by_usrgrpid($usrgrpid){
+ function get_group_by_usrgrpid($usrgrpid){
if($row = DBfetch(DBselect("select * from usrgrp where usrgrpid=".$usrgrpid))){
return $row;
}
@@ -418,7 +421,7 @@
}
/********************************/
- function get_user_menu_array($userids = array()){
+ function set_users_jsmenu_array(){
$menu_all = array();
$menu_gui_access = array();
$menu_users_status = array();
@@ -464,28 +467,27 @@
' WHERE ug.userid='.$userid.
' AND g.usrgrpid=ug.usrgrpid '.
' AND '.DBin_node('g.usrgrpid', get_current_nodeid(false));
- if($res = DBselect($sql)){
- while($group = DBFetch($res)){
- $group['name'] = htmlspecialchars($group['name']);
-
- $gui_access = $group['gui_access'];
- $users_status = $group['users_status'];
-
- unset($group['gui_access']);
- unset($group['users_status']);
+ $res = DBselect($sql);
+
+ while($group = DBFetch($res)){
+ $group['name'] = htmlspecialchars($group['name']);
- $usr_grp_all_in[] = $group;
- if($gui_access != GROUP_GUI_ACCESS_SYSTEM){
- $usr_grp_gui_in[] = $groups;
- }
- if($users_status == GROUP_STATUS_DISABLED){
- $usr_grp_status_in[] = $group;
- }
+ $gui_access = $group['gui_access'];
+ $users_status = $group['users_status'];
+
+ unset($group['gui_access']);
+ unset($group['users_status']);
+
+ $usr_grp_all_in[] = $group;
+ if($gui_access != GROUP_GUI_ACCESS_SYSTEM){
+ $usr_grp_gui_in[] = $group;
+ }
+ if($users_status == GROUP_STATUS_DISABLED){
+ $usr_grp_status_in[] = $group;
}
}
$action = new CSpan(S_SELECT);
-
$script = new CScript("javascript: create_user_menu(event,".
$userid.",".
zbx_jsvalue($usr_grp_all_in).",".
diff --git a/frontends/php/items.php b/frontends/php/items.php
index 731cb258..db101da2 100644
--- a/frontends/php/items.php
+++ b/frontends/php/items.php
@@ -447,16 +447,12 @@ include_once "include/page_header.php";
}
else{ /* groups */
$hosts_ids = array();
- $group_ids = "";
- foreach($_REQUEST['copy_targetid'] as $group_id){
- $group_ids .= $group_id.',';
- }
- $group_ids = trim($group_ids,',');
+ $group_ids = $_REQUEST['copy_targetid'];
- $db_hosts = DBselect('select distinct h.hostid '.
- ' from hosts h, hosts_groups hg'.
- ' where h.hostid=hg.hostid '.
- ' and hg.groupid in ('.$group_ids.')');
+ $db_hosts = DBselect('SELECT DISTINCT h.hostid '.
+ ' FROM hosts h, hosts_groups hg'.
+ ' WHERE h.hostid=hg.hostid '.
+ ' AND '.DBcondition('hg.groupid',$group_ids));
while($db_host = DBfetch($db_hosts)){
array_push($hosts_ids, $db_host['hostid']);
}
diff --git a/frontends/php/js/ajax_req.js b/frontends/php/js/ajax_req.js
new file mode 100644
index 00000000..b1eb851f
--- /dev/null
+++ b/frontends/php/js/ajax_req.js
@@ -0,0 +1,143 @@
+// JavaScript Document
+/*
+** ZABBIX
+** Copyright (C) 2000-2008 SIA Zabbix
+**
+** 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+function send_params(params){
+
+ var uri = new url(location.href);
+ new Ajax.Request(uri.getPath()+"?output=ajax",
+ {
+ 'method': 'post',
+ 'parameters':params,
+ 'onSuccess': function(resp){ },//alert(resp.responseText);
+ 'onFailure': function(){ document.location = uri.getPath()+'?'+Object.toQueryString(params); }
+ }
+ );
+}
+
+
+function setRefreshRate(id,interval){
+ if(typeof(Ajax) == 'undefined'){
+ throw("Prototype.js lib is required!");
+ return false;
+ }
+
+ var params = {
+ 'favobj': 'set_rf_rate',
+ 'favid': id,
+ 'favcnt': interval
+ }
+
+ send_params(params);
+}
+
+function add2favorites(favobj,favid){
+ if('undefined' == typeof(Ajax)){
+ throw("Prototype.js lib is required!");
+ return false;
+ }
+
+ if(typeof(favobj) == 'undefined'){
+ var fav_form = document.getElementById('fav_form');
+ if(!fav_form) throw "Object not found.";
+
+ var favobj = fav_form.favobj.value;
+ var favid = fav_form.favid.value;
+ }
+
+ if((typeof(favid) == 'undefined') || empty(favid)) return;
+
+ var params = {
+ 'favobj': favobj,
+ 'favid': favid,
+ 'action': 'add'
+ }
+
+ send_params(params);
+// json.onetime('dashboard.php?output=json&'+Object.toQueryString(params));
+}
+
+function rm4favorites(favobj,favid,menu_rowid){
+// alert(favobj+','+favid+','+menu_rowid);
+ if('undefined' == typeof(Ajax)){
+ throw("Prototype.js lib is required!");
+ return false;
+ }
+
+ if((typeof(favobj) == 'undefined') || (typeof(favid) == 'undefined'))
+ throw "No agruments sent to function [rm4favorites()].";
+
+ var params = {
+ 'favobj': favobj,
+ 'favid': favid,
+ 'favcnt': menu_rowid,
+ 'action': 'remove'
+ }
+
+ send_params(params);
+// json.onetime('dashboard.php?output=json&'+Object.toQueryString(params));
+}
+
+function change_hat_state(icon, divid){
+ deselectAll();
+ var hat_state = ShowHide(divid);
+ switchElementsClass(icon,"arrowup","arrowdown");
+
+ if(false === hat_state) return false;
+
+ var params = {
+ 'favobj': 'hat',
+ 'favid': divid,
+ 'state': hat_state
+ }
+
+ send_params(params);
+}
+
+function change_filter_state(icon, divid){
+ deselectAll();
+ var filter_state = ShowHide(divid);
+ switchElementsClass(icon,"filteropened","filterclosed");
+
+ if(false === filter_state) return false;
+
+ var params = {
+ 'favobj': 'filter',
+ 'favid': divid,
+ 'state': filter_state
+ }
+
+ send_params(params);
+}
+
+
+function switch_mute(icon){
+ deselectAll();
+ var sound_state = switchElementsClass(icon,"iconmute","iconsound");
+
+ if(false === sound_state) return false;
+ sound_state = (sound_state == "iconmute")?1:0;
+
+ var params = {
+ 'favobj': 'sound',
+ 'state': sound_state
+ }
+
+ send_params(params);
+} \ No newline at end of file
diff --git a/frontends/php/js/chkbxrange.js b/frontends/php/js/chkbxrange.js
index ba57b3c8..a2dcc23e 100644
--- a/frontends/php/js/chkbxrange.js
+++ b/frontends/php/js/chkbxrange.js
@@ -1,4 +1,26 @@
// JavaScript Document
+/*
+** ZABBIX
+** Copyright (C) 2000-2008 SIA Zabbix
+**
+** 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+*/
+
+// Title: automatic checkbox range selection class
+// Author: Aly
var chkbx_range_ext = {
startbox: null, // start checkbox obj
diff --git a/frontends/php/js/common.js b/frontends/php/js/common.js
index 97befa5d..efed52ef 100644
--- a/frontends/php/js/common.js
+++ b/frontends/php/js/common.js
@@ -16,6 +16,8 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
+
+
var agt = navigator.userAgent.toLowerCase();
var OP = (agt.indexOf("opera") != -1) && window.opera;
var IE = (agt.indexOf("msie") != -1) && document.all && !OP;
@@ -61,20 +63,6 @@ function is_array(obj) {
'splice' in obj && 'join' in obj;
}
-if (!Array.prototype.forEach){
- Array.prototype.forEach = function(fun /*, thisp*/){
- var len = this.length;
- if (typeof fun != "function")
- throw new TypeError();
-
- var thisp = arguments[1];
- for (var i = 0; i < len; i++){
- if (i in this)
- fun.call(thisp, this[i], i, this);
- }
- };
-}
-
function SDI(msg){
var div_help = document.getElementById('div_help');
@@ -94,113 +82,20 @@ function SDI(msg){
div_help.appendChild(document.createElement("br"));
}
-function close_window(){
-
- window.setTimeout("window.close()", 500); /* Solve bug for Internet Explorer */
- return false;
-}
-
-function add2favorites(favobj,favid){
- if('undefined' == typeof(Ajax)){
- throw("Prototype.js lib is required!");
- return false;
- }
+/// Alpha-Betic sorting
- if(typeof(favobj) == 'undefined'){
- var fav_form = document.getElementById('fav_form');
- if(!fav_form) throw "Object not found.";
-
- var favobj = fav_form.favobj.value;
- var favid = fav_form.favid.value;
- }
-
- if((typeof(favid) == 'undefined') || empty(favid)) return;
-
- var params = {
- 'favobj': favobj,
- 'favid': favid,
- 'action': 'add'
- }
+function addListener(element, eventname, expression, bubbling){
+ bubbling = bubbling || false;
- send_params(params);
-// json.onetime('dashboard.php?output=json&'+Object.toQueryString(params));
-}
-
-function rm4favorites(favobj,favid,menu_rowid){
-// alert(favobj+','+favid+','+menu_rowid);
- if('undefined' == typeof(Ajax)){
- throw("Prototype.js lib is required!");
- return false;
- }
-
- if((typeof(favobj) == 'undefined') || (typeof(favid) == 'undefined'))
- throw "No agruments sent to function [rm4favorites()].";
-
- var params = {
- 'favobj': favobj,
- 'favid': favid,
- 'favcnt': menu_rowid,
- 'action': 'remove'
- }
-
- send_params(params);
-// json.onetime('dashboard.php?output=json&'+Object.toQueryString(params));
-}
-
-function getPosition(obj){
- var pos = {top: 0, left: 0};
- if(typeof(obj.offsetParent) != 'undefined') {
- pos.left = obj.offsetLeft;
- pos.top = obj.offsetTop;
- while (obj = obj.offsetParent) {
- pos.left += obj.offsetLeft;
- pos.top += obj.offsetTop;
- }
- }
-return pos;
-}
-
-function get_scroll_pos(){
- var scrOfX = 0, scrOfY = 0;
-//Netscape compliant
- if( typeof( window.pageYOffset ) == 'number' ){
- scrOfY = window.pageYOffset;
- scrOfX = window.pageXOffset;
- }
-//DOM compliant
- else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ){
- scrOfY = document.body.scrollTop;
- scrOfX = document.body.scrollLeft;
- }
-//IE6 standards compliant mode
- else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ){
- scrOfY = document.documentElement.scrollTop;
- scrOfX = document.documentElement.scrollLeft;
- }
- return [ scrOfX, scrOfY ];
-}
-
-function get_cursor_position(e){
- e = e || window.event;
- var cursor = {x:0, y:0};
- if(e.pageX || e.pageY){
- cursor.x = e.pageX;
- cursor.y = e.pageY;
+ if(window.addEventListener) {
+ element.addEventListener(eventname, expression, bubbling);
+ return true;
}
- else {
- var de = document.documentElement;
- var b = document.body;
- cursor.x = e.clientX +
- (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
- cursor.y = e.clientY +
- (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
- }
- return cursor;
-}
-
-function redirect(url) {
- window.location = url;
- return false;
+ else if(window.attachEvent) {
+ element.attachEvent('on'+eventname, expression);
+ return true;
+ }
+ else return false;
}
function add_variable(o_el, s_name, x_value, s_formname, o_document){
@@ -235,6 +130,48 @@ function add_variable(o_el, s_name, x_value, s_formname, o_document){
return true;
}
+function cancelEvent(e){
+ if (!e) var e = window.event;
+//SDI(e);
+ if(e){
+ if(IE){
+ e.cancelBubble = true;
+ e.returnValue = false;
+ }
+ else{
+ e.stopPropagation();
+ e.preventDefault();
+ }
+ }
+return false;
+}
+
+function CheckAll(form_name, chkMain, shkName){
+ var frmForm = document.forms[form_name];
+ var value = frmForm.elements[chkMain].checked;
+ for (var i=0; i < frmForm.length; i++){
+ name = frmForm.elements[i].name.split('[')[0];
+ if(frmForm.elements[i].type != 'checkbox') continue;
+ if(name == chkMain) continue;
+ if(shkName && shkName != name) continue;
+ if(frmForm.elements[i].disabled == true) continue;
+ frmForm.elements[i].checked = value;
+ }
+}
+
+function close_window(){
+
+ window.setTimeout("window.close()", 500); /* Solve bug for Internet Explorer */
+ return false;
+}
+
+function Confirm(msg){
+ if(confirm(msg,'title'))
+ return true;
+ else
+ return false;
+}
+
function create_var(form_name, var_name, var_val, subm){
var frmForm = (is_string(form_name))?document.forms[form_name]:form_name;
@@ -263,121 +200,6 @@ function create_var(form_name, var_name, var_val, subm){
return false;
}
-function Confirm(msg){
- if(confirm(msg,'title'))
- return true;
- else
- return false;
-}
-
-function ShowHide(obj,style){
- if(typeof(style) == 'undefined')
- var style = 'inline';
- if(is_string(obj))
- obj = document.getElementById(obj);
- if(!obj){
- throw 'ShowHide(): Object not foun.';
- return false;
- }
-
- if(obj.style.display != 'none'){
- obj.style.display = 'none';
- return 0;
- }
- else{
- obj.style.display = style;
- return 1;
- }
-return false;
-}
-
-function switchElementsClass(obj,class1,class2){
- obj = $(obj);
- if(!obj) return false;
-
- if(obj.className == class1){
- obj.className = class2;
- return class2;
- }
- else{
- obj.className = class1;
- return class1;
- }
-return false;
-}
-
-function PopUp(url,width,height,form_name){
- if(!width) width = 600;
- if(!height) height = 450;
- if(!form_name) form_name = 'zbx_popup';
-
- var left = (screen.width-(width+150))/2;
- var top = (screen.height-(height+150))/2;
-
- var popup = window.open(url,form_name,'width=' + width +',height=' + height + ',top='+ top +',left='+ left +
- ',resizable=yes,scrollbars=yes,location=no,menubar=no');
-
- popup.focus();
-
- return false;
-}
-
-function CheckAll(form_name, chkMain, shkName){
- var frmForm = document.forms[form_name];
- var value = frmForm.elements[chkMain].checked;
- for (var i=0; i < frmForm.length; i++){
- name = frmForm.elements[i].name.split('[')[0];
- if(frmForm.elements[i].type != 'checkbox') continue;
- if(name == chkMain) continue;
- if(shkName && shkName != name) continue;
- if(frmForm.elements[i].disabled == true) continue;
- frmForm.elements[i].checked = value;
- }
-}
-
-
-
-function openWinCentered(loc, winname, iwidth, iheight, params){
- tp=Math.ceil((screen.height-iheight)/2);
- lf=Math.ceil((screen.width-iwidth)/2);
- if (params.length > 0){
- params = ', ' + params;
- }
-
- var WinObjReferer = window.open(loc,winname,"width="+iwidth+",height="+iheight+",top="+tp+",left="+lf+params);
- WinObjReferer.focus();
-}
-
-
-function addListener(element, eventname, expression, bubbling){
- bubbling = bubbling || false;
-
- if(window.addEventListener) {
- element.addEventListener(eventname, expression, bubbling);
- return true;
- }
- else if(window.attachEvent) {
- element.attachEvent('on'+eventname, expression);
- return true;
- }
- else return false;
-}
-
-function cancelEvent(e){
- if (!e) var e = window.event;
-//SDI(e);
- if(e){
- if(IE){
- e.cancelBubble = true;
- e.returnValue = false;
- }
- else{
- e.stopPropagation();
- e.preventDefault();
- }
- }
-return false;
-}
function deselectAll(){
if(IE){
@@ -389,6 +211,24 @@ function deselectAll(){
}
}
+function empty_form(id){
+ id = $(id);
+ var count = 0;
+
+ var inputs = id.getElementsByTagName('input');
+ for(var i=0; i<inputs.length;i++){
+ if((inputs[i].type == 'text') && (typeof(inputs[i].hidden) == 'undefined') && !empty(inputs[i].value)) return false;
+ if((inputs[i].type == 'checkbox') && (inputs[i].checked)) return false;
+ }
+
+ var selects = id.getElementsByTagName('select');
+ for(var i=0; i<selects.length;i++){
+ if((typeof(selects[i].hidden) == 'undefined') && (selects[i].selectedIndex)) return false;
+ }
+
+return true;
+}
+
function eventTarget(e){
var targ = false;
@@ -402,71 +242,20 @@ function eventTarget(e){
return targ;
}
-function send_params(params){
-
- var uri = new url(location.href);
- new Ajax.Request(uri.getPath()+"?output=ajax",
- {
- 'method': 'post',
- 'parameters':params,
- 'onSuccess': function(resp){ },//alert(resp.responseText);
- 'onFailure': function(){ document.location = uri.getPath()+'?'+Object.toQueryString(params); }
- }
- );
-}
-
-
-/************************************************************************************/
-/* Pages stuff */
-/************************************************************************************/
-function change_hat_state(icon, divid){
- deselectAll();
- var hat_state = ShowHide(divid);
- switchElementsClass(icon,"arrowup","arrowdown");
-
- if(false === hat_state) return false;
-
- var params = {
- 'favobj': 'hat',
- 'favid': divid,
- 'state': hat_state
- }
-
- send_params(params);
-}
-
-function change_filter_state(icon, divid){
- deselectAll();
- var filter_state = ShowHide(divid);
- switchElementsClass(icon,"filteropened","filterclosed");
-
- if(false === filter_state) return false;
-
- var params = {
- 'favobj': 'filter',
- 'favid': divid,
- 'state': filter_state
- }
-
- send_params(params);
-}
-
-function switch_mute(icon){
- deselectAll();
- var sound_state = switchElementsClass(icon,"iconmute","iconsound");
-
- if(false === sound_state) return false;
- sound_state = (sound_state == "iconmute")?1:0;
-
- var params = {
- 'favobj': 'sound',
- 'state': sound_state
+function getPosition(obj){
+ var pos = {top: 0, left: 0};
+ if(typeof(obj.offsetParent) != 'undefined') {
+ pos.left = obj.offsetLeft;
+ pos.top = obj.offsetTop;
+ while (obj = obj.offsetParent) {
+ pos.left += obj.offsetLeft;
+ pos.top += obj.offsetTop;
+ }
}
-
- send_params(params);
+return pos;
}
-function GetSelectedText(obj){
+function getSelectedText(obj){
if(IE){
obj.focus();
return document.selection.createRange().text;
@@ -481,20 +270,91 @@ function GetSelectedText(obj){
return obj.value;
}
-function ScaleChartToParenElement(obj_name){
- var obj = document.getElementsByName(obj_name);
- if(obj.length <= 0) throw "Can't find objects with name [" + obj_name +"]";
+function get_bodywidth(){
+ var w = parseInt(document.body.scrollWidth);
+ var w2 = parseInt(document.body.offsetWidth);
- for(i = obj.length-1; i>=0; i--){
- obj[i].src += "&width=" + (obj[i].parentNode.offsetWidth - obj[i].parentNode.offsetLeft - 10);
+ if(KQ){
+ w = (w2 < w)?w2:w;
+ w-=16;
+ }
+ else{
+ w = (w2 > w)?w2:w;
}
+return w;
}
-function insert_sizeable_graph(graph_id,url){
- if((typeof(ZBX_G_WIDTH) != 'undefined')) url += "&amp;width="+ZBX_G_WIDTH;
- document.write('<img id="'+graph_id+'" src="'+url+'" alt="graph" /><br />');
+function get_cursor_position(e){
+ e = e || window.event;
+ var cursor = {x:0, y:0};
+ if(e.pageX || e.pageY){
+ cursor.x = e.pageX;
+ cursor.y = e.pageY;
+ }
+ else {
+ var de = document.documentElement;
+ var b = document.body;
+ cursor.x = e.clientX +
+ (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
+ cursor.y = e.clientY +
+ (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
+ }
+ return cursor;
+}
+
+function get_scroll_pos(){
+ var scrOfX = 0, scrOfY = 0;
+//Netscape compliant
+ if( typeof( window.pageYOffset ) == 'number' ){
+ scrOfY = window.pageYOffset;
+ scrOfX = window.pageXOffset;
+ }
+//DOM compliant
+ else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ){
+ scrOfY = document.body.scrollTop;
+ scrOfX = document.body.scrollLeft;
+ }
+//IE6 standards compliant mode
+ else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ){
+ scrOfY = document.documentElement.scrollTop;
+ scrOfX = document.documentElement.scrollLeft;
+ }
+ return [ scrOfX, scrOfY ];
+}
+
+
+function openWinCentered(loc, winname, iwidth, iheight, params){
+ tp=Math.ceil((screen.height-iheight)/2);
+ lf=Math.ceil((screen.width-iwidth)/2);
+ if (params.length > 0){
+ params = ', ' + params;
+ }
+
+ var WinObjReferer = window.open(loc,winname,"width="+iwidth+",height="+iheight+",top="+tp+",left="+lf+params);
+ WinObjReferer.focus();
+}
+
+function PopUp(url,width,height,form_name){
+ if(!width) width = 600;
+ if(!height) height = 450;
+ if(!form_name) form_name = 'zbx_popup';
+
+ var left = (screen.width-(width+150))/2;
+ var top = (screen.height-(height+150))/2;
+
+ var popup = window.open(url,form_name,'width=' + width +',height=' + height + ',top='+ top +',left='+ left +
+ ',resizable=yes,scrollbars=yes,location=no,menubar=no');
+
+ popup.focus();
+
+ return false;
+}
+
+function redirect(url) {
+ window.location = url;
+ return false;
}
function remove_childs(form_name,rmvbyname,tag){
@@ -552,69 +412,58 @@ function resizeiframe(id){
}
}
-function get_bodywidth(){
- var w = parseInt(document.body.scrollWidth);
- var w2 = parseInt(document.body.offsetWidth);
+function ShowHide(obj,style){
+ if(typeof(style) == 'undefined')
+ var style = 'inline';
+ if(is_string(obj))
+ obj = document.getElementById(obj);
+ if(!obj){
+ throw 'ShowHide(): Object not foun.';
+ return false;
+ }
- if(KQ){
- w = (w2 < w)?w2:w;
- w-=16;
+ if(obj.style.display != 'none'){
+ obj.style.display = 'none';
+ return 0;
}
else{
- w = (w2 > w)?w2:w;
+ obj.style.display = style;
+ return 1;
}
-return w;
+return false;
}
-function empty_form(id){
- id = $(id);
- var count = 0;
-
- var inputs = id.getElementsByTagName('input');
- for(var i=0; i<inputs.length;i++){
- if((inputs[i].type == 'text') && (typeof(inputs[i].hidden) == 'undefined') && !empty(inputs[i].value)) return false;
- if((inputs[i].type == 'checkbox') && (inputs[i].checked)) return false;
+function switchElementsClass(obj,class1,class2){
+ obj = $(obj);
+ if(!obj) return false;
+
+ if(obj.className == class1){
+ obj.className = class2;
+ return class2;
}
-
- var selects = id.getElementsByTagName('select');
- for(var i=0; i<selects.length;i++){
- if((typeof(selects[i].hidden) == 'undefined') && (selects[i].selectedIndex)) return false;
+ else{
+ obj.className = class1;
+ return class1;
}
-
-return true;
+return false;
}
-function moveListBoxSelectedItem(formname,objname,from,to,action){
- var result = true
-
- from = $(from);
- to = $(to);
-
- for(i = 0; i < from.options.length; i++) {
- if(from.options[i].selected == true) {
-/*
- var temp = document.createElement('option');
- temp.setAttribute('value',from.options[i].value);
-
- var caption = IE?from.options[i].innerText:from.options[i].textContent;
- temp.appendChild(document.createTextNode(caption));
-*/
- var temp = from.options[i].cloneNode(true);
-
- if(action.toLowerCase() == 'add'){
- result &= create_var(formname, objname+'['+from.options[i].value+']', from.options[i].value, false);
- }
- else if(action.toLowerCase() == 'rmv'){
- result &= remove_element(objname+'['+from.options[i].value+']','input');
- }
-
- from.removeChild(from.options[i]);
-
- to.appendChild(temp);
- i--;
- }
+/************************************************************************************/
+/* Pages stuff */
+/************************************************************************************/
+function ScaleChartToParenElement(obj_name){
+ var obj = document.getElementsByName(obj_name);
+
+ if(obj.length <= 0) throw "Can't find objects with name [" + obj_name +"]";
+
+ for(i = obj.length-1; i>=0; i--){
+ obj[i].src += "&width=" + (obj[i].parentNode.offsetWidth - obj[i].parentNode.offsetLeft - 10);
}
+}
-return result;
+function insert_sizeable_graph(graph_id,url){
+ if((typeof(ZBX_G_WIDTH) != 'undefined')) url += "&amp;width="+ZBX_G_WIDTH;
+
+ document.write('<img id="'+graph_id+'" src="'+url+'" alt="graph" /><br />');
} \ No newline at end of file
diff --git a/frontends/php/js/dashboard.js b/frontends/php/js/dashboard.js
deleted file mode 100644
index 56f2c90f..00000000
--- a/frontends/php/js/dashboard.js
+++ /dev/null
@@ -1,69 +0,0 @@
-// JavaScript Document
-/*
-** ZABBIX
-** Copyright (C) 2000-2008 SIA Zabbix
-**
-** 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-**/
-function setRefreshRate(id,interval){
- if(typeof(Ajax) == 'undefined'){
- throw("Prototype.js lib is required!");
- return false;
- }
-
- var params = {
- 'favobj': 'set_rf_rate',
- 'favid': id,
- 'favcnt': interval
- }
-
- send_params(params);
-}
-
-function create_menu(e,id){
- if(!e) var e = window.event;
- id='menu_'+id;
-
- var dbrd_menu = new Array();
-
-//to create a copy of array, but not references!!!!
-//alert(id+' : '+dashboard_menu[id]);
- for(var i=0; i < dashboard_menu[id].length; i++){
- if((typeof(dashboard_menu[id][i]) != 'undefined') && !empty(dashboard_menu[id][i]))
- dbrd_menu[i] = dashboard_menu[id][i].clone();
- }
-
- for(var i=0; i < dashboard_submenu[id].length; i++){
- if((typeof(dashboard_submenu[id][i]) != 'undefined') && !empty(dashboard_submenu[id][i])){
- var row = dashboard_submenu[id][i];
- var menu_row = new Array(row.name,"javascript: rm4favorites('"+row.favobj+"','"+row.favid+"','"+i+"');");
- dbrd_menu[dbrd_menu.length-1].push(menu_row);
- }
- }
-//alert(dashboard_menu[id]);
- show_popup_menu(e,dbrd_menu,280);// JavaScript Document
-}
-
-
-function getTimeFormated(timestamp){
- var dt = new Date();
-
- var hours = dt.getHours();
- var minutes = dt.getMinutes();
- var seconds = dt.getSeconds();
- var str = '['+hours+':'+minutes+':'+seconds+']';
-
-return str;
-} \ No newline at end of file
diff --git a/frontends/php/js/json.js b/frontends/php/js/json.js
deleted file mode 100644
index 162b959b..00000000
--- a/frontends/php/js/json.js
+++ /dev/null
@@ -1,105 +0,0 @@
-// JavaScript Document
-function callJSON(){
-// json.clean();
- json.createScript('dashboard.php?output=json');
- json.buildAll();
- json.addAll();
-}
-
-var json = {
-scripts: new Array(), // array of existing scripts id's
-nextId: 1, // id of next script tag
-
-head: '', // DOM Head obj
-
-initialize: function(){
- this.head = document.getElementsByTagName("head").item(0);
-},
-
-callBack: function(){
- if(this.callBack.arguments.length > 0)
- alert(this.callBack.arguments[0])
- else
- alert('callBack!');
-},
-
-onetime: function(url){
- var onetimeid;
- onetimeid = this.createScript(url);
- this.buildScript(onetimeid);
- this.addScript(onetimeid);
-},
-
-createScript: function(url){
- this.scripts[this.nextId] = {
- 'id': this.nextId,
- 'fullurl': url+'&jsscriptid='+this.nextId,
- 'noCacheIE': '&noCacheIE=' + (new Date()).getTime(),
- 'scriptId': 'JscriptId' + this.nextId,
- 'status': 1
- };
-//SDI('create:' + this.nextId);
- this.nextId++;
-return (this.nextId-1);
-},
-
-buildScript: function(id){
- if((typeof(id) != 'undefined')){
- if((typeof(this.scripts[id]) != 'undefined') && !empty(this.scripts[id]) && (this.scripts[id].status == 1)){
- var scriptObj = document.createElement("script");
-
- // Add script object attributes
- scriptObj.setAttribute("type", "text/javascript");
- scriptObj.setAttribute("charset", "utf-8");
-
- scriptObj.setAttribute("src", this.scripts[id].fullurl+this.scripts[id].noCacheIE);
-
- scriptObj.setAttribute("id", this.scripts[id].scriptId);
-
- this.scripts[id].scriptObj = scriptObj;
- this.scripts[id].status = 2;
- }
- }
-},
-
-buildAll: function() {
- for(var i=1; i < this.nextId; i++){
- this.buildScript(i);
- }
-},
-
-addScript: function(id){
- if((typeof(id) != 'undefined')){
- if((typeof(this.scripts[id]) != 'undefined') && !empty(this.scripts[id]) && (this.scripts[id].status == 2)){
- this.head.appendChild(this.scripts[id].scriptObj);
- this.scripts[id].status = 3;
- }
- }
-},
-
-addAll: function(){
- for(var i=1; i < this.nextId; i++){
- this.addScript(i);
- }
-},
-
-removeScript: function(id){
- if((typeof(id) != 'undefined')){
- if((typeof(this.scripts[id]) != 'undefined') && !empty(this.scripts[id]) && (this.scripts[id].status == 3)){
-//SDI('remove:'+this.scripts[id].scriptId);
- this.head.removeChild(this.scripts[id].scriptObj);
- this.scripts[id] = null;
- }
- }
-},
-
-clean: function(){
- for(var i=1; i < this.nextId; i++){
- this.removeScript(i);
- }
- this.scripts = new Array();
- this.nextId = 1;
-}
-}
-
-json.initialize(); \ No newline at end of file
diff --git a/frontends/php/js/menu.js b/frontends/php/js/menu.js
index 8c0abc6f..93037f58 100644
--- a/frontends/php/js/menu.js
+++ b/frontends/php/js/menu.js
@@ -59,13 +59,11 @@ function popup_menu (a_items, a_tpl, x, y) {
this.n_scroll_left = get_scroll_pos()[0];
this.n_scroll_top = get_scroll_pos()[1];
- if(document.body.clientWidth)
- {
+ if(document.body.clientWidth){
this.n_scr_width = document.body.clientWidth;
this.n_scr_height = document.body.clientHeight;
}
- else
- {
+ else{
this.n_scr_width = document.width;
this.n_scr_height = document.height;
}
@@ -175,7 +173,8 @@ function menu_collapse (n_id) {
}
}
A_MENUS.splice(this.o_root.n_id);
- } else {
+ }
+ else {
// hide all items over the level specified
for (n_id = 0; n_id < this.a_index.length; n_id++) {
var o_curritem = this.a_index[n_id];
@@ -365,23 +364,25 @@ function menu_item (o_parent, n_order) {
this.n_x -= this.getprop('width');
}
- if(!o_parent.n_y_direction && !n_order)
- {
- //alert("w: " +this.getprop('height') +" i:" + (o_parent.a_config.length - item_offset) );
- // calculate menu direction in first element
- o_parent.set_y_direction(
- (this.getprop('height') * (o_parent.a_config.length - item_offset) + o_parent.n_y + this.getprop('block_top')
- > o_root.n_scr_height + o_root.n_scroll_top)
- ? -1 : 1
- );
+ if(!o_parent.n_y_direction && !n_order){
+//alert("w: " +this.getprop('height') +" i:" + (o_parent.a_config.length - item_offset) );
+
+// calculate menu direction in first element
+/* calculates Wrongly! <c> Aly
+ var mi_height = this.getprop('height') * (o_parent.a_config.length - item_offset) + o_parent.n_y + this.getprop('block_top');
+ var scr_height = o_root.n_scr_height + o_root.n_scroll_top;
+ var mi_direction = (mi_height > scr_height)?-1:1;
+//*/
+ var mi_direction = 1; // always show menu in down direction.
+ o_parent.set_y_direction(mi_direction);
}
-
+
+// TOP
this.n_y = n_order
? o_parent.a_children[n_order - 1].n_y + this.getprop('top')
: o_parent.n_y + this.getprop('block_top') * (o_parent == o_root ? o_parent.get_y_direction() : 1);
- if(-1 == o_parent.get_y_direction() && !n_order)
- {
+ if(-1 == o_parent.get_y_direction() && !n_order){
this.n_y -= this.getprop('height') * (o_parent.a_config.length - item_offset);
}
@@ -432,7 +433,7 @@ function menu_item (o_parent, n_order) {
}
function A_MENUS_onclick(){ return A_MENUS[this.o_root_n_id].onclick(this.this_n_id); }
-function A_MENUS_onmouseout(){ return A_MENUS[this.o_root_n_id].onmouseout(this.this_n_id); }//false;}//
+function A_MENUS_onmouseout(){ return A_MENUS[this.o_root_n_id].onmouseout(this.this_n_id); }// false;}//
function A_MENUS_onmouseover(){ return A_MENUS[this.o_root_n_id].onmouseover(this.this_n_id); }
function A_MENUS_onmousedown(){ return A_MENUS[this.o_root_n_id].onmousedown(this.this_n_id); }
diff --git a/frontends/php/js/menu_scripts.js b/frontends/php/js/menu_scripts.js
new file mode 100644
index 00000000..9a17d016
--- /dev/null
+++ b/frontends/php/js/menu_scripts.js
@@ -0,0 +1,226 @@
+// JavaScript Document
+/*
+** ZABBIX
+** Copyright (C) 2000-2008 SIA Zabbix
+**
+** 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+//------------------------------------------------------
+// USERS JS MENU
+//------------------------------------------------------
+//var menu_usrgrp_all = new Array();
+//var menu_usrgrp_gui = new Array();
+//var menu_usrgrp_status = new Array();
+
+function create_user_menu(e,userid,usr_grp_all_in,usr_grp_gui_in,usr_grp_status_in){
+ if(!e) var e = window.event;
+
+// ALL GROUPS
+ var grp_add_to = new Array('Add to',null,null,{'outer' : ['pum_o_submenu'],'inner' : ['pum_i_submenu']});
+ grp_add_to.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
+
+ var grp_rmv_frm = new Array('Remove from',null,null,{'outer' : 'pum_o_submenu','inner' : ['pum_i_submenu']});
+ grp_rmv_frm.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
+
+// add to
+ for(var i=0; i < menu_usrgrp_all.length; i++){
+ if((typeof(menu_usrgrp_all[i]) != 'undefined') && !empty(menu_usrgrp_all[i])){
+ var row = menu_usrgrp_all[i];
+ var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=1&userid="+userid+"&usrgrpid="+row.usrgrpid);
+ grp_add_to.push(menu_row);
+ }
+ }
+
+// remove from
+ for(var i=0; i < usr_grp_all_in.length; i++){
+ if((typeof(usr_grp_all_in[i]) != 'undefined') && !empty(usr_grp_all_in[i])){
+ var row = usr_grp_all_in[i];
+ var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=0&userid="+userid+"&usrgrpid="+row.usrgrpid);
+ grp_rmv_frm.push(menu_row);
+ }
+ }
+
+// GUI ACCESS GROUPS
+ var grp_gui_add_to = new Array('Add to',null,null,{'outer' : ['pum_o_submenu'],'inner' : ['pum_i_submenu']});
+ grp_gui_add_to.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
+
+ var grp_gui_rmv_frm = new Array('Remove from',null,null,{'outer' : 'pum_o_submenu','inner' : ['pum_i_submenu']});
+ grp_gui_rmv_frm.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
+
+// add to
+ for(var i=0; i < menu_usrgrp_gui.length; i++){
+ if((typeof(menu_usrgrp_gui[i]) != 'undefined') && !empty(menu_usrgrp_gui[i])){
+ var row = menu_usrgrp_gui[i];
+ var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=1&userid="+userid+"&usrgrpid="+row.usrgrpid);
+ grp_gui_add_to.push(menu_row);
+ }
+ }
+
+// remove from
+ for(var i=0; i < usr_grp_gui_in.length; i++){
+ if((typeof(usr_grp_all_in[i]) != 'undefined') && !empty(usr_grp_gui_in[i])){
+ var row = usr_grp_gui_in[i];
+ var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=0&userid="+userid+"&usrgrpid="+row.usrgrpid);
+ grp_gui_rmv_frm.push(menu_row);
+ }
+ }
+
+// DISABLED STATUS GROUPS
+ var grp_status_add_to = new Array('Add to',null,null,{'outer' : ['pum_o_submenu'],'inner' : ['pum_i_submenu']});
+ grp_status_add_to.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
+
+ var grp_status_rmv_frm = new Array('Remove from',null,null,{'outer' : 'pum_o_submenu','inner' : ['pum_i_submenu']});
+ grp_status_rmv_frm.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
+
+// add to
+ for(var i=0; i < menu_usrgrp_status.length; i++){
+ if((typeof(menu_usrgrp_status[i]) != 'undefined') && !empty(menu_usrgrp_status[i])){
+ var row = menu_usrgrp_status[i];
+ var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=1&userid="+userid+"&usrgrpid="+row.usrgrpid);
+ grp_status_add_to.push(menu_row);
+ }
+ }
+
+// remove from
+ for(var i=0; i < usr_grp_status_in.length; i++){
+ if((typeof(usr_grp_status_in[i]) != 'undefined') && !empty(usr_grp_status_in[i])){
+ var row = usr_grp_status_in[i];
+ var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=0&userid="+userid+"&usrgrpid="+row.usrgrpid);
+ grp_status_rmv_frm.push(menu_row);
+ }
+ }
+//['&lt;span class=&quot;red&quot;&gt;Disabled users&lt;/span&gt;','users.php?config=0&form=update&grpaction=1&userid=2&usrgrpid=9']
+ var grp_menu = new Array(
+ Array('Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}),
+ grp_add_to,
+ grp_rmv_frm,
+ Array('GUI access',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}),
+ grp_gui_add_to,
+ grp_gui_rmv_frm,
+ Array('Status disabled',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}),
+ grp_status_add_to,
+ grp_status_rmv_frm
+ );
+
+//to create a copy of array, but not references!!!!
+//alert(id+' : '+dashboard_menu[id]);
+
+
+
+//alert(dashboard_menu[id]);
+ show_popup_menu(e,grp_menu,280);// JavaScript Document
+}
+//---------------------------------------------------------------
+
+
+//------------------------------------------------------
+// HOSTS JS MENU
+//------------------------------------------------------
+//var menu_hstgrp_all = new Array();
+
+function create_host_menu(e,hostid,hst_grp_all_in){
+ if(!e) var e = window.event;
+
+// ALL GROUPS
+ var grp_add_to = new Array('Add to group',null,null,{'outer' : 'pum_o_submenu','inner' : ['pum_i_submenu']});
+ grp_add_to.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
+
+ var grp_rmv_frm = new Array('Remove from group',null,null,{'outer' : 'pum_o_submenu','inner' : ['pum_i_submenu']});
+ grp_rmv_frm.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
+
+// add to
+ for(var i=0; i < menu_hstgrp_all.length; i++){
+ if((typeof(menu_hstgrp_all[i]) != 'undefined') && !empty(menu_hstgrp_all[i])){
+ var row = menu_hstgrp_all[i];
+ var menu_row = new Array(row.name,'?add_to_group='+row.groupid+'&hostid='+hostid);
+ grp_add_to.push(menu_row);
+ }
+ }
+
+// remove from
+ for(var i=0; i < hst_grp_all_in.length; i++){
+ if((typeof(hst_grp_all_in[i]) != 'undefined') && !empty(hst_grp_all_in[i])){
+ var row = hst_grp_all_in[i];
+ var menu_row = new Array(row.name,'?delete_from_group='+row.groupid+'&hostid='+hostid);
+ grp_rmv_frm.push(menu_row);
+ }
+ }
+
+
+ var grp_menu = new Array(
+ ['Show',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],
+ ['Items','items.php?hostid='+hostid,{'tw' : ''}],
+ ['Triggers','triggers.php?hostid='+hostid,{'tw' : ''}],
+ ['Graphs','graphs.php?hostid='+hostid,{'tw' : ''}],
+ ['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],
+ grp_add_to,
+ grp_rmv_frm
+ );
+
+//to create a copy of array, but not references!!!!
+//alert(id+' : '+dashboard_menu[id]);
+
+
+
+//alert(dashboard_menu[id]);
+ show_popup_menu(e,grp_menu,280);// JavaScript Document
+}
+/*
+show_popup_menu(event,new Array(['Show',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],
+ ['Items','items.php?hostid=10017',{'tw' : ''}],
+ ['Triggers','triggers.php?hostid=10017',{'tw' : ''}],
+ ['Graphs','graphs.php?hostid=10017',{'tw' : ''}],
+ ['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],
+ ['Add to group',null,null,{'outer' : 'pum_o_submenu','inner' : ['pum_i_submenu']},
+ ['Linux servers','?&amp;add_to_group=2&amp;hostid=10017'],
+ ['Templates','?&amp;add_to_group=1&amp;hostid=10017'],
+ ['Windows servers','?&amp;add_to_group=3&amp;hostid=10017']
+ ],
+ ['Delete from group',null,null,{'outer' : 'pum_o_submenu','inner' : ['pum_i_submenu']},
+ ['Test Group','?&amp;delete_from_group=5&amp;hostid=10017'],
+ ['ZABBIX Servers','?&amp;delete_from_group=4&amp;hostid=10017']
+ ]
+ ),null);
+*/
+
+
+//------------------------------------------------------
+// DASHBOARD JS MENU
+//------------------------------------------------------
+
+function create_dashboard_menu(e,id){
+ if(!e) var e = window.event;
+ id='menu_'+id;
+
+ var dbrd_menu = new Array();
+
+//to create a copy of array, but not references!!!!
+//alert(id+' : '+dashboard_menu[id]);
+ for(var i=0; i < dashboard_menu[id].length; i++){
+ if((typeof(dashboard_menu[id][i]) != 'undefined') && !empty(dashboard_menu[id][i]))
+ dbrd_menu[i] = dashboard_menu[id][i].clone();
+ }
+
+ for(var i=0; i < dashboard_submenu[id].length; i++){
+ if((typeof(dashboard_submenu[id][i]) != 'undefined') && !empty(dashboard_submenu[id][i])){
+ var row = dashboard_submenu[id][i];
+ var menu_row = new Array(row.name,"javascript: rm4favorites('"+row.favobj+"','"+row.favid+"','"+i+"');");
+ dbrd_menu[dbrd_menu.length-1].push(menu_row);
+ }
+ }
+//alert(dashboard_menu[id]);
+ show_popup_menu(e,dbrd_menu,280);// JavaScript Document
+} \ No newline at end of file
diff --git a/frontends/php/js/tree.js b/frontends/php/js/tree.js
index 2681dd00..393016c2 100644
--- a/frontends/php/js/tree.js
+++ b/frontends/php/js/tree.js
@@ -17,6 +17,8 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
// JavaScript Document
+// Tree manipulations class
+// author: Aly
var tree ={
init : function(){
diff --git a/frontends/php/js/users.js b/frontends/php/js/users.js
deleted file mode 100644
index d05aca70..00000000
--- a/frontends/php/js/users.js
+++ /dev/null
@@ -1,103 +0,0 @@
-// JavaScript Document
-//var menu_usrgrp_all = new Array();
-//var menu_usrgrp_gui = new Array();
-//var menu_usrgrp_status = new Array();
-
-function create_user_menu(e,userid,usr_grp_all_in,usr_grp_gui_in,usr_grp_status_in){
- if(!e) var e = window.event;
-
-// ALL GROUPS
- var grp_add_to = new Array('Add to',null,null,{'outer' : ['pum_o_submenu'],'inner' : ['pum_i_submenu']});
- grp_add_to.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
-
- var grp_rmv_frm = new Array('Remove from',null,null,{'outer' : 'pum_o_submenu','inner' : ['pum_i_submenu']});
- grp_rmv_frm.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
-
-// add to
- for(var i=0; i < menu_usrgrp_all.length; i++){
- if((typeof(menu_usrgrp_all[i]) != 'undefined') && !empty(menu_usrgrp_all[i])){
- var row = menu_usrgrp_all[i];
- var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=1&userid="+userid+"&usrgrpid="+row.usrgrpid);
- grp_add_to.push(menu_row);
- }
- }
-
-// remove from
- for(var i=0; i < usr_grp_all_in.length; i++){
- if((typeof(usr_grp_all_in[i]) != 'undefined') && !empty(usr_grp_all_in[i])){
- var row = usr_grp_all_in[i];
- var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=0&userid="+userid+"&usrgrpid="+row.usrgrpid);
- grp_rmv_frm.push(menu_row);
- }
- }
-
-// GUI ACCESS GROUPS
- var grp_gui_add_to = new Array('Add to',null,null,{'outer' : ['pum_o_submenu'],'inner' : ['pum_i_submenu']});
- grp_gui_add_to.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
-
- var grp_gui_rmv_frm = new Array('Remove from',null,null,{'outer' : 'pum_o_submenu','inner' : ['pum_i_submenu']});
- grp_gui_rmv_frm.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
-
-// add to
- for(var i=0; i < menu_usrgrp_gui.length; i++){
- if((typeof(menu_usrgrp_gui[i]) != 'undefined') && !empty(menu_usrgrp_gui[i])){
- var row = menu_usrgrp_gui[i];
- var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=1&userid="+userid+"&usrgrpid="+row.usrgrpid);
- grp_gui_add_to.push(menu_row);
- }
- }
-
-// remove from
- for(var i=0; i < usr_grp_gui_in.length; i++){
- if((typeof(usr_grp_all_in[i]) != 'undefined') && !empty(usr_grp_gui_in[i])){
- var row = usr_grp_gui_in[i];
- var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=0&userid="+userid+"&usrgrpid="+row.usrgrpid);
- grp_gui_rmv_frm.push(menu_row);
- }
- }
-
-// DISABLED STATUS GROUPS
- var grp_status_add_to = new Array('Add to',null,null,{'outer' : ['pum_o_submenu'],'inner' : ['pum_i_submenu']});
- grp_status_add_to.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
-
- var grp_status_rmv_frm = new Array('Remove from',null,null,{'outer' : 'pum_o_submenu','inner' : ['pum_i_submenu']});
- grp_status_rmv_frm.push(['Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]);
-
-// add to
- for(var i=0; i < menu_usrgrp_status.length; i++){
- if((typeof(menu_usrgrp_status[i]) != 'undefined') && !empty(menu_usrgrp_status[i])){
- var row = menu_usrgrp_status[i];
- var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=1&userid="+userid+"&usrgrpid="+row.usrgrpid);
- grp_status_add_to.push(menu_row);
- }
- }
-
-// remove from
- for(var i=0; i < usr_grp_status_in.length; i++){
- if((typeof(usr_grp_status_in[i]) != 'undefined') && !empty(usr_grp_status_in[i])){
- var row = usr_grp_status_in[i];
- var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=0&userid="+userid+"&usrgrpid="+row.usrgrpid);
- grp_status_rmv_frm.push(menu_row);
- }
- }
-//['&lt;span class=&quot;red&quot;&gt;Disabled users&lt;/span&gt;','users.php?config=0&form=update&grpaction=1&userid=2&usrgrpid=9']
- var grp_menu = new Array(
- Array('Groups',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}),
- grp_add_to,
- grp_rmv_frm,
- Array('GUI access',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}),
- grp_gui_add_to,
- grp_gui_rmv_frm,
- Array('Status disabled',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}),
- grp_status_add_to,
- grp_status_rmv_frm
- );
-
-//to create a copy of array, but not references!!!!
-//alert(id+' : '+dashboard_menu[id]);
-
-
-
-//alert(dashboard_menu[id]);
- show_popup_menu(e,grp_menu,280);// JavaScript Document
-} \ No newline at end of file
diff --git a/frontends/php/latest.php b/frontends/php/latest.php
index 80e50fab..7a00dbf8 100644
--- a/frontends/php/latest.php
+++ b/frontends/php/latest.php
@@ -116,11 +116,11 @@ include_once "include/page_header.php";
$cmbHosts->AddItem(0,S_ALL_SMALL);
$available_groups= get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST);
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST,PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST);
$result=DBselect('SELECT DISTINCT g.groupid,g.name '.
' FROM groups g, hosts_groups hg, hosts h, items i '.
- ' WHERE g.groupid IN ('.$available_groups.') '.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND hg.groupid=g.groupid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND h.hostid=i.hostid '.
diff --git a/frontends/php/overview.php b/frontends/php/overview.php
index 0ff603cb..c3d8f2a2 100644
--- a/frontends/php/overview.php
+++ b/frontends/php/overview.php
@@ -97,9 +97,11 @@ if(isset($_REQUEST['select']) && ($_REQUEST['select']!='')){
$where = $from = '';
}
+ $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST);
+
$result=DBselect('SELECT DISTINCT g.groupid,g.name '.
' FROM groups g, hosts_groups hg, hosts h, items i'.$from.
- ' WHERE g.groupid IN ('.get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST).') '.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND hg.groupid=g.groupid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND h.hostid=i.hostid '.
diff --git a/frontends/php/popup.php b/frontends/php/popup.php
index 1df0f8a1..4932714b 100644
--- a/frontends/php/popup.php
+++ b/frontends/php/popup.php
@@ -524,10 +524,11 @@ include_once "include/page_header.php";
$table = new CTableInfo(S_NO_GROUPS_DEFINED);
$table->SetHeader(array(S_NAME));
- $db_groups = DBselect("SELECT DISTINCT groupid,name from groups ".
- ' where '.DBin_node('groupid', $nodeid).
- " AND groupid in (".$available_groups.") ".
- " order by name");
+ $db_groups = DBselect('SELECT DISTINCT groupid,name '.
+ ' FROM groups '.
+ ' WHERE '.DBin_node('groupid', $nodeid).
+ ' AND '.DBcondition('groupid',$available_groups).
+ ' ORDER BY name');
while($row = DBfetch($db_groups)){
$name = new CLink($row["name"],"#","action");
if(isset($_REQUEST['reference']) && ($_REQUEST['reference'] =='dashboard')){
@@ -1273,7 +1274,7 @@ include_once "include/page_header.php";
$db_groups = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name,n.nodeid '.
' FROM hosts_groups hg, groups g '.
' LEFT JOIN nodes n ON n.nodeid='.DBid2nodeid('g.groupid').
- ' WHERE g.groupid IN ('.$available_groups.') '.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND '.DBin_node('g.groupid',$nodeid).
' ORDER BY n.nodeid,g.name');
diff --git a/frontends/php/screens.php b/frontends/php/screens.php
index e3e8402f..950b8915 100644
--- a/frontends/php/screens.php
+++ b/frontends/php/screens.php
@@ -217,7 +217,7 @@ include_once 'include/page_header.php';
validate_group_with_host(PERM_READ_ONLY,$options);
$available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST);
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST,PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST);
$cmbGroup = new CComboBox('groupid',$_REQUEST['groupid'],'submit()');
$cmbHosts = new CComboBox('hostid',$_REQUEST['hostid'],'submit()');
@@ -227,7 +227,7 @@ include_once 'include/page_header.php';
$sql = 'SELECT DISTINCT g.groupid, g.name '.
' FROM groups g, hosts_groups hg, hosts h, items i '.
- ' WHERE g.groupid in ('.$available_groups.') '.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND hg.groupid=g.groupid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND h.hostid=i.hostid '.
diff --git a/frontends/php/scripts.php b/frontends/php/scripts.php
index 9aecb665..0c3175b8 100644
--- a/frontends/php/scripts.php
+++ b/frontends/php/scripts.php
@@ -175,7 +175,7 @@ if(isset($_REQUEST['form'])){
$sql = 'SELECT DISTINCT g.name, g.groupid '.
' FROM groups g '.
- ' WHERE g.groupid IN ('.$available_groups.') '.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' ORDER BY g.name';
$grp_result = DBselect($sql);
diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php
index 2e755b77..929bb062 100644
--- a/frontends/php/tr_status.php
+++ b/frontends/php/tr_status.php
@@ -232,14 +232,14 @@ include_once "include/page_header.php";
$cmbHosts->AddItem(0,S_ALL_SMALL);
$available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY);
- $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY);
$available_triggers = get_accessible_triggers(PERM_READ_ONLY,PERM_RES_IDS_ARRAY);
$scripts_by_hosts = get_accessible_scripts_by_hosts($available_hosts);
$sql = 'SELECT DISTINCT g.groupid,g.name '.
' FROM groups g, hosts_groups hg, hosts h, items i '.
- ' WHERE g.groupid in ('.$available_groups.') '.
+ ' WHERE '.DBcondition('g.groupid',$available_groups).
' AND hg.groupid=g.groupid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND h.hostid=i.hostid '.
diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php
index 2fdac9f5..6ed1487a 100644
--- a/frontends/php/triggers.php
+++ b/frontends/php/triggers.php
@@ -240,16 +240,12 @@ include_once "include/page_header.php";
}
else{ /* groups */
$hosts_ids = array();
- $group_ids = '';
- foreach($_REQUEST['copy_targetid'] as $id => $group_id){
- $group_ids .= $group_id.',';
- }
- $group_ids = trim($group_ids,',');
+ $group_ids = $_REQUEST['copy_targetid'];
$db_hosts = DBselect('SELECT DISTINCT h.hostid '.
' FROM hosts h, hosts_groups hg'.
' WHERE h.hostid=hg.hostid '.
- ' AND hg.groupid in ('.$group_ids.')');
+ ' AND '.DBcondition('hg.groupid',$group_ids));
while($db_host = DBfetch($db_hosts)){
array_push($hosts_ids, $db_host['hostid']);
}
diff --git a/frontends/php/users.php b/frontends/php/users.php
index 418ab504..448ac74d 100644
--- a/frontends/php/users.php
+++ b/frontends/php/users.php
@@ -29,7 +29,7 @@
$page['title'] = 'S_USERS';
$page['file'] = 'users.php';
$page['hist_arg'] = array('config');
- $page['scripts'] = array('users.js');
+ $page['scripts'] = array('menu_scripts.js');
include_once 'include/page_header.php';
@@ -571,7 +571,7 @@ include_once 'include/page_header.php';
$jsmenu = new CPUMenu(null,270);
$jsmenu->InsertJavaScript();
- get_user_menu_array();
+ set_users_jsmenu_array();
}
}
else if($_REQUEST['config']==1){ // USER GROUPS