diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-04-14 13:26:42 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-04-14 13:26:42 +0000 |
| commit | 5348f67b28ed1da2539db6de7a11c605a5dc3a57 (patch) | |
| tree | 4646832d5a7263dbe6818409d9ce9e9dff419008 /frontends/php/include/items.inc.php | |
| parent | c44eed92d3f3bcfc0efad6e18e31323f089a9ce6 (diff) | |
| download | zabbix-5348f67b28ed1da2539db6de7a11c605a5dc3a57.tar.gz zabbix-5348f67b28ed1da2539db6de7a11c605a5dc3a57.tar.xz zabbix-5348f67b28ed1da2539db6de7a11c605a5dc3a57.zip | |
- [DEV-142] added transactions to DB actions (beta) (Artem)
- [DEV-137] improvements in permission checks (Artem)
- [DEV-137] changes in schema (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5619 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/items.inc.php')
| -rw-r--r-- | frontends/php/include/items.inc.php | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index 45233964..4dd3197d 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -142,29 +142,26 @@ } # Delete Item definition from selected group - - function delete_item_from_group($groupid,$itemid) - { - if(!isset($itemid)) - { + function delete_item_from_group($groupid,$itemid){ + if(!isset($itemid)){ return 0; } $item=get_item_by_itemid($itemid); - if(!$item) - { + if(!$item){ return 0; } - $sql="select i.itemid from hosts_groups hg,items i". - " where hg.groupid=$groupid and i.key_=".zbx_dbstr($item["key_"]). - " and hg.hostid=i.hostid"; + $sql='SELECT i.itemid '. + ' FROM hosts_groups hg,items i'. + ' WHERE hg.groupid='.$groupid. + ' AND i.key_='.zbx_dbstr($item["key_"]). + ' AND hg.hostid=i.hostid'; $result=DBexecute($sql); - while($row=DBfetch($result)) - { + while($row=DBfetch($result)){ delete_item($row["itemid"]); } - return 1; + return 1; } # Add Item definition to selected group @@ -776,15 +773,13 @@ * Comments: !!! Don't forget sync code with C !!! * * * ******************************************************************************/ - function delete_item($itemid) - { + function delete_item($itemid){ $item = get_item_by_itemid($itemid); $host = get_host_by_itemid($itemid); // first delete child items $db_items = DBselect("select itemid from items where templateid=$itemid"); - while($db_item = DBfetch($db_items)) - {// recursion + while($db_item = DBfetch($db_items)){// recursion $result = delete_item($db_item["itemid"]); if(!$result) return $result; } @@ -802,24 +797,21 @@ $result = delete_history_by_itemid($itemid, 1 /* use housekeeper */); if(!$result) return $result; - DBexecute('delete from screens_items where resourceid='.$itemid.' and resourcetype in ('. + $result &= DBexecute('delete from screens_items where resourceid='.$itemid.' and resourcetype in ('. (implode(',',array( SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT) ) ).')'); - $result = DBexecute("delete from items_applications where itemid=$itemid"); - if(!$result) return $result; - - $result = DBexecute("delete from items where itemid=$itemid"); - if(!$result) return $result; + $result &= DBexecute('delete from items_applications where itemid='.$itemid); + $result &= DBexecute('delete from items where itemid='.$itemid); + $result &= DBexecute('DELETE FROM profiles WHERE idx="web.favorite.graphids" AND resource="itemid" AND value='.$itemid); - $result = rm4favorites('web.favorite.graphids',$itemid,ZBX_FAVORITES_ALL,'itemid'); if($result){ info("Item '".$host["host"].":".$item["key_"]."' deleted"); } - return $result; + return $result; } /* @@ -889,7 +881,7 @@ function get_items_data_overview($groupid,$view_style=null) { global $USER_DETAILS; - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, null, null, get_current_nodeid()); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); if(is_null($view_style)) $view_style = get_profile('web.overview.view.style',STYLE_TOP); |
