summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-27 11:56:36 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-27 11:56:36 +0000
commit1fb44c22f51cccab8f5c32b51fd8b52969c36073 (patch)
treeabac8d01bac879156b1d1ea654d4eaccd0d8a69b /frontends/php
parent4606e2b5acf4fd9527d106e01c87bba1a263a166 (diff)
downloadzabbix-1fb44c22f51cccab8f5c32b51fd8b52969c36073.tar.gz
zabbix-1fb44c22f51cccab8f5c32b51fd8b52969c36073.tar.xz
zabbix-1fb44c22f51cccab8f5c32b51fd8b52969c36073.zip
- added popup menu for quick hosts controlling in configuration screen (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3941 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/css.css18
-rw-r--r--frontends/php/hosts.php95
-rw-r--r--frontends/php/include/classes/cpumenu.inc.php16
-rw-r--r--frontends/php/include/config.inc.php2
-rw-r--r--frontends/php/include/hosts.inc.php9
-rw-r--r--frontends/php/js/menu.js7
6 files changed, 137 insertions, 10 deletions
diff --git a/frontends/php/css.css b/frontends/php/css.css
index 3c33c184..010acf7b 100644
--- a/frontends/php/css.css
+++ b/frontends/php/css.css
@@ -1059,6 +1059,24 @@ ul
}
+/* menu menu item with submenu */
+.pum_o_submenu{
+ font-family: sans-serif, Tahoma, Verdana, Geneva, Arial, Helvetica;
+ font-size: 12px;
+ text-decoration: none;
+ background: #ECECFF;
+ border: black 1px solid;
+ margin: 0px;
+}
+.pum_o_submenu:hover {
+ text-decoration: none;
+ background-color: #FDFDFF;
+}
+.pum_i_submenu{
+ margin: 3px 0px 0px 8px;
+
+}
+
/* menu group header */
.pum_oheader {
cursor: default;
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php
index c80e03e5..fb3a9697 100644
--- a/frontends/php/hosts.php
+++ b/frontends/php/hosts.php
@@ -102,6 +102,9 @@ include_once "include/page_header.php";
"activate"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
"disable"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "add_to_group"=> array(T_ZBX_INT, O_OPT, P_SYS|P_ACT, DB_ID, NULL),
+ "delete_from_group"=> array(T_ZBX_INT, O_OPT, P_SYS|P_ACT, DB_ID, NULL),
+
"unlink"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
"unlink_and_clear"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
@@ -274,6 +277,38 @@ include_once "include/page_header.php";
}
/* ACTIVATE / DISABLE HOSTS */
elseif(($_REQUEST["config"]==0 || $_REQUEST["config"]==3) &&
+ (inarr_isset(array('add_to_group','hostid'))))
+ {
+ global $USER_DETAILS;
+
+ if(!in_array($_REQUEST['add_to_group'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,
+ PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ {
+ access_deny();
+ }
+
+ show_messages(
+ add_host_to_group($_REQUEST['hostid'], $_REQUEST['add_to_group']),
+ S_HOST_UPDATED,
+ S_CANNOT_UPDATE_HOST);
+ }
+ elseif(($_REQUEST["config"]==0 || $_REQUEST["config"]==3) &&
+ (inarr_isset(array('delete_from_group','hostid'))))
+ {
+ global $USER_DETAILS;
+
+ if(!in_array($_REQUEST['delete_from_group'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,
+ PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ {
+ access_deny();
+ }
+
+ if( delete_host_from_group($_REQUEST['hostid'], $_REQUEST['delete_from_group']) )
+ {
+ show_messages(true, S_HOST_UPDATED);
+ }
+ }
+ elseif(($_REQUEST["config"]==0 || $_REQUEST["config"]==3) &&
(isset($_REQUEST["activate"])||isset($_REQUEST["disable"])))
{
$result = 0;
@@ -572,7 +607,7 @@ include_once "include/page_header.php";
$show_only_tmp ? NULL : S_STATUS,
$show_only_tmp ? NULL : S_AVAILABILITY,
$show_only_tmp ? NULL : S_ERROR,
- S_SHOW
+ S_ACTIONS
));
$sql="select h.* from";
@@ -589,6 +624,9 @@ include_once "include/page_header.php";
while($row=DBfetch($result))
{
+ $add_to = array();
+ $delete_from = array();
+
$templates = get_templates_by_hostid($row["hostid"]);
$host=new CCol(array(
@@ -645,15 +683,56 @@ include_once "include/page_header.php";
else $error = new CCol($row["error"],"on");
}
-
- $show = array(
- new CLink(S_ITEMS,"items.php?hostid=".$row["hostid"],'action'),
- SPACE.":".SPACE,
- new CLink(S_TRIGGERS,"triggers.php?hostid=".$row["hostid"],'action'),
- SPACE.":".SPACE,
- new CLink(S_GRAPHS,"graphs.php?hostid=".$row["hostid"],'action')
+
+ $popup_menu_actions = array(
+ array(S_SHOW, null, null, array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader'))),
+ array(S_ITEMS, 'items.php?hostid='.$row['hostid'], array('tw'=>'_blank')),
+ array(S_TRIGGERS, 'triggers.php?hostid='.$row['hostid'], array('tw'=>'_blank')),
+ array(S_GRAPHS, 'graphs.php?hostid='.$row['hostid'], array('tw'=>'_blank')),
);
+ $db_groups = DBselect('select g.groupid, g.name from groups g left join hosts_groups hg '.
+ ' on g.groupid=hg.groupid and hg.hostid='.$row['hostid'].
+ ' where hostid is NULL order by name,groupid');
+ while($group_data = DBfetch($db_groups))
+ {
+ $add_to[] = array($group_data['name'], '?'.
+ url_param($group_data['groupid'], false, 'add_to_group').
+ url_param($row['hostid'], false, 'hostid')
+ );
+ }
+
+ $db_groups = DBselect('select g.groupid, g.name from groups g, hosts_groups hg '.
+ ' where g.groupid=hg.groupid and hg.hostid='.$row['hostid'].
+ ' order by name,groupid');
+ while($group_data = DBfetch($db_groups))
+ {
+ $delete_from[] = array($group_data['name'], '?'.
+ url_param($group_data['groupid'], false, 'delete_from_group').
+ url_param($row['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(S_SELECT, '#', 'action', $mnuActions->GetOnActionJS());
+
$table->addRow(array(
$host,
$dns,
diff --git a/frontends/php/include/classes/cpumenu.inc.php b/frontends/php/include/classes/cpumenu.inc.php
index 1b697941..95cb104e 100644
--- a/frontends/php/include/classes/cpumenu.inc.php
+++ b/frontends/php/include/classes/cpumenu.inc.php
@@ -30,6 +30,22 @@
function CPUMenu($items=array(), $width=null)
{
$this->InsertJavaScript();
+ /*********************** ITEM ARRAY ***********************
+ ITEM: array(name, url, param, css, submenu1, submenu2, ... , submenuN)
+
+ name: text
+ url: text (url for href perameter)
+ param: array(tw => t_val, sb => s_val)
+ tw: target parameter
+ t_val: one of '_blank', '_parent', '_self', '_top'
+ sb: text for statusbar)
+ s_val: text
+ css: array(outer => cssarray, inner => cssarray)
+ outer -> style for outer div element
+ inner -> style for inner link element with text
+ cssarray -> array(normal, mouseover, mousedown)
+ submen1-N: list of subitems
+ **********************************************************/
$this->items = $items;
$this->width = $width;
}
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index c3c1b316..76c273f2 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -224,7 +224,7 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!!
if(!is_array($value))
{
if(is_object($value)) return unpack_object($value);
- if(is_string($value)) return '\''.str_replace('\'','\\\'',zbx_jsstr($value)).'\'';
+ if(is_string($value)) return '\''.str_replace('\'','\\\'',str_replace("\n", '\n', str_replace("\r", '', ($value)))).'\'';
if(is_null($value)) return 'null';
return strval($value);
}
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index 044df43a..6d37652b 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -38,6 +38,15 @@ require_once "include/items.inc.php";
return $hostgroupid;
}
+ function delete_host_from_group($hostid, $groupid)
+ {
+ if(!is_numeric($hostid) || !is_numeric($groupid)){
+ error("incorrect parameters for 'add_host_to_group' [hostid:".$hostid."][groupid:".$groupid."]");
+ return false;
+ }
+ return DBexecute('delete from hosts_groups where hostid='.$hostid.' and groupid='.$groupid);
+ }
+
function db_save_group($name,$groupid=null)
{
if(!is_string($name)){
diff --git a/frontends/php/js/menu.js b/frontends/php/js/menu.js
index 1824a5be..d9625c1d 100644
--- a/frontends/php/js/menu.js
+++ b/frontends/php/js/menu.js
@@ -224,7 +224,12 @@ function menu_expand (n_id) {
// --------------------------------------------------------------------------------
function menu_onclick (n_id) {
// don't go anywhere if item has no link defined
- return Boolean(this.a_index[n_id].a_config[1]);
+ if(Boolean(this.a_index[n_id].a_config[1]))
+ {
+ this.collapse(0);
+ return true;
+ }
+ return false;
}
// --------------------------------------------------------------------------------