2011-08-01 Tomas Palacios <tomas.palacios@artica.es>
* godmode/massive: fixed a bug regarding warnings, SQL errors and undefined variables in massive alert ops. * godmode/snmpconsole/snmp_alert.php godmode/users/profile_list.php: fixed a bug regarding creation of snmp alerts and profiles with no info at all. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4659 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
d983c38f45
commit
e6d02b7540
|
@ -66,7 +66,7 @@ $id_alert_compounds = (array) get_parameter ('id_alert_compounds');
|
||||||
$add = (bool) get_parameter_post ('add');
|
$add = (bool) get_parameter_post ('add');
|
||||||
|
|
||||||
if ($add) {
|
if ($add) {
|
||||||
if(empty($id_agents))
|
if(empty($id_agents) || $id_agents[0] == 0)
|
||||||
ui_print_result_message (false, '', __('Could not be added').". ".__('No agents selected'));
|
ui_print_result_message (false, '', __('Could not be added').". ".__('No agents selected'));
|
||||||
else {
|
else {
|
||||||
$action = (int) get_parameter ('action');
|
$action = (int) get_parameter ('action');
|
||||||
|
|
|
@ -44,7 +44,7 @@ if (is_ajax ()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function process_manage_add ($id_alert_template, $id_agents, $module_names) {
|
function process_manage_add ($id_alert_template, $id_agents, $module_names) {
|
||||||
if (empty ($id_agents)) {
|
if (empty ($id_agents) || $id_agents[0] == 0) {
|
||||||
echo '<h3 class="error">'.__('No agents selected').'</h3>';
|
echo '<h3 class="error">'.__('No agents selected').'</h3>';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ $id_alert_compounds = (array) get_parameter ('id_alert_compounds');
|
||||||
$delete = (bool) get_parameter_post ('delete');
|
$delete = (bool) get_parameter_post ('delete');
|
||||||
|
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
if(empty($id_agents))
|
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 {
|
||||||
$action = (int) get_parameter ('action');
|
$action = (int) get_parameter ('action');
|
||||||
|
|
|
@ -51,7 +51,7 @@ function process_manage_delete ($id_alert_template, $id_agents, $module_names) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty ($id_agents)) {
|
if (empty ($id_agents) || $id_agents[0] == 0) {
|
||||||
echo '<h3 class="error">'.__('No agents selected').'</h3>';
|
echo '<h3 class="error">'.__('No agents selected').'</h3>';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,9 +93,9 @@ 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_disabled_alerts);
|
$info = 'Alert: ' . json_encode($id_enabled_alerts);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
db_pandora_audit("Masive management", "Disaable alert", false, false, $info);
|
db_pandora_audit("Masive management", "Disable alert", false, false, $info);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
db_pandora_audit("Masive management", "Fail try to Disable alert", false, false, $info);
|
db_pandora_audit("Masive management", "Fail try to Disable alert", false, false, $info);
|
||||||
|
|
|
@ -65,9 +65,14 @@ if (isset ($_GET["update_alert"]) && $_GET["update_alert"] == "-1") {
|
||||||
'max_alerts' => $max_alerts,
|
'max_alerts' => $max_alerts,
|
||||||
'min_alerts' => $min_alerts,
|
'min_alerts' => $min_alerts,
|
||||||
'priority' => $priority);
|
'priority' => $priority);
|
||||||
|
if (!$source_ip || !$oid) {
|
||||||
|
$result = '';
|
||||||
|
}
|
||||||
|
else {
|
||||||
$result = db_process_sql_insert('talert_snmp', $values);
|
$result = db_process_sql_insert('talert_snmp', $values);
|
||||||
|
}
|
||||||
|
|
||||||
if ($result === false) {
|
if (!$result) {
|
||||||
echo '<h3 class="error">'.__('There was a problem creating the alert').'</h3>';
|
echo '<h3 class="error">'.__('There was a problem creating the alert').'</h3>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -75,6 +80,11 @@ if (isset ($_GET["update_alert"]) && $_GET["update_alert"] == "-1") {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if (!$source_ip || !$oid) {
|
||||||
|
$result = '';
|
||||||
|
}
|
||||||
|
else {
|
||||||
$sql = sprintf ("UPDATE talert_snmp SET
|
$sql = sprintf ("UPDATE talert_snmp SET
|
||||||
priority = %d, id_alert = %d, al_field1 = '%s', al_field2 = '%s', al_field3 = '%s', description = '%s', agent = '%s', custom_oid = '%s',
|
priority = %d, id_alert = %d, al_field1 = '%s', al_field2 = '%s', al_field3 = '%s', description = '%s', agent = '%s', custom_oid = '%s',
|
||||||
oid = '%s', time_threshold = %d, max_alerts = %d, min_alerts = %d WHERE id_as = %d",
|
oid = '%s', time_threshold = %d, max_alerts = %d, min_alerts = %d WHERE id_as = %d",
|
||||||
|
@ -82,8 +92,9 @@ if (isset ($_GET["update_alert"]) && $_GET["update_alert"] == "-1") {
|
||||||
$oid, $time_threshold, $max_alerts, $min_alerts, $id_as);
|
$oid, $time_threshold, $max_alerts, $min_alerts, $id_as);
|
||||||
|
|
||||||
$result = db_process_sql ($sql);
|
$result = db_process_sql ($sql);
|
||||||
|
}
|
||||||
|
|
||||||
if ($result === false) {
|
if (!$result) {
|
||||||
echo '<h3 class="error">'.__('There was a problem updating the alert').'</h3>';
|
echo '<h3 class="error">'.__('There was a problem updating the alert').'</h3>';
|
||||||
} else {
|
} else {
|
||||||
echo '<h3 class="suc">'.__('Successfully updated').'</h3>';
|
echo '<h3 class="suc">'.__('Successfully updated').'</h3>';
|
||||||
|
|
|
@ -89,6 +89,7 @@ if ($update_profile) {
|
||||||
$alert_management = (bool) get_parameter ("alert_management");
|
$alert_management = (bool) get_parameter ("alert_management");
|
||||||
$pandora_management = (bool) get_parameter ("pandora_management");
|
$pandora_management = (bool) get_parameter ("pandora_management");
|
||||||
|
|
||||||
|
if ($name) {
|
||||||
$sql = sprintf ('UPDATE tperfil SET
|
$sql = sprintf ('UPDATE tperfil SET
|
||||||
name = "%s", incident_view = %d, incident_edit = %d,
|
name = "%s", incident_view = %d, incident_edit = %d,
|
||||||
incident_management = %d, agent_view = %d, agent_edit = %d,
|
incident_management = %d, agent_view = %d, agent_edit = %d,
|
||||||
|
@ -114,6 +115,10 @@ if ($update_profile) {
|
||||||
else {
|
else {
|
||||||
echo '<h3 class="error"'.__('There was a problem updating this profile').'</h3>';
|
echo '<h3 class="error"'.__('There was a problem updating this profile').'</h3>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo '<h3 class="error"'.__('Profile name cannot be empty').'</h3>';
|
||||||
|
}
|
||||||
$id_profile = 0;
|
$id_profile = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +148,8 @@ if ($create_profile) {
|
||||||
'db_management' => $db_management,
|
'db_management' => $db_management,
|
||||||
'alert_management' => $alert_management,
|
'alert_management' => $alert_management,
|
||||||
'pandora_management' => $pandora_management);
|
'pandora_management' => $pandora_management);
|
||||||
|
|
||||||
|
if ($name) {
|
||||||
$ret = db_process_sql_insert('tperfil', $values);
|
$ret = db_process_sql_insert('tperfil', $values);
|
||||||
|
|
||||||
if ($ret !== false) {
|
if ($ret !== false) {
|
||||||
|
@ -160,6 +167,10 @@ if ($create_profile) {
|
||||||
else {
|
else {
|
||||||
echo '<h3 class="error">'.__('There was a problem creating this profile').'</h3>';
|
echo '<h3 class="error">'.__('There was a problem creating this profile').'</h3>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo '<h3 class="error"'.__('There was a problem creating this profile').'</h3>';
|
||||||
|
}
|
||||||
$id_profile = 0;
|
$id_profile = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue