summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/items.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/php/include/items.inc.php')
-rw-r--r--frontends/php/include/items.inc.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php
index d0d0dd96..e2c4365b 100644
--- a/frontends/php/include/items.inc.php
+++ b/frontends/php/include/items.inc.php
@@ -724,6 +724,52 @@
error("No item with itemid=[$itemid]");
return FALSE;
}
+
+/*
+ * Function: get_same_items_for_host
+ *
+ * Description:
+ * Replace items for specified host
+ *
+ * Author:
+ * Aly
+ *
+ * Comments:
+ * $error= true : rise Error if item doesn't exists(error generated), false: special processing (NO error generated)
+ */
+ function get_same_item_for_host($item,$dest_hostid, $error=true){
+
+ if(!is_array($item)){
+ $itemid = $item;
+ }
+ else if(isset($item['itemid'])){
+ $itemid = $item['itemid'];
+ }
+
+ if(isset($itemid)){
+ $sql = 'SELECT src.itemid '.
+ ' FROM items src, items dest '.
+ ' WHERE dest.itemid='.zbx_dbstr($itemid).
+ ' AND src.key_=dest.key_ '.
+ ' AND src.hostid='.$dest_hostid;
+
+ $db_item = DBfetch(DBselect($sql));
+ if (!$db_item && $error){
+ $item = get_item_by_itemid($db_item['itemid']);
+ $host = get_host_by_hostid($dest_hostid);
+ error('Missed key "'.$item['key_'].'" for host "'.$host['host'].'"');
+ }
+ else{
+ if(is_array($item)){
+ return get_item_by_itemid($db_item['itemid']);
+ }
+ else{
+ return $db_item['itemid'];
+ }
+ }
+ }
+ return false;
+ }
/******************************************************************************
* *