2011-07-20 Tomas Palacios <tomas.palacios@artica.es>

* godmode/groups/modu_group_list.php: Fixed a bug
        regarding adition of module groups with a identical names.

        * godmode/agentes/planned_downtime.php: Fixed a bug
        regarding adition of planned downtimes with identical
        or blank "name" fields.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4596 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Aldrioth 2011-07-20 11:21:51 +00:00
parent 62375eb291
commit db8a398679
2 changed files with 62 additions and 26 deletions

View File

@ -96,6 +96,9 @@ if ($delete_downtime) {
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);
@ -105,24 +108,44 @@ if ($create_downtime || $update_downtime) {
else {
$sql = '';
if ($create_downtime) {
$values = array(
'name' => $name,
'description' => $description,
'date_from' => $datetime_from,
'date_to' => $datetime_to,
'id_group' => $id_group,
'only_alerts' => (int)$only_alerts);
$result = db_process_sql_insert('tplanned_downtime', $values);
if ($name) {
if (!$check) {
$values = array(
'name' => $name,
'description' => $description,
'date_from' => $datetime_from,
'date_to' => $datetime_to,
'id_group' => $id_group,
'only_alerts' => (int)$only_alerts);
$result = db_process_sql_insert('tplanned_downtime', $values);
}
else {
echo "<h3 class='error'>".__('Each planned downtime must have a different name')."</h3>";
}
}
else {
echo '<h3 class="error">'.__('Planned downtime must have a name').'</h3>';
}
}
else if ($update_downtime) {
$values = array(
'name' => $name,
'description' => $description,
'date_from' => $datetime_from,
'date_to' => $datetime_to,
'id_group' => $id_group,
'only_alerts' => (int)$only_alerts);
$result = db_process_sql_update('tplanned_downtime', $values, array('id' => $id_downtime));
if ($name) {
if (!$check || $subcheck == $name) {
$values = array(
'name' => $name,
'description' => $description,
'date_from' => $datetime_from,
'date_to' => $datetime_to,
'id_group' => $id_group,
'only_alerts' => (int)$only_alerts);
$result = db_process_sql_update('tplanned_downtime', $values, array('id' => $id_downtime));
}
else {
echo "<h3 class='error'>".__('Each planned downtime must have a different name')."</h3>";
}
}
else {
echo '<h3 class="error">'.__('Planned downtime must have a name').'</h3>';
}
}
if ($result === false) {
@ -134,10 +157,10 @@ if ($create_downtime || $update_downtime) {
}
}
else {
if($create_downtime) {
if($create_downtime && $name && !$check) {
echo '<h3 class="suc">'.__('Successfully created').'</h3>';
}
else {
else if ($update_downtime && $name && !$check || $subcheck == $name) {
echo '<h3 class="suc">'.__('Successfully updated').'</h3>';
}
}

View File

@ -64,15 +64,21 @@ if ($create_group) {
$id_parent = (int) get_parameter ('id_parent');
$alerts_disabled = (bool) get_parameter ('alerts_disabled');
$custom_id = (string) get_parameter ('custom_id');
$check = db_get_value('name', 'tmodule_group', 'name', $name);
if ($name){
$result = db_process_sql_insert('tmodule_group', array('name' => $name));
if (!$check) {
$result = db_process_sql_insert('tmodule_group', array('name' => $name));
if ($result) {
echo "<h3 class='suc'>".__('Group successfully created')."</h3>";
if ($result) {
echo "<h3 class='suc'>".__('Group successfully created')."</h3>";
}
else {
echo "<h3 class='error'>".__('There was a problem creating group')."</h3>";
}
}
else {
echo "<h3 class='error'>".__('There was a problem creating group')."</h3>";
echo "<h3 class='error'>".__('Each module group must have a different name')."</h3>";
}
}
else {
@ -88,15 +94,22 @@ if ($update_group) {
$id_parent = (int) get_parameter ('id_parent');
$alerts_enabled = (bool) get_parameter ('alerts_enabled');
$custom_id = (string) get_parameter ('custom_id');
$check = db_get_value('name', 'tmodule_group', 'name', $name);
$subcheck = db_get_value('name', 'tmodule_group', 'id_mg', $id_group);
if ($name) {
$result = db_process_sql_update('tmodule_group', array('name' => $name), array('id_mg' => $id_group));
if (!$check || $subcheck == $name) {
$result = db_process_sql_update('tmodule_group', array('name' => $name), array('id_mg' => $id_group));
if ($result !== false) {
echo "<h3 class='suc'>".__('Group successfully updated')."</h3>";
if ($result !== false) {
echo "<h3 class='suc'>".__('Group successfully updated')."</h3>";
}
else {
echo "<h3 class='error'>".__('There was a problem modifying group')."</h3>";
}
}
else {
echo "<h3 class='error'>".__('There was a problem modifying group')."</h3>";
echo "<h3 class='error'>".__('Each module group must have a different name')."</h3>";
}
}
else {