summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--frontends/php/hosts.php5
-rw-r--r--frontends/php/include/blocks.inc.php7
-rw-r--r--frontends/php/include/classes/cldap.inc.php2
-rw-r--r--frontends/php/include/defines.inc.php3
-rw-r--r--frontends/php/include/hosts.inc.php42
-rw-r--r--frontends/php/include/locales/en_gb.inc.php1
-rw-r--r--frontends/php/include/maps.inc.php3
-rw-r--r--frontends/php/include/scripts.inc.php117
-rw-r--r--frontends/php/include/users.inc.php3
-rw-r--r--frontends/php/maps.php10
-rw-r--r--frontends/php/scripts.php91
-rw-r--r--frontends/php/tr_status.php9
13 files changed, 193 insertions, 101 deletions
diff --git a/ChangeLog b/ChangeLog
index b3cd0c27..df107564 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
Changes for 1.5.1:
+ - [DEV-154] added more flexibility to scripts (Artem)
- [DEV-166] fixed problem with node syncing (Sasha)
- [DEV-145] added Ldap authentication (Artem)
- [DEV-147] added support network and disk stats under OpenBSD (Sasha)
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php
index 03d29986..77cff0ba 100644
--- a/frontends/php/hosts.php
+++ b/frontends/php/hosts.php
@@ -137,10 +137,9 @@ include_once "include/page_header.php";
if(isset($_REQUEST["hostid"])){
$templateid=$_REQUEST["hostid"];
$result = false;
+
// Permission check
- $tmp_hosts = array_diff($hosts,$available_hosts);
- $hosts = array_diff($hosts,$tmp_hosts);
- unset($tmp_hosts);
+ $hosts = array_intersect($hosts,$available_hosts);
//--
DBstart();
foreach($hosts as $id => $hostid){
diff --git a/frontends/php/include/blocks.inc.php b/frontends/php/include/blocks.inc.php
index 779a050c..c3809ccf 100644
--- a/frontends/php/include/blocks.inc.php
+++ b/frontends/php/include/blocks.inc.php
@@ -549,8 +549,11 @@ function make_latest_issues(){
$menus.= "['".$script['name']."',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=".$row['hostid']."&scriptid=".$script['scriptid']."','".S_TOOLS."',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
}
- $menus = trim($menus,',');
- if(!empty($menus)) $menus="show_popup_menu(event,[[".zbx_jsvalue(S_TOOLS).",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],".$menus."],180);";
+ $menus.= "[".zbx_jsvalue(S_LINKS).",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],";
+ $menus.= "['".S_LATEST_DATA."',\"javascript: Redirect('latest.php?hostid=".$row['hostid']."')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
+
+ $menus = rtrim($menus,',');
+ $menus="show_popup_menu(event,[[".zbx_jsvalue(S_TOOLS).",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],".$menus."],180);";
$host = new CSpan($row['host']);
$host->AddOption('onclick','javascript: '.$menus);
diff --git a/frontends/php/include/classes/cldap.inc.php b/frontends/php/include/classes/cldap.inc.php
index b363a452..6a2bc2ec 100644
--- a/frontends/php/include/classes/cldap.inc.php
+++ b/frontends/php/include/classes/cldap.inc.php
@@ -70,7 +70,7 @@ class CLdap{
$this->bound = 0;
- if(!$this->ds = ldap_connect($this->cnf['host'],$this->cnf['port'])){
+ if(!$this->ds=ldap_connect($this->cnf['host'],$this->cnf['port'])){
error("LDAP: couldn't connect to LDAP server");
return false;
}
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index fd307982..728288b1 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -339,9 +339,6 @@
define('PERM_READ_LIST', 1);
define('PERM_DENY', 0);
- define('SCRIPT_HOST_ACCESS_READ', 0);
- define('SCRIPT_HOST_ACCESS_WRITE', 1);
-
define('PERM_RES_STRING_LINE', 0); /* return string of nodes id - '1,2,3,4,5' */
define('PERM_RES_IDS_ARRAY', 1); /* return array of nodes id - array(1,2,3,4) */
define('PERM_RES_DATA_ARRAY', 2);
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index b64af77f..40b39caa 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -477,20 +477,17 @@ require_once "include/items.inc.php";
return DBexecute("delete from groups where groupid=$groupid");
}
- function get_hostgroup_by_groupid($groupid)
- {
+ function get_hostgroup_by_groupid($groupid){
$result=DBselect("select * from groups where groupid=".$groupid);
$row=DBfetch($result);
- if($row)
- {
+ if($row){
return $row;
}
error("No host groups with groupid=[$groupid]");
return false;
}
- function db_save_proxy($name,$proxyid=null)
- {
+ function db_save_proxy($name,$proxyid=null){
if(!is_string($name)){
error("incorrect parameters for 'db_save_proxy'");
return false;
@@ -504,43 +501,41 @@ require_once "include/items.inc.php";
' and '.DBin_node('hostid').' AND host='.zbx_dbstr($name).
' and hostid<>'.$proxyid);
- if(DBfetch($result))
- {
+ if(DBfetch($result)){
error("Proxy '$name' already exists");
return false;
}
- if(is_null($proxyid))
- {
+
+ if(is_null($proxyid)){
$proxyid=get_dbid('hosts','hostid');
if(!DBexecute('insert into hosts (hostid,host,status)'.
- ' values ('.$proxyid.','.zbx_dbstr($name).','.HOST_STATUS_PROXY.')'))
+ ' values ('.$proxyid.','.zbx_dbstr($name).','.HOST_STATUS_PROXY.')'))
+ {
return false;
+ }
+
return $proxyid;
}
else
return DBexecute('update hosts set host='.zbx_dbstr($name).' where hostid='.$proxyid);
}
- function delete_proxy($proxyid)
- {
+ function delete_proxy($proxyid){
if(!DBexecute("update hosts set proxy_hostid=0 where proxy_hostid=$proxyid"))
return false;
return DBexecute("delete from hosts where hostid=$proxyid");
}
- function update_hosts_by_proxyid($proxyid,$hosts=array())
- {
+ function update_hosts_by_proxyid($proxyid,$hosts=array()){
DBexecute('update hosts set proxy_hostid=0 where proxy_hostid='.$proxyid);
- foreach($hosts as $hostid)
- {
+ foreach($hosts as $hostid){
DBexecute('update hosts set proxy_hostid='.$proxyid.' where hostid='.$hostid);
}
}
- function add_proxy($name,$hosts=array())
- {
+ function add_proxy($name,$hosts=array()){
$proxyid = db_save_proxy($name);
if(!$proxyid)
return $proxyid;
@@ -550,8 +545,7 @@ require_once "include/items.inc.php";
return $proxyid;
}
- function update_proxy($proxyid,$name,$hosts)
- {
+ function update_proxy($proxyid,$name,$hosts){
$result = db_save_proxy($name,$proxyid);
if(!$result)
return $result;
@@ -561,13 +555,11 @@ require_once "include/items.inc.php";
return $result;
}
- function get_host_by_itemid($itemid)
- {
+ function get_host_by_itemid($itemid){
$sql="select h.* from hosts h, items i where i.hostid=h.hostid and i.itemid=$itemid";
$result=DBselect($sql);
$row=DBfetch($result);
- if($row)
- {
+ if($row){
return $row;
}
error("No host with itemid=[$itemid]");
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index d87c11a1..42f30c42 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -870,6 +870,7 @@
// sysmap.php
'S_LINK'=> 'Link',
+ 'S_LINKS'=> 'Links',
'S_LABEL'=> 'Label',
'S_X'=> 'X',
'S_Y'=> 'Y',
diff --git a/frontends/php/include/maps.inc.php b/frontends/php/include/maps.inc.php
index 47c20ca8..6cc8999d 100644
--- a/frontends/php/include/maps.inc.php
+++ b/frontends/php/include/maps.inc.php
@@ -693,6 +693,9 @@
if( (bccomp($host_nodeid ,$script_nodeid ) == 0))
$menus.= "['".$script['name']."',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=".$db_element["elementid"]."&scriptid=".$script['scriptid']."','".S_TOOLS."',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
}
+
+ $menus.= "[".zbx_jsvalue(S_LINKS).",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],";
+
$menus.= "['".S_STATUS_OF_TRIGGERS."',\"javascript: Redirect('tr_status.php?hostid=".$db_element['elementid']."&noactions=true&onlytrue=true&compact=true')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
if(!empty($db_element["url"])){
diff --git a/frontends/php/include/scripts.inc.php b/frontends/php/include/scripts.inc.php
index 037a15ef..8e7b3e73 100644
--- a/frontends/php/include/scripts.inc.php
+++ b/frontends/php/include/scripts.inc.php
@@ -10,10 +10,10 @@ function get_script_by_scriptid($scriptid){
return $rows;
}
-function add_script($name,$command,$access){
+function add_script($name,$command,$usrgrpid,$groupid,$access){
$scriptid = get_dbid('scripts','scriptid');
- $sql = 'INSERT INTO scripts (scriptid,name,command,host_access) '.
- " VALUES ('$scriptid','$name',".zbx_dbstr($command).",$access)";
+ $sql = 'INSERT INTO scripts (scriptid,name,command,usrgrpid,groupid,host_access) '.
+ " VALUES ('$scriptid','$name',".zbx_dbstr($command).",$usrgrpid,$groupid,$access)";
$result = DBexecute($sql);
if($result){
$result = $scriptid;
@@ -27,11 +27,13 @@ function delete_script($scriptid){
return $result;
}
-function update_script($scriptid,$name,$command,$access){
+function update_script($scriptid,$name,$command,$usrgrpid,$groupid,$access){
$sql = 'UPDATE scripts SET '.
' name='.zbx_dbstr($name).
' ,command='.zbx_dbstr($command).
+ ' ,usrgrpid='.$usrgrpid.
+ ' ,groupid='.$groupid.
' ,host_access='.$access.
' WHERE scriptid='.$scriptid;
@@ -65,40 +67,38 @@ function execute_script($scriptid,$hostid){
$command = script_make_command($scriptid,$hostid);
$nodeid = id2nodeid($hostid);
- $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
- if(!$socket)
- {
+ if(!$socket){
$res = 0;
}
- if($res)
- {
+
+ if($res){
global $ZBX_SERVER, $ZBX_SERVER_PORT;
- $res = @socket_connect($socket, $ZBX_SERVER, $ZBX_SERVER_PORT);
+ $res = socket_connect($socket, $ZBX_SERVER, $ZBX_SERVER_PORT);
}
- if($res)
- {
+
+ if($res){
$send = "Command\255$nodeid\255$command\n";
- @socket_write($socket,$send);
+ socket_write($socket,$send);
}
- if($res)
- {
- $res = @socket_read($socket,65535);
+
+ if($res){
+ $res = socket_read($socket,65535);
}
- if($res)
- {
+
+ if($res){
list($flag,$msg)=split("\255",$res);
$message["flag"]=$flag;
$message["message"]=$msg;
}
- else
- {
+ else{
$message["flag"]=-1;
$message["message"] = S_CONNECT_TO_SERVER_ERROR.' ['.$ZBX_SERVER.':'.$ZBX_SERVER_PORT.'] ['.socket_strerror(socket_last_error()).']';
}
- if($socket)
- {
- @socket_close($socket);
+
+ if($socket){
+ socket_close($socket);
}
return $message;
}
@@ -110,9 +110,35 @@ function get_accessible_scripts_by_hosts($hosts){
if(!is_array($hosts)){
$hosts = array('0' => hosts);
}
-
- $hosts_read_only = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY));
- $hosts_read_write = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE));
+
+// Selecting usrgroups by user
+ $sql = 'SELECT ug.usrgrpid '.
+ ' FROM users_groups ug '.
+ ' WHERE ug.userid='.$USER_DETAILS['userid'];
+
+ $user_groups = DBfetch(DBselect($sql));
+ $user_groups[] = 0; // to ALL user groups
+//
+
+
+// Selecting groups by Hosts
+ $sql = 'SELECT hg.hostid,hg.groupid '.
+ ' FROM hosts_groups hg '.
+ ' WHERE '.DBcondition('hg.hostid',$hosts);
+
+ $hg_res = DBselect($sql);
+ while($hg_rows = DBfetch($hg_res)){
+ $hosts_groups[$hg_rows['groupid']][$hg_rows['hostid']] = $hg_rows['hostid'];
+ $hg_groups[$hg_rows['groupid']] = $hg_rows['groupid'];
+ }
+ $hg_groups[] = 0; // to ALL host groups
+//
+
+ $hosts_read_only = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY);
+ $hosts_read_write = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY);
+
+ $hosts_read_only = array_intersect($hosts,$hosts_read_only);
+ $hosts_read_write = array_intersect($hosts,$hosts_read_write);
// initialize array
foreach($hosts as $id => $hostid){
@@ -120,27 +146,36 @@ function get_accessible_scripts_by_hosts($hosts){
}
//-----
- $sql = 'SELECT * FROM scripts '.
- ' WHERE '.DBin_node('scriptid').
+ $sql = 'SELECT s.* FROM scripts s'.
+ ' WHERE '.DBin_node('s.scriptid').
+ ' AND '.DBcondition('s.groupid',$hg_groups).
+ ' AND '.DBcondition('s.usrgrpid',$user_groups).
' ORDER BY scriptid ASC';
-
+
$res=DBselect($sql);
while($script = DBfetch($res)){
- foreach($hosts as $id => $hostid){
- if($script['host_access'] == SCRIPT_HOST_ACCESS_WRITE){
- if(uint_in_array($hostid,$hosts_read_write)){
- $scripts_by_host[$hostid][] = $script;
- }
- }
- else{
- if(uint_in_array($hostid,$hosts_read_only)){
- $scripts_by_host[$hostid][] = $script;
- }
- }
+ $add_to_hosts = array();
+ if(PERM_READ_WRITE == $script['host_access']){
+ if($script['groupid'] > 0)
+ $add_to_hosts = array_intersect($hosts_read_write, $hosts_groups[$script['groupid']]);
+ else
+ $add_to_hosts = $hosts_read_write;
+ }
+ else if(PERM_READ_ONLY == $script['host_access']){
+ if($script['groupid'] > 0)
+ $add_to_hosts = array_intersect($hosts_read_only, $hosts_groups[$script['groupid']]);
+ else
+ $add_to_hosts = $hosts_read_only;
+ }
+
+ foreach($add_to_hosts as $id => $hostid){
+ $scripts_by_host[$hostid][] = $script;
}
}
+/*
+*/
return $scripts_by_host;
}
-?>
+?> \ No newline at end of file
diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php
index bf2b9e67..0db25825 100644
--- a/frontends/php/include/users.inc.php
+++ b/frontends/php/include/users.inc.php
@@ -589,5 +589,4 @@
return $action;
}
-
-?>
+?> \ No newline at end of file
diff --git a/frontends/php/maps.php b/frontends/php/maps.php
index 2a01f1f8..ad847e3f 100644
--- a/frontends/php/maps.php
+++ b/frontends/php/maps.php
@@ -161,12 +161,11 @@ include_once "include/page_header.php";
$cmbMaps = new CComboBox("sysmapid",get_request("sysmapid",0),"submit()");
- foreach($all_maps as $id => $name)
- {
+ foreach($all_maps as $id => $name){
$cmbMaps->AddItem($id, $name);
}
- if($cmbMaps->ItemsCount()>0)
- {
+
+ if($cmbMaps->ItemsCount()>0){
$form->AddItem($cmbMaps);
}
@@ -174,8 +173,7 @@ include_once "include/page_header.php";
?>
<?php
$table = new CTable(S_NO_MAPS_DEFINED,"map");
- if(isset($_REQUEST["sysmapid"]))
- {
+ if(isset($_REQUEST["sysmapid"])){
$action_map = get_action_map_by_sysmapid($_REQUEST["sysmapid"]);
$table->AddRow($action_map);
diff --git a/frontends/php/scripts.php b/frontends/php/scripts.php
index 4dececf4..95875cf5 100644
--- a/frontends/php/scripts.php
+++ b/frontends/php/scripts.php
@@ -22,6 +22,7 @@
include_once "include/config.inc.php";
require_once "include/hosts.inc.php";
require_once "include/scripts.inc.php";
+ require_once "include/users.inc.php";
$page['title'] = "S_SCRIPTS";
$page['file'] = 'scripts.php';
@@ -45,7 +46,9 @@ include_once "include/page_header.php";
// form
'name'=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'),
'command'=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'),
- 'access'=> array(T_ZBX_INT, O_OPT, NULL, IN('0,1'), 'isset({save})'),
+ 'access'=> array(T_ZBX_INT, O_OPT, NULL, IN('0,1,2,3'), 'isset({save})'),
+ 'groupid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({save})'),
+ 'usrgrpid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({save})'),
'form'=> array(T_ZBX_STR, O_OPT, NULL, NULL, null),
'form_refresh'=> array(T_ZBX_INT, O_OPT, NULL, NULL, null),
@@ -67,14 +70,14 @@ if(isset($_REQUEST['action'])){
else{
if(isset($_REQUEST['scriptid'])){
- $result = update_script($_REQUEST['scriptid'],$_REQUEST['name'],$_REQUEST['command'],$_REQUEST['access']);
+ $result = update_script($_REQUEST['scriptid'],$_REQUEST['name'],$_REQUEST['command'],$_REQUEST['usrgrpid'],$_REQUEST['groupid'],$_REQUEST['access']);
show_messages($result, S_SCRIPT_UPDATED, S_CANNOT_UPDATE_SCRIPT);
$scriptid = $_REQUEST['scriptid'];
$audit_acrion = AUDIT_ACTION_UPDATE;
}
else {
- $result = add_script($_REQUEST['name'],$_REQUEST['command'],$_REQUEST['access']);
+ $result = add_script($_REQUEST['name'],$_REQUEST['command'],$_REQUEST['usrgrpid'],$_REQUEST['groupid'],$_REQUEST['access']);
show_messages($result, S_SCRIPT_ADDED, S_CANNOT_ADD_SCRIPT);
$scriptid = $result;
@@ -117,6 +120,7 @@ if(isset($_REQUEST['action'])){
}
if(isset($_REQUEST['form'])){
+ $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY);
show_table_header(S_SCRIPTS);
echo SBR;
@@ -126,16 +130,25 @@ if(isset($_REQUEST['form'])){
if(isset($_REQUEST['scriptid'])) $frmScr->AddVar('scriptid',$_REQUEST['scriptid']);
- $name = get_request('name','');
- $command = get_request('command','');
- $access = get_request('access', SCRIPT_HOST_ACCESS_READ);
-
+ if(!isset($_REQUEST['scriptid']) || isset($_REQUEST['form_refresh'])){
+ $name = get_request('name','');
+ $command = get_request('command','');
+
+ $usrgrpid = get_request('usrgrpid', 0);
+ $groupid = get_request('groupid', 0);
+
+ $access = get_request('access', PERM_READ_ONLY);
+ }
if(isset($_REQUEST['scriptid']) && !isset($_REQUEST['form_refresh'])){
$frmScr->AddVar('form_refresh',get_request('form_refresh',1));
if($script = get_script_by_scriptid($_REQUEST['scriptid'])){
$name = $script['name'];
$command = $script['command'];
+
+ $usrgrpid = $script['usrgrpid'];
+ $groupid = $script['groupid'];
+
$access = $script['host_access'];
}
}
@@ -143,9 +156,38 @@ if(isset($_REQUEST['form'])){
$frmScr->AddRow(S_NAME,new CTextBox('name',$name,80));
$frmScr->AddRow(S_COMMAND,new CTextBox('command',$command,80));
- $select_acc = new CCombobox('access');
- $select_acc->AddItem(SCRIPT_HOST_ACCESS_READ,S_READ,(($access == SCRIPT_HOST_ACCESS_READ)?'yes':'no'));
- $select_acc->AddItem(SCRIPT_HOST_ACCESS_WRITE,S_WRITE,(($access == SCRIPT_HOST_ACCESS_WRITE)?'yes':'no'));
+ $usr_groups = new CCombobox('usrgrpid',$usrgrpid);
+ $usr_groups->AddItem(0,S_ALL);
+
+ $sql = 'SELECT DISTINCT ug.name, ug.usrgrpid '.
+ ' FROM usrgrp ug '.
+ ' ORDER BY ug.name';
+
+ $usrgrp_result = DBselect($sql);
+ while($usr_group=DBfetch($usrgrp_result)){
+ $usr_groups->AddItem($usr_group['usrgrpid'],$usr_group['name']);
+ }
+
+ $frmScr->AddRow(S_USER_GROUPS,$usr_groups);
+
+ $host_groups = new CCombobox('groupid',$groupid);
+ $host_groups->AddItem(0,S_ALL);
+
+ $sql = 'SELECT DISTINCT g.name, g.groupid '.
+ ' FROM groups g '.
+ ' WHERE g.groupid IN ('.$available_groups.') '.
+ ' ORDER BY g.name';
+
+ $grp_result = DBselect($sql);
+ while($group=DBfetch($grp_result)){
+ $host_groups->AddItem($group['groupid'],$group['name']);
+ }
+
+ $frmScr->AddRow(S_HOST_GROUPS,$host_groups);
+
+ $select_acc = new CCombobox('access',$access);
+ $select_acc->AddItem(PERM_READ_ONLY,S_READ);
+ $select_acc->AddItem(PERM_READ_WRITE,S_WRITE);
$frmScr->AddRow(S_REQUIRED_HOST.SPACE.S_PERMISSIONS_SMALL,$select_acc);
@@ -165,17 +207,34 @@ else {
$table=new CTableInfo(S_NO_SCRIPTS_DEFINED);
$table->setHeader(array(
array(new CCheckBox('all_scripts',null,"CheckAll('".$form->GetName()."','all_scripts');"),S_NAME),
- S_COMMAND, S_HOST_ACCESS
+ S_COMMAND,
+ S_USER_GROUP,
+ S_HOST_GROUP,
+ S_HOST_ACCESS
)
);
- $sql = 'SELECT * FROM scripts '.
- ' WHERE '.DBin_node('scriptid').
- ' ORDER BY scriptid ASC';
+ $sql = 'SELECT s.* '.
+ ' FROM scripts s '.
+ ' WHERE '.DBin_node('s.scriptid').
+ ' ORDER BY s.scriptid ASC';
$scripts=DBselect($sql);
while($script=DBfetch($scripts)){
+
+ $user_group_name = S_ALL;
+ if($script['usrgrpid'] > 0){
+ $user_group = get_group_by_usrgrpid($script['usrgrpid']);
+ $user_group_name = $user_group['name'];
+ }
+
+ $host_group_name = S_ALL;
+ if($script['groupid'] > 0){
+ $group = get_hostgroup_by_groupid($script['groupid']);
+ $host_group_name = $group['name'];
+ }
+
$table->addRow(array(
array(
@@ -183,7 +242,9 @@ else {
new CLink($script['name'],'scripts.php?form=1'.'&scriptid='.$script['scriptid'].'#form','action')
),
htmlspecialchars($script['command']),
- (($script['host_access'] == SCRIPT_HOST_ACCESS_READ)?S_READ:S_WRITE)
+ $user_group_name,
+ $host_group_name,
+ ((PERM_READ_WRITE == $script['host_access'])?S_WRITE:S_READ)
));
}
$qbutton = new CButtonQMessage('delete',S_DELETE_SELECTED,S_DELETE_SELECTED_SCRIPTS_Q,'1');
diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php
index 5159fbe6..21f92cc3 100644
--- a/frontends/php/tr_status.php
+++ b/frontends/php/tr_status.php
@@ -168,7 +168,7 @@ include_once "include/page_header.php";
$scripts_by_hosts = get_accessible_scripts_by_hosts(explode(',',$available_hosts));
- $available_triggers = get_accessible_triggers(PERM_READ_ONLY,PERM_RES_DATA_ARRAY);
+ $available_triggers = get_accessible_triggers(PERM_READ_ONLY,PERM_RES_IDS_ARRAY);
$result=DBselect('SELECT DISTINCT g.groupid,g.name '.
' FROM groups g, hosts_groups hg, hosts h, items i '.
@@ -480,8 +480,11 @@ include_once "include/page_header.php";
$menus.= "['".$script['name']."',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=".$row['hostid']."&scriptid=".$script['scriptid']."','".S_TOOLS."',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
}
- $menus = trim($menus,',');
- if(!empty($menus)) $menus="show_popup_menu(event,[[".zbx_jsvalue(S_TOOLS).",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],".$menus."],180);";
+ $menus.= "[".zbx_jsvalue(S_LINKS).",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],";
+ $menus.= "['".S_LATEST_DATA."',\"javascript: Redirect('latest.php?hostid=".$row['hostid']."')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
+
+ $menus = rtrim($menus,',');
+ $menus="show_popup_menu(event,[[".zbx_jsvalue(S_TOOLS).",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],".$menus."],180);";
$host = new CSpan($row['host']);
$host->AddOption('onclick','javascript: '.$menus);