diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 3dc3549508..15a899ea80 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2011-09-05 Miguel de Dios + + * godmode/agentes/planned_downtime.php: fixed to avoid create or update + "Planned downtimes" with empty names or all white spaces or identical name + to others. And disabled the button to add agent in the "Planned downtimes" + when in the list of agents in group is none. + + Fixes: #3371256 + 2011-09-05 Juan Manuel Ramon * general/pandora_help.php: Fixed visualization error on this view. diff --git a/pandora_console/godmode/agentes/planned_downtime.php b/pandora_console/godmode/agentes/planned_downtime.php index 73b48e6298..14d3ea9ac9 100644 --- a/pandora_console/godmode/agentes/planned_downtime.php +++ b/pandora_console/godmode/agentes/planned_downtime.php @@ -97,7 +97,6 @@ if ($create_downtime || $update_downtime) { $description = (string) get_parameter ('description'); $name = (string) get_parameter ('name'); $check = db_get_value ('name', 'tplanned_downtime', 'name', $name); - $subcheck = db_get_value ('name', 'tplanned_downtime', 'id_group', $id_group); $datetime_from = strtotime ($date_from.' '.$time_from); $datetime_to = strtotime ($date_to.' '.$time_to); @@ -108,7 +107,7 @@ if ($create_downtime || $update_downtime) { else { $sql = ''; if ($create_downtime) { - if ($name) { + if (trim(io_safe_output($name)) != '') { if (!$check) { $values = array( 'name' => $name, @@ -128,8 +127,8 @@ if ($create_downtime || $update_downtime) { } } else if ($update_downtime) { - if ($name) { - if (!$check || $subcheck == $name) { + if (trim(io_safe_output($name)) != '') { + if (!$check) { $values = array( 'name' => $name, 'description' => $description, @@ -160,15 +159,17 @@ if ($create_downtime || $update_downtime) { if($create_downtime && $name && !$check) { echo '

'.__('Successfully created').'

'; } - else if ($update_downtime && $name && !$check || $subcheck == $name) { + else if ($update_downtime && $name && !$check) { echo '

'.__('Successfully updated').'

'; } } } } + +//////////////////////////////// // Show create / update form - +//////////////////////////////// if (($first_create != 0) OR ($first_update != 0)){ // Have any data to show ? if ($id_downtime > 0) { @@ -269,12 +270,18 @@ if ($create_downtime || $update_downtime) { ORDER by tagente.nombre", $id_downtime); $downtimes = db_get_all_rows_sql ($sql); $data = array (); - if ($downtimes) + if ($downtimes) { foreach ($downtimes as $downtime) { if (check_acl ($config["id_user"], $downtime['id_grupo'], "AR")) { $data[$downtime['id_agente']] = $downtime['nombre']; } } + } + + $disabled_add_button = false; + if (empty($data)) { + $disabled_add_button = true; + } echo "
"; @@ -288,7 +295,7 @@ if ($create_downtime || $update_downtime) { echo html_print_select ($data, "id_agent[]", '', '', '', 0, false, true, true, '', false, 'width: 180px;'); echo "


"; - html_print_submit_button (__('Add'), '', false, 'class="sub next"',false); + html_print_submit_button (__('Add'), '', $disabled_add_button, 'class="sub next"',false); echo "
"; echo "";