diff options
author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-02-23 11:01:09 +0000 |
---|---|---|
committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-02-23 11:01:09 +0000 |
commit | 03d1b9eef78d98b057ad1741653823c414329000 (patch) | |
tree | b468335030b77d717d1164c3bcbbcf19cdd9a9a7 | |
parent | 7db62d1b7ad353a843755ef93b6e3eb918976d7a (diff) | |
download | zabbix-03d1b9eef78d98b057ad1741653823c414329000.tar.gz zabbix-03d1b9eef78d98b057ad1741653823c414329000.tar.xz zabbix-03d1b9eef78d98b057ad1741653823c414329000.zip |
- added group operations for actions (Eugene)
- frontend support for action status (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2679 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | frontends/php/actionconf.php | 103 | ||||
-rw-r--r-- | frontends/php/include/actions.inc.php | 16 | ||||
-rw-r--r-- | frontends/php/include/defines.inc.php | 3 | ||||
-rw-r--r-- | frontends/php/include/forms.inc.php | 7 | ||||
-rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/include/triggers.inc.php | 13 | ||||
-rw-r--r-- | frontends/php/triggers.php | 2 |
8 files changed, 131 insertions, 17 deletions
@@ -1,5 +1,7 @@ Changes for 1.1beta7: + - added group operations for actions (Eugene) + - frontend support for action status (Eugene) - support for action statuses: enable and disabled (Alexei) - added column actions.status (Alexei) - added Hostname for graphs displaying (Eugene) diff --git a/frontends/php/actionconf.php b/frontends/php/actionconf.php index d2ba403b..f9ef70b2 100644 --- a/frontends/php/actionconf.php +++ b/frontends/php/actionconf.php @@ -51,6 +51,7 @@ "subject"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'), "message"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'), "repeat"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), 'isset({save})'), + "status"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), 'isset({save})'), "maxrepeats"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'{repeat}==1&&isset({save})'), "repeatdelay"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'{repeat}==1&&isset({save})'), @@ -65,11 +66,16 @@ // "rem_condition[i][operator]"=> array(T_ZBX_INT, O_OPT, NULL, NULL, NULL); // "rem_condition[i][value]"=> array(NULL, O_OPT, NULL, NULL, NULL); + "g_actionid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), + "new_condition_type"=> array(T_ZBX_INT, O_OPT, NULL, NULL, 'isset({add_condition})'), "new_condition_operator"=> array(T_ZBX_INT, O_OPT, NULL, NULL, 'isset({add_condition})'), "new_condition_value"=> array(NULL, O_OPT, NULL, NULL, 'isset({add_condition})'), /* actions */ + "group_delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + "group_enable"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + "group_disable"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), "add_condition"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), "del_condition"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), @@ -97,13 +103,13 @@ $actionid=$_REQUEST["actionid"]; $result = update_action($actionid, $_REQUEST['userid'], $_REQUEST["delay"], $_REQUEST["subject"], $_REQUEST["message"],$_REQUEST["recipient"], - $_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"]); + $_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"],$_REQUEST["status"]); show_messages($result,S_ACTION_UPDATED,S_CANNOT_UPDATE_ACTION); } else { $actionid=add_action($_REQUEST['userid'], $_REQUEST["delay"], $_REQUEST["subject"],$_REQUEST["message"],$_REQUEST["recipient"], - $_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"]); + $_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"],$_REQUEST["status"]); $result=$actionid; show_messages($result,S_ACTION_ADDED,S_CANNOT_ADD_ACTION); @@ -165,6 +171,40 @@ unset($_REQUEST["conditions"][$val]); } } +/* GROUP ACTIONS */ + elseif(isset($_REQUEST["group_enable"])&&isset($_REQUEST["g_actionid"])) + { + $result=DBselect("select distinct actionid from actions"); + while($row=DBfetch($result)) + { + if(!in_array($row["actionid"], $_REQUEST["g_actionid"])) continue; + $res=update_action_status($row["actionid"],0); + } + if(isset($res)) + show_messages(true, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS); + } + elseif(isset($_REQUEST["group_disable"])&&isset($_REQUEST["g_actionid"])) + { + $result=DBselect("select distinct actionid from actions"); + while($row=DBfetch($result)) + { + if(!in_array($row["actionid"], $_REQUEST["g_actionid"])) continue; + $res=update_action_status($row["actionid"],1); + } + if(isset($res)) + show_messages(true, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS); + } + elseif(isset($_REQUEST["group_delete"])&&isset($_REQUEST["g_actionid"])) + { + $result=DBselect("select distinct actionid from actions"); + while($row=DBfetch($result)) + { + if(!in_array($row["actionid"], $_REQUEST["g_actionid"])) continue; + $del_res = delete_action($row["actionid"]); + } + if(isset($del_res)) + show_messages(TRUE, S_ACTIONS_DELETED, S_CANNOT_DELETE_ACTIONS); + } ?> <?php @@ -175,7 +215,7 @@ else { /* table header */ - $form = new CForm("actionconf.php"); + $form = new CForm(); $cmbType = new CComboBox("actiontype",$_REQUEST["actiontype"],"submit()"); $cmbType->AddItem(0,S_SEND_MESSAGE); @@ -188,9 +228,17 @@ show_header2(S_ACTIONS, $form); /* table */ + $form = new CForm(); + $form->SetName('actions'); + $tblActions = new CTableInfo(S_NO_ACTIONS_DEFINED); - $tblActions->SetHeader(array(S_SOURCE,S_CONDITIONS,S_SEND_MESSAGE_TO, - S_DELAY,S_SUBJECT,S_REPEATS)); + $tblActions->SetHeader(array( + array( new CCheckBox("all_items",NULL,NULL, + "CheckAll('".$form->GetName()."','all_items');"), + S_SOURCE + ), + S_CONDITIONS,S_SEND_MESSAGE_TO, + S_DELAY,S_SUBJECT,S_REPEATS,S_STATUS)); if(isset($_REQUEST["actiontype"])&&($_REQUEST["actiontype"]==1)) { @@ -223,18 +271,53 @@ $recipient=$groupd["name"]; } + if($row["status"] == ACTION_STATUS_DISABLED) + { + $status= new CLink(S_DISABLED, + "actionconf.php?group_enable=1&g_actionid%5B%5D=".$row["actionid"], + 'disabled'); + } + else if($row["status"] == ACTION_STATUS_ENABLED) + { + $status= new CLink(S_ENABLED, + "actionconf.php?group_disable=1&g_actionid%5B%5D=".$row["actionid"], + 'enabled'); + } + $tblActions->AddRow(array( - new CLink( - get_source_description($row["source"]), - "actionconf.php?form=update&actionid=".$row['actionid'],'action'), + array( + new CCheckBox( + "g_actionid[]", /* name */ + NULL, /* checked */ + NULL, /* caption */ + NULL, /* action */ + $row["actionid"]), /* value */ + SPACE, + new CLink( + get_source_description($row["source"]), + "actionconf.php?form=update&actionid=".$row['actionid'],'action'), + ), $conditions, $recipient, htmlspecialchars($row["delay"]), htmlspecialchars($row["subject"]), - $row["maxrepeats"] == 0 ? S_NO_REPEATS : $row["maxrepeats"] + $row["maxrepeats"] == 0 ? S_NO_REPEATS : $row["maxrepeats"], + $status )); } - $tblActions->Show(); + $footerButtons = array(); + array_push($footerButtons, new CButton('group_enable','enable selected', + "return Confirm('Enable selected actions?');")); + array_push($footerButtons, SPACE); + array_push($footerButtons, new CButton('group_disable','disable selected', + "return Confirm('Disable selected actions?');")); + array_push($footerButtons, SPACE); + array_push($footerButtons, new CButton('group_delete','delete selected', + "return Confirm('Delete selected action?');")); + $tblActions->SetFooter(new CCol($footerButtons),'table_footer'); + + $form->AddItem($tblActions); + $form->Show(); } show_page_footer(); diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index 334d7071..a6f1ad15 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -36,7 +36,7 @@ # Add Action - function add_action( $id, $delay, $subject, $message, $recipient, $maxrepeats, $repeatdelay) + function add_action($id,$delay,$subject,$message,$recipient,$maxrepeats,$repeatdelay,$status) { // if(!check_right_on_trigger("A",$triggerid)) // { @@ -44,14 +44,16 @@ // return 0; // } - $sql="insert into actions (userid,delay,nextcheck,subject,message,recipient,maxrepeats,repeatdelay) values ($id,$delay,0,".zbx_dbstr($subject).",".zbx_dbstr($message).",$recipient,$maxrepeats,$repeatdelay)"; + $sql="insert into actions (userid,delay,nextcheck,subject,message,recipient,". + "maxrepeats,repeatdelay,status) values ($id,$delay,0,".zbx_dbstr($subject).",". + zbx_dbstr($message).",$recipient,$maxrepeats,$repeatdelay,$status)"; $result=DBexecute($sql); return DBinsert_id($result,"actions","actionid"); } # Update Action - function update_action($actionid, $id, $delay, $subject, $message, $recipient, $maxrepeats, $repeatdelay) + function update_action($actionid, $id, $delay, $subject, $message, $recipient, $maxrepeats, $repeatdelay, $status) { // if(!check_right_on_trigger("U",$triggerid)) // { @@ -59,8 +61,7 @@ // return 0; // } - $sql="update actions set userid=$id,delay=$delay,nextcheck=0,subject=".zbx_dbstr($subject).",message=".zbx_dbstr($message).",recipient=$recipient,maxrepeats=$maxrepeats, repeatdelay=$repeatdelay where actionid=$actionid"; - $result=DBexecute($sql); + $result=DBexecute("update actions set userid=$id,delay=$delay,nextcheck=0,subject=".zbx_dbstr($subject).",message=".zbx_dbstr($message).",recipient=$recipient,maxrepeats=$maxrepeats, repeatdelay=$repeatdelay where actionid=$actionid,status=$status"); return $result; } @@ -338,4 +339,9 @@ $result=DBexecute($sql); return DBinsert_id($result,"conditions","conditionid"); } + + function update_action_status($actionid, $status) + { + return DBexecute("update actions set status=$status where actionid=$actionid"); + } ?> diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 9bd7de10..69b3ba80 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -136,6 +136,9 @@ define("TRIGGER_VALUE_TRUE",1); define("TRIGGER_VALUE_UNKNOWN",2); + define("ACTION_STATUS_ENABLED",0); + define("ACTION_STATUS_DISABLED",1); + define("TRIGGER_STATUS_ENABLED",0); define("TRIGGER_STATUS_DISABLED",1); define("TRIGGER_STATUS_UNKNOWN",2); diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 46a338ad..4e1d432c 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -1141,6 +1141,7 @@ $recipient = $action["recipient"]; $maxrepeats = $action["maxrepeats"]; $repeatdelay = $action["repeatdelay"]; + $status = $action["status"]; if(isset($_REQUEST["repeat"])) { @@ -1182,6 +1183,7 @@ $maxrepeats = get_request("maxrepeats",0); $repeatdelay = get_request("repeatdelay",600); $repeat = get_request("repeat",0); + $status = get_request("status",ACTION_STATUS_ENABLED); if($recipient==RECIPIENT_TYPE_GROUP) $uid = get_request("usrgrpid",NULL); @@ -1394,6 +1396,11 @@ $frmAction->AddVar("repeatdelay",$repeatdelay); } + $cmbStatus = new CComboBox('status',$status); + $cmbStatus->AddItem(0,S_ENABLED); + $cmbStatus->AddItem(1,S_DISABLED); + $frmAction->AddRow(S_STATUS, $cmbStatus); + $frmAction->AddItemToBottomRow(new CButton('save',S_SAVE)); if(isset($_REQUEST["actionid"])) { diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 303c3979..ffa74c0f 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -47,6 +47,8 @@ "S_CONDITIONS"=> "Conditions", "S_CONDITION"=> "Condition", "S_NO_CONDITIONS_DEFINED"=> "No conditions defined", + "S_ACTIONS_DELETED"=> "Actions deleted", + "S_CANNOT_DELETE_ACTIONS"=> "Cannot delete actions", // actions.php "S_ACTIONS"=> "Actions", diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index 36a19c52..e752b37a 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -647,6 +647,8 @@ { return $result; } + DBexecute("delete from trigger_depends where triggerid_up=$triggerid"); + $result=delete_function_by_triggerid($triggerid); if(!$result) { @@ -663,9 +665,18 @@ return $result; } - DBexecute("delete from trigger_depends where triggerid_up=$triggerid"); + DBexecute("delete from alerts where triggerid=$triggerid"); DBexecute("update sysmaps_links set triggerid=NULL where triggerid=$triggerid"); + + $db_actions = DBselect("select distinct c.actionid from conditions c, triggers t". + " where c.conditiontype=CONDITION_TYPE_TRIGGER". + " and c.value=t.triggerid"); + while($db_action = DBfetch($db_actions)) + { + DBexecute("update actions set status=".ACTION_STATUS_DISABLED. + " where actionid=".$db_action["actionid"]); + } $trigger = get_trigger_by_triggerid($triggerid); diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php index 8e4648b8..dce769d1 100644 --- a/frontends/php/triggers.php +++ b/frontends/php/triggers.php @@ -411,7 +411,7 @@ "return Confirm('Disable selected triggers?');")); array_push($footerButtons, SPACE); array_push($footerButtons, new CButton('group_delete','delete selected', - "return Confirm('".S_DISABLE_SELECTED_TRIGGERS_Q."');")); + "return Confirm('Delete selected triggers?');")); $table->SetFooter(new CCol($footerButtons),'table_footer'); $form->AddItem($table); |