2013-02-20 Miguel de Dios <miguel.dedios@artica.es>

* godmode/servers/recon_script.php, godmode/servers/plugin.php,
	godmode/snmpconsole/snmp_filters.php,
	godmode/massive/massive_delete_alerts.php,
	godmode/massive/massive_enable_disable_alerts.php,
	godmode/massive/massive_edit_agents.php,
	godmode/massive/massive_delete_modules.php,
	godmode/massive/massive_add_action_alerts.php,
	godmode/massive/massive_delete_action_alerts.php: improved the code
	style.
	
	* include/ajax/events.php, include/functions_events.php,
	operation/agentes/custom_fields.php: fixed the show admin custom
	fields for user without permisitions.
	
	Fixes: #3605278




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7683 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-02-20 12:07:00 +00:00
parent cdc431f8b8
commit 067b5a1d8b
13 changed files with 191 additions and 136 deletions

View File

@ -1,3 +1,21 @@
2013-02-20 Miguel de Dios <miguel.dedios@artica.es>
* godmode/servers/recon_script.php, godmode/servers/plugin.php,
godmode/snmpconsole/snmp_filters.php,
godmode/massive/massive_delete_alerts.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_edit_agents.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_add_action_alerts.php,
godmode/massive/massive_delete_action_alerts.php: improved the code
style.
* include/ajax/events.php, include/functions_events.php,
operation/agentes/custom_fields.php: fixed the show admin custom
fields for user without permisitions.
Fixes: #3605278
2013-02-19 Ramon Novoa <rnovoa@artica.es> 2013-02-19 Ramon Novoa <rnovoa@artica.es>
* include/auth/ldap.php: Do not bind anonymously to check whether the * include/auth/ldap.php: Do not bind anonymously to check whether the

View File

@ -29,14 +29,14 @@ require_once ('include/functions_users.php');
if (is_ajax ()) { if (is_ajax ()) {
$get_alerts = (bool) get_parameter ('get_alerts'); $get_alerts = (bool) get_parameter ('get_alerts');
if ($get_alerts) { if ($get_alerts) {
$id_agents = get_parameter ('id_agents'); $id_agents = get_parameter ('id_agents');
if (empty($id_agents)) { if (empty($id_agents)) {
echo json_encode (''); echo json_encode ('');
return; return;
} }
if(is_array($id_agents) && count($id_agents) == 1 && $id_agents[0] == '') { if(is_array($id_agents) && count($id_agents) == 1 && $id_agents[0] == '') {
$id_agents = false; $id_agents = false;
} }
@ -105,7 +105,7 @@ if ($add) {
ui_print_result_message (false, '', __('Could not be added').". ".__('No action selected')); ui_print_result_message (false, '', __('Could not be added').". ".__('No action selected'));
} }
} }
} }
$groups = users_get_groups (); $groups = users_get_groups ();
@ -148,7 +148,7 @@ $table->data[2][1] = html_print_select (array(), 'id_alert_templates[]', '', '',
$actions = alerts_get_alert_actions (); $actions = alerts_get_alert_actions ();
$table->data[3][0] = __('Action'); $table->data[3][0] = __('Action');
$table->data[3][1] = html_print_select ($actions, 'action[]', '', '', '', '', true, true); $table->data[3][1] = html_print_select ($actions, 'action[]', '', '', '', '', true, true);
$table->data[3][1] .= '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' &raquo; </a></span>'; $table->data[3][1] .= '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' &raquo; </a></span>';
$table->data[3][1] .= '<span id="advanced_actions" class="advanced_actions invisible">'; $table->data[3][1] .= '<span id="advanced_actions" class="advanced_actions invisible">';
$table->data[3][1] .= __('Number of alerts match from').' '; $table->data[3][1] .= __('Number of alerts match from').' ';
@ -186,7 +186,7 @@ ui_require_jquery_file ('pandora.controls');
<script type="text/javascript"> <script type="text/javascript">
$(document).ready (function () { $(document).ready (function () {
update_alerts(); update_alerts();
var recursion; var recursion;
$("#checkbox-recursion").click(function (){ $("#checkbox-recursion").click(function (){
recursion = this.checked ? 1 : 0; recursion = this.checked ? 1 : 0;

View File

@ -29,7 +29,7 @@ require_once ('include/functions_users.php');
if (is_ajax ()) { if (is_ajax ()) {
$get_alerts = (bool) get_parameter ('get_alerts'); $get_alerts = (bool) get_parameter ('get_alerts');
if ($get_alerts) { if ($get_alerts) {
$id_agents = get_parameter ('id_agents'); $id_agents = get_parameter ('id_agents');
if (empty($id_agents)) { if (empty($id_agents)) {
@ -51,37 +51,39 @@ $recursion = get_parameter ('recursion');
$delete = (bool) get_parameter_post ('delete'); $delete = (bool) get_parameter_post ('delete');
if ($delete) { if ($delete) {
if(empty($id_agents) || $id_agents[0] == 0) if (empty($id_agents) || $id_agents[0] == 0)
ui_print_result_message (false, '', __('Could not be deleted').". ".__('No agents selected')); ui_print_result_message (false, '',
__('Could not be deleted. No agents selected'));
else { else {
$actions = get_parameter ('action'); $actions = get_parameter ('action');
if(!empty($actions)){ if (!empty($actions)) {
$agent_alerts = agents_get_alerts($id_agents); $agent_alerts = agents_get_alerts($id_agents);
$alerts_agent_modules = array(); $alerts_agent_modules = array();
foreach($agent_alerts['simple'] as $agent_alert){ foreach ($agent_alerts['simple'] as $agent_alert){
if (in_array($agent_alert['id_alert_template'], $id_alert_templates)) { if (in_array($agent_alert['id_alert_template'], $id_alert_templates)) {
$alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module ($agent_alert['id_agent_module'], true, false, 'id')); $alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module ($agent_alert['id_agent_module'], true, false, 'id'));
} }
} }
if (empty($alerts_agent_modules)) { if (empty($alerts_agent_modules)) {
ui_print_result_message (false, '', __('Could not be deleted').". ".__('No alerts selected')); ui_print_result_message (false, '',
__('Could not be deleted. No alerts selected'));
} }
else { else {
$results = true; $results = true;
$agent_module_actions = array(); $agent_module_actions = array();
foreach($alerts_agent_modules as $alert_agent_module){
$agent_module_actions = alerts_get_alert_agent_module_actions ($alert_agent_module['id'], array('id','id_alert_action'));
foreach ($alerts_agent_modules as $alert_agent_module) {
$agent_module_actions = alerts_get_alert_agent_module_actions ($alert_agent_module['id'], array('id','id_alert_action'));
foreach ($agent_module_actions as $agent_module_action){ foreach ($agent_module_actions as $agent_module_action){
foreach($actions as $action) { foreach ($actions as $action) {
if($agent_module_action['id_alert_action'] == $action) { if ($agent_module_action['id_alert_action'] == $action) {
$result = alerts_delete_alert_agent_module_action ($agent_module_action['id']); $result = alerts_delete_alert_agent_module_action ($agent_module_action['id']);
if($result === false) if ($result === false)
$results = false; $results = false;
} }
} }
@ -98,12 +100,15 @@ if ($delete) {
'Agent: ' . json_encode($id_agents) . ' Alert templates: ' . json_encode($id_alert_templates) . 'Agent: ' . json_encode($id_agents) . ' Alert templates: ' . json_encode($id_alert_templates) .
' Actions: ' . implode(',',$actions)); ' Actions: ' . implode(',',$actions));
} }
ui_print_result_message ($results, __('Successfully deleted'), __('Could not be deleted')); ui_print_result_message ($results,
__('Successfully deleted'),
__('Could not be deleted'));
} }
} }
else { else {
ui_print_result_message (false, '', __('Could not be deleted').". ".__('No action selected')); ui_print_result_message (false, '',
__('Could not be deleted. No action selected'));
} }
} }
@ -150,12 +155,17 @@ $table->data[2][1] = html_print_select (index_array ($alert_templates, 'id_alert
$actions = alerts_get_alert_actions (); $actions = alerts_get_alert_actions ();
$table->data[3][0] = __('Action'); $table->data[3][0] = __('Action');
$table->data[3][1] = html_print_select ($actions, 'action[]', '', '', '', '', true, true); $table->data[3][1] = html_print_select ($actions, 'action[]', '', '',
'', '', true, true);
echo '<form method="post" id="form_alert" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_action_alerts">'; echo '<form method="post" id="form_alert" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_action_alerts">';
html_print_table ($table); html_print_table ($table);
$sql = 'SELECT id_agente FROM tagente_modulo WHERE id_agente_modulo IN (SELECT id_agent_module FROM talert_template_modules)'; $sql = 'SELECT id_agente
FROM tagente_modulo
WHERE id_agente_modulo IN (
SELECT id_agent_module
FROM talert_template_modules)';
$agents_with_templates = db_get_all_rows_sql($sql); $agents_with_templates = db_get_all_rows_sql($sql);
$agents_with_templates_json = array(); $agents_with_templates_json = array();
foreach($agents_with_templates as $ag) { foreach($agents_with_templates as $ag) {
@ -171,16 +181,16 @@ html_print_submit_button (__('Delete'), 'go', false, 'class="sub delete"');
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
echo '<h3 class="error invisible" id="message"> </h3>'; echo '<h3 class="error invisible" id="message"></h3>';
ui_require_jquery_file ('form'); ui_require_jquery_file('form');
ui_require_jquery_file ('pandora.controls'); ui_require_jquery_file('pandora.controls');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready (function () { $(document).ready (function () {
update_alerts(); update_alerts();
var recursion; var recursion;
$("#checkbox-recursion").click(function (){ $("#checkbox-recursion").click(function (){
recursion = this.checked ? 1 : 0; recursion = this.checked ? 1 : 0;
@ -198,36 +208,36 @@ $(document).ready (function () {
$("option", $select_template).remove (); $("option", $select_template).remove ();
} }
}); });
$("#id_agents").change (function () { $("#id_agents").change (function () {
update_alerts(); update_alerts();
}); });
function update_alerts() { function update_alerts() {
var idAgents = Array(); var idAgents = Array();
jQuery.each ($("#id_agents option:selected"), function (i, val) { jQuery.each ($("#id_agents option:selected"), function (i, val) {
idAgents.push($(val).val()); idAgents.push($(val).val());
}); });
$("#template_loading").show(); $("#template_loading").show();
var $select_template = $("#id_alert_templates").disable (); var $select_template = $("#id_alert_templates").disable ();
$("option", $select_template).remove (); $("option", $select_template).remove ();
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
{"page" : "godmode/massive/massive_delete_action_alerts", {"page" : "godmode/massive/massive_delete_action_alerts",
"get_alerts" : 1, "get_alerts" : 1,
"id_agents[]" : idAgents "id_agents[]" : idAgents
}, },
function (data, status) { function (data, status) {
options = ""; options = "";
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
options += "<option value=\""+id+"\">"+value+"</option>"; options += "<option value=\""+id+"\">"+value+"</option>";
}); });
$("#id_alert_templates").append (options); $("#id_alert_templates").append (options);
$("#template_loading").hide (); $("#template_loading").hide ();
$select_template.enable (); $select_template.enable ();
}, },
"json" "json"
); );
} }

View File

@ -256,7 +256,7 @@ $(document).ready (function () {
$("#modules_selection_mode").change (function() { $("#modules_selection_mode").change (function() {
$("#id_agents").trigger('change'); $("#id_agents").trigger('change');
}); });
}); });
/* ]]> */ /* ]]> */
</script> </script>

View File

@ -60,15 +60,15 @@ function process_manage_delete ($module_name, $id_agents) {
} }
db_process_sql_begin (); db_process_sql_begin ();
$module_name = (array)$module_name; $module_name = (array)$module_name;
// We are selecting "any" agent for the selected modules // We are selecting "any" agent for the selected modules
if (($id_agents[0] == 0) and (is_array($id_agents)) and (count($id_agents) == 1)) if (($id_agents[0] == 0) and (is_array($id_agents)) and (count($id_agents) == 1))
$id_agents = NULL; $id_agents = NULL;
$selection_delete_mode = get_parameter('selection_mode', 'modules'); $selection_delete_mode = get_parameter('selection_mode', 'modules');
// Selection mode by Agents // Selection mode by Agents
if ($selection_delete_mode == 'agents') { if ($selection_delete_mode == 'agents') {
// We are selecting "any" module for the selecteds agents // We are selecting "any" module for the selecteds agents
@ -76,16 +76,16 @@ function process_manage_delete ($module_name, $id_agents) {
$filter_for_module_deletion = false; $filter_for_module_deletion = false;
else else
$filter_for_module_deletion = sprintf('nombre IN ("%s")', implode('","',$module_name)); $filter_for_module_deletion = sprintf('nombre IN ("%s")', implode('","',$module_name));
$modules = agents_get_modules ($id_agents, 'id_agente_modulo', $modules = agents_get_modules ($id_agents, 'id_agente_modulo',
$filter_for_module_deletion, true); $filter_for_module_deletion, true);
} }
else { else {
$modules = agents_get_modules ($id_agents, 'id_agente_modulo', $modules = agents_get_modules ($id_agents, 'id_agente_modulo',
sprintf('nombre IN ("%s")', implode('","',$module_name)), true); sprintf('nombre IN ("%s")', implode('","',$module_name)), true);
} }
$count_deleted_modules = count($modules); $count_deleted_modules = count($modules);
$success = modules_delete_agent_module ($modules); $success = modules_delete_agent_module ($modules);
@ -291,7 +291,7 @@ $table->data[4][0] = __('Agents');
$table->data[4][1] = html_print_select ($agents, 'id_agents[]', $table->data[4][1] = html_print_select ($agents, 'id_agents[]',
$agents_id, false, '', '', true, true, false, '', false, 'width:100%'); $agents_id, false, '', '', true, true, false, '', false, 'width:100%');
$table->data[4][2] = __('When select agents'); $table->data[4][2] = __('When select agents');
$table->data[4][2] .= '<br>'; $table->data[4][2] .= '<br>';
$table->data[4][2] .= html_print_select (array('common' => __('Show common modules'), 'all' => __('Show all modules')), 'modules_selection_mode', $table->data[4][2] .= html_print_select (array('common' => __('Show common modules'), 'all' => __('Show all modules')), 'modules_selection_mode',

View File

@ -315,7 +315,7 @@ $table->data[3][1] = '<div id="delete_configurations" style="display: none">'. _
$table->data[3][1] .= '<span id="n_configurations"></span>'; $table->data[3][1] .= '<span id="n_configurations"></span>';
$table->data[3][1] .= ') '.html_print_checkbox_extended ("delete_conf", 1, 0, false, '', 'style="margin-right: 40px;"', true).'</div>'; $table->data[3][1] .= ') '.html_print_checkbox_extended ("delete_conf", 1, 0, false, '', 'style="margin-right: 40px;"', true).'</div>';
$table->data[3][1] .= '<div id="not_available_configurations" style="display: none"><em>'.__('Not available').'</em></div>'; $table->data[3][1] .= '<div id="not_available_configurations" style="display: none"><em>'.__('Not available').'</em></div>';
$listIcons = gis_get_array_list_icons(); $listIcons = gis_get_array_list_icons();
@ -474,7 +474,7 @@ $(document).ready (function () {
function changeIcons() { function changeIcons() {
icon = $("#icon_path :selected").val(); icon = $("#icon_path :selected").val();
$("#icon_without_status").attr("src", "images/spinner.png"); $("#icon_without_status").attr("src", "images/spinner.png");
$("#icon_default").attr("src", "images/spinner.png"); $("#icon_default").attr("src", "images/spinner.png");
$("#icon_ok").attr("src", "images/spinner.png"); $("#icon_ok").attr("src", "images/spinner.png");
@ -489,11 +489,16 @@ function changeIcons() {
$("#icon_warning").attr("style", "display:none;"); $("#icon_warning").attr("style", "display:none;");
} }
else { else {
$("#icon_without_status").attr("src", "<?php echo $path; ?>" + icon + ".default.png"); $("#icon_without_status").attr("src",
$("#icon_default").attr("src", "<?php echo $path; ?>" + icon + ".default.png"); "<?php echo $path; ?>" + icon + ".default.png");
$("#icon_ok").attr("src", "<?php echo $path; ?>" + icon + ".ok.png"); $("#icon_default").attr("src",
$("#icon_bad").attr("src", "<?php echo $path; ?>" + icon + ".bad.png"); "<?php echo $path; ?>" + icon + ".default.png");
$("#icon_warning").attr("src", "<?php echo $path; ?>" + icon + ".warning.png"); $("#icon_ok").attr("src",
"<?php echo $path; ?>" + icon + ".ok.png");
$("#icon_bad").attr("src",
"<?php echo $path; ?>" + icon + ".bad.png");
$("#icon_warning").attr("src",
"<?php echo $path; ?>" + icon + ".warning.png");
$("#icon_without_status").attr("style", ""); $("#icon_without_status").attr("style", "");
$("#icon_default").attr("style", ""); $("#icon_default").attr("style", "");
$("#icon_ok").attr("style", ""); $("#icon_ok").attr("style", "");

View File

@ -95,7 +95,7 @@ switch ($action) {
ui_print_result_message ($result, __('Successfully disabled'), __('Could not be disabled')); ui_print_result_message ($result, __('Successfully disabled'), __('Could not be disabled'));
$info = 'Alert: ' . json_encode($id_enabled_alerts); $info = 'Alert: ' . json_encode($id_enabled_alerts);
if ($result) { if ($result) {
db_pandora_audit("Masive management", "Disable alert", false, false, $info); db_pandora_audit("Masive management", "Disable alert", false, false, $info);
} }

View File

@ -54,7 +54,8 @@ if ($view != "") {
$form_plugin_type = $plugin ["plugin_type"]; $form_plugin_type = $plugin ["plugin_type"];
$macros = $plugin ["macros"]; $macros = $plugin ["macros"];
$parameters = $plugin ["parameters"]; $parameters = $plugin ["parameters"];
} }
if ($create != "") { if ($create != "") {
$form_name = ""; $form_name = "";
$form_description = ""; $form_description = "";
@ -74,7 +75,7 @@ $sec = 'gservers';
if (($create != "") OR ($view != "")) { if (($create != "") OR ($view != "")) {
if(defined('METACONSOLE')) { if (defined('METACONSOLE')) {
components_meta_print_header(); components_meta_print_header();
$sec = 'advanced'; $sec = 'advanced';
} }
@ -142,8 +143,8 @@ if (($create != "") OR ($view != "")) {
// If we have plugin id (update mode) and this plugin used by any module or component // If we have plugin id (update mode) and this plugin used by any module or component
// The command configuration will be locked // The command configuration will be locked
if ($plugin_id > 0) { if ($plugin_id > 0) {
$modules_using_plugin = db_get_value_filter('count(*)','tagente_modulo', array('delete_pending' => 0, 'id_plugin' => $plugin_id)); $modules_using_plugin = db_get_value_filter('count(*)','tagente_modulo', array('delete_pending' => 0, 'id_plugin' => $plugin_id));
$components_using_plugin = db_get_value_filter('count(*)','tnetwork_component', array('id_plugin' => $plugin_id)); $components_using_plugin = db_get_value_filter('count(*)','tnetwork_component', array('id_plugin' => $plugin_id));
if(($components_using_plugin + $modules_using_plugin) == 0) { if(($components_using_plugin + $modules_using_plugin) == 0) {
$locked = false; $locked = false;
} }
@ -480,7 +481,7 @@ ui_require_javascript_file('pandora_modules');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
function update_preview() { function update_preview() {
var command = $('#form_execute').val(); var command = $('#form_execute').val();
@ -502,7 +503,7 @@ $(document).ready(function() {
$('#command_preview').html(command+' '+parameters); $('#command_preview').html(command+' '+parameters);
} }
update_preview(); update_preview();
$('.command_component').live( 'keyup', function() { $('.command_component').live( 'keyup', function() {
@ -512,12 +513,12 @@ $(document).ready(function() {
}); });
<?php <?php
if($locked) { if($locked) {
?> ?>
$('.command_advanced_conf').click(function() { $('.command_advanced_conf').click(function() {
alert('<?php echo __("The plugin command cannot be updated because some modules or components are using the plugin."); ?>'); alert('<?php echo __("The plugin command cannot be updated because some modules or components are using the plugin."); ?>');
}); });
<?php <?php
} }
?> ?>

View File

@ -111,14 +111,14 @@ if (($create != "") OR ($view != "")){
} }
else { else {
ui_print_page_header (__('Recon scripts registered in Pandora FMS'), "", false, "", true); ui_print_page_header (__('Recon scripts registered in Pandora FMS'), "", false, "", true);
// Update reconscript // Update reconscript
if (isset($_GET["update_reconscript"])) { // if modified any parameter if (isset($_GET["update_reconscript"])) { // if modified any parameter
$id_recon_script = get_parameter ("update_reconscript", 0); $id_recon_script = get_parameter ("update_reconscript", 0);
$reconscript_name = get_parameter ("form_name", ""); $reconscript_name = get_parameter ("form_name", "");
$reconscript_description = get_parameter ("form_description", ""); $reconscript_description = get_parameter ("form_description", "");
$reconscript_script = get_parameter ("form_script", ""); $reconscript_script = get_parameter ("form_script", "");
$sql_update ="UPDATE trecon_script SET $sql_update ="UPDATE trecon_script SET
name = '$reconscript_name', name = '$reconscript_name',
description = '$reconscript_description', description = '$reconscript_description',
@ -126,7 +126,7 @@ else {
WHERE id_recon_script = $id_recon_script"; WHERE id_recon_script = $id_recon_script";
$result = false; $result = false;
if ($reconscript_name != '' && $reconscript_script != '') if ($reconscript_name != '' && $reconscript_script != '')
$result = db_process_sql ($sql_update); $result = db_process_sql ($sql_update);
if (! $result) { if (! $result) {
echo "<h3 class='error'>" . __('Problem updating') . "</h3>"; echo "<h3 class='error'>" . __('Problem updating') . "</h3>";
} }

View File

@ -94,7 +94,7 @@ if ($edit_filter > -2) {
$table->data[0][1] = html_print_input_text ('description', $description, '', 60, 100, true); $table->data[0][1] = html_print_input_text ('description', $description, '', 60, 100, true);
$table->data[1][0] = __('Filter'); $table->data[1][0] = __('Filter');
$table->data[1][1] = html_print_input_text ('filter', $filter, '', 60, 100, true); $table->data[1][1] = html_print_input_text ('filter', $filter, '', 60, 100, true);
echo '<form action="index.php?sec=estado&sec2=godmode/snmpconsole/snmp_filters" method="post">'; echo '<form action="index.php?sec=estado&sec2=godmode/snmpconsole/snmp_filters" method="post">';
html_print_input_hidden ('update_filter', $edit_filter); html_print_input_hidden ('update_filter', $edit_filter);
html_print_table ($table); html_print_table ($table);
@ -125,7 +125,7 @@ else {
$table->class= "databox"; $table->class= "databox";
$table->align = array (); $table->align = array ();
$table->head[0] = __('Description'); $table->head[0] = __('Description');
$table->head[1] = __('Filter'); $table->head[1] = __('Filter');
$table->head[2] = __('Action'); $table->head[2] = __('Action');
$table->size[2] = "50px"; $table->size[2] = "50px";
@ -146,7 +146,7 @@ else {
html_print_table ($table); html_print_table ($table);
} }
unset ($table); unset ($table);
echo '<div style="text-align:right; width:98%">'; echo '<div style="text-align:right; width:98%">';
echo '<form name="agente" method="post" action="index.php?sec=estado&sec2=godmode/snmpconsole/snmp_filters&edit_filter=-1">'; echo '<form name="agente" method="post" action="index.php?sec=estado&sec2=godmode/snmpconsole/snmp_filters&edit_filter=-1">';

View File

@ -158,35 +158,35 @@ if ($dialogue_event_response) {
} }
} }
if($add_comment) { if ($add_comment) {
$comment = get_parameter ('comment'); $comment = get_parameter ('comment');
$event_id = get_parameter ('event_id'); $event_id = get_parameter ('event_id');
$return = events_comment ($event_id, $comment, 'Added comment', $meta, $history); $return = events_comment ($event_id, $comment, 'Added comment', $meta, $history);
if ($return) if ($return)
echo 'comment_ok'; echo 'comment_ok';
else else
echo 'comment_error'; echo 'comment_error';
return; return;
} }
if($change_status) { if ($change_status) {
$event_ids = get_parameter ('event_ids'); $event_ids = get_parameter ('event_ids');
$new_status = get_parameter ('new_status'); $new_status = get_parameter ('new_status');
$return = events_change_status (explode(',',$event_ids), $new_status, $meta, $history); $return = events_change_status (explode(',',$event_ids), $new_status, $meta, $history);
if ($return) if ($return)
echo 'status_ok'; echo 'status_ok';
else else
echo 'status_error'; echo 'status_error';
return; return;
} }
if($change_owner) { if ($change_owner) {
$new_owner = get_parameter ('new_owner'); $new_owner = get_parameter ('new_owner');
$event_id = get_parameter ('event_id'); $event_id = get_parameter ('event_id');
$similars = true; $similars = true;
@ -194,23 +194,23 @@ if($change_owner) {
if($new_owner == -1) { if($new_owner == -1) {
$new_owner = ''; $new_owner = '';
} }
$return = events_change_owner($event_id, $new_owner, true, $meta, $history); $return = events_change_owner($event_id, $new_owner, true, $meta, $history);
if ($return) if ($return)
echo 'owner_ok'; echo 'owner_ok';
else else
echo 'owner_error'; echo 'owner_error';
return; return;
} }
if($get_extended_event) { if ($get_extended_event) {
global $config; global $config;
$event_id = get_parameter('event_id',false); $event_id = get_parameter('event_id',false);
if($meta) { if ($meta) {
$event = events_meta_get_event($event_id, false, $history); $event = events_meta_get_event($event_id, false, $history);
} }
else { else {
@ -219,13 +219,13 @@ if($get_extended_event) {
// Clean url from events and store in array // Clean url from events and store in array
$event['clean_tags'] = events_clean_tags($event['tags']); $event['clean_tags'] = events_clean_tags($event['tags']);
// If the event is not found, we abort // If the event is not found, we abort
if(empty($event)) { if (empty($event)) {
ui_print_error_message('Event not found'); ui_print_error_message('Event not found');
return false; return false;
} }
$dialog_page = get_parameter('dialog_page','general'); $dialog_page = get_parameter('dialog_page','general');
$similar_ids = get_parameter('similar_ids', $event_id); $similar_ids = get_parameter('similar_ids', $event_id);
$group_rep = get_parameter('group_rep',false); $group_rep = get_parameter('group_rep',false);
@ -233,27 +233,27 @@ if($get_extended_event) {
$timestamp_first = get_parameter('timestamp_first', $event['utimestamp']); $timestamp_first = get_parameter('timestamp_first', $event['utimestamp']);
$timestamp_last = get_parameter('timestamp_last', $event['utimestamp']); $timestamp_last = get_parameter('timestamp_last', $event['utimestamp']);
$server_id = get_parameter('server_id', 0); $server_id = get_parameter('server_id', 0);
$event['similar_ids'] = $similar_ids; $event['similar_ids'] = $similar_ids;
$event['timestamp_first'] = $timestamp_first; $event['timestamp_first'] = $timestamp_first;
$event['timestamp_last'] = $timestamp_last; $event['timestamp_last'] = $timestamp_last;
$event['event_rep'] = $event_rep; $event['event_rep'] = $event_rep;
// Check ACLs // Check ACLs
if (is_user_admin ($config["id_user"])) { if (is_user_admin ($config["id_user"])) {
//Do nothing if you're admin, you get full access //Do nothing if you're admin, you get full access
} }
else if($config["id_user"] == $event['owner_user']) { else if ($config["id_user"] == $event['owner_user']) {
//Do nothing if you're the owner user, you get access //Do nothing if you're the owner user, you get access
} }
else if($event['id_grupo'] == 0){ else if ($event['id_grupo'] == 0) {
//If the event has access to all groups, you get access //If the event has access to all groups, you get access
} }
else { else {
// Get your groups // Get your groups
$groups = users_get_groups($config['id_user'], 'ER'); $groups = users_get_groups($config['id_user'], 'ER');
if(in_array ($event['id_grupo'], array_keys ($groups))) { if (in_array ($event['id_grupo'], array_keys ($groups))) {
//If the event group is among the groups of the user, you get access //If the event group is among the groups of the user, you get access
} }
else { else {
@ -265,21 +265,21 @@ if($get_extended_event) {
// Print group_rep in a hidden field to recover it from javascript // Print group_rep in a hidden field to recover it from javascript
html_print_input_hidden('group_rep',(int)$group_rep); html_print_input_hidden('group_rep',(int)$group_rep);
if($event === false) { if ($event === false) {
return; return;
} }
// Tabs // Tabs
$tabs = "<ul style='background:#eeeeee;border:0px'>"; $tabs = "<ul style='background:#eeeeee;border:0px'>";
$tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png',true).__('General')."</a></li>"; $tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png',true).__('General')."</a></li>";
$tabs .= "<li><a href='#extended_event_details_page' id='link_details'>".html_print_image('images/zoom.png',true).__('Details')."</a></li>"; $tabs .= "<li><a href='#extended_event_details_page' id='link_details'>".html_print_image('images/zoom.png',true).__('Details')."</a></li>";
$tabs .= "<li><a href='#extended_event_custom_fields_page' id='link_custom_fields'>".html_print_image('images/note.png',true).__('Agent fields')."</a></li>"; $tabs .= "<li><a href='#extended_event_custom_fields_page' id='link_custom_fields'>".html_print_image('images/note.png',true).__('Agent fields')."</a></li>";
$tabs .= "<li><a href='#extended_event_comments_page' id='link_comments'>".html_print_image('images/pencil.png',true).__('Comments')."</a></li>"; $tabs .= "<li><a href='#extended_event_comments_page' id='link_comments'>".html_print_image('images/pencil.png',true).__('Comments')."</a></li>";
if (tags_check_acl ($config['id_user'], $event['id_grupo'], "EW", $event['clean_tags']) || tags_check_acl ($config['id_user'], $event['id_grupo'], "EM", $event['clean_tags'])) { if (tags_check_acl ($config['id_user'], $event['id_grupo'], "EW", $event['clean_tags']) || tags_check_acl ($config['id_user'], $event['id_grupo'], "EM", $event['clean_tags'])) {
$tabs .= "<li><a href='#extended_event_responses_page' id='link_responses'>".html_print_image('images/cog.png',true).__('Responses')."</a></li>"; $tabs .= "<li><a href='#extended_event_responses_page' id='link_responses'>".html_print_image('images/cog.png',true).__('Responses')."</a></li>";
} }
$tabs .= "</ul>"; $tabs .= "</ul>";
// Get criticity image // Get criticity image
switch ($event["criticity"]) { switch ($event["criticity"]) {
@ -307,7 +307,7 @@ if($get_extended_event) {
break; break;
} }
if (tags_check_acl ($config['id_user'], $event['id_grupo'], "EW", $event['clean_tags']) || tags_check_acl ($config['id_user'], $event['id_grupo'], "EM", $event['clean_tags'])) { if (tags_check_acl ($config['id_user'], $event['id_grupo'], "EW", $event['clean_tags']) || tags_check_acl ($config['id_user'], $event['id_grupo'], "EM", $event['clean_tags'])) {
$responses = events_page_responses($event); $responses = events_page_responses($event);
} }
else { else {
@ -316,19 +316,19 @@ if($get_extended_event) {
$console_url = ''; $console_url = '';
// If metaconsole switch to node to get details and custom fields // If metaconsole switch to node to get details and custom fields
if($meta) { if ($meta) {
$server = metaconsole_get_connection_by_id ($server_id); $server = metaconsole_get_connection_by_id ($server_id);
metaconsole_connect($server); metaconsole_connect($server);
} }
else { else {
$server = ""; $server = "";
} }
$details = events_page_details($event, $server); $details = events_page_details($event, $server);
$custom_fields = events_page_custom_fields($event); $custom_fields = events_page_custom_fields($event);
if($meta) { if ($meta) {
metaconsole_restore_db_force(); metaconsole_restore_db_force();
} }
@ -342,7 +342,7 @@ if($get_extended_event) {
$notifications .= '<div id="notification_status_success" style="display:none">'.ui_print_success_message(__('Event status changed successfully'),'',true).'</div>'; $notifications .= '<div id="notification_status_success" style="display:none">'.ui_print_success_message(__('Event status changed successfully'),'',true).'</div>';
$notifications .= '<div id="notification_owner_error" style="display:none">'.ui_print_error_message(__('Error changing event owner'),'',true).'</div>'; $notifications .= '<div id="notification_owner_error" style="display:none">'.ui_print_error_message(__('Error changing event owner'),'',true).'</div>';
$notifications .= '<div id="notification_owner_success" style="display:none">'.ui_print_success_message(__('Event owner changed successfully'),'',true).'</div>'; $notifications .= '<div id="notification_owner_success" style="display:none">'.ui_print_success_message(__('Event owner changed successfully'),'',true).'</div>';
$loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif',true).'</div>'; $loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif',true).'</div>';
$out = '<div id="tabs" style="height:95%; overflow: auto">'. $out = '<div id="tabs" style="height:95%; overflow: auto">'.
@ -364,7 +364,7 @@ if($get_extended_event) {
'; ';
// Load the required tab // Load the required tab
switch($dialog_page) { switch ($dialog_page) {
case "general": case "general":
$js .= '$tabs.tabs( "option", "active", 0);'; $js .= '$tabs.tabs( "option", "active", 0);';
break; break;
@ -389,13 +389,13 @@ if($get_extended_event) {
echo $out.$js; echo $out.$js;
} }
if($get_events_details) { if ($get_events_details) {
$event_ids = explode(',',get_parameter ('event_ids')); $event_ids = explode(',',get_parameter ('event_ids'));
$events = db_get_all_rows_filter ('tevento', $events = db_get_all_rows_filter ('tevento',
array ('id_evento' => $event_ids, array ('id_evento' => $event_ids,
'order' => 'utimestamp ASC'), 'order' => 'utimestamp ASC'),
array ('evento', 'utimestamp', 'estado', 'criticity')); array ('evento', 'utimestamp', 'estado', 'criticity'));
$out = '<table class="eventtable" style="width:100%;height:100%;padding:0px 0px 0px 0px; border-spacing: 0px; margin: 0px 0px 0px 0px;">'; $out = '<table class="eventtable" style="width:100%;height:100%;padding:0px 0px 0px 0px; border-spacing: 0px; margin: 0px 0px 0px 0px;">';
$out .= '<tr style="font-size:0px; heigth: 0px; background: #ccc;"><td></td><td></td></tr>'; $out .= '<tr style="font-size:0px; heigth: 0px; background: #ccc;"><td></td><td></td></tr>';
foreach($events as $event) { foreach($events as $event) {
@ -413,7 +413,7 @@ if($get_events_details) {
$title = __('Event in process'); $title = __('Event in process');
break; break;
} }
$out .= '<tr class="'.get_priority_class ($event['criticity']).'"><td class="'.get_priority_class ($event['criticity']).'">'; $out .= '<tr class="'.get_priority_class ($event['criticity']).'"><td class="'.get_priority_class ($event['criticity']).'">';
$out .= '<img src="'.$img.'" alt="'.$title.'" title="'.$title.'">'; $out .= '<img src="'.$img.'" alt="'.$title.'" title="'.$title.'">';
$out .= '</td><td class="'.get_priority_class ($event['criticity']).'" style="font-size:7pt">'; $out .= '</td><td class="'.get_priority_class ($event['criticity']).'" style="font-size:7pt">';

View File

@ -1679,9 +1679,18 @@ function events_page_custom_fields ($event) {
$table->style[1] = 'text-align: left;'; $table->style[1] = 'text-align: left;';
$table->class = "databox alternate"; $table->class = "databox alternate";
$fields = db_get_all_rows_filter('tagent_custom_fields'); $all_customs_fields = (bool)check_acl($config["id_user"],
$agent["id_grupo"], "AW");
if($event['id_agente'] == 0) { if ($all_customs_fields) {
$fields = db_get_all_rows_filter('tagent_custom_fields');
}
else {
$fields = db_get_all_rows_filter('tagent_custom_fields',
array('display_on_front' => 1));
}
if ($event['id_agente'] == 0) {
$fields_data = array(); $fields_data = array();
} }
else { else {
@ -1695,7 +1704,7 @@ function events_page_custom_fields ($event) {
} }
} }
foreach($fields as $field) { foreach ($fields as $field) {
// Owner // Owner
$data = array(); $data = array();
$data[0] = $field['name']; $data[0] = $field['name'];

View File

@ -31,15 +31,23 @@ if ($id_agente === -1) {
if (! check_acl ($config["id_user"], $agent["id_grupo"], "AR")) { if (! check_acl ($config["id_user"], $agent["id_grupo"], "AR")) {
db_pandora_audit("ACL Violation", db_pandora_audit("ACL Violation",
"Trying to access Agent General Information"); "Trying to access Agent General Information");
require_once ("general/noaccess.php"); require_once ("general/noaccess.php");
return; return;
} }
$all_customs_fields = (bool)check_acl($config["id_user"],
$agent["id_grupo"], "AW");
$fields = db_get_all_fields_in_table('tagent_custom_fields'); if ($all_customs_fields) {
$fields = db_get_all_rows_filter('tagent_custom_fields');
}
else {
$fields = db_get_all_rows_filter('tagent_custom_fields',
array('display_on_front' => 1));
}
if($fields === false) { if ($fields === false) {
$fields = array(); $fields = array();
echo "<div class='nf'>". __("No fields defined"). "</div>"; echo "<div class='nf'>". __("No fields defined"). "</div>";
} }
@ -47,35 +55,39 @@ else {
$table->width = '98%'; $table->width = '98%';
$table->head = array (); $table->head = array ();
$table->head[0] = __('Field'); $table->head[0] = __('Field');
$table->head[1] = __('Display on front') . ui_print_help_tip (__('The fields with display on front enabled will be displayed into the agent details'), true); $table->head[1] = __('Display on front') .
ui_print_help_tip (__('The fields with display on front enabled will be displayed into the agent details'), true);
$table->head[2] = __('Description'); $table->head[2] = __('Description');
$table->align = array (); $table->align = array ();
$table->align[1] = 'center'; $table->align[1] = 'center';
$table->align[2] = 'center'; $table->align[2] = 'center';
$table->data = array (); $table->data = array ();
foreach ($fields as $field) {
foreach ($fields as $field) {
$data[0] = '<b>'.$field['name'].'</b>'; $data[0] = '<b>'.$field['name'].'</b>';
if($field['display_on_front']) { if ($field['display_on_front']) {
$data[1] = html_print_image('images/tick.png', true); $data[1] = html_print_image('images/tick.png', true);
} }
else { else {
$data[1] = html_print_image('images/delete.png', true); $data[1] = html_print_image('images/delete.png', true);
} }
$custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente)); $custom_value = db_get_value_filter('description',
'tagent_custom_data', array(
if($custom_value === false || $custom_value == '') { 'id_field' => $field['id_field'],
'id_agent' => $id_agente));
if ($custom_value === false || $custom_value == '') {
$custom_value = '<i>-'.__('empty').'-</i>'; $custom_value = '<i>-'.__('empty').'-</i>';
} }
$data[2] = $custom_value; $data[2] = $custom_value;
array_push ($table->data, $data); array_push ($table->data, $data);
} }
html_print_table ($table); html_print_table ($table);
} }
?> ?>