diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-06-16 10:42:29 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-06-16 10:42:29 +0000 |
| commit | 400140ceb21e1f141ebfd62afa145cbc4ee2901d (patch) | |
| tree | 28b3a1dd8f334272dc25dcbe7aa3912915d817ae /frontends/php | |
| parent | 5603bd407a6fc337ca523ac7f372588f3c645162 (diff) | |
- [DEV-181] temp expression on triggers copy changed from {???:???} to 0 (Artem)
- [DEV-137] improvements in user operation result determination in hosts,triggers,items screens (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5769 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/hosts.php | 125 | ||||
| -rw-r--r-- | frontends/php/include/db.inc.php | 16 | ||||
| -rw-r--r-- | frontends/php/include/triggers.inc.php | 6 | ||||
| -rw-r--r-- | frontends/php/items.php | 111 | ||||
| -rw-r--r-- | frontends/php/triggers.php | 48 |
5 files changed, 165 insertions, 141 deletions
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php index c1906b3c..730ce160 100644 --- a/frontends/php/hosts.php +++ b/frontends/php/hosts.php @@ -138,7 +138,7 @@ include_once 'include/page_header.php'; $hosts = get_request('hosts',array()); if(isset($_REQUEST['hostid'])){ $templateid=$_REQUEST['hostid']; - $result = false; + $result = true; // Permission check $hosts = array_intersect($hosts,$available_hosts); @@ -154,7 +154,7 @@ include_once 'include/page_header.php'; $unlink_hosts = array_diff($linked_hosts,$hosts); foreach($unlink_hosts as $id => $value){ - unlink_template($value, $templateid, false); + $result &= unlink_template($value, $templateid, false); } //---------- //-- link -- @@ -173,13 +173,13 @@ include_once 'include/page_header.php'; $templates_tmp=get_templates_by_hostid($hostid); $templates_tmp[$templateid]=$template_name['host']; - $result=update_host($hostid, + $result &= update_host($hostid, $host['host'],$host['port'],$host['status'],$host['useip'],$host['dns'], $host['ip'],$host['proxy_hostid'],$templates_tmp,null,$host_groups); } //---------- - $result = DBend(); + $result = DBend($result); show_messages($result, S_LINK_TO_TEMPLATE, S_CANNOT_LINK_TO_TEMPLATE); if($result){ @@ -236,8 +236,9 @@ include_once 'include/page_header.php'; access_deny(); } - DBstart(); - + $result = true; + + DBstart(); foreach($hosts as $id => $hostid){ $db_host = get_host_by_hostid($hostid); @@ -258,7 +259,7 @@ include_once 'include/page_header.php'; if(isset($visible['template_table'])){ foreach($db_templates as $templateid => $name){ - unlink_template($hostid, $templateid, false); + $result &= unlink_template($hostid, $templateid, false); } $db_host['templates'] = $_REQUEST['templates']; } @@ -266,12 +267,12 @@ include_once 'include/page_header.php'; $db_host['templates'] = $db_templates; } - $update = update_host($hostid, + $result = update_host($hostid, $db_host['host'],$db_host['port'],$db_host['status'],$db_host['useip'],$db_host['dns'], $db_host['ip'],$db_host['proxy_hostid'],$db_host['templates'],$_REQUEST['newgroup'],$db_host['groups']); - if($update && isset($visible['useprofile'])){ + if($result && isset($visible['useprofile'])){ $host_profile=DBfetch(DBselect('SELECT * FROM hosts_profiles WHERE hostid='.$hostid)); @@ -284,7 +285,7 @@ include_once 'include/page_header.php'; } } - add_host_profile($hostid, + $result &= add_host_profile($hostid, $host_profile['devicetype'],$host_profile['name'],$host_profile['os'], $host_profile['serialno'],$host_profile['tag'],$host_profile['macaddress'], $host_profile['hardware'],$host_profile['software'],$host_profile['contact'], @@ -293,7 +294,7 @@ include_once 'include/page_header.php'; } } - $result = DBend(); + $result = DBend($result); $msg_ok = S_HOSTS.SPACE.S_UPDATED; $msg_fail = S_CANNOT_UPDATE.SPACE.S_HOSTS; @@ -333,18 +334,20 @@ include_once 'include/page_header.php'; $_REQUEST['proxy_hostid'] = get_request('proxy_hostid',0); if(isset($_REQUEST['hostid'])){ + $result = true; + DBstart(); - if(isset($_REQUEST['clear_templates'])) { foreach($_REQUEST['clear_templates'] as $id){ - unlink_template($_REQUEST['hostid'], $id, false); + $result &= unlink_template($_REQUEST['hostid'], $id, false); } } - update_host($_REQUEST['hostid'], + $result = update_host($_REQUEST['hostid'], $_REQUEST['host'],$_REQUEST['port'],$_REQUEST['status'],$useip,$_REQUEST['dns'], $_REQUEST['ip'],$_REQUEST['proxy_hostid'],$templates,$_REQUEST['newgroup'],$groups); - $result = DBend(); + + $result = DBend($result); $msg_ok = S_HOST_UPDATED; $msg_fail = S_CANNOT_UPDATE_HOST; @@ -357,7 +360,8 @@ include_once 'include/page_header.php'; $hostid = add_host( $_REQUEST['host'],$_REQUEST['port'],$_REQUEST['status'],$useip,$_REQUEST['dns'], $_REQUEST['ip'],$_REQUEST['proxy_hostid'],$templates,$_REQUEST['newgroup'],$groups); - $result = DBend()?$hostid:false; + + $result = DBend($hostid); $msg_ok = S_HOST_ADDED; $msg_fail = S_CANNOT_ADD_HOST; @@ -377,7 +381,7 @@ include_once 'include/page_header.php'; $_REQUEST['hardware'],$_REQUEST['software'],$_REQUEST['contact'], $_REQUEST['location'],$_REQUEST['notes']); } - $result = DBend(); + $result = DBend($result); } show_messages($result, $msg_ok, $msg_fail); @@ -403,8 +407,8 @@ include_once 'include/page_header.php'; $host=get_host_by_hostid($_REQUEST["hostid"]); DBstart(); - delete_host($_REQUEST["hostid"], $unlink_mode); - $result=DBend(); + $result = delete_host($_REQUEST["hostid"], $unlink_mode); + $result=DBend($result); show_messages($result, S_HOST_DELETED, S_CANNOT_DELETE_HOST); if($result){ @@ -417,7 +421,7 @@ include_once 'include/page_header.php'; } else { /* group operations */ - $result = 0; + $result = true; $hosts = get_request("hosts",array()); DBstart(); @@ -426,12 +430,12 @@ include_once 'include/page_header.php'; $host=get_host_by_hostid($db_host["hostid"]); if(!uint_in_array($db_host["hostid"],$hosts)) continue; - $result=delete_host($db_host["hostid"], $unlink_mode); + $result &= delete_host($db_host["hostid"], $unlink_mode); if($result) add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST,"Host [".$host["host"]."]"); } - $result = DBend(); + $result = DBend($result); show_messages($result, S_HOST_DELETED, S_CANNOT_DELETE_HOST); } unset($_REQUEST["delete"]); @@ -445,8 +449,8 @@ include_once 'include/page_header.php'; } DBstart(); - add_host_to_group($_REQUEST['hostid'], $_REQUEST['add_to_group']); - $result = DBend(); + $result = add_host_to_group($_REQUEST['hostid'], $_REQUEST['add_to_group']); + $result = DBend($result); show_messages($result,S_HOST_UPDATED,S_CANNOT_UPDATE_HOST); } @@ -458,14 +462,14 @@ include_once 'include/page_header.php'; } DBstart(); - delete_host_from_group($_REQUEST['hostid'], $_REQUEST['delete_from_group']); - $result = DBend(); + $result = delete_host_from_group($_REQUEST['hostid'], $_REQUEST['delete_from_group']); + $result = DBend($result); show_messages($result, S_HOST_UPDATED, S_CANNOT_UPDATE_HOST); } else if(($_REQUEST["config"]==0 || $_REQUEST["config"]==3) && (isset($_REQUEST["activate"])||isset($_REQUEST["disable"]))){ - $result = 0; + $result = true; $status = isset($_REQUEST["activate"]) ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED; $hosts = get_request("hosts",array()); @@ -475,13 +479,13 @@ include_once 'include/page_header.php'; if(!uint_in_array($db_host["hostid"],$hosts)) continue; $host=get_host_by_hostid($db_host["hostid"]); - $res=update_host_status($db_host["hostid"],$status); + $result &= update_host_status($db_host["hostid"],$status); - if($res){ + if($result){ add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST,"Old status [".$host["status"]."] "."New status [".$status."]"); } } - $result = DBend(); + $result = DBend($result); show_messages($result, S_HOST_STATUS_UPDATED, S_CANNOT_UPDATE_HOST); unset($_REQUEST["activate"]); @@ -491,7 +495,9 @@ include_once 'include/page_header.php'; $host=get_host_by_hostid($_REQUEST["hostid"]); - update_host_status($_REQUEST["hostid"],$_REQUEST["chstatus"]); + DBstart(); + $result = update_host_status($_REQUEST["hostid"],$_REQUEST["chstatus"]); + $result = DBend($result); show_messages($result,S_HOST_STATUS_UPDATED,S_CANNOT_UPDATE_HOST_STATUS); if($result){ @@ -511,8 +517,8 @@ include_once 'include/page_header.php'; $hosts = get_request("hosts",array()); if(isset($_REQUEST["groupid"])){ DBstart(); - $result = update_host_group($_REQUEST["groupid"], $_REQUEST["gname"], $hosts); - $result = DBend(); + $result = update_host_group($_REQUEST["groupid"], $_REQUEST["gname"], $hosts); + $result = DBend($result); $action = AUDIT_ACTION_UPDATE; $msg_ok = S_GROUP_UPDATED; @@ -524,8 +530,8 @@ include_once 'include/page_header.php'; access_deny(); DBstart(); - $groupid = add_host_group($_REQUEST["gname"], $hosts); - $result = DBend(); + $groupid = add_host_group($_REQUEST["gname"], $hosts); + $result = DBend($groupid); $action = AUDIT_ACTION_ADD; $msg_ok = S_GROUP_ADDED; @@ -544,7 +550,7 @@ include_once 'include/page_header.php'; if($group = get_hostgroup_by_groupid($_REQUEST["groupid"])){ DBstart(); $result = delete_host_group($_REQUEST["groupid"]); - $result = DBend(); + $result = DBend($result); } if($result){ @@ -558,31 +564,31 @@ include_once 'include/page_header.php'; } else { /* group operations */ - $groups = get_request("groups",array()); + $result = true; + $groups = get_request("groups",array()); $db_groups=DBselect('select groupid, name from groups where '.DBin_node('groupid')); DBstart(); while($db_group=DBfetch($db_groups)){ if(!uint_in_array($db_group["groupid"],$groups)) continue; - if(!($group = get_hostgroup_by_groupid($db_group["groupid"]))) continue; - $result = delete_host_group($db_group["groupid"]); + if(!$group = get_hostgroup_by_groupid($db_group["groupid"])) continue; + $result &= delete_host_group($db_group["groupid"]); if($result){ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST_GROUP, S_HOST_GROUP." [".$group["name"]." ] [".$group['groupid']."]"); } } - $result = DBend(); - + $result = DBend($result); show_messages(true, S_GROUP_DELETED, S_CANNOT_DELETE_GROUP); } unset($_REQUEST["delete"]); } if($_REQUEST["config"]==1&&(isset($_REQUEST["activate"])||isset($_REQUEST["disable"]))){ - $result = 0; + $result = true; $status = isset($_REQUEST["activate"]) ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED; $groups = get_request("groups",array()); @@ -591,19 +597,19 @@ include_once 'include/page_header.php'; ' where h.hostid=hg.hostid '. ' and h.status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.')'. ' and '.DBin_node('h.hostid')); + DBstart(); while($db_host=DBfetch($db_hosts)){ if(!uint_in_array($db_host["groupid"],$groups)) continue; $host=get_host_by_hostid($db_host["hostid"]); - if(!update_host_status($db_host["hostid"],$status)) continue; - $result = 1; + $result &= update_host_status($db_host["hostid"],$status); add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST, "Old status [".$host["status"]."] "."New status [".$status."]"); } - $result = DBend(); - + $result = DBend($result); show_messages($result, S_HOST_STATUS_UPDATED, S_CANNOT_UPDATE_HOST); + unset($_REQUEST["activate"]); } @@ -622,7 +628,7 @@ include_once 'include/page_header.php'; $msg_ok = S_APPLICATION_ADDED; $msg_fail = S_CANNOT_ADD_APPLICATION; } - $result = DBend(); + $result = DBend($applicationid); show_messages($result, $msg_ok, $msg_fail); if($result){ @@ -639,7 +645,7 @@ include_once 'include/page_header.php'; DBstart(); $result=delete_application($_REQUEST["applicationid"]); - $result = DBend(); + $result = DBend($result); } show_messages($result, S_APPLICATION_DELETED, S_CANNOT_DELETE_APPLICATION); @@ -651,8 +657,9 @@ include_once 'include/page_header.php'; } else { /* group operations */ + $result = true; + $applications = get_request("applications",array()); - $db_applications = DBselect("select applicationid, name, hostid from applications ". 'where '.DBin_node('applicationid')); @@ -660,14 +667,14 @@ include_once 'include/page_header.php'; while($db_app = DBfetch($db_applications)){ if(!uint_in_array($db_app["applicationid"],$applications)) continue; - $result = delete_application($db_app["applicationid"]); + $result &= delete_application($db_app["applicationid"]); if($result){ $host = get_host_by_hostid($db_app["hostid"]); add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_APPLICATION,"Application [".$db_app["name"]."] from host [".$host["host"]."]"); } } - $result = DBend(); + $result = DBend($result); show_messages(true, S_APPLICATION_DELETED, NULL); } @@ -705,15 +712,16 @@ include_once 'include/page_header.php'; } } } - $result = DBend(); + $result = DBend($result); (isset($_REQUEST["activate"]))?show_messages($result, S_ITEMS_ACTIVATED, null):show_messages($result, S_ITEMS_DISABLED, null); } else if($_REQUEST["config"]==5 && isset($_REQUEST["save"])){ + $result = true; $hosts = get_request("hosts",array()); DBstart(); if(isset($_REQUEST["hostid"])){ - $result = update_proxy($_REQUEST["hostid"], $_REQUEST["host"], $hosts); + $result &= update_proxy($_REQUEST["hostid"], $_REQUEST["host"], $hosts); $action = AUDIT_ACTION_UPDATE; $msg_ok = S_PROXY_UPDATED; $msg_fail = S_CANNOT_UPDATE_PROXY; @@ -723,12 +731,12 @@ include_once 'include/page_header.php'; if(!count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY,get_current_nodeid()))) access_deny(); - $hostid = add_proxy($_REQUEST["host"], $hosts); + $hostid &= add_proxy($_REQUEST["host"], $hosts); $action = AUDIT_ACTION_ADD; $msg_ok = S_PROXY_ADDED; $msg_fail = S_CANNOT_ADD_PROXY; } - $result = DBend(); + $result = DBend($result); show_messages($result, $msg_ok, $msg_fail); if($result){ @@ -778,7 +786,7 @@ include_once 'include/page_header.php'; $_REQUEST["form"] = "clone"; } else if($_REQUEST["config"]==5 && (isset($_REQUEST["activate"]) || isset($_REQUEST["disable"]))){ - $result = false; + $result = true; $status = isset($_REQUEST["activate"]) ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED; $hosts = get_request("hosts",array()); @@ -794,14 +802,13 @@ include_once 'include/page_header.php'; $old_status = $db_host["status"]; if($old_status == $status) continue; - $result = update_host_status($db_host["hostid"], $status); + $result &= update_host_status($db_host["hostid"], $status); if(!$result) continue; add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST,"Old status [".$old_status."] "."New status [".$status."] [".$db_host["hostid"]."]"); } } - $result = DBend(); - + $result = DBend($result && !empty($hosts)); show_messages($result, S_HOST_STATUS_UPDATED, NULL); if(isset($_REQUEST["activate"])) diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 69621042..49f52478 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -268,19 +268,25 @@ if(!isset($DB)){ $DB['TRANSACTIONS'] = 0; - if(empty($result)) - $result = $DB['TRANSACTION_STATE']; + if(is_null($result)){ + $DBresult = $DB['TRANSACTION_STATE']; + } + else{ + $DBresult = $result && $DB['TRANSACTION_STATE']; + } //SDI('Result: '.$result); - if($result){ // OK - $result = DBcommit(); + if($DBresult){ // OK + $DBresult = DBcommit(); } - if(!$result){ // FAIL + if(!$DBresult){ // FAIL DBrollback(); } + $result = (!is_null($result) && $DBresult)?$result:$DBresult; + return $result; } diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index 88d2d07d..3936f408 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -808,9 +808,9 @@ * Comments: !!! Don't forget sync code with C !!! * * * ******************************************************************************/ - function replace_template_dependencies($deps, $hostid){ + function replace_template_dependencies($deps, $hostid){ foreach($deps as $id => $val){ - if($db_new_dep = DBfetch(DBselect('SEELCT t.triggerid '. + if($db_new_dep = DBfetch(DBselect('SELECT t.triggerid '. ' FROM triggers t,functions f,items i '. ' WHERE t.templateid='.$val. ' AND f.triggerid=t.triggerid '. @@ -871,7 +871,7 @@ ' (triggerid,description,type,priority,status,comments,url,value,expression,templateid)'. ' VALUES ('.$newtriggerid.','.zbx_dbstr($trigger['description']).','.$trigger['type'].','.$trigger['priority'].','. $trigger["status"].','.zbx_dbstr($trigger["comments"]).','. - zbx_dbstr($trigger["url"]).",2,'{???:???}',".($copy_mode ? 0 : $triggerid).')'); + zbx_dbstr($trigger["url"]).",2,'0',".($copy_mode ? 0 : $triggerid).')'); if(!$result) return $result; diff --git a/frontends/php/items.php b/frontends/php/items.php index 117f77b1..aa1992d7 100644 --- a/frontends/php/items.php +++ b/frontends/php/items.php @@ -319,8 +319,8 @@ include_once "include/page_header.php"; $result = false; if($item = get_item_by_itemid($_REQUEST['itemid'])){ DBstart(); - delete_item($_REQUEST['itemid']); - $result = DBend(); + $result = delete_item($_REQUEST['itemid']); + $result = DBend($result); } show_messages($result, S_ITEM_DELETED, S_CANNOT_DELETE_ITEM); if($result){ @@ -344,17 +344,17 @@ include_once "include/page_header.php"; if(isset($_REQUEST["itemid"])){ DBstart(); - smart_update_item($_REQUEST["itemid"], - $_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"], - $_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"], - $_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"], - $_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"], - $_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"], - $_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"], - $_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"], - $_REQUEST["logtimefmt"],$_REQUEST["valuemapid"],$db_delay_flex,$_REQUEST["params"], - $applications); - $result = DBend(); + $result = smart_update_item($_REQUEST["itemid"], + $_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"], + $_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"], + $_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"], + $_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"], + $_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"], + $_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"], + $_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"], + $_REQUEST["logtimefmt"],$_REQUEST["valuemapid"],$db_delay_flex,$_REQUEST["params"], + $applications); + $result = DBend($result); $itemid = $_REQUEST["itemid"]; $action = AUDIT_ACTION_UPDATE; @@ -374,7 +374,7 @@ include_once "include/page_header.php"; $_REQUEST["logtimefmt"],$_REQUEST["valuemapid"],$db_delay_flex,$_REQUEST["params"], $applications); - $result = DBend(); + $result = DBend($itemid); $action = AUDIT_ACTION_ADD; show_messages($result, S_ITEM_ADDED, S_CANNOT_ADD_ITEM); @@ -392,8 +392,8 @@ include_once "include/page_header.php"; $result = false; if($item = get_item_by_itemid($_REQUEST["itemid"])){ DBstart(); - delete_history_by_itemid($_REQUEST["itemid"]); - $result = DBend(); + $result = delete_history_by_itemid($_REQUEST["itemid"]); + $result = DBend($result); } if($result){ @@ -419,11 +419,13 @@ include_once "include/page_header.php"; if(!is_null(get_request("formula",null))) $_REQUEST['multiplier']=1; if("0" === get_request("formula",null)) $_REQUEST['multiplier']=0; + + $group_itemid = $_REQUEST["group_itemid"]; + $result = true; DBstart(); - $group_itemid = $_REQUEST["group_itemid"]; foreach($group_itemid as $id){ - smart_update_item($id, + $result &= smart_update_item($id, null,null,null,get_request("delay"), get_request("history"),get_request("status"),get_request("type"), get_request("snmp_community"),get_request("snmp_oid"),get_request("value_type"), @@ -433,7 +435,7 @@ include_once "include/page_header.php"; get_request("snmpv3_privpassphrase"),get_request("formula"),get_request("trends"), get_request("logtimefmt"),get_request("valuemapid"),$db_delay_flex,null,$applications); } - $result = DBend(); + $result = DBend($result && !empty($group_itemid)); show_messages($result, S_ITEMS_UPDATED); unset($_REQUEST["group_itemid"], $_REQUEST["form_mass_update"], $_REQUEST["update"]); @@ -460,10 +462,13 @@ include_once "include/page_header.php"; } } + $result = true; + DBstart(); foreach($_REQUEST["group_itemid"] as $item_id) foreach($hosts_ids as $host_id){ - copy_item_to_host($item_id, $host_id, true); + $result &= copy_item_to_host($item_id, $host_id, true); } + $result = DBend($result); unset($_REQUEST["form_copy_to"]); } else{ @@ -498,7 +503,7 @@ include_once "include/page_header.php"; $_REQUEST["trends"],$_REQUEST["logtimefmt"],$_REQUEST["valuemapid"], $db_delay_flex, $_REQUEST["params"], $applications); - $result = DBend(); + $result = DBend($itemid); show_messages($result, S_ITEM_ADDED, S_CANNOT_ADD_ITEM); if($result){ unset($_REQUEST["form"]); @@ -519,18 +524,18 @@ include_once "include/page_header.php"; $db_delay_flex = trim($db_delay_flex,';'); DBstart(); - update_item_in_group($_REQUEST["add_groupid"], - $_REQUEST["itemid"],$_REQUEST["description"],$_REQUEST["key"], - $_REQUEST["hostid"],$_REQUEST["delay"],$_REQUEST["history"], - $_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"], - $_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"], - $_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"], - $_REQUEST["delta"],$_REQUEST["snmpv3_securityname"], - $_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"], - $_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"], - $_REQUEST["trends"],$_REQUEST["logtimefmt"],$_REQUEST["valuemapid"], - $db_delay_flex, $_REQUEST["params"], $applications); - $result = DBend(); + $result = update_item_in_group($_REQUEST["add_groupid"], + $_REQUEST["itemid"],$_REQUEST["description"],$_REQUEST["key"], + $_REQUEST["hostid"],$_REQUEST["delay"],$_REQUEST["history"], + $_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"], + $_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"], + $_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"], + $_REQUEST["delta"],$_REQUEST["snmpv3_securityname"], + $_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"], + $_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"], + $_REQUEST["trends"],$_REQUEST["logtimefmt"],$_REQUEST["valuemapid"], + $db_delay_flex, $_REQUEST["params"], $applications); + $result = DBend($result); show_messages($result, S_ITEM_UPDATED, S_CANNOT_UPDATE_ITEM); if($result){ @@ -541,8 +546,8 @@ include_once "include/page_header.php"; if($_REQUEST["action"]=="delete from group"){ DBstart(); - delete_item_from_group($_REQUEST["add_groupid"],$_REQUEST["itemid"]); - $result = DBend(); + $result = delete_item_from_group($_REQUEST["add_groupid"],$_REQUEST["itemid"]); + $result = DBend($result); show_messages($result, S_ITEM_DELETED, S_CANNOT_DELETE_ITEM); if($result){ @@ -554,28 +559,30 @@ include_once "include/page_header.php"; } else if(isset($_REQUEST["group_task"])&&isset($_REQUEST["group_itemid"])){ if($_REQUEST["group_task"]==S_DELETE_SELECTED){ - $result = false; - + $result = true; $group_itemid = $_REQUEST["group_itemid"]; + + DBstart(); foreach($group_itemid as $id){ - if(!($item = get_item_by_itemid($id))) continue; + if(!$item = get_item_by_itemid($id)) continue; if($item["templateid"]<>0) continue; - DBstart(); - delete_item($id); - $result = DBend(); + $result &= delete_item($id); if($result){ $host = get_host_by_hostid($item["hostid"]); add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_ITEM,S_ITEM." [".$item["key_"]."] [".$id."] ".S_HOST." [".$host['host']."]"); } } + + $result = DBend($result && !empty($group_itemid)); show_messages($result, S_ITEMS_DELETED, null); } else if($_REQUEST["group_task"]==S_ACTIVATE_SELECTED){ $result = false; - $group_itemid = $_REQUEST["group_itemid"]; + + DBstart(); foreach($group_itemid as $id){ if(!$item = get_item_by_itemid($id)) continue; @@ -589,8 +596,9 @@ include_once "include/page_header.php"; } else if($_REQUEST["group_task"]==S_DISABLE_SELECTED){ $result = false; - $group_itemid = $_REQUEST["group_itemid"]; + + DBstart(); foreach($group_itemid as $id){ if(!($item = get_item_by_itemid($id))) continue; @@ -601,27 +609,28 @@ include_once "include/page_header.php"; add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ITEM, S_ITEM." [".$item["key_"]."] [".$id."] ".S_HOST." [".$host['host']."] ".S_ITEMS_DISABLED); } } + $result = DBend($result && !empty($group_itemid)); show_messages($result, S_ITEMS_DISABLED, null); } else if($_REQUEST["group_task"]==S_CLEAN_HISTORY_SELECTED_ITEMS){ - $result = false; - + $result = true; $group_itemid = $_REQUEST["group_itemid"]; + + DBstart(); foreach($group_itemid as $id){ - if(!($item = get_item_by_itemid($id))) continue; + if(!$item = get_item_by_itemid($id)) continue; - DBstart(); - delete_history_by_itemid($id); - $result = DBend(); + + $result &= delete_history_by_itemid($id); if($result){ - DBexecute("update items set nextcheck=0,lastvalue=null,". - "lastclock=null,prevvalue=null where itemid=$id"); + DBexecute("update items set nextcheck=0,lastvalue=null,lastclock=null,prevvalue=null where itemid=$id"); $host = get_host_by_hostid($item["hostid"]); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ITEM, S_ITEM." [".$item["key_"]."] [".$id."] ".S_HOST." [".$host['host']."] ".S_HISTORY_CLEANED); } } + $result = DBend($result && !empty($group_itemid)); show_messages($result, S_HISTORY_CLEANED, $result); } } diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php index 57b51e32..f73521c5 100644 --- a/frontends/php/triggers.php +++ b/frontends/php/triggers.php @@ -129,7 +129,7 @@ include_once "include/page_header.php"; $_REQUEST['expression'],$_REQUEST['description'],$type, $_REQUEST['priority'],$status,$_REQUEST['comments'],$_REQUEST['url'], $deps, $trigger_data['templateid']); - $result = DBend(); + $result = DBend($result); $triggerid = $_REQUEST['triggerid']; $audit_action = AUDIT_ACTION_UPDATE; @@ -141,7 +141,7 @@ include_once "include/page_header.php"; $triggerid=add_trigger($_REQUEST['expression'],$_REQUEST['description'],$type, $_REQUEST['priority'],$status,$_REQUEST['comments'],$_REQUEST['url'], $deps); - $result = DBend(); + $result = DBend($triggerid); $audit_action = AUDIT_ACTION_ADD; show_messages($result, S_TRIGGER_ADDED, S_CANNOT_ADD_TRIGGER); @@ -167,7 +167,7 @@ include_once "include/page_header.php"; { DBstart(); $result = delete_trigger($_REQUEST['triggerid']); - $result = DBend(); + $result = DBend($result); } show_messages($result, S_TRIGGER_DELETED, S_CANNOT_DELETE_TRIGGER); @@ -201,12 +201,13 @@ include_once "include/page_header.php"; array_push($hosts_ids, $db_host['hostid']); } } + $result = true; DBstart(); foreach($_REQUEST['g_triggerid'] as $trigger_id) foreach($hosts_ids as $host_id){ - copy_trigger_to_host($trigger_id, $host_id, true); + $result &= copy_trigger_to_host($trigger_id, $host_id, true); } - $result = DBend(); + $result = DBend($result); unset($_REQUEST['form_copy_to']); } else{ @@ -232,15 +233,16 @@ include_once "include/page_header.php"; } /* GROUP ACTIONS */ else if(isset($_REQUEST["group_enable"])&&isset($_REQUEST["g_triggerid"])){ - + $result = true; + DBstart(); foreach($_REQUEST["g_triggerid"] as $triggerid){ if(!check_right_on_trigger_by_triggerid(null, $triggerid)) continue; - $result=DBselect('SELECT triggerid FROM triggers t WHERE t.triggerid='.zbx_dbstr($triggerid)); - if(!$row = DBfetch($result)) continue; + $res = DBselect('SELECT triggerid FROM triggers t WHERE t.triggerid='.zbx_dbstr($triggerid)); + if(!$row = DBfetch($res)) continue; - if($result = update_trigger_status($row['triggerid'],0)){ + if($result &= update_trigger_status($row['triggerid'],0)){ $serv_status = get_service_status_of_trigger($row['triggerid']); update_services($triggerid, $serv_status); // updating status to all services by the dependency @@ -249,51 +251,51 @@ include_once "include/page_header.php"; S_TRIGGER." [".$triggerid."] [".expand_trigger_description($triggerid)."] ".S_ENABLED); } } - - $result = DBend(); + $result = DBend($result && !empty($_REQUEST["g_triggerid"])); show_messages($result, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS); } else if(isset($_REQUEST["group_disable"])&&isset($_REQUEST["g_triggerid"])){ + $result = true; + DBstart(); foreach($_REQUEST["g_triggerid"] as $triggerid){ if(!check_right_on_trigger_by_triggerid(null, $triggerid)) continue; - $result=DBselect("SELECT triggerid FROM triggers t WHERE t.triggerid=".zbx_dbstr($triggerid)); - if(!($row = DBfetch($result))) continue; - if($result = update_trigger_status($row["triggerid"],1));{ + $res=DBselect("SELECT triggerid FROM triggers t WHERE t.triggerid=".zbx_dbstr($triggerid)); + if(!$row = DBfetch($res)) continue; + if($result &= update_trigger_status($row["triggerid"],1));{ update_services($triggerid, 0); // updating status to all services by the dependency add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER, S_TRIGGER." [".$triggerid."] [".expand_trigger_description($triggerid)."] ".S_DISABLED); } } - - $result = DBend(); + $result = DBend($result && !empty($_REQUEST["g_triggerid"])); show_messages($result, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS); + } else if(isset($_REQUEST["group_delete"])&&isset($_REQUEST["g_triggerid"])){ - + $result = true; + DBstart(); foreach($_REQUEST["g_triggerid"] as $triggerid){ if(!check_right_on_trigger_by_triggerid(null, $triggerid)) continue; - $result=DBselect("SELECT triggerid,templateid FROM triggers t WHERE t.triggerid=".zbx_dbstr($triggerid)); - if(!($row = DBfetch($result))) continue; + $res=DBselect("SELECT triggerid,templateid FROM triggers t WHERE t.triggerid=".zbx_dbstr($triggerid)); + if(!$row = DBfetch($result)) continue; if($row["templateid"] <> 0) continue; $description = expand_trigger_description($triggerid); - - $result = delete_trigger($row["triggerid"]); + $result &= delete_trigger($row["triggerid"]); if($result){ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER, S_TRIGGER." [".$triggerid."] [".$description."] ".S_DISABLED); } } - - $result = DBend(); + $result = DBend($result && !empty($_REQUEST["g_triggerid"])); show_messages($result, S_TRIGGERS_DELETED, S_CANNOT_DELETE_TRIGGERS); } ?> |
