mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
2009-02-18 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Removed from repository. Agent alerts manager is now done in alerts/alert_list.php * godmode/agentes/manage_config.php, godmode/alerts/configure_alert, godmode/agentes/configurar_agente.php: Use alerts/alert_list.php instead of deleted agentes/alert_manager.php. * godmode/alerts/alert_list.php: It can handle now a list of agents or be included by configurar_agente. Now it's a single page to manage all the alerts defined in agents. * godmode/reporting/map_builder.php: Javascript style correction. * include/javascript/jquery.pandora.controls.js: Added pandoraSelectAgent which allows the loading of a module list from an agent list. * include/styles/pandora.css: Styles for alert_list. * include/functions_agents.php: Added options to get_agent_alerts_compound() and get_agent_alerts_simple() to add extra user filtering. * pandoradb.sql, pandoradb_migrate_20_to_21.sql, include/functions_alerts.php: Actions in an alert module has now id or they cannot be removed. * include/functions_db.php: format_array_to_where_clause_sql() can now get limit and offset values. * include/functions_html.php: Removed select- prefix to print_select elements because it was breaking javascript code. Needs more works on that. * operation/agentes/estado_agente.php: Added get_agent_module_last_value AJAX operation. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1466 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
0f4f36dcf9
commit
0d5884b55c
@ -1,3 +1,42 @@
|
|||||||
|
2009-02-18 Esteban Sanchez <estebans@artica.es>
|
||||||
|
|
||||||
|
* godmode/agentes/alert_manager.php: Removed from repository. Agent
|
||||||
|
alerts manager is now done in alerts/alert_list.php
|
||||||
|
|
||||||
|
* godmode/agentes/manage_config.php, godmode/alerts/configure_alert,
|
||||||
|
godmode/agentes/configurar_agente.php: Use alerts/alert_list.php
|
||||||
|
instead of deleted agentes/alert_manager.php.
|
||||||
|
|
||||||
|
* godmode/alerts/alert_list.php: It can handle now a list of agents or
|
||||||
|
be included by configurar_agente. Now it's a single page to manage all
|
||||||
|
the alerts defined in agents.
|
||||||
|
|
||||||
|
* godmode/reporting/map_builder.php: Javascript style correction.
|
||||||
|
|
||||||
|
* include/javascript/jquery.pandora.controls.js: Added
|
||||||
|
pandoraSelectAgent which allows the loading of a module list from an
|
||||||
|
agent list.
|
||||||
|
|
||||||
|
* include/styles/pandora.css: Styles for alert_list.
|
||||||
|
|
||||||
|
* include/functions_agents.php: Added options to
|
||||||
|
get_agent_alerts_compound() and get_agent_alerts_simple() to add extra
|
||||||
|
user filtering.
|
||||||
|
|
||||||
|
* pandoradb.sql, pandoradb_migrate_20_to_21.sql,
|
||||||
|
include/functions_alerts.php: Actions in an alert module has now id or
|
||||||
|
they cannot be removed.
|
||||||
|
|
||||||
|
* include/functions_db.php: format_array_to_where_clause_sql() can now
|
||||||
|
get limit and offset values.
|
||||||
|
|
||||||
|
* include/functions_html.php: Removed select- prefix to print_select
|
||||||
|
elements because it was breaking javascript code. Needs more works on
|
||||||
|
that.
|
||||||
|
|
||||||
|
* operation/agentes/estado_agente.php: Added
|
||||||
|
get_agent_module_last_value AJAX operation.
|
||||||
|
|
||||||
2009-02-17 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
2009-02-17 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||||
|
|
||||||
* general/login_ok.php, operation/visual_console/index.php,
|
* general/login_ok.php, operation/visual_console/index.php,
|
||||||
|
@ -1,454 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// Pandora FMS - the Flexible Monitoring System
|
|
||||||
// ============================================
|
|
||||||
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
|
|
||||||
// Please see http://pandora.sourceforge.net for full contribution list
|
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License
|
|
||||||
// as published by the Free Software Foundation for version 2.
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
// Load global vars
|
|
||||||
require_once ('include/config.php');
|
|
||||||
require_once ('include/functions_alerts.php');
|
|
||||||
|
|
||||||
|
|
||||||
if (defined ('AJAX')) {
|
|
||||||
$get_agent_alerts_simple = (bool) get_parameter ('get_agent_alerts_simple');
|
|
||||||
|
|
||||||
if ($get_agent_alerts_simple) {
|
|
||||||
$id_agent = (int) get_parameter ('id_agent');
|
|
||||||
if ($id_agent <= 0) {
|
|
||||||
echo json_encode (false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$id_group = get_agent_group ($id_agent);
|
|
||||||
|
|
||||||
if (! give_acl ($config['id_user'], $id_group, "AR")) {
|
|
||||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
|
||||||
"Trying to access Alert Management");
|
|
||||||
echo json_encode (false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once ('include/functions_agents.php');
|
|
||||||
require_once ('include/functions_alerts.php');
|
|
||||||
|
|
||||||
$alerts = get_agent_alerts_simple ($id_agent);
|
|
||||||
if (empty ($alerts)) {
|
|
||||||
echo json_encode (false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$retval = array ();
|
|
||||||
foreach ($alerts as $alert) {
|
|
||||||
$alert['template'] = get_alert_template ($alert['id_alert_template']);
|
|
||||||
$alert['module_name'] = get_agentmodule_name ($alert['id_agent_module']);
|
|
||||||
$alert['agent_name'] = get_agentmodule_agent_name ($alert['id_agent_module']);
|
|
||||||
$retval[$alert['id']] = $alert;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode ($retval);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset ($id_agente)) {
|
|
||||||
die ("Not Authorized");
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "<h2>".__('Agent configuration')." > ".__('Alerts')."</h2>";
|
|
||||||
|
|
||||||
$create_alert = (bool) get_parameter ('create_alert');
|
|
||||||
$add_action = (bool) get_parameter ('add_action');
|
|
||||||
$delete_action = (bool) get_parameter ('delete_action');
|
|
||||||
$delete_alert = (bool) get_parameter ('delete_alert');
|
|
||||||
$disable_alert = (bool) get_parameter ('disable_alert');
|
|
||||||
$enable_alert = (bool) get_parameter ('enable_alert');
|
|
||||||
|
|
||||||
if ($create_alert) {
|
|
||||||
$id_alert_template = (int) get_parameter ('template');
|
|
||||||
$id_agent_module = (int) get_parameter ('id_agent_module');
|
|
||||||
|
|
||||||
$id = create_alert_agent_module ($id_agent_module, $id_alert_template);
|
|
||||||
print_error_message ($id, __('Successfully created'),
|
|
||||||
__('Could not be created'));
|
|
||||||
if ($id !== false) {
|
|
||||||
$id_alert_action = (int) get_parameter ('action');
|
|
||||||
$fires_min = (int) get_parameter ('fires_min');
|
|
||||||
$fires_max = (int) get_parameter ('fires_max');
|
|
||||||
$values = array ();
|
|
||||||
if ($fires_min != -1)
|
|
||||||
$values['fires_min'] = $fires_min;
|
|
||||||
if ($fires_max != -1)
|
|
||||||
$values['fires_max'] = $fires_max;
|
|
||||||
|
|
||||||
add_alert_agent_module_action ($id, $id_alert_action, $values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($delete_alert) {
|
|
||||||
$id_alert_agent_module = (int) get_parameter ('id_alert');
|
|
||||||
|
|
||||||
$result = delete_alert_agent_module ($id_alert_agent_module);
|
|
||||||
print_error_message ($id, __('Successfully deleted'),
|
|
||||||
__('Could not be deleted'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($add_action) {
|
|
||||||
$id_action = (int) get_parameter ('action');
|
|
||||||
$id_alert_module = (int) get_parameter ('id_alert_module');
|
|
||||||
$fires_min = (int) get_parameter ('fires_min');
|
|
||||||
$fires_max = (int) get_parameter ('fires_max');
|
|
||||||
$values = array ();
|
|
||||||
if ($fires_min != -1)
|
|
||||||
$values['fires_min'] = $fires_min;
|
|
||||||
if ($fires_max != -1)
|
|
||||||
$values['fires_max'] = $fires_max;
|
|
||||||
|
|
||||||
$result = add_alert_agent_module_action ($id_alert_module, $id_action, $values);
|
|
||||||
print_error_message ($id, __('Successfully added'),
|
|
||||||
__('Could not be added'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($delete_action) {
|
|
||||||
$id_action = (int) get_parameter ('id_action');
|
|
||||||
$id_alert = (int) get_parameter ('id_alert');
|
|
||||||
|
|
||||||
$result = delete_alert_agent_module_action ($id_alert, $id_action);
|
|
||||||
print_error_message ($id, __('Successfully deleted'),
|
|
||||||
__('Could not be deleted'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($enable_alert) {
|
|
||||||
$id_alert = (int) get_parameter ('id_alert');
|
|
||||||
|
|
||||||
$result = set_alerts_agent_module_disable ($id_alert, false);
|
|
||||||
print_error_message ($id, __('Successfully enabled'),
|
|
||||||
__('Could not be enabled'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($disable_alert) {
|
|
||||||
$id_alert = (int) get_parameter ('id_alert');
|
|
||||||
|
|
||||||
$result = set_alerts_agent_module_disable ($id_alert, true);
|
|
||||||
print_error_message ($id, __('Successfully disabled'),
|
|
||||||
__('Could not be disabled'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$modules = get_agent_modules ($id_agente,
|
|
||||||
array ('id_tipo_modulo', 'nombre', 'id_agente'));
|
|
||||||
|
|
||||||
echo "<h3>".__('Alerts defined')."</h3>";
|
|
||||||
|
|
||||||
$table->class = 'databox_color modules';
|
|
||||||
$table->cellspacing = '0';
|
|
||||||
$table->width = '90%';
|
|
||||||
$table->data = array ();
|
|
||||||
$table->rowstyle = array ();
|
|
||||||
$table->style = array ();
|
|
||||||
$table->style[1] = 'vertical-align: top';
|
|
||||||
|
|
||||||
$table_alerts->class = 'listing';
|
|
||||||
$table_alerts->width = '100%';
|
|
||||||
$table_alerts->size = array ();
|
|
||||||
$table_alerts->size[0] = '50%';
|
|
||||||
$table_alerts->size[1] = '50%';
|
|
||||||
$table_alerts->style = array ();
|
|
||||||
$table_alerts->style[0] = 'vertical-align: top';
|
|
||||||
$table_alerts->style[1] = 'vertical-align: top';
|
|
||||||
|
|
||||||
foreach ($modules as $id_agent_module => $module) {
|
|
||||||
$last_data = get_agent_module_last_value ($id_agent_module);
|
|
||||||
if ($last_data === false)
|
|
||||||
$last_data = '<em>'.__('N/A').'</em>';
|
|
||||||
|
|
||||||
$table->data[0][0] = '<span><strong>Module</strong>: '.$module['nombre'].'</span>';
|
|
||||||
$table->data[0][0] .= '<div class="actions left" style="visibility: hidden;">';
|
|
||||||
$table->data[0][0] .= '<span class="module_values" style="float: right;">';
|
|
||||||
$table->data[0][0] .= '<em>'.__('Latest value').'</em>: ';
|
|
||||||
if ($last_data == '')
|
|
||||||
$table->data[0][0] .= '<em>'.__('Empty').'</em>';
|
|
||||||
elseif (is_numeric ($last_data))
|
|
||||||
$table->data[0][0] .= format_numeric ($last_data);
|
|
||||||
else
|
|
||||||
$table->data[0][0] .= $last_data;
|
|
||||||
|
|
||||||
$table->data[0][0] .= '</span>';
|
|
||||||
$table->data[0][0] .= '</div>';
|
|
||||||
$table->data[0][0] .= '<div class="actions right" style="visibility: hidden;">';
|
|
||||||
$table->data[0][0] .= '<span class="add">';
|
|
||||||
$table->data[0][0] .= '<a href="#" class="add_alert" id="module-'.$id_agent_module.'">';
|
|
||||||
$table->data[0][0] .= __('Add alert');
|
|
||||||
$table->data[0][0] .= '</a>';
|
|
||||||
$table->data[0][0] .= '</span>';
|
|
||||||
$table->data[0][0] .= '</div>';
|
|
||||||
|
|
||||||
|
|
||||||
/* Alerts in module list */
|
|
||||||
$table_alerts->id = 'alerts-'.$id_agent_module;
|
|
||||||
$table_alerts->data = array ();
|
|
||||||
|
|
||||||
$alerts = get_alerts_agent_module ($id_agent_module, true);
|
|
||||||
if ($alerts === false) {
|
|
||||||
$alerts = array ();
|
|
||||||
$table->data[1][0] = '';
|
|
||||||
$table->rowstyle[1] = 'display: none';
|
|
||||||
} else {
|
|
||||||
$table->data[1][0] = '<h4 class="left" style="clear: left">';
|
|
||||||
$table->data[1][0] .= __('Alerts assigned');
|
|
||||||
$table->data[1][0] .= '</h4>';
|
|
||||||
$table->rowstyle[1] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($alerts as $alert) {
|
|
||||||
$alert_data = array ();
|
|
||||||
|
|
||||||
$alert_actions = get_alert_agent_module_actions ($alert['id']);
|
|
||||||
|
|
||||||
$alert_data[0] = get_alert_template_name ($alert['id_alert_template']);
|
|
||||||
|
|
||||||
if (empty ($alert_actions)) {
|
|
||||||
$alert_data[0] .= '<form style="display: inline" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente.'" method="post" class="delete_link">';
|
|
||||||
$alert_data[0] .= print_input_image ('delete', 'images/cross.png', 1, '', true);
|
|
||||||
$alert_data[0] .= print_input_hidden ('delete_alert', 1, true);
|
|
||||||
$alert_data[0] .= print_input_hidden ('id_alert', $alert['id'], true);
|
|
||||||
$alert_data[0] .= '</form>';
|
|
||||||
} else {
|
|
||||||
$alert_data[0] .= '<form style="display: inline" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente.'" method="post">';
|
|
||||||
if ($alert['disabled']) {
|
|
||||||
$alert_data[0] .= print_input_image ('enable', 'images/lightbulb_off.png', 1, '', true);
|
|
||||||
$alert_data[0] .= print_input_hidden ('enable_alert', 1, true);
|
|
||||||
} else {
|
|
||||||
$alert_data[0] .= print_input_image ('disable', 'images/lightbulb.png', 1, '', true);
|
|
||||||
$alert_data[0] .= print_input_hidden ('disable_alert', 1, true);
|
|
||||||
}
|
|
||||||
$alert_data[0] .= print_input_hidden ('id_alert', $alert['id'], true);
|
|
||||||
$alert_data[0] .= '</form>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$alert_data[0] .= '<span class="actions" style="visibility: hidden">';
|
|
||||||
$alert_data[0] .= '<a href="ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template='.$alert['id_alert_template'].'"
|
|
||||||
class="template_details">';
|
|
||||||
$alert_data[0] .= print_image ("images/zoom.png", true,
|
|
||||||
array ("id" => 'template-details-'.$alert['id'],
|
|
||||||
"class" => "left img_help")
|
|
||||||
);
|
|
||||||
$alert_data[0] .= '</a>';
|
|
||||||
$alert_data[0] .= '</span>';
|
|
||||||
|
|
||||||
$alert_data[1] = '<ul style="float: left; margin-bottom: 10px">';
|
|
||||||
foreach ($alert_actions as $action) {
|
|
||||||
$alert_data[1] .= '<li><div>';
|
|
||||||
$alert_data[1] .= '<span class="left">';
|
|
||||||
$alert_data[1] .= $action['name'].' ';
|
|
||||||
$alert_data[1] .= '<em>(';
|
|
||||||
if ($action['fires_min'] == $action['fires_max']) {
|
|
||||||
if ($action['fires_min'] == 0)
|
|
||||||
$alert_data[1] .= __('Always');
|
|
||||||
else
|
|
||||||
$alert_data[1] .= __('On').' '.$action['fires_min'];
|
|
||||||
} else {
|
|
||||||
if ($action['fires_min'] == 0)
|
|
||||||
$alert_data[1] .= __('Until').' '.$action['fires_max'];
|
|
||||||
else
|
|
||||||
$alert_data[1] .= __('From').' '.$action['fires_min'].
|
|
||||||
' '.__('to').' '.$action['fires_max'];
|
|
||||||
}
|
|
||||||
$url = '&delete_action=1&id_alert='.$alert['id'].'&id_action='.$action['id'];
|
|
||||||
$alert_data[1] .= ')</em>';
|
|
||||||
$alert_data[1] .= '</span>';
|
|
||||||
$alert_data[1] .= ' <span class="actions" style="visibility: hidden">';
|
|
||||||
$alert_data[1] .= '<span class="delete">';
|
|
||||||
$alert_data[1] .= '<form action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente.'" method="post" class="delete_link">';
|
|
||||||
$alert_data[1] .= print_input_image ('delete', 'images/cross.png', 1, '', true);
|
|
||||||
$alert_data[1] .= print_input_hidden ('delete_action', 1, true);
|
|
||||||
$alert_data[1] .= print_input_hidden ('id_alert', $alert['id'], true);
|
|
||||||
$alert_data[1] .= print_input_hidden ('id_action', $action['id'], true);
|
|
||||||
$alert_data[1] .= '</form>';
|
|
||||||
$alert_data[1] .= '</span>';
|
|
||||||
$alert_data[1] .= '</span>';
|
|
||||||
$alert_data[1] .= '</div></li>';
|
|
||||||
}
|
|
||||||
$alert_data[1] .= '</ul>';
|
|
||||||
|
|
||||||
$alert_data[1] .= '<div class="actions left invisible" style="clear: left">';
|
|
||||||
$alert_data[1] .= '<a class="add_action" id="add-action-'.$alert['id'].'" href="#">';
|
|
||||||
$alert_data[1] .= __('Add action');
|
|
||||||
$alert_data[1] .= '</a>';
|
|
||||||
$alert_data[1] .= '</div>';
|
|
||||||
|
|
||||||
$table_alerts->data['alert-'.$alert['id']] = $alert_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table->data[1][0] .= print_table ($table_alerts, true);
|
|
||||||
|
|
||||||
print_table ($table);
|
|
||||||
$table->data = array ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This hidden value is used in Javascript. It's a workaraound for IE because
|
|
||||||
it doesn't allow input elements creation. */
|
|
||||||
print_input_hidden ('add_action', 1);
|
|
||||||
print_input_hidden ('id_alert_module', 0);
|
|
||||||
|
|
||||||
echo '<form class="add_alert_form invisible" method="post"
|
|
||||||
action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.
|
|
||||||
$id_agente.'">';
|
|
||||||
echo '<div style="float:left">';
|
|
||||||
print_label (__('Template'), 'template');
|
|
||||||
$templates = get_alert_templates ();
|
|
||||||
if (empty ($templates))
|
|
||||||
$templates = array ();
|
|
||||||
print_select ($templates, 'template', '', '', __('None'), 0);
|
|
||||||
echo '</div><div style="margin-left: 270px">';
|
|
||||||
print_label (__('Action'), 'action');
|
|
||||||
$actions = get_alert_actions ();
|
|
||||||
if (empty ($actions))
|
|
||||||
$actions = array ();
|
|
||||||
print_select ($actions, 'action', '', '', __('None'), 0);
|
|
||||||
echo '<br />';
|
|
||||||
echo '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' » </a></span>';
|
|
||||||
echo '<span class="advanced_actions invisible">';
|
|
||||||
echo __('From').' ';
|
|
||||||
print_input_text ('fires_min', -1, '', 4, 10);
|
|
||||||
echo ' '.__('to').' ';
|
|
||||||
print_input_text ('fires_max', -1, '', 4, 10);
|
|
||||||
echo ' '.__('matches of the alert');
|
|
||||||
echo pandora_help("alert-matches", true);
|
|
||||||
echo '</span></div>';
|
|
||||||
echo '<div style="float: right; margin-left: 30px;"><br />';
|
|
||||||
print_submit_button (__('Add'), 'add', false, 'class="sub next"');
|
|
||||||
print_input_hidden ('id_agent_module', 0);
|
|
||||||
print_input_hidden ('create_alert', 1);
|
|
||||||
echo '</div></form>';
|
|
||||||
$config['jquery'][] = 'cluetip';
|
|
||||||
$config['css'][] = 'cluetip';
|
|
||||||
?>
|
|
||||||
<script type="text/javascript">
|
|
||||||
/* <![CDATA[ */
|
|
||||||
$(document).ready (function () {
|
|
||||||
$("table.modules tr").hover (
|
|
||||||
function () {
|
|
||||||
$(".actions", this).css ("visibility", "");
|
|
||||||
},
|
|
||||||
function () {
|
|
||||||
$(".actions", this).css ("visibility", "hidden");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$("a.add_alert").click (function () {
|
|
||||||
place = $(this).parents ("tbody").children ("tr:last").children ("td");
|
|
||||||
if ($("form.add_alert_form", place).length > 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id = this.id.split ("-").pop ();
|
|
||||||
form = $("form.add_alert_form:last").clone (true);
|
|
||||||
$("input#hidden-id_agent_module", form).attr ("value", id);
|
|
||||||
$(place).append (form);
|
|
||||||
$(form).show ();
|
|
||||||
$(this).parents ("tbody").children ("tr:last").show ();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".add_alert_form").submit (function () {
|
|
||||||
if ($("#template", this).attr ("value") == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
$("a.show_advanced_actions").click (function () {
|
|
||||||
/* It can be done in two different site, so it must use two different selectors */
|
|
||||||
actions = $(this).parents ("form").children ("span.advanced_actions");
|
|
||||||
if (actions.length == 0)
|
|
||||||
actions = $(this).parents ("div").children ("span.advanced_actions")
|
|
||||||
$("#text-fires_min", actions).attr ("value", 0);
|
|
||||||
$("#text-fires_max", actions).attr ("value", 0);
|
|
||||||
$(actions).show ();
|
|
||||||
$(this).remove ();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".actions a.add_action").click (function () {
|
|
||||||
id = this.id.split ("-").pop ();
|
|
||||||
|
|
||||||
/* Remove new alert form (if shown) to clean a bit the UI */
|
|
||||||
$(this).parents ("td:last").children ("form.add_alert_form")
|
|
||||||
.remove ();
|
|
||||||
|
|
||||||
/* Replace link with a combo with the actions and a form */
|
|
||||||
a = $("a.show_advanced_actions:first").clone (true);
|
|
||||||
advanced = $("span.advanced_actions:first").clone (true).hide ();
|
|
||||||
select = $("select#action:first").clone ();
|
|
||||||
button = $('<input type="image" class="sub next" value="'+"<?php echo __('Add');?>"+'"></input>');
|
|
||||||
divbutton = $("<div></div>").css ("float", "right").html (button);
|
|
||||||
input1 = $("input#hidden-add_action");
|
|
||||||
input2 = $("input#hidden-id_alert_module").clone ().attr ("value", id);
|
|
||||||
form = $('<form method="post"></form>')
|
|
||||||
.append (select)
|
|
||||||
.append ("<br></br>")
|
|
||||||
.append (a)
|
|
||||||
.append (advanced)
|
|
||||||
.append (divbutton)
|
|
||||||
.append (input1)
|
|
||||||
.append (input2);
|
|
||||||
|
|
||||||
$(this).parents (".actions:first").replaceWith (form);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$("a.template_details").cluetip ({
|
|
||||||
arrows: true,
|
|
||||||
attribute: 'href',
|
|
||||||
cluetipClass: 'default'
|
|
||||||
}).click (function () {
|
|
||||||
return false;
|
|
||||||
});;
|
|
||||||
|
|
||||||
$("select[name=template]").change (function () {
|
|
||||||
if (this.value == 0) {
|
|
||||||
$(this).parents ("div:first").children ("a").remove ();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
details = $("a.template_details:first").clone (true)
|
|
||||||
.attr ("href",
|
|
||||||
"ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template=" + this.value);
|
|
||||||
$(this).after (details);
|
|
||||||
});
|
|
||||||
$("form.delete_link").submit (function () {
|
|
||||||
if (! confirm ("<?php echo __('Are you sure?')?>"))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
$("input[name=disable]").attr ("title", "<?php echo __('Disable')?>")
|
|
||||||
.hover (function () {
|
|
||||||
$(this).attr ("src", "images/lightbulb_off.png");
|
|
||||||
},
|
|
||||||
function () {
|
|
||||||
$(this).attr ("src", "images/lightbulb.png");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$("input[name=enable]").attr ("title", "<?php echo __('Enable')?>")
|
|
||||||
.hover (function () {
|
|
||||||
$(this).attr ("src", "images/lightbulb.png");
|
|
||||||
},
|
|
||||||
function () {
|
|
||||||
$(this).attr ("src", "images/lightbulb_off.png");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
/* ]]> */
|
|
||||||
</script>
|
|
@ -585,7 +585,8 @@ switch ($tab) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "alert":
|
case "alert":
|
||||||
require ("alert_manager.php");
|
/* Because $id_agente is set, it will show only agent alerts */
|
||||||
|
require ("godmode/alerts/alert_list.php");
|
||||||
break;
|
break;
|
||||||
case "template":
|
case "template":
|
||||||
require ("agent_template.php");
|
require ("agent_template.php");
|
||||||
|
@ -288,7 +288,7 @@ $(document).ready (function () {
|
|||||||
|
|
||||||
/* Get alerts */
|
/* Get alerts */
|
||||||
jQuery.post ("ajax.php",
|
jQuery.post ("ajax.php",
|
||||||
{"page" : "godmode/agentes/alert_manager",
|
{"page" : "godmode/alerts/alert_list",
|
||||||
"get_agent_alerts_simple" : 1,
|
"get_agent_alerts_simple" : 1,
|
||||||
"id_agent" : id_agent
|
"id_agent" : id_agent
|
||||||
},
|
},
|
||||||
|
@ -17,7 +17,80 @@
|
|||||||
|
|
||||||
check_login ();
|
check_login ();
|
||||||
|
|
||||||
if (! give_acl ($config['id_user'], 0, "LM")) {
|
if (defined ('AJAX')) {
|
||||||
|
$get_agent_alerts_simple = (bool) get_parameter ('get_agent_alerts_simple');
|
||||||
|
$disable_alert = (bool) get_parameter ('disable_alert');
|
||||||
|
$enable_alert = (bool) get_parameter ('enable_alert');
|
||||||
|
|
||||||
|
if ($get_agent_alerts_simple) {
|
||||||
|
$id_agent = (int) get_parameter ('id_agent');
|
||||||
|
if ($id_agent <= 0) {
|
||||||
|
echo json_encode (false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$id_group = get_agent_group ($id_agent);
|
||||||
|
|
||||||
|
if (! give_acl ($config['id_user'], $id_group, "AR")) {
|
||||||
|
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||||
|
"Trying to access Alert Management");
|
||||||
|
echo json_encode (false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once ('include/functions_agents.php');
|
||||||
|
require_once ('include/functions_alerts.php');
|
||||||
|
|
||||||
|
$alerts = get_agent_alerts_simple ($id_agent);
|
||||||
|
if (empty ($alerts)) {
|
||||||
|
echo json_encode (false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$retval = array ();
|
||||||
|
foreach ($alerts as $alert) {
|
||||||
|
$alert['template'] = get_alert_template ($alert['id_alert_template']);
|
||||||
|
$alert['module_name'] = get_agentmodule_name ($alert['id_agent_module']);
|
||||||
|
$alert['agent_name'] = get_agentmodule_agent_name ($alert['id_agent_module']);
|
||||||
|
$retval[$alert['id']] = $alert;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode ($retval);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($enable_alert) {
|
||||||
|
$id_alert = (int) get_parameter ('id_alert');
|
||||||
|
|
||||||
|
$result = set_alerts_agent_module_disable ($id_alert, false);
|
||||||
|
if ($result)
|
||||||
|
echo __('Successfully enabled');
|
||||||
|
else
|
||||||
|
echo __('Could not be enabled');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($disable_alert) {
|
||||||
|
$id_alert = (int) get_parameter ('id_alert');
|
||||||
|
|
||||||
|
$result = set_alerts_agent_module_disable ($id_alert, true);
|
||||||
|
if ($result)
|
||||||
|
echo __('Successfully disabled');
|
||||||
|
else
|
||||||
|
echo __('Could not be disabled');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id_group = 0;
|
||||||
|
/* Check if this page is included from a agent edition */
|
||||||
|
if (isset ($id_agente)) {
|
||||||
|
$id_group = get_agent_group ($id_agente);
|
||||||
|
} else {
|
||||||
|
$id_agente = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! give_acl ($config['id_user'], $id_group, "LM")) {
|
||||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||||
"Trying to access Alert Management");
|
"Trying to access Alert Management");
|
||||||
require ("general/noaccess.php");
|
require ("general/noaccess.php");
|
||||||
@ -27,112 +100,329 @@ if (! give_acl ($config['id_user'], 0, "LM")) {
|
|||||||
require_once ('include/functions_agents.php');
|
require_once ('include/functions_agents.php');
|
||||||
require_once ('include/functions_alerts.php');
|
require_once ('include/functions_alerts.php');
|
||||||
|
|
||||||
|
$create_alert = (bool) get_parameter ('create_alert');
|
||||||
|
$add_action = (bool) get_parameter ('add_action');
|
||||||
|
$delete_action = (bool) get_parameter ('delete_action');
|
||||||
|
$delete_alert = (bool) get_parameter ('delete_alert');
|
||||||
$disable_alert = (bool) get_parameter ('disable_alert');
|
$disable_alert = (bool) get_parameter ('disable_alert');
|
||||||
$enable_alert = (bool) get_parameter ('enable_alert');
|
$enable_alert = (bool) get_parameter ('enable_alert');
|
||||||
|
|
||||||
|
if ($create_alert) {
|
||||||
|
$id_alert_template = (int) get_parameter ('template');
|
||||||
|
$id_agent_module = (int) get_parameter ('id_agent_module');
|
||||||
|
|
||||||
|
$id = create_alert_agent_module ($id_agent_module, $id_alert_template);
|
||||||
|
print_error_message ($id, __('Successfully created'),
|
||||||
|
__('Could not be created'));
|
||||||
|
if ($id !== false) {
|
||||||
|
$actions = (array) get_parameter ('actions');
|
||||||
|
$fires_min = (array) get_parameter ('fires_min');
|
||||||
|
$fires_max = (array) get_parameter ('fires_max');
|
||||||
|
|
||||||
|
foreach ($actions as $id_action) {
|
||||||
|
$values = array ();
|
||||||
|
if (isset ($fires_min[$id_action]))
|
||||||
|
$values['fires_min'] = max ($fires_min[$id_action], 0);
|
||||||
|
if ($fires_max != -1)
|
||||||
|
$values['fires_max'] = max ($fires_max[$id_action], 0);
|
||||||
|
add_alert_agent_module_action ($id, $id_action, $values);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($delete_alert) {
|
||||||
|
$id_alert_agent_module = (int) get_parameter ('id_alert');
|
||||||
|
|
||||||
|
$result = delete_alert_agent_module ($id_alert_agent_module);
|
||||||
|
print_error_message ($id, __('Successfully deleted'),
|
||||||
|
__('Could not be deleted'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($add_action) {
|
||||||
|
$id_action = (int) get_parameter ('action');
|
||||||
|
$id_alert_module = (int) get_parameter ('id_alert_module');
|
||||||
|
$fires_min = (int) get_parameter ('fires_min');
|
||||||
|
$fires_max = (int) get_parameter ('fires_max');
|
||||||
|
$values = array ();
|
||||||
|
if ($fires_min != -1)
|
||||||
|
$values['fires_min'] = $fires_min;
|
||||||
|
if ($fires_max != -1)
|
||||||
|
$values['fires_max'] = $fires_max;
|
||||||
|
|
||||||
|
$result = add_alert_agent_module_action ($id_alert_module, $id_action, $values);
|
||||||
|
print_error_message ($id, __('Successfully added'),
|
||||||
|
__('Could not be added'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($delete_action) {
|
||||||
|
$id_action = (int) get_parameter ('id_action');
|
||||||
|
$id_alert = (int) get_parameter ('id_alert');
|
||||||
|
|
||||||
|
$result = delete_alert_agent_module_action ($id_action);
|
||||||
|
print_error_message ($id, __('Successfully deleted'),
|
||||||
|
__('Could not be deleted'));
|
||||||
|
}
|
||||||
|
|
||||||
if ($enable_alert) {
|
if ($enable_alert) {
|
||||||
$id_alert = (int) get_parameter ('id_alert');
|
$id_alert = (int) get_parameter ('id_alert');
|
||||||
|
|
||||||
$result = set_alerts_agent_module_disable ($id_alert, false);
|
$result = set_alerts_agent_module_disable ($id_alert, false);
|
||||||
print_error_message ($id, __('Successfully enabled'),
|
print_error_message ($result, __('Successfully enabled'),
|
||||||
__('Could not be enabled'));
|
__('Could not be enabled'));
|
||||||
if (defined ('AJAX'))
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($disable_alert) {
|
if ($disable_alert) {
|
||||||
$id_alert = (int) get_parameter ('id_alert');
|
$id_alert = (int) get_parameter ('id_alert');
|
||||||
|
|
||||||
$result = set_alerts_agent_module_disable ($id_alert, true);
|
$result = set_alerts_agent_module_disable ($id_alert, true);
|
||||||
print_error_message ($id, __('Successfully disabled'),
|
print_error_message ($result, __('Successfully disabled'),
|
||||||
__('Could not be disabled'));
|
__('Could not be disabled'));
|
||||||
if (defined ('AJAX'))
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<h1>'.__('Alerts').'</h1>';
|
if ($id_agente) {
|
||||||
|
echo '<h1>'.__('Agent configuration').' > '.__('Alerts').'</h1>';
|
||||||
$groups = get_user_groups ();
|
$agents = array ($id_agente => get_agent_name ($id_agente));
|
||||||
$agents = get_group_agents (array_keys ($groups), false, "none");
|
} else {
|
||||||
|
echo '<h1>'.__('Alerts').'</h1>';
|
||||||
$simple_alerts = array ();
|
$groups = get_user_groups ();
|
||||||
$compound_alerts = array ();
|
$agents = get_group_agents (array_keys ($groups), false, "none");
|
||||||
|
|
||||||
foreach ($agents as $agent_id => $agent_name) {
|
|
||||||
$agent_alerts = get_agent_alerts_simple ($agent_id);
|
|
||||||
if (! empty ($agent_alerts))
|
|
||||||
$simple_alerts[$agent_id] = $agent_alerts;
|
|
||||||
|
|
||||||
$compound_alerts = get_agent_alerts_compound ($agent_id);
|
|
||||||
if (! empty ($agent_alerts))
|
|
||||||
$compound_alerts[$agent_id] = $compound_alerts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($simple_alerts as $agent_id => $alerts) {
|
|
||||||
if (empty ($alerts))
|
if ($id_agente) {
|
||||||
continue;
|
$simple_alerts = get_agent_alerts_simple (array_keys ($agents));
|
||||||
|
} else {
|
||||||
|
$sql = sprintf ('SELECT COUNT(*) FROM talert_template_modules
|
||||||
|
WHERE id_agent_module IN (SELECT id_agente_modulo
|
||||||
|
FROM tagente_modulo WHERE id_agente IN (%s))',
|
||||||
|
implode (',', array_keys ($agents)));
|
||||||
|
$total = get_db_sql ($sql);
|
||||||
|
|
||||||
echo '<h3>'.get_agent_name ($agent_id).' - '.__('Alerts defined').'</h3>';
|
pagination ($total, 'index.php?sec=gagente&sec2=godmode/alerts/alert_list');
|
||||||
|
$simple_alerts = get_agent_alerts_simple (array_keys ($agents), '',
|
||||||
$table->class = 'alert_list';
|
array ('offset' => (int) get_parameter ('offset'),
|
||||||
$table->width = '90%';
|
'limit' => $config['block_size']));
|
||||||
$table->data = array ();
|
}
|
||||||
$table->head = array ();
|
|
||||||
$table->head[0] = '';
|
$table->class = 'alert_list';
|
||||||
$table->head[1] = __('Module');
|
$table->width = '90%';
|
||||||
$table->head[2] = __('Template');
|
$table->size = array ();
|
||||||
$table->head[3] = __('Actions');
|
$table->head = array ();
|
||||||
$table->size = array ();
|
$table->head[0] = '';
|
||||||
|
if (! $id_agente) {
|
||||||
|
$table->style = array ();
|
||||||
|
$table->style[1] = 'font-weight: bold';
|
||||||
|
$table->head[1] = __('Agent');
|
||||||
$table->size[0] = '20px';
|
$table->size[0] = '20px';
|
||||||
|
$table->size[1] = '15%';
|
||||||
|
$table->size[2] = '20%';
|
||||||
|
$table->size[3] = '15%';
|
||||||
|
$table->size[4] = '50%';
|
||||||
|
} else {
|
||||||
|
/* Different sizes or the layout screws up */
|
||||||
|
$table->size[0] = '20px';
|
||||||
|
$table->size[2] = '30%';
|
||||||
|
$table->size[3] = '20%';
|
||||||
|
$table->size[4] = '50%';
|
||||||
|
}
|
||||||
|
$table->head[2] = __('Module');
|
||||||
|
$table->head[3] = __('Template');
|
||||||
|
$table->head[4] = __('Actions');
|
||||||
|
$table->data = array ();
|
||||||
|
|
||||||
|
foreach ($simple_alerts as $alert) {
|
||||||
|
$data = array ();
|
||||||
|
|
||||||
foreach ($alerts as $alert) {
|
$data[0] = '<form class="disable_alert_form" method="post" style="display: inline;">';
|
||||||
$data = array ();
|
if ($alert['disabled']) {
|
||||||
|
$data[0] .= print_input_image ('enable', 'images/lightbulb_off.png', 1, '', true);
|
||||||
$data[0] = '<form class="disable_alert_form" method="post" style="display: inline;">';
|
$data[0] .= print_input_hidden ('enable_alert', 1, true);
|
||||||
if ($alert['disabled']) {
|
} else {
|
||||||
$data[0] .= print_input_image ('enable', 'images/lightbulb_off.png', 1, '', true);
|
$data[0] .= print_input_image ('disable', 'images/lightbulb.png', 1, '', true);
|
||||||
$data[0] .= print_input_hidden ('enable_alert', 1, true);
|
$data[0] .= print_input_hidden ('disable_alert', 1, true);
|
||||||
} else {
|
|
||||||
$data[0] .= print_input_image ('disable', 'images/lightbulb.png', 1, '', true);
|
|
||||||
$data[0] .= print_input_hidden ('disable_alert', 1, true);
|
|
||||||
}
|
|
||||||
$data[0] .= print_input_hidden ('id_alert', $alert['id'], true);
|
|
||||||
$data[0] .= '</form>';
|
|
||||||
$data[1] = get_agentmodule_name ($alert['id_agent_module']);
|
|
||||||
$data[2] = get_alert_template_name ($alert['id_alert_template']);
|
|
||||||
$data[2] .= ' <a class="template_details"
|
|
||||||
href="ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template='.$alert['id_alert_template'].'">
|
|
||||||
<img id="template-details-'.$alert['id_alert_template'].'" class="img_help" src="images/zoom.png"/></a>';
|
|
||||||
|
|
||||||
$actions = get_alert_actions ($alert['id']);
|
|
||||||
$data[3] = '<ul class="action_list">';
|
|
||||||
foreach ($actions as $action) {
|
|
||||||
$data[3] .= '<li>'.$action.'</li>';
|
|
||||||
}
|
|
||||||
$data[3] .= '</ul>';
|
|
||||||
|
|
||||||
array_push ($table->data, $data);
|
|
||||||
}
|
}
|
||||||
|
$data[0] .= print_input_hidden ('id_alert', $alert['id'], true);
|
||||||
|
$data[0] .= '</form>';
|
||||||
|
|
||||||
print_table ($table);
|
if (! $id_agente) {
|
||||||
|
$id_agent = get_agentmodule_agent ($alert['id_agent_module']);
|
||||||
|
$data[1] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$id_agent.'">';
|
||||||
|
$data[1] .= get_agent_name ($id_agent);
|
||||||
|
$data[1] .= '</a>';
|
||||||
|
}
|
||||||
|
$data[2] = get_agentmodule_name ($alert['id_agent_module']);
|
||||||
|
$data[3] = get_alert_template_name ($alert['id_alert_template']);
|
||||||
|
$data[3] .= ' <a class="template_details"
|
||||||
|
href="ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template='.$alert['id_alert_template'].'">
|
||||||
|
<img id="template-details-'.$alert['id_alert_template'].'" class="img_help" src="images/zoom.png"/></a>';
|
||||||
|
|
||||||
|
$actions = get_alert_agent_module_actions ($alert['id']);
|
||||||
|
$data[4] = '<ul class="action_list">';
|
||||||
|
foreach ($actions as $action_id => $action) {
|
||||||
|
$data[4] .= '<li><div>';
|
||||||
|
$data[4] .= '<span class="left">';
|
||||||
|
$data[4] .= $action['name'];
|
||||||
|
$data[4] .= ' <em>(';
|
||||||
|
if ($action['fires_min'] == $action['fires_max']) {
|
||||||
|
if ($action['fires_min'] == 0)
|
||||||
|
$data[4] .= __('Always');
|
||||||
|
else
|
||||||
|
$data[4] .= __('On').' '.$action['fires_min'];
|
||||||
|
} else {
|
||||||
|
if ($action['fires_min'] == 0)
|
||||||
|
$data[4] .= __('Until').' '.$action['fires_max'];
|
||||||
|
else
|
||||||
|
$data[4] .= __('From').' '.$action['fires_min'].
|
||||||
|
' '.__('to').' '.$action['fires_max'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data[4] .= ')</em>';
|
||||||
|
$data[4] .= '</span>';
|
||||||
|
$data[4] .= ' <span class="delete">';
|
||||||
|
$data[4] .= '<form method="post" class="delete_link">';
|
||||||
|
$data[4] .= print_input_image ('delete', 'images/cross.png', 1, '', true);
|
||||||
|
$data[4] .= print_input_hidden ('delete_action', 1, true);
|
||||||
|
$data[4] .= print_input_hidden ('id_alert', $alert['id'], true);
|
||||||
|
$data[4] .= print_input_hidden ('id_action', $action_id, true);
|
||||||
|
$data[4] .= '</form>';
|
||||||
|
$data[4] .= '</span>';
|
||||||
|
$data[4] .= '</div></li>';
|
||||||
|
}
|
||||||
|
$data[4] .= '</ul>';
|
||||||
|
|
||||||
|
$data[4] .= '<a class="add_action" id="add-action-'.$alert['id'].'" href="#">';
|
||||||
|
$data[4] .= print_image ('images/add.png', true);
|
||||||
|
$data[4] .= ' '.__('Add action');
|
||||||
|
$data[4] .= '</a>';
|
||||||
|
|
||||||
|
array_push ($table->data, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$config['css'][] = "cluetip"; //link tags can't go in body
|
print_table ($table);
|
||||||
$config['jquery'][] = "cluetip"; //make sure it doesn't get overwritten
|
|
||||||
$config['jquery'][] = "form";
|
echo '<h3>'.__('Add alert').'</h3>';
|
||||||
|
|
||||||
|
$table->id = 'add_alert_table';
|
||||||
|
$table->class = 'databox';
|
||||||
|
$table->head = array ();
|
||||||
|
$table->data = array ();
|
||||||
|
$table->size = array ();
|
||||||
|
$table->size = array ();
|
||||||
|
$table->size[0] = '10%';
|
||||||
|
$table->size[1] = '90%';
|
||||||
|
$table->style[0] = 'font-weight: bold; vertical-align: top;';
|
||||||
|
|
||||||
|
/* Add an agent selector */
|
||||||
|
if (! $id_agente) {
|
||||||
|
$table->data['group'][0] = __('Group');
|
||||||
|
$table->data['group'][1] = print_select ($groups, 'id_group', $id_group,
|
||||||
|
false, '', '', true);
|
||||||
|
|
||||||
|
$table->data['agent'][0] = __('Agent');
|
||||||
|
$table->data['agent'][1] = print_select (get_group_agents ($groups, false, "none"),
|
||||||
|
'id_agent', 0, false, __('Select'), 0, true);
|
||||||
|
$table->data['agent'][1] .= ' <span id="agent_loading" class="invisible">';
|
||||||
|
$table->data['agent'][1] .= '<img src="images/spinner.gif" />';
|
||||||
|
$table->data['agent'][1] .= '</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$table->data[0][0] = __('Module');
|
||||||
|
$modules = array ();
|
||||||
|
if ($id_agente)
|
||||||
|
$modules = get_agent_modules ($id_agente);
|
||||||
|
$table->data[0][1] = print_select ($modules, 'id_agent_module', 0, true,
|
||||||
|
__('Select'), 0, true, false, true, '', ($id_agente == 0));
|
||||||
|
$table->data[0][1] .= ' <span id="latest_value" class="invisible">'.__('Latest value').': ';
|
||||||
|
$table->data[0][1] .= '<span id="value"> </span></span>';
|
||||||
|
$table->data[0][1] .= ' <span id="module_loading" class="invisible">';
|
||||||
|
$table->data[0][1] .= '<img src="images/spinner.gif" /></span>';
|
||||||
|
|
||||||
|
$table->data[1][0] = __('Template');
|
||||||
|
$templates = get_alert_templates ();
|
||||||
|
if (empty ($templates))
|
||||||
|
$templates = array ();
|
||||||
|
$table->data[1][1] = print_select ($templates, 'template', '', '', __('Select'),
|
||||||
|
0, true);
|
||||||
|
$table->data[1][1] .= ' <a class="template_details invisible" href="#">
|
||||||
|
<img class="img_help" src="images/zoom.png" /></a>';
|
||||||
|
|
||||||
|
$table->data[2][0] = __('Actions');
|
||||||
|
$actions = get_alert_actions ();
|
||||||
|
if (empty ($actions))
|
||||||
|
$actions = array ();
|
||||||
|
$table->data[2][1] = '<div class="actions_container">';
|
||||||
|
foreach ($actions as $action_id => $action_name) {
|
||||||
|
$id = 'actions['.$action_id.']';
|
||||||
|
$table->data[2][1] .= print_checkbox ($id, $action_id, false, true);
|
||||||
|
$table->data[2][1] .= print_label ($action_name, 'checkbox-'.$id, true);
|
||||||
|
$table->data[2][1] .= ' <span id="advanced_'.$action_id.'" class="advanced_actions invisible">';
|
||||||
|
$table->data[2][1] .= __('From').' ';
|
||||||
|
$table->data[2][1] .= print_input_text ('fires_min['.$action_id.']', -1, '', 4, 10, true);
|
||||||
|
$table->data[2][1] .= ' '.__('to').' ';
|
||||||
|
$table->data[2][1] .= print_input_text ('fires_max['.$action_id.']', -1, '', 4, 10, true);
|
||||||
|
$table->data[2][1] .= ' '.__('matches of the alert');
|
||||||
|
$table->data[2][1] .= '</span>';
|
||||||
|
$table->data[2][1] .= '<br />';
|
||||||
|
}
|
||||||
|
$table->data[2][1] .= '</div>';
|
||||||
|
|
||||||
|
echo '<form class="add_alert_form" method="post">';
|
||||||
|
|
||||||
|
print_table ($table);
|
||||||
|
|
||||||
|
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||||
|
print_submit_button (__('Add'), 'add', false, 'class="sub next"');
|
||||||
|
print_input_hidden ('create_alert', 1);
|
||||||
|
echo '</div></form>';
|
||||||
|
|
||||||
|
echo '<form id="add_action_form" method="post" class="invisible">';
|
||||||
|
print_input_hidden ('add_action', 1);
|
||||||
|
print_input_hidden ('id_alert_module', 0);
|
||||||
|
print_select ($actions, 'action', '', '', __('None'), 0);
|
||||||
|
echo '<br />';
|
||||||
|
echo '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' » </a></span>';
|
||||||
|
echo '<span class="advanced_actions invisible">';
|
||||||
|
echo __('From').' ';
|
||||||
|
print_input_text ('fires_min', -1, '', 4, 10);
|
||||||
|
echo ' '.__('to').' ';
|
||||||
|
print_input_text ('fires_max', -1, '', 4, 10);
|
||||||
|
echo ' '.__('matches of the alert');
|
||||||
|
echo pandora_help ("alert-matches", true);
|
||||||
|
echo '</span>';
|
||||||
|
echo '<div class="right">';
|
||||||
|
print_submit_button (__('Add'), 'add_action', false, 'class="sub next"');
|
||||||
|
echo '</div>';
|
||||||
|
echo '</form>';
|
||||||
|
|
||||||
|
$config['css'][] = 'cluetip';
|
||||||
|
$config['jquery'][] = 'cluetip';
|
||||||
|
$config['jquery'][] = 'pandora.controls';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
/* <![CDATA[ */
|
/* <![CDATA[ */
|
||||||
$(document).ready (function () {
|
$(document).ready (function () {
|
||||||
|
<?php if (! $id_agente) : ?>
|
||||||
|
$("#id_group").pandoraSelectGroup ({
|
||||||
|
callbackBefore: function () {
|
||||||
|
$select = $("#id_agent_module").disable ();
|
||||||
|
$select.siblings ("span#latest_value").hide ();
|
||||||
|
$("option[value!=0]", $select).remove ();
|
||||||
|
},
|
||||||
|
callbackAfter: function () {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#id_agent").pandoraSelectAgent ();
|
||||||
|
<?php endif; ?>
|
||||||
$("a.template_details").cluetip ({
|
$("a.template_details").cluetip ({
|
||||||
arrows: true,
|
arrows: true,
|
||||||
attribute: 'href',
|
attribute: 'href',
|
||||||
cluetipClass: 'default'
|
cluetipClass: 'default'
|
||||||
}).click (function () {
|
}).click (function () {
|
||||||
return false;
|
return false;
|
||||||
});;
|
});
|
||||||
|
|
||||||
$("input[name=disable]").attr ("title", "<?php echo __('Disable')?>")
|
$("input[name=disable]").attr ("title", "<?php echo __('Disable')?>")
|
||||||
.hover (function () {
|
.hover (function () {
|
||||||
$(this).attr ("src", "images/lightbulb_off.png");
|
$(this).attr ("src", "images/lightbulb_off.png");
|
||||||
@ -150,19 +440,85 @@ $(document).ready (function () {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
$("form.disable_alert_form").submit (function () {
|
$("form.disable_alert_form").submit (function () {
|
||||||
jQuery.post ("ajax.php",
|
return true;
|
||||||
{"page" : "godmode/alerts/alert_list",
|
});
|
||||||
"enable-alert" : $("#hidden-enable_alert", this).attr ("value"),
|
|
||||||
"disable-alert" : $("#hidden-disable_alert", this).attr ("value"),
|
$("a.add_action").click (function () {
|
||||||
"id-alert" : $("#hidden-id_alert", this).attr ("value")},
|
id = this.id.split ("-").pop ();
|
||||||
function (data, status) {
|
|
||||||
$("#hidden-enable_alert", this).attr ("value", 0);
|
/* Replace link with a combo with the actions and a form */
|
||||||
$("#hidden-disable_alert", this).attr ("value", 1);
|
form = $('form#add_action_form:last').clone (true).show ();
|
||||||
},
|
$("input#hidden-id_alert_module", form).attr ("value", id);
|
||||||
"html"
|
$(this).replaceWith (form);
|
||||||
);
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("form.delete_link").submit (function () {
|
||||||
|
if (! confirm ("<?php echo __('Are you sure?')?>"))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("a.show_advanced_actions").click (function () {
|
||||||
|
/* It can be done in two different sites, so it must use two different selectors */
|
||||||
|
actions = $(this).parents ("form").children ("span.advanced_actions");
|
||||||
|
if (actions.length == 0)
|
||||||
|
actions = $(this).parents ("div").children ("span.advanced_actions")
|
||||||
|
$("#text-fires_min", actions).attr ("value", 0);
|
||||||
|
$("#text-fires_max", actions).attr ("value", 0);
|
||||||
|
$(actions).show ();
|
||||||
|
$(this).remove ();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("select#template").change (function () {
|
||||||
|
id = this.value;
|
||||||
|
$a = $(this).siblings ("a");
|
||||||
|
if (id == 0) {
|
||||||
|
$a.hide ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$a.unbind ()
|
||||||
|
.attr ("href", "ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template="+id)
|
||||||
|
.show ()
|
||||||
|
.cluetip ({
|
||||||
|
arrows: true,
|
||||||
|
attribute: 'href',
|
||||||
|
cluetipClass: 'default'
|
||||||
|
}).click (function () {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#id_agent_module").change (function () {
|
||||||
|
var $value = $(this).siblings ("span#latest_value").hide ();
|
||||||
|
var $loading = $(this).siblings ("span#module_loading").show ();
|
||||||
|
$("#value", $value).empty ();
|
||||||
|
jQuery.post ("ajax.php",
|
||||||
|
{"page" : "operation/agentes/estado_agente",
|
||||||
|
"get_agent_module_last_value" : 1,
|
||||||
|
"id_agent_module" : 1
|
||||||
|
},
|
||||||
|
function (data, status) {
|
||||||
|
if (data === false) {
|
||||||
|
$("#value", $value).append ("<em><?php echo __('Unknown') ?></em>");
|
||||||
|
} else if (data == "") {
|
||||||
|
$("#value", $value).append ("<em><?php echo __('Empty') ?></em>");
|
||||||
|
} else {
|
||||||
|
$("#value", $value).append (data);
|
||||||
|
}
|
||||||
|
$loading.hide ();
|
||||||
|
$value.show ();
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("form.add_alert_form :checkbox[name^=actions]").change (function () {
|
||||||
|
$advanced = $(this).siblings ("span#advanced_"+this.value);
|
||||||
|
$("input", $advanced).attr ("value", 0);
|
||||||
|
$advanced.toggle ();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
/* ]]> */
|
/* ]]> */
|
||||||
</script>
|
</script>
|
||||||
|
@ -710,7 +710,7 @@ $(document).ready (function () {
|
|||||||
$("#alerts_loading").show ();
|
$("#alerts_loading").show ();
|
||||||
$("#alert_list tbody").empty ();
|
$("#alert_list tbody").empty ();
|
||||||
jQuery.post ("ajax.php",
|
jQuery.post ("ajax.php",
|
||||||
{"page" : "godmode/agentes/alert_manager",
|
{"page" : "godmode/alerts/alert_list",
|
||||||
"get_agent_alerts_simple" : 1,
|
"get_agent_alerts_simple" : 1,
|
||||||
"id_agent" : this.value
|
"id_agent" : this.value
|
||||||
},
|
},
|
||||||
|
@ -448,9 +448,9 @@ function agent_changed (event, id_agent, selected) {
|
|||||||
$('#form_layout_data_editor #module').empty ();
|
$('#form_layout_data_editor #module').empty ();
|
||||||
$('#form_layout_data_editor #module').append ($('<option></option>').html ("<?php echo __('Loading'); ?>...").attr ("value", 0));
|
$('#form_layout_data_editor #module').append ($('<option></option>').html ("<?php echo __('Loading'); ?>...").attr ("value", 0));
|
||||||
jQuery.post ('ajax.php',
|
jQuery.post ('ajax.php',
|
||||||
{page: "operation/agentes/ver_agente",
|
{"page": "operation/agentes/ver_agente",
|
||||||
get_agent_modules_json: 1,
|
"get_agent_modules_json": 1,
|
||||||
id_agent: id_agent
|
"id_agent": id_agent
|
||||||
},
|
},
|
||||||
function (data) {
|
function (data) {
|
||||||
$('#form_layout_data_editor #module').empty ();
|
$('#form_layout_data_editor #module').empty ();
|
||||||
@ -479,9 +479,9 @@ $(document).ready (function () {
|
|||||||
possible to kwown the image dimensions using javascript
|
possible to kwown the image dimensions using javascript
|
||||||
in some cases where the image was not loaded */
|
in some cases where the image was not loaded */
|
||||||
jQuery.post ('ajax.php',
|
jQuery.post ('ajax.php',
|
||||||
{page: "godmode/reporting/map_builder",
|
{"page": "godmode/reporting/map_builder",
|
||||||
get_background_info: 1,
|
"get_background_info": 1,
|
||||||
background: background
|
"background": background
|
||||||
},
|
},
|
||||||
function (data) {
|
function (data) {
|
||||||
$("#layout_map").css ('backgroundImage', 'url(images/console/background/' + background + ')');
|
$("#layout_map").css ('backgroundImage', 'url(images/console/background/' + background + ')');
|
||||||
@ -529,9 +529,9 @@ $(document).ready (function () {
|
|||||||
drop: function (ev, ui) {
|
drop: function (ev, ui) {
|
||||||
id = ui.draggable[0].id.split ("-").pop ();
|
id = ui.draggable[0].id.split ("-").pop ();
|
||||||
jQuery.post ('ajax.php',
|
jQuery.post ('ajax.php',
|
||||||
{page: "godmode/reporting/map_builder",
|
{"page": "godmode/reporting/map_builder",
|
||||||
get_layout_data: 1,
|
"get_layout_data": 1,
|
||||||
id_layout_data: id
|
"id_layout_data": id
|
||||||
},
|
},
|
||||||
function (data) {
|
function (data) {
|
||||||
$("#form_layout_data_editor #text-label").attr ('value', data['label']);
|
$("#form_layout_data_editor #text-label").attr ('value', data['label']);
|
||||||
@ -568,7 +568,7 @@ $(document).ready (function () {
|
|||||||
css ('margin-top', 0). attr ('id', 'delete-layout-data-' + id).
|
css ('margin-top', 0). attr ('id', 'delete-layout-data-' + id).
|
||||||
appendTo ("#"+this.id + " #elements");
|
appendTo ("#"+this.id + " #elements");
|
||||||
$(ui.draggable[0]).remove ();
|
$(ui.draggable[0]).remove ();
|
||||||
$('<input type="hidden" name="ids_layout_data[]" />').attr ('value', id).
|
$('<input type="hidden" name="ids_layout_data[]"></input>').attr ('value', id).
|
||||||
appendTo ($("#form_layout_data_trash"));
|
appendTo ($("#form_layout_data_trash"));
|
||||||
$("#form_layout_data_trash #submit-delete_buttons").removeAttr ('disabled');
|
$("#form_layout_data_trash #submit-delete_buttons").removeAttr ('disabled');
|
||||||
setTimeout (function() { refresh_lines (lines, 'layout_map'); }, 1000);
|
setTimeout (function() { refresh_lines (lines, 'layout_map'); }, 1000);
|
||||||
@ -577,10 +577,10 @@ $(document).ready (function () {
|
|||||||
$("#form_layout_data_editor #image").change (function () {
|
$("#form_layout_data_editor #image").change (function () {
|
||||||
$("#image_preview").empty ();
|
$("#image_preview").empty ();
|
||||||
if (this.value != '') {
|
if (this.value != '') {
|
||||||
$("#image_preview").append ($('<img />').attr ('src', 'images/console/icons/' + this.value + '.png'));
|
$("#image_preview").append ($('<img></img>').attr ('src', 'images/console/icons/' + this.value + '.png'));
|
||||||
$("#image_preview").append ($('<img />').attr ('src', 'images/console/icons/' + this.value + '_ok.png'));
|
$("#image_preview").append ($('<img></img>').attr ('src', 'images/console/icons/' + this.value + '_ok.png'));
|
||||||
$("#image_preview").append ($('<img />').attr ('src', 'images/console/icons/' + this.value + '_warning.png'));
|
$("#image_preview").append ($('<img></img>').attr ('src', 'images/console/icons/' + this.value + '_warning.png'));
|
||||||
$("#image_preview").append ($('<img />').attr ('src', 'images/console/icons/' + this.value + '_bad.png'));
|
$("#image_preview").append ($('<img></img>').attr ('src', 'images/console/icons/' + this.value + '_bad.png'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("#form_layout_data_editor #agent").change (agent_changed);
|
$("#form_layout_data_editor #agent").change (agent_changed);
|
||||||
|
@ -23,11 +23,13 @@
|
|||||||
* @param int Agent id
|
* @param int Agent id
|
||||||
* @param string Filter on "fired", "notfired" or "disabled". Any other value
|
* @param string Filter on "fired", "notfired" or "disabled". Any other value
|
||||||
* will not do any filter.
|
* will not do any filter.
|
||||||
|
* @param array Extra filter options in an indexed array. See
|
||||||
|
* format_array_to_where_clause_sql()
|
||||||
*
|
*
|
||||||
* @return array All simple alerts defined for an agent. Empty array if no
|
* @return array All simple alerts defined for an agent. Empty array if no
|
||||||
* alerts found.
|
* alerts found.
|
||||||
*/
|
*/
|
||||||
function get_agent_alerts_simple ($id_agent, $filter = false) {
|
function get_agent_alerts_simple ($id_agent, $filter = '', $options = false) {
|
||||||
switch ($filter) {
|
switch ($filter) {
|
||||||
case "notfired":
|
case "notfired":
|
||||||
$filter = ' AND times_fired = 0 AND disabled = 0';
|
$filter = ' AND times_fired = 0 AND disabled = 0';
|
||||||
@ -42,10 +44,15 @@ function get_agent_alerts_simple ($id_agent, $filter = false) {
|
|||||||
$filter = '';
|
$filter = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$id_agent = (array) $id_agent;
|
||||||
$id_modules = array_keys (get_agent_modules ($id_agent));
|
$id_modules = array_keys (get_agent_modules ($id_agent));
|
||||||
if (empty ($id_modules))
|
if (empty ($id_modules))
|
||||||
return array ();
|
return array ();
|
||||||
|
|
||||||
|
if (is_array ($options)) {
|
||||||
|
$filter .= format_array_to_where_clause_sql ($options);
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf ("SELECT talert_template_modules.*
|
$sql = sprintf ("SELECT talert_template_modules.*
|
||||||
FROM talert_template_modules
|
FROM talert_template_modules
|
||||||
WHERE id_agent_module in (%s)%s",
|
WHERE id_agent_module in (%s)%s",
|
||||||
@ -62,10 +69,13 @@ function get_agent_alerts_simple ($id_agent, $filter = false) {
|
|||||||
* Get all the combined alerts of an agent.
|
* Get all the combined alerts of an agent.
|
||||||
*
|
*
|
||||||
* @param int $id_agent Agent id
|
* @param int $id_agent Agent id
|
||||||
|
* @param string Special filter. Can be: "notfired", "fired" or "disabled".
|
||||||
|
* @param array Extra filter options in an indexed array. See
|
||||||
|
* format_array_to_where_clause_sql()
|
||||||
*
|
*
|
||||||
* @return array An array with all combined alerts defined for an agent.
|
* @return array An array with all combined alerts defined for an agent.
|
||||||
*/
|
*/
|
||||||
function get_agent_alerts_compound ($id_agent, $filter = false) {
|
function get_agent_alerts_compound ($id_agent, $filter = '', $options = false) {
|
||||||
switch ($filter) {
|
switch ($filter) {
|
||||||
case "notfired":
|
case "notfired":
|
||||||
$filter = ' AND times_fired = 0 AND disabled = 0';
|
$filter = ' AND times_fired = 0 AND disabled = 0';
|
||||||
@ -80,9 +90,15 @@ function get_agent_alerts_compound ($id_agent, $filter = false) {
|
|||||||
$filter = '';
|
$filter = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_array ($options)) {
|
||||||
|
$filter .= format_array_to_where_clause_sql ($options);
|
||||||
|
}
|
||||||
|
|
||||||
|
$id_agent = array ($id_agent);
|
||||||
|
|
||||||
$sql = sprintf ("SELECT * FROM talert_compound
|
$sql = sprintf ("SELECT * FROM talert_compound
|
||||||
WHERE id_agent = %d%s",
|
WHERE id_agent in (%s)%s",
|
||||||
$id_agent, $filter);
|
implode (',', $id_agent), $filter);
|
||||||
|
|
||||||
$alerts = get_db_all_rows_sql ($sql);
|
$alerts = get_db_all_rows_sql ($sql);
|
||||||
|
|
||||||
@ -95,14 +111,16 @@ function get_agent_alerts_compound ($id_agent, $filter = false) {
|
|||||||
* Get all the alerts of an agent, simple and combined.
|
* Get all the alerts of an agent, simple and combined.
|
||||||
*
|
*
|
||||||
* @param int $id_agent Agent id
|
* @param int $id_agent Agent id
|
||||||
|
* @param string Special filter. Can be: "notfired", "fired" or "disabled".
|
||||||
|
* @param array Extra filter options in an indexed array. See
|
||||||
|
* format_array_to_where_clause_sql()
|
||||||
*
|
*
|
||||||
* @return array An array with all alerts defined for an agent.
|
* @return array An array with all alerts defined for an agent.
|
||||||
*/
|
*/
|
||||||
function get_agent_alerts ($id_agent, $filter = false) {
|
function get_agent_alerts ($id_agent, $filter = false, $options = false) {
|
||||||
$simple_alerts = get_agent_alerts_simple ($id_agent, $filter);
|
$simple_alerts = get_agent_alerts_simple ($id_agent, $filter, $options);
|
||||||
$combined_alerts = get_agent_alerts_compound ($id_agent, $filter);
|
$combined_alerts = get_agent_alerts_compound ($id_agent, $filter, $options);
|
||||||
|
|
||||||
return array ('simple' => $simple_alerts, 'compounds' => $combined_alerts);
|
return array ('simple' => $simple_alerts, 'compounds' => $combined_alerts);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -680,31 +680,29 @@ function add_alert_agent_module_action ($id_alert_agent_module, $id_alert_action
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = sprintf ('INSERT INTO talert_template_module_actions
|
$sql = sprintf ('INSERT INTO talert_template_module_actions
|
||||||
|
(id_alert_template_module, id_alert_action, fires_min, fires_max)
|
||||||
VALUES (%d, %d, %d, %d)',
|
VALUES (%d, %d, %d, %d)',
|
||||||
$id_alert_agent_module, $id_alert_action, $fires_min, $fires_max);
|
$id_alert_agent_module, $id_alert_action, $fires_min, $fires_max);
|
||||||
|
|
||||||
return @process_sql ($sql) !== false;
|
return process_sql ($sql, 'insert_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_alert_agent_module_action ($id_alert_agent_module, $id_alert_action) {
|
function delete_alert_agent_module_action ($id_alert_agent_module_action) {
|
||||||
if (empty ($id_alert_agent_module))
|
if (empty ($id_alert_agent_module_action))
|
||||||
return false;
|
|
||||||
if (empty ($id_alert_action))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$sql = sprintf ('DELETE FROM talert_template_module_actions
|
$sql = sprintf ('DELETE FROM talert_template_module_actions
|
||||||
WHERE id_alert_template_module = %d
|
WHERE id = %d',
|
||||||
AND id_alert_action = %d',
|
$id_alert_agent_module_action);
|
||||||
$id_alert_agent_module, $id_alert_action);
|
|
||||||
|
|
||||||
return @process_sql ($sql) !== false;
|
return process_sql ($sql) !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_alert_agent_module_actions ($id_alert_agent_module) {
|
function get_alert_agent_module_actions ($id_alert_agent_module) {
|
||||||
if (empty ($id_alert_agent_module))
|
if (empty ($id_alert_agent_module))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$sql = sprintf ('SELECT id_alert_action id, fires_min, fires_max
|
$sql = sprintf ('SELECT id, id_alert_action, fires_min, fires_max
|
||||||
FROM talert_template_module_actions
|
FROM talert_template_module_actions
|
||||||
WHERE id_alert_template_module = %d',
|
WHERE id_alert_template_module = %d',
|
||||||
$id_alert_agent_module);
|
$id_alert_agent_module);
|
||||||
@ -714,10 +712,10 @@ function get_alert_agent_module_actions ($id_alert_agent_module) {
|
|||||||
|
|
||||||
$retval = array ();
|
$retval = array ();
|
||||||
foreach ($actions as $element) {
|
foreach ($actions as $element) {
|
||||||
$action = get_alert_action ($element['id']);
|
$action = get_alert_action ($element['id_alert_action']);
|
||||||
$action['fires_min'] = $element['fires_min'];
|
$action['fires_min'] = $element['fires_min'];
|
||||||
$action['fires_max'] = $element['fires_max'];
|
$action['fires_max'] = $element['fires_max'];
|
||||||
array_push ($retval, $action);
|
$retval[$element['id']] = $action;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $retval;
|
return $retval;
|
||||||
|
@ -1721,7 +1721,8 @@ function format_array_to_update_sql ($values) {
|
|||||||
$values = array ();
|
$values = array ();
|
||||||
$values['name'] = "Name";
|
$values['name'] = "Name";
|
||||||
$values['description'] = "Long description";
|
$values['description'] = "Long description";
|
||||||
$sql = 'SELECT * FROM table WHERE '.format_array_to_where_sql ($values).' LIMIT 20';
|
$values['limit'] = $config['block_size']; // Assume it's 20
|
||||||
|
$sql = 'SELECT * FROM table WHERE '.format_array_to_where_sql ($values);
|
||||||
echo $sql;
|
echo $sql;
|
||||||
</code>
|
</code>
|
||||||
* Will return:
|
* Will return:
|
||||||
@ -1730,6 +1731,8 @@ function format_array_to_update_sql ($values) {
|
|||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param array Values to be formatted in an array indexed by the field name.
|
* @param array Values to be formatted in an array indexed by the field name.
|
||||||
|
* There are special parameters such as 'limit' and 'offset' that will be used
|
||||||
|
* as LIMIT and OFFSET clauses respectively.
|
||||||
* @param string Join operator. AND by default.
|
* @param string Join operator. AND by default.
|
||||||
*
|
*
|
||||||
* @return string Values joined into an SQL string that can fits into the WHERE
|
* @return string Values joined into an SQL string that can fits into the WHERE
|
||||||
@ -1743,6 +1746,8 @@ function format_array_to_where_clause_sql ($values, $join = 'AND') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$query = '';
|
$query = '';
|
||||||
|
$limit = '';
|
||||||
|
$offset = '';
|
||||||
$i = 1;
|
$i = 1;
|
||||||
$max = count ($values);
|
$max = count ($values);
|
||||||
foreach ($values as $field => $value) {
|
foreach ($values as $field => $value) {
|
||||||
@ -1750,6 +1755,16 @@ function format_array_to_where_clause_sql ($values, $join = 'AND') {
|
|||||||
/* Avoid numeric field names */
|
/* Avoid numeric field names */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if ($field == 'limit') {
|
||||||
|
$limit = sprintf (' LIMIT %d', $value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($field == 'offset') {
|
||||||
|
$offset = sprintf (' OFFSET %d', $value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($field[0] != "`") {
|
if ($field[0] != "`") {
|
||||||
$field = "`".$field."`";
|
$field = "`".$field."`";
|
||||||
}
|
}
|
||||||
@ -1770,7 +1785,7 @@ function format_array_to_where_clause_sql ($values, $join = 'AND') {
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query;
|
return $query.$limit.$offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing =
|
|||||||
$attributes .= ' disabled="disabled"';
|
$attributes .= ' disabled="disabled"';
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= '<select id="select-'.$name.'" name="'.$name.'"'.$attributes.'>';
|
$output .= '<select id="'.$name.'" name="'.$name.'"'.$attributes.'>';
|
||||||
|
|
||||||
if ($nothing != '') {
|
if ($nothing != '') {
|
||||||
$output .= '<option value="'.$nothing_value.'"';
|
$output .= '<option value="'.$nothing_value.'"';
|
||||||
|
@ -26,6 +26,7 @@ $(document).ready (function () {
|
|||||||
var $select = $("select#"+config.agentSelectId).disable ();
|
var $select = $("select#"+config.agentSelectId).disable ();
|
||||||
$("#"+config.loadingId).show ();
|
$("#"+config.loadingId).show ();
|
||||||
$("option[value!=0]", $select).remove ();
|
$("option[value!=0]", $select).remove ();
|
||||||
|
config.callbackBefore (this);
|
||||||
|
|
||||||
jQuery.post ("ajax.php",
|
jQuery.post ("ajax.php",
|
||||||
{"page" : "godmode/groups/group_list",
|
{"page" : "godmode/groups/group_list",
|
||||||
@ -53,7 +54,58 @@ $(document).ready (function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$.extend ({
|
||||||
|
pandoraSelectAgent: new function() {
|
||||||
|
this.defaults = {
|
||||||
|
moduleSelectId: "id_agent_module",
|
||||||
|
loadingId: "module_loading",
|
||||||
|
callbackBefore: dummyFunc,
|
||||||
|
callbackPre: dummyFunc,
|
||||||
|
callbackPost: dummyFunc,
|
||||||
|
callbackAfter: dummyFunc,
|
||||||
|
debug: false
|
||||||
|
};
|
||||||
|
|
||||||
|
/* public methods */
|
||||||
|
this.construct = function (settings) {
|
||||||
|
return this.each (function() {
|
||||||
|
this.config = {};
|
||||||
|
|
||||||
|
var config = $.extend (this.config, $.pandoraSelectAgent.defaults, settings);
|
||||||
|
|
||||||
|
$(this).change (function () {
|
||||||
|
var $select = $("select#"+config.moduleSelectId).disable ();
|
||||||
|
$("#"+config.loadingId).show ();
|
||||||
|
$("option[value!=0]", $select).remove ();
|
||||||
|
config.callbackBefore (this);
|
||||||
|
|
||||||
|
jQuery.post ('ajax.php',
|
||||||
|
{"page": "operation/agentes/ver_agente",
|
||||||
|
"get_agent_modules_json": 1,
|
||||||
|
"id_agent": this.value
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
jQuery.each (data, function (i, value) {
|
||||||
|
config.callbackPre ();
|
||||||
|
option = $("<option></option>")
|
||||||
|
.attr ("value", value['id_agente_modulo'])
|
||||||
|
.html (html_entity_decode (value['nombre']));
|
||||||
|
config.callbackPost (i, value, option);
|
||||||
|
$("#"+config.moduleSelectId).append (option);
|
||||||
|
});
|
||||||
|
$("#"+config.loadingId).hide ();
|
||||||
|
$select.enable ();
|
||||||
|
config.callbackAfter ();
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
$.fn.extend({
|
$.fn.extend({
|
||||||
pandoraSelectGroup: $.pandoraSelectGroup.construct
|
pandoraSelectGroup: $.pandoraSelectGroup.construct,
|
||||||
|
pandoraSelectAgent: $.pandoraSelectAgent.construct,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -879,13 +879,33 @@ fieldset {
|
|||||||
width: 90%;
|
width: 90%;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
fieldset legend span {
|
fieldset legend span,
|
||||||
|
span#latest_value {
|
||||||
font-style:italic;
|
font-style:italic;
|
||||||
|
}
|
||||||
|
span#latest_value span#value {
|
||||||
|
font-style:normal;
|
||||||
}
|
}
|
||||||
form#filter_form {
|
form#filter_form {
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
ul.action_list {
|
||||||
|
margin: 0;
|
||||||
|
list-style: none inside url(../../images/arrow.png);
|
||||||
|
}
|
||||||
|
ul.action_list li div {
|
||||||
|
margin-left: 15px;
|
||||||
|
}
|
||||||
|
div.actions_container {
|
||||||
|
overflow:auto;
|
||||||
|
width: 100%;
|
||||||
|
max-height: 200px;
|
||||||
|
}
|
||||||
|
div.actions_container label {
|
||||||
|
display: inline;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
/* timeEntry styles */
|
/* timeEntry styles */
|
||||||
.timeEntry_control {
|
.timeEntry_control {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
@ -27,6 +27,24 @@ if (! give_acl ($config['id_user'], 0, "AR")) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined ('AJAX')) {
|
||||||
|
$get_agent_module_last_value = (bool) get_parameter ('get_agent_module_last_value');
|
||||||
|
|
||||||
|
if ($get_agent_module_last_value) {
|
||||||
|
$id_module = (int) get_parameter ('id_agent_module');
|
||||||
|
|
||||||
|
if (! give_acl ($config['id_user'], get_agentmodule_group ($id_module), "AR")) {
|
||||||
|
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||||
|
"Trying to access agent main list view");
|
||||||
|
echo json_encode (false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
echo json_encode (get_agent_module_last_value ($id_module));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Take some parameters (GET)
|
// Take some parameters (GET)
|
||||||
$offset = get_parameter ("offset", 0);
|
$offset = get_parameter ("offset", 0);
|
||||||
$group_id = get_parameter ("group_id", 0);
|
$group_id = get_parameter ("group_id", 0);
|
||||||
|
@ -274,10 +274,12 @@ CREATE TABLE IF NOT EXISTS `talert_template_modules` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `talert_template_module_actions` (
|
CREATE TABLE IF NOT EXISTS `talert_template_module_actions` (
|
||||||
|
`id` int(10) unsigned NOT NULL auto_increment,
|
||||||
`id_alert_template_module` int(10) unsigned NOT NULL,
|
`id_alert_template_module` int(10) unsigned NOT NULL,
|
||||||
`id_alert_action` int(10) unsigned NOT NULL,
|
`id_alert_action` int(10) unsigned NOT NULL,
|
||||||
`fires_min` int(3) unsigned default 0,
|
`fires_min` int(3) unsigned default 0,
|
||||||
`fires_max` int(3) unsigned default 0,
|
`fires_max` int(3) unsigned default 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
FOREIGN KEY (`id_alert_template_module`) REFERENCES talert_template_modules(`id`)
|
FOREIGN KEY (`id_alert_template_module`) REFERENCES talert_template_modules(`id`)
|
||||||
ON DELETE CASCADE ON UPDATE CASCADE,
|
ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
|
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
|
||||||
|
@ -105,10 +105,12 @@ CREATE TABLE IF NOT EXISTS `talert_template_modules` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `talert_template_module_actions` (
|
CREATE TABLE IF NOT EXISTS `talert_template_module_actions` (
|
||||||
|
`id` int(10) unsigned NOT NULL auto_increment,
|
||||||
`id_alert_template_module` int(10) unsigned NOT NULL,
|
`id_alert_template_module` int(10) unsigned NOT NULL,
|
||||||
`id_alert_action` int(10) unsigned NOT NULL,
|
`id_alert_action` int(10) unsigned NOT NULL,
|
||||||
`fires_min` int(3) unsigned default 0,
|
`fires_min` int(3) unsigned default 0,
|
||||||
`fires_max` int(3) unsigned default 0,
|
`fires_max` int(3) unsigned default 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
FOREIGN KEY (`id_alert_template_module`) REFERENCES
|
FOREIGN KEY (`id_alert_template_module`) REFERENCES
|
||||||
talert_template_modules(`id`)
|
talert_template_modules(`id`)
|
||||||
ON DELETE CASCADE ON UPDATE CASCADE,
|
ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user