diff options
author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-01-20 11:51:40 +0000 |
---|---|---|
committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-01-20 11:51:40 +0000 |
commit | d57d1c42166cd82e6fb91bd0371b077e9e9f381b (patch) | |
tree | 73d9a9f349d7baf52c02011ae3f03ec61dbae7eb /frontends/php | |
parent | 00ad786c34052a414e1c9d4a19dc4065b76192d8 (diff) | |
download | zabbix-d57d1c42166cd82e6fb91bd0371b077e9e9f381b.tar.gz zabbix-d57d1c42166cd82e6fb91bd0371b077e9e9f381b.tar.xz zabbix-d57d1c42166cd82e6fb91bd0371b077e9e9f381b.zip |
- Frontend improvements (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2547 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r-- | frontends/php/css.css | 2 | ||||
-rw-r--r-- | frontends/php/hosts.php | 315 | ||||
-rw-r--r-- | frontends/php/include/classes/cbutton.inc.php | 58 | ||||
-rw-r--r-- | frontends/php/include/classes/cspan.inc.php | 32 | ||||
-rw-r--r-- | frontends/php/include/config.inc.php | 51 | ||||
-rw-r--r-- | frontends/php/include/forms.inc.php | 98 | ||||
-rw-r--r-- | frontends/php/include/hosts.inc.php | 11 | ||||
-rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 2 |
8 files changed, 362 insertions, 207 deletions
diff --git a/frontends/php/css.css b/frontends/php/css.css index 4638ce06..9760c28b 100644 --- a/frontends/php/css.css +++ b/frontends/php/css.css @@ -260,7 +260,7 @@ A.off:active { color:#00AA00; text-decoration: underline;} A.on:link { color:#AA0000; text-decoration: none; } A.on:visited { color:#AA0000; text-decoration: none; } -A.no:hover { color:#AA0000; text-decoration: underline; } +A.on:hover { color:#AA0000; text-decoration: underline; } A.on:active { color:#AA0000; text-decoration: underline;} .on diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php index 157af394..7046ddf5 100644 --- a/frontends/php/hosts.php +++ b/frontends/php/hosts.php @@ -44,7 +44,9 @@ unset($_REQUEST["form"]); } - if(isset($_REQUEST["save"])&&$_REQUEST["config"]==0) +/************ ACTIONS FOR HOSTS ****************/ +/* SAVE HOST */ + if($_REQUEST["config"]==0&&isset($_REQUEST["save"])) { $useip = get_request("useip","no"); @@ -123,33 +125,150 @@ unset($_REQUEST["form"]); unset($_REQUEST["hostid"]); } - } elseif(isset($_REQUEST["delete"])&&($_REQUEST["config"]==0)) - { - $host=get_host_by_hostid($_REQUEST["hostid"]); - $result=delete_host($_REQUEST["hostid"]); + unset($_REQUEST["save"]); + } - show_messages($result, S_HOST_DELETED, S_CANNOT_DELETE_HOST); - if($result) +/* DELETE HOST */ + if(($_REQUEST["config"]==0)&&isset($_REQUEST["delete"])){ + if(isset($_REQUEST["hostid"])){ + $host=get_host_by_hostid($_REQUEST["hostid"]); + $result=delete_host($_REQUEST["hostid"]); + + show_messages($result, S_HOST_DELETED, S_CANNOT_DELETE_HOST); + if($result) + { + add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST, + "Host [".addslashes($host["host"])."]"); + + unset($_REQUEST["form"]); + unset($_REQUEST["hostid"]); + } + } else { +/* group operations */ + $result = 0; + $db_hosts=DBselect("select hostid from hosts"); + while($db_host=DBfetch($db_hosts)) + { + if(!isset($_REQUEST[$db_host["hostid"]])) continue; + $result = 1; + $res=delete_host($db_host["hostid"]); + + if(!$res) continue; + $host=get_host_by_hostid($db_host["hostid"]); + add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST, + "Host [".addslashes($host["host"])."]"); + } + show_messages($result, S_HOST_DELETED, NULL); + } + unset($_REQUEST["delete"]); + } + if($_REQUEST["config"]==0&&(isset($_REQUEST["activate"])||isset($_REQUEST["disable"]))){ + $result = 0; + $status = isset($_REQUEST["activate"]) ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED; + $db_hosts=DBselect("select hostid from hosts"); + while($db_host=DBfetch($db_hosts)) { - add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST,"Host [".addslashes($host["host"])."]"); + if(!isset($_REQUEST[$db_host["hostid"]])) continue; + $result = 1; + $res=update_host_status($db_host["hostid"],$status); - unset($_REQUEST["form"]); - unset($_REQUEST["hostid"]); + if(!$res) continue; + $host=get_host_by_hostid($db_host["hostid"]); + add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST, + "Old status [".$host["status"]."] "."New status [".$status."]"); } + show_messages($result, S_HOST_STATUS_UPDATED, NULL); + unset($_REQUEST["activate"]); } - if(isset($_REQUEST["changestatus"])) + + if($_REQUEST["config"]==0&&isset($_REQUEST["chstatus"])&&isset($_REQUEST["hostid"])) { $host=get_host_by_hostid($_REQUEST["hostid"]); - $result=update_host_status($_REQUEST["hostid"],$_REQUEST["status"]); + $result=update_host_status($_REQUEST["hostid"],$_REQUEST["chstatus"]); show_messages($result,S_HOST_STATUS_UPDATED,S_CANNOT_UPDATE_HOST_STATUS); if($result) { add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST, - "Old status [".$host["status"]."] New status [".$_REQUEST["status"]."]"); + "Old status [".$host["status"]."] New status [".$_REQUEST["chstatus"]."]"); } + unset($_REQUEST["chstatus"]); unset($_REQUEST["hostid"]); } +/****** ACTIONS FOR GROUPS **********/ + if($_REQUEST["config"]==1&&isset($_REQUEST["save"])) + { + $hosts = get_request("hosts",array()); + if(isset($_REQUEST["groupid"])){ + $result = update_host_group($_REQUEST["groupid"], $_REQUEST["name"], $hosts); + $msg_ok = S_GROUP_UPDATED; + $msg_fail = S_CANNOT_UPDATE_GROUP; + } else { + $result = add_host_group($_REQUEST["name"], $hosts); + $msg_ok = S_GROUP_ADDED; + $msg_fail = S_CANNOT_ADD_GROUP; + } + show_messages($result, $msg_ok, $msg_fail); + if($result){ + unset($_REQUEST["form"]); + } + unset($_REQUEST["save"]); + } + if($_REQUEST["config"]==1&&isset($_REQUEST["delete"])) + { + if(isset($_REQUEST["groupid"])){ + $result=delete_host_group($_REQUEST["groupid"]); + if($result){ +// $group = get_group_by_groupid($_REQUEST["groupid"]); +// add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_GROUP, +// "Group [".$group["name"]."]"); + + unset($_REQUEST["form"]); + } + show_messages($result, S_GROUP_DELETED, S_CANNOT_DELETE_GROUP); + unset($_REQUEST["groupid"]); + } else { +/* group operations */ + $result = 0; + + $db_groups=DBselect("select groupid, name from groups"); + while($db_group=DBfetch($db_groups)) + { + if(!isset($_REQUEST[$db_group["groupid"]])) continue; + $result = 1; + if(!delete_host_group($db_group["groupid"])) continue + + add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_GROUP, + "Group [".$db_group["name"]."]"); + } + show_messages($result, S_GROUP_DELETED, NULL); + } + unset($_REQUEST["delete"]); + } + + if($_REQUEST["config"]==1&&(isset($_REQUEST["activate"])||isset($_REQUEST["disable"]))){ + $result = 0; + $status = isset($_REQUEST["activate"]) ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED; + + $db_hosts=DBselect("select h.hostid, hg.groupid from hosts_groups hg, hosts h". + " where h.hostid=hg.hostid and h.status<>".HOST_STATUS_DELETED); + while($db_host=DBfetch($db_hosts)) + { + if(!isset($_REQUEST[$db_host["groupid"]])) continue; + $result = 1; + $res=update_host_status($db_host["hostid"],$status); + + if(!$res) continue; + $host=get_host_by_hostid($db_host["hostid"]); + add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST, + "Old status [".$host["status"]."] "."New status [".$status."]"); + } + show_messages($result, S_HOST_STATUS_UPDATED, NULL); + unset($_REQUEST["activate"]); + } + +/************* OLD ACTIONS ***************/ + if(isset($_REQUEST["register"])) { if($_REQUEST["register"]=="add items from template") @@ -204,119 +323,20 @@ show_messages($result, S_TEMPLATE_LINKAGE_DELETED, S_CANNOT_DELETE_TEMPLATE_LINKAGE); unset($_REQUEST["hosttemplateid"]); } - if($_REQUEST["register"]=="add group") - { - $result=add_host_group($_REQUEST["name"], $_REQUEST["hosts"]); - show_messages($result, S_GROUP_ADDED, S_CANNOT_ADD_GROUP); - } - if($_REQUEST["register"]=="delete group") - { - $result=delete_host_group($_REQUEST["groupid"]); - show_messages($result, S_GROUP_DELETED, S_CANNOT_DELETE_GROUP); - unset($_REQUEST["groupid"]); - } - if($_REQUEST["register"]=="update group") - { - $result=update_host_group($_REQUEST["groupid"], $_REQUEST["name"], $_REQUEST["hosts"]); - show_messages($result, S_GROUP_UPDATED, _S_CANNOT_UPDATE_GROUP); - } - if($_REQUEST["register"]=="start monitoring") - { - $result=DBselect("select hostid from hosts_groups where groupid=".$_REQUEST["groupid"]); - while($row=DBfetch($result)) - { - $res=update_host_status($row["hostid"],HOST_STATUS_MONITORED); - if($res) - { - add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST, - "New status [".HOST_STATUS_MONITORED."]"); - } - } - show_messages(1,S_HOST_STATUS_UPDATED,S_CANNOT_UPDATE_HOST_STATUS); - } - if($_REQUEST["register"]=="stop monitoring") - { - $result=DBselect("select hostid from hosts_groups where groupid=".$_REQUEST["groupid"]); - while($row=DBfetch($result)) - { - $res=update_host_status($row["hostid"],HOST_STATUS_NOT_MONITORED); - if($res) - { - add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST,"New status [".HOST_STATUS_NOT_MONITORED."]"); - } - } - show_messages(1,S_HOST_STATUS_UPDATED,S_CANNOT_UPDATE_HOST_STATUS); - } - if($_REQUEST["register"]=="Activate selected") - { - $result=DBselect("select hostid from hosts"); - while($row=DBfetch($result)) - { -// $$ is correct here - if(isset($_REQUEST[$row["hostid"]])) - { - $res=update_host_status($row["hostid"],HOST_STATUS_MONITORED); - if($res) - { - add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST,"New status [".HOST_STATUS_MONITORED."]"); - } - } - } - show_messages(1,S_HOST_STATUS_UPDATED,S_CANNOT_UPDATE_HOST_STATUS); - } - if($_REQUEST["register"]=="Disable selected") - { - $result=DBselect("select hostid from hosts"); - while($row=DBfetch($result)) - { -// $$ is correct here - if(isset($_REQUEST[$row["hostid"]])) - { - $res=update_host_status($row["hostid"],HOST_STATUS_NOT_MONITORED); - if($res) - { - add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST,"New status [".HOST_STATUS_NOT_MONITORED."]"); - } - } - } - show_messages(1,S_HOST_STATUS_UPDATED,S_CANNOT_UPDATE_HOST_STATUS); - } - if($_REQUEST["register"]=="Delete selected") - { - $result=DBselect("select hostid from hosts"); - while($row=DBfetch($result)) - { -// $$ is correct here - if(isset($_REQUEST[$row["hostid"]])) - { - $host=get_host_by_hostid($row["hostid"]); - $res=delete_host($row["hostid"]); - if($res) - { - add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST,"Host [".addslashes($host["host"])."]"); - } - } - } - show_messages($result, S_HOST_DELETED, S_CANNOT_DELETE_HOST); - } } ?> <?php - if(!isset($_REQUEST["config"])) - { - $_REQUEST["config"]=0; - } - $cmbConf = new CComboBox("config",$_REQUEST["config"],"submit()"); $cmbConf->AddItem(0,S_HOSTS); $cmbConf->AddItem(1,S_HOST_GROUPS); -// $cmbConf->AddItem(2,S_HOSTS_TEMPLATES_LINKAGE); + $cmbConf->AddItem(2,S_HOSTS_TEMPLATES_LINKAGE); switch($_REQUEST["config"]){ case 0: $btnCaption = S_CREATE_HOST; break; case 1: $btnCaption = S_CREATE_GROUP; break; + case 2: $btnCaption = "S_CREATE_LINKAGE"; break; } $frmForm = new CForm("hosts.php"); @@ -408,34 +428,52 @@ } else { show_table_header(S_HOST_GROUPS_BIG); $table = new CTableInfo(S_NO_HOST_GROUPS_DEFINED); - $table->setHeader(array(S_NAME,S_MEMBERS,S_MONITORING)); + $table->setHeader(array(S_NAME,S_MEMBERS)); $db_groups=DBselect("select groupid,name from groups order by name"); - while($row=DBfetch($db_groups)) + while($db_group=DBfetch($db_groups)) { - $db_hosts = DBselect("select distinct h.host from hosts h, hosts_groups hg". - " where h.hostid=hg.hostid and hg.groupid=".$row["groupid"]. + $db_hosts = DBselect("select distinct h.host, h.status". + " from hosts h, hosts_groups hg". + " where h.hostid=hg.hostid and hg.groupid=".$db_group["groupid"]. " and h.status not in (".HOST_STATUS_DELETED.") order by host"); - $hosts = ""; - if($db_host=DBfetch($db_hosts)) $hosts .= $db_host["host"]; - while($db_host=DBfetch($db_hosts)) $hosts .= ", ".$db_host["host"]; + $hosts = array(""); + if($db_host=DBfetch($db_hosts)){ + $style = $db_host["status"]==HOST_STATUS_MONITORED ? NULL: "on"; + array_push($hosts,new CSpan($db_host["host"],$style)); + } + while($db_host=DBfetch($db_hosts)){ + $style = $db_host["status"]==HOST_STATUS_MONITORED ? NULL: "on"; + array_push($hosts,", ",new CSpan($db_host["host"],$style)); + } $table->addRow(array( - new CLink( - $row["name"], - "hosts.php?config=".$_REQUEST["config"]. - "&groupid=".$row["groupid"]. - "&form=0"), - $hosts, array( - S_START, - BR, - S_STOP - ) + new CCheckBox($db_group["groupid"]), + new CLink( + $db_group["name"], + "hosts.php?form=0&groupid=".$db_group["groupid"]. + url_param("config")) + ), + $hosts )); } - $table->show(); + $footerButtons = array(); + array_push($footerButtons, new CButton('activate','Activate selected', + "return Confirm('".S_ACTIVATE_SELECTED_HOSTS_Q."');")); + array_push($footerButtons, SPACE); + array_push($footerButtons, new CButton('disable','Disable selected', + "return Confirm('".S_DISABLE_SELECTED_HOSTS_Q."');")); + array_push($footerButtons, SPACE); + array_push($footerButtons, new CButton('delete','Delete selected', + "return Confirm('".S_DELETE_SELECTED_GROUPS_Q."');")); + $table->SetFooter(new CCol($footerButtons),'table_footer'); + + $form = new CForm('hosts.php'); + $form->AddVar("config",get_request("config",0)); + $form->AddItem($table); + $form->Show(); } } ?> @@ -543,7 +581,7 @@ if(check_right("Host","U",$row["hostid"])) { $text=new CLink($text,"hosts.php?hostid=".$row["hostid"]. - "&changestatus=1&status=".HOST_STATUS_NOT_MONITORED, + "&chstatus=".HOST_STATUS_NOT_MONITORED.url_param("config"), "off"); } $status=new CCol($text,"off"); @@ -552,7 +590,7 @@ if(check_right("Host","U",$row["hostid"])) { $text=new CLink($text,"hosts.php?hostid=".$row["hostid"]. - "&changestatus=1&status=".HOST_STATUS_MONITORED, + "&chstatus=".HOST_STATUS_MONITORED.url_param("config"), "on"); } $status=new CCol($text,"on"); @@ -590,15 +628,18 @@ } $footerButtons = array(); - array_push($footerButtons, new CButton('register','Activate selected', + array_push($footerButtons, new CButton('activate','Activate selected', "return Confirm('".S_ACTIVATE_SELECTED_HOSTS_Q."');")); - array_push($footerButtons, new CButton('register','Disable selected', + array_push($footerButtons, SPACE); + array_push($footerButtons, new CButton('disable','Disable selected', "return Confirm('".S_DISABLE_SELECTED_HOSTS_Q."');")); - array_push($footerButtons, new CButton('register','Delete selected', + array_push($footerButtons, SPACE); + array_push($footerButtons, new CButton('delete','Delete selected', "return Confirm('".S_DELETE_SELECTED_HOSTS_Q."');")); $table->SetFooter(new CCol($footerButtons),'table_footer'); $form = new CForm('hosts.php'); + $form->AddVar("config",get_request("config",0)); $form->AddItem($table); $form->Show(); diff --git a/frontends/php/include/classes/cbutton.inc.php b/frontends/php/include/classes/cbutton.inc.php index 9a5801fb..d09afb22 100644 --- a/frontends/php/include/classes/cbutton.inc.php +++ b/frontends/php/include/classes/cbutton.inc.php @@ -82,4 +82,62 @@ return $this->AddOption("value",$value); } } + + class CButtonCancel extends CButton + { + function CButtonCancel($vars=NULL){ + parent::CButton("cancel",S_CANCEL); + $this->SetVars($vars); + } + function SetVars($value=NULL){ + global $page; + + $url = $page["file"]."?cancel=1"; + + if(!is_null($value)) + $url = $url.$value; + + return $this->SetAction("return Redirect('$url')"); + } + } + + class CButtonDelete extends CButton + { + var $vars; + var $msg; + + function CButtonDelete($msg=NULL, $vars=NULL){ + parent::CButton("delete",S_DELETE); + $this->SetMessage($msg); + $this->SetVars($vars); + } + function SetVars($value=NULL){ + if(!is_string($value) && !is_null($value)){ + return $this->error("Incorrect value for SetVars [$value]"); + } + $this->vars = $value; + $this->SetAction(NULL); + } + function SetMessage($value=NULL){ + if(is_null($value)) + $value = "Are You Sure?"; + + if(!is_string($value)){ + return $this->error("Incorrect value for SetMessage [$value]"); + } + $this->msg = $value; + $this->SetAction(NULL); + } + function SetAction($value=NULL){ + if(!is_null($value)) + return parent::SetAction($value); + + global $page; + + $confirmation = "Confirm('".$this->msg."')"; + $redirect = "Redirect('".$page["file"]."?delete=1".$this->vars."')"; + + return parent::SetAction("if(".$confirmation.") return ".$redirect."; else return false;"); + } + } ?> diff --git a/frontends/php/include/classes/cspan.inc.php b/frontends/php/include/classes/cspan.inc.php new file mode 100644 index 00000000..b0a0ffda --- /dev/null +++ b/frontends/php/include/classes/cspan.inc.php @@ -0,0 +1,32 @@ +<?php +/* +** ZABBIX +** Copyright (C) 2000-2005 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. +**/ +?> +<?php + class CSpan extends CTag + { +/* public */ + function CSpan($items=NULL,$class=NULL) + { + parent::CTag("span","yes"); + $this->SetClass($class); + $this->AddItem($items); + } + } +?> diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 8898022c..9871459e 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -55,6 +55,7 @@ function SDI($msg) { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!! // Include Classes include_once("include/classes/ctag.inc.php"); include_once("include/classes/cvar.inc.php"); + include_once("include/classes/cspan.inc.php"); include_once("include/classes/cimg.inc.php"); include_once("include/classes/clink.inc.php"); include_once("include/classes/chelp.inc.php"); @@ -630,21 +631,6 @@ function SDI($msg) { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!! return "$priorities,$md5sum"; } - function get_group_by_groupid($groupid) - { - $sql="select * from groups where groupid=$groupid"; - $result=DBselect($sql); - if(DBnum_rows($result) == 1) - { - return DBfetch($result); - } - else - { - error("No groups with groupid=[$groupid]"); - } - return $result; - } - function get_usergroup_by_usrgrpid($usrgrpid) { $result=DBselect("select usrgrpid,name from usrgrp where usrgrpid=$usrgrpid"); @@ -711,11 +697,17 @@ function SDI($msg) { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!! if(!$bool) { + if(is_null($errmsg)) + return; + $msg="ERROR:".$errmsg; $color="#AA0000"; } else { + if(is_null($msg)) + return; + $color="#223344"; } echo "<p align=center>"; @@ -2824,19 +2816,22 @@ function SDI($msg) { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!! function insert_confirm_javascript() { - echo "<script language=\"JavaScript\" type=\"text/javascript\">\n"; - echo "function Confirm(msg)\n"; - echo "{\n"; - echo " if(confirm( msg))\n"; - echo " {\n"; - echo " return true;\n"; - echo " }\n"; - echo " else\n"; - echo " {\n"; - echo " return false;\n"; - echo " }\n"; - echo "}\n"; - echo "</script>\n"; + echo " +<script language=\"JavaScript\" type=\"text/javascript\"> + function Confirm(msg) + { + if(confirm(msg,'title')) + return true; + else + return false; + } + function Redirect(url) + { + window.location = url; + return false; + } +</script> + "; } /* Use ImageSetStyle+ImageLIne instead of bugged ImageDashedLine */ diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 812c3af5..a2c799c9 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -98,22 +98,22 @@ # Insert form for User function insert_user_form($userid,$profile=0) { - $frm_title = ""; - if(isset($userid)) + $frm_title = S_USER; + if(isset($userid)&&$_REQUEST["form"]!=1) { $user=get_user_by_userid($userid); - $result=DBselect("select u.alias,u.name,u.surname,u.passwd,u.url,u.autologout,u.lang,u.refresh from users u where u.userid=$userid"); - - $alias = get_request("alias",$user["alias"]); - $name = get_request("name",$user["name"]); - $surname = get_request("surname",$user["surname"]); + $frm_title = S_USER." \"".$user["alias"]."\""; + } + if(isset($userid)&&$_REQUEST["form"]!=1) + { + $alias = $user["alias"]; + $name = $user["name"]; + $surname = $user["surname"]; $password = ""; - $url = get_request("url",$user["url"]); - $autologout = get_request("autologout",$user["autologout"]); - $lang = get_request("lang",$user["lang"]); - $refresh = get_request("refresh",$user["refresh"]); - - $frm_title = SPACE."\"".$user["alias"]."\""; + $url = $user["url"]; + $autologout = $user["autologout"]; + $lang = $user["lang"]; + $refresh = $user["refresh"]; } else { @@ -127,15 +127,15 @@ $refresh = get_request("refresh","30"); } - $frmUser = new CFormTable(S_USER.$frm_title); + $frmUser = new CFormTable($frm_title); $frmUser->SetHelp("web.users.users.php"); + $frmUser->AddVar("config",get_request("config",0)); if($profile==0) $frmUser->SetAction("users.php"); else $frmUser->SetAction("profile.php"); - $frmUser->AddVar("config",$_REQUEST["config"]); if(isset($userid)) $frmUser->AddVar("userid",$userid); if($profile==0) @@ -169,11 +169,11 @@ if(isset($userid)) { $frmUser->AddItemToBottomRow(SPACE); - $frmUser->AddItemToBottomRow(new CButton('delete',S_DELETE, - "return Confirm('Delete selected user?');")); + $frmUser->AddItemToBottomRow(new CButtonDelete( + "Delete selected user?",url_param("config").url_param("userid"))); } $frmUser->AddItemToBottomRow(SPACE); - $frmUser->AddItemToBottomRow(new CButton('cancel',S_CANCEL)); + $frmUser->AddItemToBottomRow(new CButtonCancel(url_param("config"))); $frmUser->Show(); } @@ -452,34 +452,38 @@ { global $_REQUEST; + $frm_title = S_HOST_GROUP; if(isset($groupid)) { $groupid=get_group_by_groupid($groupid); - - $name=$groupid["name"]; + $frm_title = S_HOST_GROUP." \"".$groupid["name"]."\""; + if($_REQUEST["form"]!=1) + $name=$groupid["name"]; + else + $name = get_request("name",""); } else { - $name=""; + $name=get_request("name",""); } - $frmHostG = new CFormTable(S_HOST_GROUP,"hosts.php"); + $frmHostG = new CFormTable($frm_title,"hosts.php"); $frmHostG->SetHelp("web.hosts.group.php"); + $frmHostG->AddVar("config",get_request("config",1)); if(isset($_REQUEST["groupid"])) { $frmHostG->AddVar("groupid",$_REQUEST["groupid"]); } - $frmHostG->AddVar("config",get_request("config",1)); $frmHostG->AddRow(S_GROUP_NAME,new CTextBox("name",$name,30)); $cmbHosts = new CListBox("hosts[]",5); - $hosts=DBselect("select distinct hostid,host from hosts order by host"); + $hosts=DBselect("select distinct hostid,host from hosts where status<>".HOST_STATUS_DELETED." order by host"); while($host=DBfetch($hosts)) { if(isset($_REQUEST["groupid"])) { - $sql="select count(*) as count from hosts_groups where hostid=".$host["hostid"]." and groupid=".$_REQUEST["groupid"]; - $result=DBselect($sql); + $result=DBselect("select count(*) as count from hosts_groups". + " where hostid=".$host["hostid"]." and groupid=".$_REQUEST["groupid"]); $res_row=DBfetch($result); $cmbHosts->AddItem($host["hostid"],$host["host"], ($res_row["count"]==0) ? 'no' : 'yes'); @@ -495,11 +499,14 @@ if(isset($_REQUEST["groupid"])) { $frmHostG->AddItemToBottomRow(SPACE); - $frmHostG->AddItemToBottomRow(new CButton("delete",S_DELETE, - "return Confirm('Delete selected group?');")); + $frmHostG->AddItemToBottomRow( + new CButtonDelete("Delete selected group?", + url_param("config").url_param("groupid") + ) + ); } $frmHostG->AddItemToBottomRow(SPACE); - $frmHostG->AddItemToBottomRow(new CButton("cancel",S_CANCEL)); + $frmHostG->AddItemToBottomRow(new CButtonCancel(url_param("config"))); $frmHostG->Show(); } @@ -508,25 +515,29 @@ { global $_REQUEST; - $frm_title = ""; + $frm_title = S_USER_GROUP; if(isset($usrgrpid)) { $usrgrp=get_usergroup_by_usrgrpid($usrgrpid); - $name = get_request("name",$usrgrp["name"]); - $frm_title = SPACE."\"".$usrgrp["name"]."\""; + $frm_title = S_USER_GROUP." \"".$usrgrp["name"]."\""; + } + + if(isset($usrgrpid)&&$_REQUEST["form"]!=1) + { + $name = $usrgrp["name"]; } else { $name = get_request("name",""); } - $frmUserG = new CFormTable(S_USER_GROUP.$frm_title,"users.php"); + $frmUserG = new CFormTable($frm_title,"users.php"); $frmUserG->SetHelp("web.users.groups.php"); + $frmUserG->AddVar("config",get_request("config",2)); if(isset($usrgrpid)) { $frmUserG->AddVar("usrgrpid",$usrgrpid); } - $frmUserG->AddVar("config",1); $frmUserG->AddRow(S_GROUP_NAME,new CTextBox("name",$name,30)); $form_row = array(); @@ -557,10 +568,11 @@ if(isset($_REQUEST["usrgrpid"])) { $frmUserG->AddItemToBottomRow(SPACE); - $frmUserG->AddItemToBottomRow(new CButton("delete",S_DELETE)); + $frmUserG->AddItemToBottomRow(new CButtonDelete( + "Delete selected group?",url_param("config").url_param("usrgrpid"))); } $frmUserG->AddItemToBottomRow(SPACE); - $frmUserG->AddItemToBottomRow(new CButton("cancel",S_CANCEL)); + $frmUserG->AddItemToBottomRow(new CButtonCancel(url_param("config"))); $frmUserG->Show(); } @@ -1514,12 +1526,12 @@ function insert_image_form() $contact = get_request("contact",""); $location = get_request("location",""); $notes = get_request("notes",""); - $frm_title = S_HOST; if(isset($_REQUEST["hostid"])){ $db_host=get_host_by_hostid($_REQUEST["hostid"]); $frm_title = S_HOST.SPACE."\"".$db_host["host"]."\""; - } + } else + $frm_title = S_HOST; if(isset($_REQUEST["hostid"]) && $_REQUEST["form"]!=1) { @@ -1558,10 +1570,10 @@ function insert_image_form() $frmHost = new CFormTable($frm_title,"hosts.php#form"); $frmHost->SetHelp("web.hosts.host.php"); + $frmHost->AddVar("config",get_request("config",0)); if(isset($_REQUEST["hostid"])) $frmHost->AddVar("hostid",$_REQUEST["hostid"]); if(isset($_REQUEST["groupid"])) $frmHost->AddVar("groupid",$_REQUEST["groupid"]); - $frmHost->AddVar("config",get_request("config",0)); $frmHost->AddRow(S_HOST,new CTextBox("host",$host,20)); @@ -1639,10 +1651,14 @@ function insert_image_form() // $frmHost->AddItemToBottomRow(SPACE); // $frmHost->AddItemToBottomRow(new CButton("register","add items from template")); $frmHost->AddItemToBottomRow(SPACE); - $frmHost->AddItemToBottomRow(new CButton("delete",S_DELETE,"return Confirm('".S_DELETE_SELECTED_HOST_Q."');")); + $frmHost->AddItemToBottomRow( + new CButtonDelete(S_DELETE_SELECTED_HOST_Q, + url_param("config").url_param("hostid") + ) + ); } $frmHost->AddItemToBottomRow(SPACE); - $frmHost->AddItemToBottomRow(new CButton("cancel",S_CANCEL)); + $frmHost->AddItemToBottomRow(new CButtonCancel(url_param("config"))); $frmHost->Show(); } /* diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php index 147f7f94..70662082 100644 --- a/frontends/php/include/hosts.inc.php +++ b/frontends/php/include/hosts.inc.php @@ -191,6 +191,17 @@ return DBexecute($sql); } + function get_group_by_groupid($groupid) + { + $result=DBselect("select * from groups where groupid=".$groupid); + if(DBnum_rows($result) == 1) + { + return DBfetch($result); + } + error("No groups with groupid=[$groupid]"); + return FALSE; + } + function get_host_by_itemid($itemid) { $sql="select h.* from hosts h, items i where i.hostid=h.hostid and i.itemid=$itemid"; diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index ae36200b..540ac0af 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -345,6 +345,8 @@ "S_LINK_WITH_HOST"=> "Link with host", "S_USE_PROFILE"=> "Use profile", "S_DELETE_SELECTED_HOST_Q"=> "Delete selected host?", + "S_DELETE_SELECTED_GROUP_Q"=> "Delete selected group?", + "S_DELETE_SELECTED_GROUPS_Q"=> "Delete selected groups?", "S_GROUP_NAME"=> "Group name", "S_HOST_GROUP"=> "Host group", "S_HOST_GROUPS"=> "Host groups", |