From 177dd74115df11cb4f197175e41c817a271929c7 Mon Sep 17 00:00:00 2001 From: flop25 Date: Fri, 25 Oct 2013 17:38:16 +0000 Subject: merge r25119 from trunk to branch 2.5 bug:2980 Fatal error when renaming a group git-svn-id: http://piwigo.org/svn/branches/2.5@25147 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/group_list.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'admin/group_list.php') diff --git a/admin/group_list.php b/admin/group_list.php index 390107613..827b48816 100644 --- a/admin/group_list.php +++ b/admin/group_list.php @@ -100,13 +100,23 @@ if (isset($_POST['submit']) and isset($_POST['selectAction']) and isset($_POST[' if ($action=="rename") { + // is the group not already existing ? + $query = ' +SELECT name + FROM '.GROUPS_TABLE.' +;'; + $group_names = array_from_query($query, 'name'); foreach($groups as $group) { - if ( !empty($_POST['rename_'.$group.'']) ) + if ( in_array($_POST['rename_'.$group.''], $group_names)) + { + $page['errors'][] = $_POST['rename_'.$group.''].' | '.l10n('This name is already used by another group.'); + } + elseif ( !empty($_POST['rename_'.$group.''])) { $query = ' UPDATE '.GROUPS_TABLE.' - SET name = \''.$_POST['rename_'.$group.''].'\' + SET name = \''.pwg_db_real_escape_string($_POST['rename_'.$group.'']).'\' WHERE id = '.$group.' ;'; pwg_query($query); -- cgit v1.2.3