From 43926fd0222b5a7b9caec7daa19d6e3f27106dd8 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Thu, 22 Apr 2010 16:18:32 +0000 Subject: [PATCH] 2010-04-22 Sergio Martin * godmode/groups/group_list.php: Added validation when remove a group. Now, if the group is not empty shows a message and dont allow to remove it git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2587 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++++ pandora_console/godmode/groups/group_list.php | 28 +++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index b359b2fe19..ac79ec0a0e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2010-04-22 Sergio Martin + + * godmode/groups/group_list.php: Added validation + when remove a group. Now, if the group is not empty + shows a message and dont allow to remove it + 2010-04-22 Miguel de Dios * include/javascript/pandora.js: erased trace line in the source of function diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 0ff42bf2f6..e6d4f9d685 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -113,22 +113,26 @@ if ($update_group) { if ($delete_group) { $id_group = (int) get_parameter ('id_group'); - // First valid group for destination group in agents affected by this group delete - $valid_group = process_sql ("SELECT id_group FROM tgrupo WHERE id_grupo != $id_group AND id_grupo > 0 LIMIT 1"); + $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo = %d', $id_group); + $agent = process_sql ($sql); + + if(!$agent){ - $sql = sprintf ('UPDATE tagente set id_grupo = 1 WHERE id_grupo = %d', $valid_group); - $result = process_sql ($sql); + $sql = sprintf ('DELETE FROM tgroup_stat WHERE id_group = %d', $id_group); + $result = process_sql ($sql); + + $sql = sprintf ('DELETE FROM tgrupo WHERE id_grupo = %d', $id_group); + $result = process_sql ($sql); + } + else + echo "

".__('The group is not empty.')."

"; - $sql = sprintf ('DELETE FROM tgrupo WHERE id_grupo = %d', $id_group); - $result = process_sql ($sql); - - $sql = sprintf ('DELETE FROM tgroup_stat WHERE id_group = %d', $id_group); - $result = process_sql ($sql); - - if (! $result) + + if (!$result || $agent ) echo "

".__('There was a problem deleting group')."

"; else echo "

".__('Group successfully deleted')."

"; + } @@ -143,7 +147,7 @@ $table->align = array (); $table->align[4] = 'center'; $table->data = array (); -$groups = get_user_groups ($config['id_user']); +$groups = get_user_groups ($config['id_user'], "AR"); foreach ($groups as $id_group => $group_name) { $data = array ();