$page["title"] = "S_TRIGGER_COMMENTS"; $page["file"] = "tr_comments.php"; include_once "include/page_header.php"; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array("triggerid" => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null), "comments" => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), "save" => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), "cancel" => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null)); check_fields($fields); $sql = 'SELECT * ' . ' FROM items i, functions f ' . ' WHERE i.itemid=f.itemid ' . ' AND f.triggerid=' . $_REQUEST['triggerid'] . ' AND ' . DBin_node('f.triggerid'); if (!($db_data = DBfetch(DBselect($sql)))) { fatal_error(S_NO_TRIGGER_DEFINED); } $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array($db_data['hostid'])); if (!isset($available_triggers[$_REQUEST['triggerid']])) { access_deny(); } $trigger_hostid = $db_data['hostid']; if (isset($_REQUEST["save"])) { $result = update_trigger_comments($_REQUEST["triggerid"], $_REQUEST["comments"]); show_messages($result, S_COMMENT_UPDATED, S_CANNOT_UPDATE_COMMENT); if ($result) { add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER, S_TRIGGER . " [" . $_REQUEST["triggerid"] . "] [" . expand_trigger_description($_REQUEST["triggerid"]) . "] " . S_COMMENTS . " [" . $_REQUEST["comments"] . "]"); } } else { if (isset($_REQUEST["cancel"])) { redirect('tr_status.php?hostid=' . $trigger_hostid); exit; } } show_table_header(S_TRIGGER_COMMENTS_BIG); echo SBR; insert_trigger_comment_form($_REQUEST["triggerid"]); include_once "include/page_footer.php";
$page['file'] = 'tr_comments.php'; include_once 'include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('triggerid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null), 'comments' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), 'save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null)); check_fields($fields); if (!isset($_REQUEST['triggerid'])) { fatal_error(S_NO_TRIGGER_DEFINED); } $options = array('nodeids' => get_current_nodeid(true), 'triggerids' => $_REQUEST['triggerid'], 'output' => API_OUTPUT_EXTEND, 'expandDescription' => true); $trigger = CTrigger::get($options); $trigger = reset($trigger); if (!$trigger) { access_deny(); } if (isset($_REQUEST['save'])) { $result = update_trigger_comments($_REQUEST['triggerid'], $_REQUEST['comments']); show_messages($result, S_COMMENT_UPDATED, S_CANNOT_UPDATE_COMMENT); $trigger['comments'] = $_REQUEST['comments']; if ($result) { add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER, S_TRIGGER . ' [' . $_REQUEST['triggerid'] . '] [' . $trigger['description'] . '] ' . S_COMMENTS . ' [' . $_REQUEST['comments'] . ']'); } } else { if (isset($_REQUEST['cancel'])) { jsRedirect('tr_status.php'); exit; } } show_table_header(S_TRIGGER_COMMENTS_BIG); //if user has no permissions to edit comments, no "save" button for him $triggerEditable = CTrigger::get(array('editable' => 1, 'trigegrids' => $_REQUEST['triggerid'], 'output' => API_OUTPUT_SHORTEN)); $triggerEditable = !empty($triggerEditable);