diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-08-29 07:20:50 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-08-29 07:20:50 +0000 |
| commit | e051f8e9cbe4475ef1e18a888100054575268d63 (patch) | |
| tree | 51c2f8bf137bf340ee52b351d34291678320ab67 /frontends/php/include | |
| parent | c447c7bdc5033fd351706a16ceddda7f0c505c3e (diff) | |
| download | zabbix-e051f8e9cbe4475ef1e18a888100054575268d63.tar.gz zabbix-e051f8e9cbe4475ef1e18a888100054575268d63.tar.xz zabbix-e051f8e9cbe4475ef1e18a888100054575268d63.zip | |
- group functions for item manipulations (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@2005 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/forms.inc.php | 39 | ||||
| -rw-r--r-- | frontends/php/include/items.inc.php | 61 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 3 |
3 files changed, 100 insertions, 3 deletions
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index a4624beb..454de271 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -582,6 +582,45 @@ echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"update\">"; echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"delete\" onClick=\"return Confirm('Delete selected item?');\">"; } + + show_table2_v_delimiter($col++); + echo S_GROUP; + show_table2_h_delimiter(); + $h2=""; + $h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">"; + + $result=DBselect("select groupid,name from groups order by name"); + while($row=DBfetch($result)) + { +// Check if at least one host with read permission exists for this group + $result2=DBselect("select h.hostid,h.host from hosts h,hosts_groups hg where hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid and h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host"); + $cnt=0; + while($row2=DBfetch($result2)) + { + if(!check_right("Host","U",$row2["hostid"])) + { + continue; + } + $cnt=1; break; + } + if($cnt!=0) + { + $h2=$h2.form_select("groupid",$row["groupid"],$row["name"]); + } + } + $h2=$h2."</select>"; + echo $h2; + + show_table2_v_delimiter2(); + echo "<select class=\"biginput\" name=\"action\">"; + echo "<option value=\"add to group\">".S_ADD_TO_GROUP; + if(isset($_GET["itemid"])) + { + echo "<option value=\"update in group\">".S_UPDATE_IN_GROUP; + echo "<option value=\"delete from group\">".S_DELETE_FROM_GROUP; + } + echo "</select>"; + echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"do\">"; show_table2_header_end(); } diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index 796bb2b2..e44c66e1 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -19,6 +19,56 @@ **/ ?> <?php + # Update Item definition for selected group + + function update_item_in_group($groupid,$itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends) + { + $sql="select i.itemid,i.hostid from hosts_groups hg,items i where hg.groupid=$groupid and i.key_=\"$key\" and hg.hostid=i.hostid"; + $result=DBexecute($sql); + while($row=DBfetch($result)) + { + update_item($row["itemid"],$description,$key,$row["hostid"],$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends); + } + return 1; + } + + # Delete Item definition from selected group + + function delete_item_from_group($groupid,$itemid) + { + if(!isset($itemid)) + { + return 0; + } + + $item=get_item_by_itemid($itemid); + if(!$item) + { + return 0; + } + + $sql="select i.itemid from hosts_groups hg,items i where hg.groupid=$groupid and i.key_=\"".$item["key_"]."\" and hg.hostid=i.hostid"; + $result=DBexecute($sql); + while($row=DBfetch($result)) + { + delete_item($row["itemid"]); + } + return 1; + } + + # Add Item definition to selected group + + function add_item_to_group($groupid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends) + { + $sql="select hostid from hosts_groups where groupid=$groupid"; + $result=DBexecute($sql); + while($row=DBfetch($result)) + { + add_item($description,$key,$row["hostid"],$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends); + } + return 1; + } + # Add Item definition function add_item($description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends) @@ -29,11 +79,13 @@ return 0; } + $host=get_host_by_hostid($hostid); + $sql="select count(*) from items where hostid=$hostid and key_='$key'"; $result=DBexecute($sql); if(DBget_field($result,0,0)>0) { - error("An item with the same Key already exists for this host. The key must be unique."); + error("An item with the same Key already exists for host ".$host["host"].". The key must be unique."); return 0; } @@ -125,7 +177,8 @@ $result=DBexecute($sql); if($result) { - info("Item $key updated"); + $host=get_host_by_hostid($hostid); + info("Item ".$host["host"].":$key updated"); } return $result; } @@ -264,11 +317,13 @@ { return $result; } + $item=get_item_by_itemid($itemid); + $host=get_host_by_hostid($item["hostid"]); $sql="delete from items where itemid=$itemid"; $result=DBexecute($sql); if($result) { - info("Item $key deleted"); + info("Item ".$host["host"].":".$item["key_"]." deleted"); } return $result; } diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index ba2fc613..3c9294e4 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -332,6 +332,9 @@ "S_CANNOT_UPDATE_PROFILE"=> "Cannot update profile", "S_PROFILE_DELETED"=> "Profile deleted", "S_CANNOT_DELETE_PROFILE"=> "Cannot delete profile", + "S_ADD_TO_GROUP"=> "Add to group", + "S_DELETE_FROM_GROUP"=> "Delete from group", + "S_UPDATE_IN_GROUP"=> "Update in group", // items.php "S_CONFIGURATION_OF_ITEMS"=> "Configuration of items", |
