diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-12 09:16:34 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-12 09:16:34 +0000 |
| commit | cc3ab52e16eb4c908f69f23b159293df6bac3f23 (patch) | |
| tree | c5d8acb73eef41594c3b90ec42b43d85f206fcc7 /frontends/php/acknow.php | |
| parent | 95036b5d466fb31448afc4c429968ee2fe64ba5e (diff) | |
- [DEV-45][DEV-47] merged rev. 4859:4861,4864:4865 of branches/1.4.j/ (Artem) [changed design of status of Trigger screen, added bulk acknowledge]
git-svn-id: svn://svn.zabbix.com/trunk@4866 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/acknow.php')
| -rw-r--r-- | frontends/php/acknow.php | 136 |
1 files changed, 89 insertions, 47 deletions
diff --git a/frontends/php/acknow.php b/frontends/php/acknow.php index b6006fcf..7ffaf5bd 100644 --- a/frontends/php/acknow.php +++ b/frontends/php/acknow.php @@ -31,38 +31,76 @@ include_once "include/page_header.php"; ?> <?php -// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION +// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields=array( - "eventid"=> array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, NULL), - "message"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})||isset({saveandreturn})'), + 'eventid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, '!isset({events})&&!isset({cancel})'), + 'events'=> array(T_ZBX_INT, O_OPT, null, DB_ID, '!isset({eventid})&&!isset({cancel})'), + 'message'=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})||isset({saveandreturn})'), /* actions */ + 'bulkacknowledge'=> array(T_ZBX_STR,O_OPT, P_ACT|P_SYS, NULL, NULL), "saveandreturn" => array(T_ZBX_STR,O_OPT, P_ACT|P_SYS, NULL, NULL), "save"=> array(T_ZBX_STR,O_OPT, P_ACT|P_SYS, NULL, NULL), "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null) ); check_fields($fields); + + $bulk = isset($_REQUEST['bulkacknowledge']); + + if(isset($_REQUEST['eventid'])){ + $events[$_REQUEST['eventid']] = $_REQUEST['eventid']; + } + else{ + $events = $_REQUEST['events']; + } + +//$bulk = (count($events) > 1); ?> <?php $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT); - if(! ($db_data = DBfetch(DBselect('select distinct e.*,t.triggerid,t.expression,t.description,t.expression,h.host,h.hostid '. - ' from hosts h, items i, functions f, events e, triggers t'. - ' where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and e.eventid='.$_REQUEST["eventid"]. - ' and i.hostid not in ('.$denyed_hosts.') and e.objectid=t.triggerid and e.object='.EVENT_OBJECT_TRIGGER. - ' and '.DBin_node('e.eventid') - )))) - { + $eventids = ''; + foreach($events as $id => $eventid){ + $eventids.= $id.','; + } + $eventids = trim($eventids,','); + + $db_data = DBfetch(DBselect('SELECT COUNT(DISTINCT e.eventid) as cnt'. + ' FROM hosts h, items i, functions f, events e, triggers t'. + ' WHERE h.hostid=i.hostid '. + ' AND i.itemid=f.itemid '. + ' AND f.triggerid=t.triggerid '. + ' AND e.eventid in ('.$eventids.') '. + ' AND i.hostid not in ('.$denyed_hosts.') '. + ' AND e.objectid=t.triggerid '. + ' AND e.object='.EVENT_OBJECT_TRIGGER. + ' AND '.DBin_node('e.eventid') + )); + + if($db_data['cnt'] != count($events)){ access_deny(); } + + $db_data = DBfetch(DBselect('SELECT DISTINCT e.*,t.triggerid,t.expression,t.description,t.expression,h.host,h.hostid '. + ' FROM hosts h, items i, functions f, events e, triggers t'. + ' WHERE h.hostid=i.hostid '. + ' AND i.itemid=f.itemid '. + ' AND f.triggerid=t.triggerid '. + ' AND e.eventid in ('.$eventids.') '. + ' AND i.hostid not in ('.$denyed_hosts.') '. + ' AND e.objectid=t.triggerid '. + ' AND e.object='.EVENT_OBJECT_TRIGGER. + ' AND '.DBin_node('e.eventid') + )); + unset($denyed_hosts); - if(isset($_REQUEST["save"])) + if(isset($_REQUEST['save']) && !$bulk) { $result = add_acknowledge_coment( - $db_data["eventid"], - $USER_DETAILS["userid"], - $_REQUEST["message"]); + $db_data['eventid'], + $USER_DETAILS['userid'], + $_REQUEST['message']); show_messages($result, S_COMMENT_ADDED, S_CANNOT_ADD_COMMENT); if($result) @@ -74,56 +112,60 @@ include_once "include/page_header.php"; } else if(isset($_REQUEST["saveandreturn"])) { - $result = add_acknowledge_coment( - $db_data["eventid"], - $USER_DETAILS["userid"], - $_REQUEST["message"]); + $result = true; + $_REQUEST['message'] .= ($bulk)?("\n\r".S_SYS_BULK_ACKNOWLEDGE):(''); + + foreach($events as $id => $eventid){ + $result &= add_acknowledge_coment( + $eventid, + $USER_DETAILS['userid'], + $_REQUEST['message']); + } - if($result) - { + if($result){ add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_TRIGGER, S_ACKNOWLEDGE_ADDED. - ' ['.expand_trigger_description_by_data($db_data).']'. - ' ['.$_REQUEST["message"].']'); + ' ['.($bulk)?(' BULK ACKNOWLEDGE '):(expand_trigger_description_by_data($db_data)).']'. + ' ['.$_REQUEST['message'].']'); } Redirect('tr_status.php?hostid='.get_profile('web.tr_status.hostid',0)); exit; } - else if(isset($_REQUEST["cancel"])) - { + else if(isset($_REQUEST['cancel'])){ Redirect('tr_status.php?hostid='.get_profile('web.tr_status.hostid',0)); exit; } ?> <?php - show_table_header(S_ALARM_ACKNOWLEDGES_BIG." : ". - "\"".expand_trigger_description_by_data($db_data)."\"".BR. - explode_exp($db_data["expression"],1)); + $msg=($bulk)?(' BULK ACKNOWLEDGE '):('"'.expand_trigger_description_by_data($db_data).'"'.BR.explode_exp($db_data["expression"],1)); + show_table_header(S_ALARM_ACKNOWLEDGES_BIG." : ".$msg); echo BR; - $table = new CTable(NULL,"ack_msgs"); - $table->SetAlign("center"); + if(!$bulk){ + $table = new CTable(NULL,"ack_msgs"); + $table->SetAlign("center"); - $db_acks = get_acknowledges_by_eventid($db_data["eventid"]); - while($db_ack = DBfetch($db_acks)) - { - $db_user = get_user_by_userid($db_ack["userid"]); - $table->AddRow(array( - new CCol($db_user["alias"],"user"), - new CCol(date("d-m-Y h:i:s A",$db_ack["clock"]),"time")), - "title"); - - $msgCol = new CCol(nl2br($db_ack["message"])); - $msgCol->SetColspan(2); - $table->AddRow($msgCol,"msg"); - } + $db_acks = get_acknowledges_by_eventid($db_data["eventid"]); + while($db_ack = DBfetch($db_acks)) + { + $db_user = get_user_by_userid($db_ack["userid"]); + $table->AddRow(array( + new CCol($db_user["alias"],"user"), + new CCol(date("d-m-Y h:i:s A",$db_ack["clock"]),"time")), + "title"); + + $msgCol = new CCol(nl2br($db_ack["message"])); + $msgCol->SetColspan(2); + $table->AddRow($msgCol,"msg"); + } /**/ - if($table->GetNumRows() > 0) - { - $table->Show(); - echo BR; + if($table->GetNumRows() > 0){ + $table->Show(); + echo BR; + } } - insert_new_message_form(); + + insert_new_message_form($events,$bulk); ?> <?php |
