diff --git a/pandora_console/godmode/agentes/planned_downtime.php b/pandora_console/godmode/agentes/planned_downtime.php
index a4bca24927..8eb59db83e 100644
--- a/pandora_console/godmode/agentes/planned_downtime.php
+++ b/pandora_console/godmode/agentes/planned_downtime.php
@@ -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 "
".__('Each planned downtime must have a different name')."
";
+ }
+ }
+ else {
+ echo ''.__('Planned downtime must have a name').'
';
+ }
}
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 "".__('Each planned downtime must have a different name')."
";
+ }
+ }
+ else {
+ echo ''.__('Planned downtime must have a name').'
';
+ }
}
if ($result === false) {
@@ -134,10 +157,10 @@ if ($create_downtime || $update_downtime) {
}
}
else {
- if($create_downtime) {
+ if($create_downtime && $name && !$check) {
echo ''.__('Successfully created').'
';
}
- else {
+ else if ($update_downtime && $name && !$check || $subcheck == $name) {
echo ''.__('Successfully updated').'
';
}
}
diff --git a/pandora_console/godmode/groups/modu_group_list.php b/pandora_console/godmode/groups/modu_group_list.php
index 7a67a081ff..227422056d 100644
--- a/pandora_console/godmode/groups/modu_group_list.php
+++ b/pandora_console/godmode/groups/modu_group_list.php
@@ -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 "".__('Group successfully created')."
";
+ if ($result) {
+ echo "".__('Group successfully created')."
";
+ }
+ else {
+ echo "".__('There was a problem creating group')."
";
+ }
}
else {
- echo "".__('There was a problem creating group')."
";
+ echo "".__('Each module group must have a different name')."
";
}
}
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 "".__('Group successfully updated')."
";
+ if ($result !== false) {
+ echo "".__('Group successfully updated')."
";
+ }
+ else {
+ echo "".__('There was a problem modifying group')."
";
+ }
}
else {
- echo "".__('There was a problem modifying group')."
";
+ echo "".__('Each module group must have a different name')."
";
}
}
else {