summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-04-18 09:52:54 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-04-18 09:52:54 +0000
commit5ee0e65e708340172b938d324ca316b0204b7dc5 (patch)
tree6356bab6e7f933290cf5b1964d77b1cfe2ccdddf /frontends/php/include
parentb024b6875f0b6c1575cb8317970afb5faa52df65 (diff)
downloadzabbix-5ee0e65e708340172b938d324ca316b0204b7dc5.tar.gz
zabbix-5ee0e65e708340172b938d324ca316b0204b7dc5.tar.xz
zabbix-5ee0e65e708340172b938d324ca316b0204b7dc5.zip
- [ZBX-362] merged rev. 5630:5634 of branches/1.4 (Artem) [added mass template linkage to hosts, mod by sergio.cricca]
git-svn-id: svn://svn.zabbix.com/trunk@5635 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/forms.inc.php58
-rw-r--r--frontends/php/include/hosts.inc.php15
-rw-r--r--frontends/php/include/locales/en_gb.inc.php6
3 files changed, 70 insertions, 9 deletions
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index efb3273a..b6cce472 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -4637,6 +4637,64 @@ include_once 'include/discovery.inc.php';
$frmHostP->AddItemToBottomRow(new CButtonCancel(url_param("groupid")));
$frmHostP->Show();
}
+
+// Original mod by scricca@vipsnet.net
+// Modified by Aly
+/* this code creates a form to link/unlink 1 template to/from multiple hosts */
+ function insert_template_form(){
+ global $USER_DETAILS;
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE, PERM_RES_IDS_ARRAY);
+
+ $frm_title = S_TEMPLATE;
+
+ if(isset($_REQUEST["hostid"])){
+ $template = get_host_by_hostid($_REQUEST["hostid"]);
+ $frm_title = S_TEMPLATE.' ['.$template['host'].']';
+ }
+
+ if(isset($_REQUEST['hostid']) && !isset($_REQUEST["form_refresh"])){
+ $name=$template['host'];
+ }
+ else{
+ $name=get_request("tname",'');
+ }
+
+ $frmHostT = new CFormTable($frm_title,"hosts.php");
+ $frmHostT->SetHelp("web.hosts.group.php");
+ $frmHostT->AddVar("config",get_request("config",2));
+ if(isset($_REQUEST["hostid"])){
+ $frmHostT->AddVar("hostid",$_REQUEST["hostid"]);
+ }
+
+ $frmHostT->AddRow(S_TEMPLATE,new CTextBox("tname",$name,60));
+
+ $cmbHosts = new CListBox('hosts[]',null,10);
+
+ $sql = 'SELECT DISTINCT h.hostid,h.host '.
+ ' FROM hosts h'.
+ ' WHERE ( h.status='.HOST_STATUS_MONITORED.' OR h.status='.HOST_STATUS_NOT_MONITORED.' ) '.
+ ' AND '.DBcondition('h.hostid',$available_hosts).
+ ' ORDER BY h.host';
+
+ $db_hosts=DBselect($sql);
+
+ while($db_host=DBfetch($db_hosts)){
+ $cmbHosts->AddItem(
+ $db_host["hostid"],
+ get_node_name_by_elid($db_host["hostid"]).$db_host["host"]
+ );
+ }
+
+ $frmHostT->AddRow(S_HOSTS,$cmbHosts);
+ $frmHostT->AddItemToBottomRow(new CButton('save',S_LINK_TO_TEMPLATE));
+ $frmHostT->AddItemToBottomRow(SPACE);
+ $frmHostT->AddItemToBottomRow(new CButton('unlink',S_UNLINK_FROM_TEMPLATE));
+ $frmHostT->AddItemToBottomRow(SPACE);
+ $frmHostT->AddItemToBottomRow(new CButtonCancel(url_param("config")));
+ $frmHostT->Show();
+ }
+//--- end mod ---
+
function insert_application_form()
{
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index 920adde5..9e3caf9b 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -327,12 +327,13 @@ require_once "include/items.inc.php";
* Comments: !!! Don't forget sync code with C !!!
*
*/
- function unlink_template($hostid, $templateid, $unlink_mode = true)
- {
- if( !is_numeric($templateid) ) fatal_error('Not supported type for [templateid] in [unlink_template] - ['.$templateid.']');
+ function unlink_template($hostid, $templateid, $unlink_mode = true){
+ if(!is_numeric($templateid))
+ fatal_error('Not supported type for [templateid] in [unlink_template] - ['.$templateid.']');
- delete_template_elements($hostid, $templateid, $unlink_mode);
- DBexecute("delete from hosts_templates where hostid=".$hostid.' and templateid='.$templateid);
+ $result = delete_template_elements($hostid, $templateid, $unlink_mode);
+ $result&= DBexecute("delete from hosts_templates where hostid=".$hostid.' and templateid='.$templateid);
+ return $result;
}
/*
@@ -353,6 +354,7 @@ require_once "include/items.inc.php";
delete_template_triggers($hostid, $templateid, $unlink_mode);
delete_template_items($hostid, $templateid, $unlink_mode);
delete_template_applications($hostid, $templateid, $unlink_mode);
+ return true;
}
/*
@@ -1130,8 +1132,7 @@ require_once "include/items.inc.php";
function delete_template_applications($hostid, $templateid = null, $unlink_mode = false)
{
$db_apps = get_applications_by_hostid($hostid);
- while($db_app = DBfetch($db_apps))
- {
+ while($db_app = DBfetch($db_apps)){
if($db_app["templateid"] == 0)
continue;
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index 082dc0e2..b17190cc 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -246,8 +246,10 @@
'S_NEW'=> 'New',
'S_ADD_HOST'=> 'Add host',
'S_REMOVE_HOST'=> 'Remove host',
- 'S_LINK_TO_TEMPLATE'=> 'Link to template',
- 'S_UNLINK_FROM_TEMPLATE'=> 'Unlink from template',
+ 'S_LINK_TO_TEMPLATE'=> 'Link to template',
+ 'S_CANNOT_LINK_TO_TEMPLATE'=> 'CAnnot link to template',
+ 'S_UNLINK_FROM_TEMPLATE'=> 'Unlink from template',
+ 'S_CANNOT_UNLINK_FROM_TEMPLATE'=> 'Cannot unlink from template',
'S_INCORRECT_TRIGGER'=> 'Incorrect trigger',
'S_INCORRECT_HOST'=> 'Incorrect host',