prevent groups with duplicate names from being created
This commit is contained in:
parent
c226b94ce2
commit
c073c82436
2 changed files with 10 additions and 1 deletions
|
|
@ -463,7 +463,15 @@ sub www_editGroupSave {
|
|||
return $session->privilege->adminOnly() unless (canEditGroup($session,$session->form->process("gid")));
|
||||
my $g = WebGUI::Group->new($session,$session->form->process("gid"));
|
||||
$g->description($session->form->process("description"));
|
||||
$g->name($session->form->process("groupName"));
|
||||
# We don't want them to use an existing name. If needed, we'll ad a number to the name to keep it unique.
|
||||
my $groupName = $session->form->process("groupName");
|
||||
while (WebGUI::Group->find($session, $groupName)->getId) {
|
||||
$groupName =~ s/\A(.*?)(\d*)\z/
|
||||
my $newNum = ($2 || 0) + 1;
|
||||
substr($1, 0, 100 - length($newNum)) . $newNum; #prevent name from growing over 100 chars
|
||||
/emsx;
|
||||
}
|
||||
$g->name($groupName);
|
||||
$g->expireOffset($session->form->interval("expireOffset"));
|
||||
$g->karmaThreshold($session->form->process("karmaThreshold"));
|
||||
$g->ipFilter($session->form->process("ipFilter"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue