summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
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/include
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/include')
-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
12 files changed, 179 insertions, 192 deletions
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).",".