summaryrefslogtreecommitdiffstats
path: root/frontends/php/bulkloader.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-04-20 12:56:05 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-04-20 12:56:05 +0000
commitd08edb846d21c5bd865e20122b7c57944cc2435b (patch)
tree5bafd71b0fbcdb388e2e9d4f27a3bf7d7c3bb248 /frontends/php/bulkloader.php
parentdee1b601bd7eb4156d3458570f6200f865282437 (diff)
- fixed bulkloader (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2755 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/bulkloader.php')
-rw-r--r--frontends/php/bulkloader.php34
1 files changed, 15 insertions, 19 deletions
diff --git a/frontends/php/bulkloader.php b/frontends/php/bulkloader.php
index 411ab402..9ad52d78 100644
--- a/frontends/php/bulkloader.php
+++ b/frontends/php/bulkloader.php
@@ -86,8 +86,8 @@
}
// Determine which template, if any this host is linked to
- $sql="select distinct(hostid) from hosts where status<>". HOST_STATUS_DELETED ." and host=".zbx_dbstr($tmpHostTemplate);
- $sqlResult=DBselect($sql);
+ $sqlResult=DBselect("select distinct(hostid) from hosts where status=". HOST_STATUS_TEMPLATE .
+ " and host=".zbx_dbstr($tmpHostTemplate));
if(DBnum_rows($sqlResult)==1)
{
$row=DBfetch($sqlResult);
@@ -98,24 +98,20 @@
$hostTemplate=0;
}
+ // get groups
+ $groups = array();
+ foreach(explode(',',rtrim(rtrim($tmpHostGroups," "),"\n")) as $group_name)
+ {
+ add_host_group($group_name);
+ $groupid = DBfetch(DBselect("select groupid from groups where name=".zbx_dbstr($group_name)));
+ if(!$groupid) continue;
+ array_push($groups,$groupid["groupid"]);
+ }
+
// Now that we have all the values we need process them for this host
- $result=add_host($tmpHost,$hostPort,$hostStat,$hostUseIP,$tmpHostIP,$hostTemplate,'','');
+ $result=add_host($tmpHost,$hostPort,$hostStat,$hostUseIP,$tmpHostIP,$hostTemplate,'',$groups);
show_messages($result,'Host added: '. $tmpHost,'Cannot add host: '. $tmpHost);;
- // Here we update the hosts_groups manually. This will create new groups if needed
- // And add this host to any group listed.
- $row=DBfetch(DBselect("select distinct(hostid) from hosts where host='$tmpHost'"));
- $tmpHostID=$row["hostid"];
- if($tmpHostID)
- {
- foreach(explode(',',rtrim(rtrim($tmpHostGroups," "),"\n")) as $tmpGroup)
- {
- $tmpGroupID=create_Host_Group($tmpGroup);
- add_Host_To_Group($tmpGroupID,$tmpHostID);
- }
- add_template_linkage($tmpHostID,$hostTemplate,7,7,7,7,7);
- sync_host_with_template($tmpHostID,$hostTemplate,7,7,7,7,7);
- }
break;
case "USER":
list($tmpName,$tmpSurname,$tmpAlias,$tmpPasswd,$tmpURL,$tmpAutologout,$tmpLang,$tmpRefresh,$tmpUserGroups) = explode(",",$tmpField,9);
@@ -131,8 +127,8 @@
{
foreach(explode(',',rtrim(rtrim($tmpUserGroups," "),"\n")) as $tmpGroup)
{
- $tmpGroupID=create_User_Group($tmpGroup);
- add_User_To_Group($tmpGroupID,$tmpUserID);
+ $tmpGroupID=add_user_group($tmpGroup);
+ update_user_groups($tmpGroupID,array($tmpUserID));
}
}
break;