2010-04-05 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/jquery.pandora.controls.js: changed the page to ajax in the event "pandoraSelectAgentAlert". * include/ajax/alert_list.ajax.php: new file with the source code of ajax request. * godmode/agentes/massive_config.php: changed the page to ajax in the event "source_id_agent" in the javascript source code. * godmode/alerts/alert_list.list.php: cleaned unused javascript source code that is for use in alert_list.builder.php. * godmode/alerts/alert_list.php: erase the php ajax source code and copy to alert_list.ajax.php. And move the action messages (create, delete ...) bellow to header. * godmode/alerts/alert_list.builder.php: : cleaned unused javascript source code that is for use in alert_list.list.php. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2547 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
192c8bd3de
commit
ff24893f8a
|
@ -1,5 +1,26 @@
|
|||
2010-04-05 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/javascript/jquery.pandora.controls.js: changed the page to ajax in
|
||||
the event "pandoraSelectAgentAlert".
|
||||
|
||||
* include/ajax/alert_list.ajax.php: new file with the source code of ajax
|
||||
request.
|
||||
|
||||
* godmode/agentes/massive_config.php: changed the page to ajax in the
|
||||
event "source_id_agent" in the javascript source code.
|
||||
|
||||
* godmode/alerts/alert_list.list.php: cleaned unused javascript source code
|
||||
that is for use in alert_list.builder.php.
|
||||
|
||||
* godmode/alerts/alert_list.php: erase the php ajax source code and
|
||||
copy to alert_list.ajax.php. And move the action messages (create, delete
|
||||
...) bellow to header.
|
||||
|
||||
* godmode/alerts/alert_list.builder.php: : cleaned unused javascript source
|
||||
code that is for use in alert_list.list.php.
|
||||
|
||||
2010-04-07 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/alerts/alert_list.php: cleaned source code, added the tabs for to
|
||||
use page alone (not in agent).
|
||||
|
||||
|
@ -7,7 +28,7 @@
|
|||
|
||||
* godmode/alerts/alert_list.list.php: tab for the list of alerts.
|
||||
|
||||
2010-04-05 Miguel de Dios <miguel.dedios@artica.es>
|
||||
2010-04-07 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_agents.php: changed the functions
|
||||
"get_agent_alerts_simple" and "get_agent_alerts_compound" delete new
|
||||
|
|
|
@ -223,7 +223,7 @@ $(document).ready (function () {
|
|||
|
||||
/* Get alerts */
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "godmode/alerts/alert_list",
|
||||
{"page" : "include/ajax/alert_list.ajax",
|
||||
"get_agent_alerts_simple" : 1,
|
||||
"id_agent" : id_agent
|
||||
},
|
||||
|
|
|
@ -163,33 +163,6 @@ $(document).ready (function () {
|
|||
}
|
||||
);
|
||||
|
||||
//----------------------------
|
||||
$("#text-agent_name").autocomplete ("ajax.php",
|
||||
{
|
||||
scroll: true,
|
||||
minChars: 2,
|
||||
extraParams: {
|
||||
page: "godmode/agentes/agent_manager",
|
||||
search_parents: 1,
|
||||
id_group: function() { return $("#grupo").val(); },
|
||||
id_agent: <?php echo $id_agente ?>
|
||||
},
|
||||
formatItem: function (data, i, total) {
|
||||
if (total == 0)
|
||||
$("#text-id_parent").css ('background-color', '#cc0000');
|
||||
else
|
||||
$("#text-id_parent").css ('background-color', 'none');
|
||||
if (data == "")
|
||||
return false;
|
||||
|
||||
return data[0]+'<br><span class="ac_extra_field"><?php echo __("IP") ?>: '+data[1]+'</span>';
|
||||
},
|
||||
delay: 200
|
||||
}
|
||||
);
|
||||
//----------------------------
|
||||
|
||||
|
||||
<?php if (! $id_agente) : ?>
|
||||
$("#id_group").pandoraSelectGroupAgent ({
|
||||
callbackBefore: function () {
|
||||
|
@ -199,70 +172,7 @@ $(document).ready (function () {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
//$("#id_agent").pandoraSelectAgentModule ();
|
||||
<?php endif; ?>
|
||||
$("a.template_details").cluetip ({
|
||||
arrows: true,
|
||||
attribute: 'href',
|
||||
cluetipClass: 'default'
|
||||
}).click (function () {
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#tgl_alert_control").click (function () {
|
||||
$("#alert_control").toggle ();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("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");
|
||||
}
|
||||
);
|
||||
$("form.disable_alert_form").submit (function () {
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
$("a.add_action").click (function () {
|
||||
id = this.id.split ("-").pop ();
|
||||
|
||||
/* Replace link with a combo with the actions and a form */
|
||||
$form = $('form#add_action_form:last').clone (true).show ();
|
||||
$("input#hidden-id_alert_module", $form).attr ("value", id);
|
||||
$(this).replaceWith ($form);
|
||||
return false;
|
||||
});
|
||||
|
||||
$("form.delete_link, form.delete_alert_form").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;
|
||||
|
|
|
@ -313,66 +313,6 @@ require_jquery_file ('autocomplete');
|
|||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
$(document).ready (function () {
|
||||
|
||||
$("#text_id_agent").autocomplete(
|
||||
"ajax.php",
|
||||
{
|
||||
minChars: 2,
|
||||
scroll:true,
|
||||
extraParams: {
|
||||
page: "operation/agentes/exportdata",
|
||||
search_agents: 1,
|
||||
id_group: function() { return $("#id_group").val(); }
|
||||
},
|
||||
formatItem: function (data, i, total) {
|
||||
if (total == 0)
|
||||
$("#text_id_agent").css ('background-color', '#cc0000');
|
||||
else
|
||||
$("#text_id_agent").css ('background-color', '');
|
||||
if (data == "")
|
||||
return false;
|
||||
|
||||
return data[0]+'<br><span class="ac_extra_field"><?php echo __("IP") ?>: '+data[1]+'</span>';
|
||||
},
|
||||
delay: 200
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$("#text_id_agent").result (
|
||||
function () {
|
||||
selectAgent = true;
|
||||
var agent_name = this.value;
|
||||
$('#id_agent_module').fadeOut ('normal', function () {
|
||||
$('#id_agent_module').empty ();
|
||||
var inputs = [];
|
||||
inputs.push ("agent_name=" + agent_name);
|
||||
inputs.push ('filter=delete_pending = 0');
|
||||
inputs.push ("get_agent_modules_json=1");
|
||||
inputs.push ("page=operation/agentes/ver_agente");
|
||||
jQuery.ajax ({
|
||||
data: inputs.join ("&"),
|
||||
type: 'GET',
|
||||
url: action="ajax.php",
|
||||
timeout: 10000,
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
$('#id_agent_module').append ($('<option></option>').attr ('value', 0).text ("--"));
|
||||
jQuery.each (data, function (i, val) {
|
||||
s = js_html_entity_decode (val['nombre']);
|
||||
$('#id_agent_module').append ($('<option></option>').attr ('value', val['id_agente_modulo']).text (s));
|
||||
});
|
||||
$('#id_agent_module').enable();
|
||||
$('#id_agent_module').fadeIn ('normal');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
//----------------------------
|
||||
$("#text-agent_name").autocomplete ("ajax.php",
|
||||
{
|
||||
scroll: true,
|
||||
|
@ -472,104 +412,6 @@ $(document).ready (function () {
|
|||
$(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;
|
||||
});
|
||||
|
||||
$("#action_select").hide();
|
||||
$("#action_select").html('');
|
||||
$("#action_loading").show ();
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "operation/agentes/estado_agente",
|
||||
"get_actions_alert_template" : 1,
|
||||
"id_template" : this.value
|
||||
},
|
||||
function (data, status) {
|
||||
option = $("<option></option>")
|
||||
.attr ("value", '0')
|
||||
.append ('<?php echo __('None'); ?>');
|
||||
$("#action_select").append (option);
|
||||
|
||||
if (data == false) {
|
||||
//There aren't any action
|
||||
}
|
||||
else {
|
||||
if (data != '') {
|
||||
jQuery.each (data, function (i, val) {
|
||||
option = $("<option></option>")
|
||||
.attr ("value", val["id"])
|
||||
.append (val["name"]);
|
||||
|
||||
if (val["sort_order"] == 1)
|
||||
option.attr ("selected", true);
|
||||
|
||||
$("#action_select").append (option);
|
||||
});
|
||||
}
|
||||
$('#advanced_action').show();
|
||||
}
|
||||
$("#action_loading").hide ();
|
||||
$("#action_select").show();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
});
|
||||
|
||||
$("#action_select").change(function () {
|
||||
if ($("#action_select").attr ("value") != '0') {
|
||||
$('#advanced_action').show();
|
||||
}
|
||||
else {
|
||||
$('#advanced_action').hide();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$("#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" : this.value
|
||||
},
|
||||
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>
|
|
@ -29,71 +29,6 @@ require_once ('include/functions_agents.php');
|
|||
require_once ('include/functions_alerts.php');
|
||||
$isFunctionPolicies = enterprise_include ('include/functions_policies.php');
|
||||
|
||||
if (is_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'], $_SERVER['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)) {
|
||||
|
@ -120,6 +55,8 @@ $fieldContent = get_parameter('field_content','');
|
|||
$searchType = get_parameter('search_type','');
|
||||
$priority = get_parameter('priority','');
|
||||
|
||||
$messageAction = '';
|
||||
|
||||
if ($create_alert) {
|
||||
$id_alert_template = (int) get_parameter ('template');
|
||||
$id_agent_module = (int) get_parameter ('id_agent_module');
|
||||
|
@ -128,7 +65,7 @@ if ($create_alert) {
|
|||
FROM talert_template_modules
|
||||
WHERE id_agent_module = " . $id_agent_module . "
|
||||
AND id_alert_template = " . $id_alert_template) > 0) {
|
||||
print_result_message (false, '', __('Already added'));
|
||||
$messageAction = print_result_message (false, '', __('Already added'), '', true);
|
||||
}
|
||||
else {
|
||||
$id = create_alert_agent_module ($id_agent_module, $id_alert_template);
|
||||
|
@ -140,9 +77,7 @@ if ($create_alert) {
|
|||
audit_db ($config["id_user"],$_SERVER['REMOTE_ADDR'], "Alert management",
|
||||
"Added alert '$alert_template_name' for module '$module_name' in agent '$agent_name'");
|
||||
|
||||
print_result_message ($id,
|
||||
__('Successfully created'),
|
||||
__('Could not be created'));
|
||||
$messageAction = print_result_message ($id, __('Successfully created'), __('Could not be created'), '', true);
|
||||
if ($id !== false) {
|
||||
$action_select = get_parameter('action_select');
|
||||
|
||||
|
@ -171,9 +106,7 @@ if ($delete_alert) {
|
|||
"Deleted alert '$alert_template_name' for module '$module_name' in agent '$agent_name'");
|
||||
|
||||
$result = delete_alert_agent_module ($id_alert_agent_module);
|
||||
print_result_message ($id,
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted'));
|
||||
$messageAction = print_result_message ($id, __('Successfully deleted'), __('Could not be deleted'), '', true);
|
||||
}
|
||||
|
||||
if ($add_action) {
|
||||
|
@ -188,9 +121,7 @@ if ($add_action) {
|
|||
$values['fires_max'] = $fires_max;
|
||||
|
||||
$result = add_alert_agent_module_action ($id_alert_module, $id_action, $values);
|
||||
print_result_message ($id,
|
||||
__('Successfully added'),
|
||||
__('Could not be added'));
|
||||
$messageAction = print_result_message ($id, __('Successfully added'), __('Could not be added'), '', true);
|
||||
}
|
||||
|
||||
if ($delete_action) {
|
||||
|
@ -198,32 +129,39 @@ if ($delete_action) {
|
|||
$id_alert = (int) get_parameter ('id_alert');
|
||||
|
||||
$result = delete_alert_agent_module_action ($id_action);
|
||||
print_result_message ($id,
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted'));
|
||||
$messageAction = print_result_message ($id, __('Successfully deleted'), __('Could not be deleted'), '', true);
|
||||
}
|
||||
|
||||
if ($enable_alert) {
|
||||
$id_alert = (int) get_parameter ('id_alert');
|
||||
|
||||
$result = set_alerts_agent_module_disable ($id_alert, false);
|
||||
print_result_message ($result,
|
||||
__('Successfully enabled'),
|
||||
__('Could not be enabled'));
|
||||
$messageAction = print_result_message ($result, __('Successfully enabled'), __('Could not be enabled'), '', true);
|
||||
}
|
||||
|
||||
if ($disable_alert) {
|
||||
$id_alert = (int) get_parameter ('id_alert');
|
||||
|
||||
$result = set_alerts_agent_module_disable ($id_alert, true);
|
||||
print_result_message ($result,
|
||||
__('Successfully disabled'),
|
||||
__('Could not be disabled'));
|
||||
$messageAction = print_result_message ($result, __('Successfully disabled'), __('Could not be disabled'), '', true);
|
||||
}
|
||||
|
||||
// Header
|
||||
if ($id_agente) {
|
||||
$agents = array ($id_agente => get_agent_name ($id_agente));
|
||||
|
||||
if ($group == 1) {
|
||||
$groups = get_user_groups ();
|
||||
}
|
||||
else {
|
||||
$groups = array(1 => __('All'));
|
||||
}
|
||||
|
||||
echo $messageAction;
|
||||
|
||||
require_once('godmode/alerts/alert_list.list.php');
|
||||
require_once('godmode/alerts/alert_list.builder.php');
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$buttons = array(
|
||||
|
@ -240,6 +178,8 @@ else {
|
|||
|
||||
print_page_header(__('Alerts') . ' » ' . __('Manage alerts') . ' » ' . __('List'), "images/god2.png", false, "manage_alert_list", true, $buttons);
|
||||
|
||||
echo $messageAction;
|
||||
|
||||
switch ($tab) {
|
||||
case 'list':
|
||||
if ($group == 1) {
|
||||
|
@ -265,657 +205,5 @@ else {
|
|||
return;
|
||||
break;
|
||||
}
|
||||
// print_page_header (__('Alerts').' » '.__('Manage alerts'), "images/god2.png", false, "", true);
|
||||
// $groups = get_user_groups ();
|
||||
// $agents = get_group_agents (array_keys ($groups), false, "none");
|
||||
}
|
||||
|
||||
echo '<a href="#" id="tgl_alert_control"><b>'.__('Alert control filter').'</b> '.print_image ("images/down.png", true, array ("title" => __('Toggle filter(s)'))).'</a><br><br>';
|
||||
|
||||
//INI DIV OF FORM FILTER
|
||||
echo "<div id='alert_control' style='display:none'>\n";
|
||||
// Table for filter controls
|
||||
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/alert_list&refr='.$config["refr"].'&pure='.$config["pure"].'">';
|
||||
echo "<input type='hidden' name='search' value='1' />\n";
|
||||
echo '<table style="width: 550px;" cellpadding="4" cellspacing="4" class="databox">'."\n";
|
||||
echo "<tr>\n";
|
||||
echo "<td>".__('Template name')."</td><td>";
|
||||
print_input_text ('template_name', $templateName, '', 15);
|
||||
echo "</td>\n";
|
||||
$temp = get_agents();
|
||||
$arrayAgents = array();
|
||||
foreach ($temp as $agentElement) {
|
||||
$arrayAgents[$agentElement['id_agente']] = $agentElement['nombre'];
|
||||
}
|
||||
echo "<td>".__('Agents')."</td><td>";
|
||||
echo print_input_text_extended ('agent_name', $agentName, 'text-agent_name', '', 25, 100, false, '',
|
||||
array('style' => 'background: url(images/lightning.png) no-repeat right;'), true)
|
||||
. '<a href="#" class="tip"> <span>' . __("Type at least two characters to search") . '</span></a>';
|
||||
echo "</td>\n";
|
||||
|
||||
|
||||
echo "<td>".__('Module name')."</td><td>";
|
||||
print_input_text ('module_name', $moduleName, '', 15);
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
$temp = get_db_all_rows_sql("SELECT id, name FROM talert_actions;");
|
||||
$arrayActions = array();
|
||||
if (is_array($temp)) {
|
||||
foreach ($temp as $actionElement) {
|
||||
$arrayActions[$actionElement['id']] = $actionElement['name'];
|
||||
}
|
||||
}
|
||||
echo "<td>".__('Actions')."</td><td>";
|
||||
print_select ($arrayActions, "action_id", $actionID, '', __('All'),-1);
|
||||
echo "</td>\n";
|
||||
echo "<td>".__('Field content')."</td><td>";
|
||||
print_input_text ('field_content', $fieldContent, '', 15);
|
||||
echo "</td>\n";
|
||||
echo "<td>".__('Priority')."</td><td>";
|
||||
print_select (get_priorities (), 'priority',$priority, '', __('All'),-1);
|
||||
echo "</td>";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td colspan='6' align='right'>";
|
||||
print_submit_button (__('Update'), '', false, 'class="sub upd"');
|
||||
echo "</td>";
|
||||
echo "</tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
echo "</div>\n";
|
||||
//END DIV OF FORM FILTER
|
||||
|
||||
$simple_alerts = array();
|
||||
|
||||
if ($id_agente) {
|
||||
$simple_alerts = get_agent_alerts_simple (array_keys ($agents), '', false, '', false, 'agent_module_name');
|
||||
} else {
|
||||
$total = 0;
|
||||
$where = '';
|
||||
if (!empty ($agents)) {
|
||||
$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)));
|
||||
|
||||
if (get_parameter('search',0)) {
|
||||
if ($priority != -1 )
|
||||
$where .= " AND priority = " . $priority;
|
||||
if (strlen(trim($templateName)) > 0)
|
||||
$where .= " AND id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE '%" . trim($templateName) . "%')";
|
||||
if (strlen(trim($fieldContent)) > 0)
|
||||
$where .= " AND id_alert_template IN (SELECT id FROM talert_templates
|
||||
WHERE field1 LIKE '%" . trim($fieldContent) . "%' OR field2 LIKE '%" . trim($fieldContent) . "%' OR
|
||||
field3 LIKE '%" . trim($fieldContent) . "%' OR
|
||||
field2_recovery LIKE '%" . trim($fieldContent) . "%' OR
|
||||
field3_recovery LIKE '%" . trim($fieldContent) . "%')";
|
||||
if (strlen(trim($moduleName)) > 0)
|
||||
$where .= " AND id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE '%" . trim($moduleName) . "%')";
|
||||
//if ($agentID != -1)
|
||||
//$where .= " AND id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = " . $agentID . ")";
|
||||
if (strlen(trim($agentName)) > 0)
|
||||
$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
|
||||
FROM tagente AS t1 INNER JOIN tagente_modulo AS t2 ON t1.id_agente = t2.id_agente
|
||||
WHERE t1.nombre LIKE '" . trim($agentName) . "')";
|
||||
if ($actionID != -1)
|
||||
$where .= " AND id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action = " . $actionID . ")";
|
||||
}
|
||||
|
||||
$total = get_db_sql ($sql.$where);
|
||||
}
|
||||
pagination ($total, 'index.php?sec=gagente&sec2=godmode/alerts/alert_list');
|
||||
$simple_alerts = get_agent_alerts_simple (array_keys ($agents), array('priority' => $priority),
|
||||
array ('offset' => (int) get_parameter ('offset'),
|
||||
'limit' => $config['block_size']), $where);
|
||||
}
|
||||
|
||||
$table->class = 'alert_list';
|
||||
$table->width = '90%';
|
||||
$table->size = array ();
|
||||
$table->head = array ();
|
||||
$table->head[0] = "<span title='" . __('Enabled / Disabled') . "'>" . __('E/D') . "</span>";
|
||||
if (! $id_agente) {
|
||||
$table->style = array ();
|
||||
$table->style[1] = 'font-weight: bold';
|
||||
$table->head[1] = __('Agent');
|
||||
$table->size[0] = '20px';
|
||||
$table->size[1] = '15%';
|
||||
$table->size[2] = '20%';
|
||||
$table->size[3] = '15%';
|
||||
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
|
||||
$table->size[4] = '20px';
|
||||
}
|
||||
$table->size[5] = '50%';
|
||||
} else {
|
||||
/* Different sizes or the layout screws up */
|
||||
$table->size[0] = '20px';
|
||||
$table->size[2] = '30%';
|
||||
$table->size[3] = '20%';
|
||||
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
|
||||
$table->size[4] = '20px';
|
||||
}
|
||||
$table->size[5] = '50%';
|
||||
}
|
||||
$table->head[2] = __('Module');
|
||||
$table->head[3] = __('Template');
|
||||
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
|
||||
$table->head[4] = "<span title='" . __('Policy') . "'>" . __('P.') . "</span>";
|
||||
}
|
||||
$table->head[5] = __('Actions');
|
||||
$table->head[6] = __('Status');
|
||||
$table->head[7] = '';
|
||||
|
||||
$table->data = array ();
|
||||
|
||||
$rowPair = true;
|
||||
$iterator = 0;
|
||||
|
||||
foreach ($simple_alerts as $alert) {
|
||||
if ($alert['disabled']) {
|
||||
$table->rowstyle[$iterator] = 'font-style: italic; color: #aaaaaa;';
|
||||
$table->style[$iterator][1] = 'font-style: italic; color: #aaaaaa;';
|
||||
}
|
||||
|
||||
if ($rowPair)
|
||||
$table->rowclass[$iterator] = 'rowPair';
|
||||
else
|
||||
$table->rowclass[$iterator] = 'rowOdd';
|
||||
$rowPair = !$rowPair;
|
||||
$iterator++;
|
||||
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<form class="disable_alert_form" method="post" style="display: inline;">';
|
||||
if ($alert['disabled']) {
|
||||
$data[0] .= print_input_image ('enable', 'images/lightbulb_off.png', 1, '', true);
|
||||
$data[0] .= print_input_hidden ('enable_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>';
|
||||
|
||||
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.'">';
|
||||
if ($alert['disabled'])
|
||||
$data[1] .= '<span style="font-style: italic; color: #aaaaaa;">';
|
||||
$data[1] .= get_agent_name ($id_agent);
|
||||
if ($alert['disabled'])
|
||||
$data[1] .= '</span>';
|
||||
$data[1] .= '</a>';
|
||||
|
||||
}
|
||||
$data[2] = get_agentmodule_name ($alert['id_agent_module']);
|
||||
$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> ';
|
||||
|
||||
$data[3] .= "<a href='index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&id=".$alert['id_alert_template']."'>";
|
||||
$data[3] .= get_alert_template_name ($alert['id_alert_template']);
|
||||
$data[3] .= "</a>";
|
||||
|
||||
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
|
||||
$policyInfo = isAlertInPolicy($alert['id_agent_module'], $alert['id_alert_template'], false);
|
||||
if ($policyInfo === false)
|
||||
$data[4] = '';
|
||||
else {
|
||||
$img = 'images/policies.png';
|
||||
|
||||
$data[4] = '<a href="?sec=gpolicies&sec2=enterprise/godmode/policies/policies&id=' . $policyInfo['id_policy'] . '">' .
|
||||
print_image($img,true, array('title' => $policyInfo['name_policy'])) .
|
||||
'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$actions = get_alert_agent_module_actions ($alert['id']);
|
||||
|
||||
|
||||
if (empty($actions)){
|
||||
// Get and show default actions for this alert
|
||||
$default_action = get_db_sql ("SELECT id_alert_action FROM talert_templates WHERE id = ".$alert["id_alert_template"]);
|
||||
if ($default_action != ""){
|
||||
$data[5] = __("Default"). " : ".get_db_sql ("SELECT name FROM talert_actions WHERE id = $default_action");
|
||||
}
|
||||
|
||||
} else {
|
||||
$data[5] = '<ul class="action_list">';
|
||||
foreach ($actions as $action_id => $action) {
|
||||
$data[5] .= '<li><div>';
|
||||
if ($alert['disabled'])
|
||||
$data[5] .= '<span class="action_name" style="font-style: italic; color: #aaaaaa;">';
|
||||
else
|
||||
$data[5] .= '<span class="action_name">';
|
||||
$data[5] .= $action['name'];
|
||||
$data[5] .= ' <em>(';
|
||||
if ($action['fires_min'] == $action['fires_max']) {
|
||||
if ($action['fires_min'] == 0)
|
||||
$data[5] .= __('Always');
|
||||
else
|
||||
$data[5] .= __('On').' '.$action['fires_min'];
|
||||
} else {
|
||||
if ($action['fires_min'] == 0)
|
||||
$data[5] .= __('Until').' '.$action['fires_max'];
|
||||
else
|
||||
$data[5] .= __('From').' '.$action['fires_min'].
|
||||
' '.__('to').' '.$action['fires_max'];
|
||||
}
|
||||
|
||||
$data[5] .= ')</em>';
|
||||
$data[5] .= '</span>';
|
||||
$data[5] .= ' <span class="delete" style="clear:right">';
|
||||
$data[5] .= '<form method="post" class="delete_link">';
|
||||
$data[5] .= print_input_image ('delete', 'images/cross.png', 1, '', true);
|
||||
$data[5] .= print_input_hidden ('delete_action', 1, true);
|
||||
$data[5] .= print_input_hidden ('id_alert', $alert['id'], true);
|
||||
$data[5] .= print_input_hidden ('id_action', $action_id, true);
|
||||
$data[5] .= '</form>';
|
||||
$data[5] .= '</span>';
|
||||
$data[5] .= '</div></li>';
|
||||
}
|
||||
$data[5] .= '</ul>';
|
||||
}
|
||||
|
||||
|
||||
$data[5] .= '<a class="add_action" id="add-action-'.$alert['id'].'" href="#">';
|
||||
$data[5] .= print_image ('images/add.png', true);
|
||||
if ($alert['disabled'])
|
||||
$data[5] .= ' '. '<span style="font-style: italic; color: #aaaaaa;">' .__('Add action') . '</span>';
|
||||
else
|
||||
$data[5] .= ' ' . __('Add action');
|
||||
$data[5] .= '</a>';
|
||||
|
||||
$status = STATUS_ALERT_NOT_FIRED;
|
||||
$title = "";
|
||||
|
||||
if ($alert["times_fired"] > 0) {
|
||||
$status = STATUS_ALERT_FIRED;
|
||||
$title = __('Alert fired').' '.$alert["times_fired"].' '.__('times');
|
||||
} elseif ($alert["disabled"] > 0) {
|
||||
$status = STATUS_ALERT_DISABLED;
|
||||
$title = __('Alert disabled');
|
||||
} else {
|
||||
$status = STATUS_ALERT_NOT_FIRED;
|
||||
$title = __('Alert not fired');
|
||||
}
|
||||
|
||||
$data[6] = "<center>" . print_status_image($status, $title, true) . "</center>";
|
||||
|
||||
$data[7] = '<form class="delete_alert_form" method="post" style="display: inline;">';
|
||||
|
||||
$data[7] .= print_input_image ('delete', 'images/cross.png', 1, '', true);
|
||||
$data[7] .= print_input_hidden ('delete_alert', 1, true);
|
||||
$data[7] .= print_input_hidden ('id_alert', $alert['id'], true);
|
||||
$data[7] .= '</form>';
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
if (isset($data)){
|
||||
print_table ($table);
|
||||
} else {
|
||||
echo "<div class='nf'>".__('No alerts defined')."</div>";
|
||||
}
|
||||
|
||||
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_input_text_extended ('id_agent', __('Select'), 'text_id_agent', '', 30, 100, false, '',
|
||||
array('style' => 'background: url(images/lightning.png) no-repeat right;'), true)
|
||||
. '<a href="#" class="tip"> <span>' . __("Type at least two characters to search") . '</span></a>';
|
||||
}
|
||||
|
||||
$table->data[0][0] = __('Module');
|
||||
$modules = array ();
|
||||
if ($id_agente)
|
||||
$modules = get_agent_modules ($id_agente, false, array("delete_pending" => 0));
|
||||
|
||||
$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.png" /></span>';
|
||||
|
||||
$table->data[1][0] = __('Template');
|
||||
$templates = get_alert_templates (false, array ('id', 'name'));
|
||||
$table->data[1][1] = print_select (index_array ($templates, 'id', 'name'),
|
||||
'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 = array ('0' => __('None'));
|
||||
|
||||
$table->data[2][1] = '<div class="actions_container">';
|
||||
$table->data[2][1] = print_select($actions,'action_select','','','','',true);
|
||||
$table->data[2][1] .= ' <span id="action_loading" class="invisible">';
|
||||
$table->data[2][1] .= '<img src="images/spinner.png" /></span>';
|
||||
$table->data[2][1] .= ' <span id="advanced_action" class="advanced_actions invisible">';
|
||||
$table->data[2][1] .= __('Number of alerts match from').' ';
|
||||
$table->data[2][1] .= print_input_text ('fires_min', '', '', 4, 10, true);
|
||||
$table->data[2][1] .= ' '.__('to').' ';
|
||||
$table->data[2][1] .= print_input_text ('fires_max', '', '', 4, 10, true);
|
||||
$table->data[2][1] .= print_help_icon ("alert-matches", true);
|
||||
$table->data[2][1] .= '</span>';
|
||||
$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);
|
||||
$actions = get_alert_actions ();
|
||||
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 __('Number of alerts match from').' ';
|
||||
print_input_text ('fires_min', -1, '', 4, 10);
|
||||
echo ' '.__('to').' ';
|
||||
print_input_text ('fires_max', -1, '', 4, 10);
|
||||
echo print_help_icon ("alert-matches", true);
|
||||
echo '</span>';
|
||||
echo '<div class="right">';
|
||||
print_submit_button (__('Add'), 'add_action', false, 'class="sub next"');
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
require_css_file ('cluetip');
|
||||
require_jquery_file ('cluetip');
|
||||
require_jquery_file ('pandora.controls');
|
||||
require_jquery_file ('bgiframe');
|
||||
require_jquery_file ('autocomplete');
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
$(document).ready (function () {
|
||||
|
||||
$("#text_id_agent").autocomplete(
|
||||
"ajax.php",
|
||||
{
|
||||
minChars: 2,
|
||||
scroll:true,
|
||||
extraParams: {
|
||||
page: "operation/agentes/exportdata",
|
||||
search_agents: 1,
|
||||
id_group: function() { return $("#id_group").val(); }
|
||||
},
|
||||
formatItem: function (data, i, total) {
|
||||
if (total == 0)
|
||||
$("#text_id_agent").css ('background-color', '#cc0000');
|
||||
else
|
||||
$("#text_id_agent").css ('background-color', '');
|
||||
if (data == "")
|
||||
return false;
|
||||
|
||||
return data[0]+'<br><span class="ac_extra_field"><?php echo __("IP") ?>: '+data[1]+'</span>';
|
||||
},
|
||||
delay: 200
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$("#text_id_agent").result (
|
||||
function () {
|
||||
selectAgent = true;
|
||||
var agent_name = this.value;
|
||||
$('#id_agent_module').fadeOut ('normal', function () {
|
||||
$('#id_agent_module').empty ();
|
||||
var inputs = [];
|
||||
inputs.push ("agent_name=" + agent_name);
|
||||
inputs.push ('filter=delete_pending = 0');
|
||||
inputs.push ("get_agent_modules_json=1");
|
||||
inputs.push ("page=operation/agentes/ver_agente");
|
||||
jQuery.ajax ({
|
||||
data: inputs.join ("&"),
|
||||
type: 'GET',
|
||||
url: action="ajax.php",
|
||||
timeout: 10000,
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
$('#id_agent_module').append ($('<option></option>').attr ('value', 0).text ("--"));
|
||||
jQuery.each (data, function (i, val) {
|
||||
s = js_html_entity_decode (val['nombre']);
|
||||
$('#id_agent_module').append ($('<option></option>').attr ('value', val['id_agente_modulo']).text (s));
|
||||
});
|
||||
$('#id_agent_module').enable();
|
||||
$('#id_agent_module').fadeIn ('normal');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
//----------------------------
|
||||
$("#text-agent_name").autocomplete ("ajax.php",
|
||||
{
|
||||
scroll: true,
|
||||
minChars: 2,
|
||||
extraParams: {
|
||||
page: "godmode/agentes/agent_manager",
|
||||
search_parents: 1,
|
||||
id_group: function() { return $("#grupo").val(); },
|
||||
id_agent: <?php echo $id_agente ?>
|
||||
},
|
||||
formatItem: function (data, i, total) {
|
||||
if (total == 0)
|
||||
$("#text-id_parent").css ('background-color', '#cc0000');
|
||||
else
|
||||
$("#text-id_parent").css ('background-color', 'none');
|
||||
if (data == "")
|
||||
return false;
|
||||
|
||||
return data[0]+'<br><span class="ac_extra_field"><?php echo __("IP") ?>: '+data[1]+'</span>';
|
||||
},
|
||||
delay: 200
|
||||
}
|
||||
);
|
||||
//----------------------------
|
||||
|
||||
|
||||
<?php if (! $id_agente) : ?>
|
||||
$("#id_group").pandoraSelectGroupAgent ({
|
||||
callbackBefore: function () {
|
||||
$select = $("#id_agent_module").disable ();
|
||||
$select.siblings ("span#latest_value").hide ();
|
||||
$("option[value!=0]", $select).remove ();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
//$("#id_agent").pandoraSelectAgentModule ();
|
||||
<?php endif; ?>
|
||||
$("a.template_details").cluetip ({
|
||||
arrows: true,
|
||||
attribute: 'href',
|
||||
cluetipClass: 'default'
|
||||
}).click (function () {
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#tgl_alert_control").click (function () {
|
||||
$("#alert_control").toggle ();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("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");
|
||||
}
|
||||
);
|
||||
$("form.disable_alert_form").submit (function () {
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
$("a.add_action").click (function () {
|
||||
id = this.id.split ("-").pop ();
|
||||
|
||||
/* Replace link with a combo with the actions and a form */
|
||||
$form = $('form#add_action_form:last').clone (true).show ();
|
||||
$("input#hidden-id_alert_module", $form).attr ("value", id);
|
||||
$(this).replaceWith ($form);
|
||||
return false;
|
||||
});
|
||||
|
||||
$("form.delete_link, form.delete_alert_form").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;
|
||||
});
|
||||
|
||||
$("#action_select").hide();
|
||||
$("#action_select").html('');
|
||||
$("#action_loading").show ();
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "operation/agentes/estado_agente",
|
||||
"get_actions_alert_template" : 1,
|
||||
"id_template" : this.value
|
||||
},
|
||||
function (data, status) {
|
||||
option = $("<option></option>")
|
||||
.attr ("value", '0')
|
||||
.append ('<?php echo __('None'); ?>');
|
||||
$("#action_select").append (option);
|
||||
|
||||
if (data == false) {
|
||||
//There aren't any action
|
||||
}
|
||||
else {
|
||||
if (data != '') {
|
||||
jQuery.each (data, function (i, val) {
|
||||
option = $("<option></option>")
|
||||
.attr ("value", val["id"])
|
||||
.append (val["name"]);
|
||||
|
||||
if (val["sort_order"] == 1)
|
||||
option.attr ("selected", true);
|
||||
|
||||
$("#action_select").append (option);
|
||||
});
|
||||
}
|
||||
$('#advanced_action').show();
|
||||
}
|
||||
$("#action_loading").hide ();
|
||||
$("#action_select").show();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
});
|
||||
|
||||
$("#action_select").change(function () {
|
||||
if ($("#action_select").attr ("value") != '0') {
|
||||
$('#advanced_action').show();
|
||||
}
|
||||
else {
|
||||
$('#advanced_action').hide();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$("#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" : this.value
|
||||
},
|
||||
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>
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org 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.
|
||||
|
||||
global $config;
|
||||
|
||||
// Login check
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "LW")) {
|
||||
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once ('include/functions_agents.php');
|
||||
require_once ('include/functions_alerts.php');
|
||||
$isFunctionPolicies = enterprise_include ('include/functions_policies.php');
|
||||
|
||||
$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'], $_SERVER['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;
|
||||
?>
|
|
@ -142,7 +142,7 @@
|
|||
return;
|
||||
|
||||
jQuery.post ('ajax.php',
|
||||
{"page": "godmode/alerts/alert_list",
|
||||
{"page": "include/ajax/alert_list.ajax",
|
||||
"get_agent_alerts_simple": 1,
|
||||
"id_agent": this.value
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue