From 77091f07eacd743a71797be5839fe91b9b7672c6 Mon Sep 17 00:00:00 2001 From: psc Date: Fri, 26 Jun 2009 10:49:06 +0000 Subject: [PATCH] Check for double group names (Trac: #2756) When adding new groups or editting existing groups check for existing groups and abort with an error if same named groups exist in the same unit tag git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13801 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../locale/core/de/LC_MESSAGES/messages.po | 3 ++ .../admin/groups/class_groupGeneric.inc | 42 +++++++++---------- .../admin/groups/class_groupManagement.inc | 1 + 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/trunk/gosa-core/locale/core/de/LC_MESSAGES/messages.po b/trunk/gosa-core/locale/core/de/LC_MESSAGES/messages.po index 78ad7769d..b235d85d1 100644 --- a/trunk/gosa-core/locale/core/de/LC_MESSAGES/messages.po +++ b/trunk/gosa-core/locale/core/de/LC_MESSAGES/messages.po @@ -6522,3 +6522,6 @@ msgstr "" "Authentisierungscache um eine automatische Wiederanmeldung des Browsers zu " "verhindern." +#: plugins/admin/groups/class_groupGeneric.inc: +msgid "Another group of the same name already exists, saving or creating this group is not allowed. Please rename the group or remove the other group." +msgstr "Es existiert bereits eine gleichnamige Gruppe, daher ist das Erstellen oder Speichern dieser Gruppe nicht erlaubt. Bitte benennen Sie die Gruppe um oder entfernen Sie die andere Gruppe." diff --git a/trunk/gosa-core/plugins/admin/groups/class_groupGeneric.inc b/trunk/gosa-core/plugins/admin/groups/class_groupGeneric.inc index 9740e80ec..4f9cf0767 100644 --- a/trunk/gosa-core/plugins/admin/groups/class_groupGeneric.inc +++ b/trunk/gosa-core/plugins/admin/groups/class_groupGeneric.inc @@ -175,6 +175,7 @@ class group extends plugin $this->groupType= 0; } $this->oldgroupType= $this->groupType; + } /* Get global filter config */ @@ -1121,30 +1122,29 @@ class group extends plugin $message[]= msgPool::duplicated(_("Name")); } } - }else{ - - /* Check for used 'cn' */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",array("cn")); - if ($ldap->count() != 0){ - - /* New entry? */ - if ($this->dn == 'new'){ - $message[]= msgPool::duplicated(_("Name")); - } - - /* Moved? */ - elseif ($new_dn != $this->orig_dn){ - $ldap->fetch(); - if ($ldap->getDN() != $this->orig_dn){ - $message[]= msgPool::duplicated(_("Name")); + /* Check for used 'cn' */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",array("cn", "gosaUnitTag")); + if ($ldap->count() != 0){ + while ($entry = $ldap->fetch()) { + if ($this->gosaUnitTag == '' || ($this->orig_dn != $new_dn)) { + $tag = $this->get_gosaUnitTag($new_dn); + } + else { + $tag = $this->gosaUnitTag; + } + if ($entry['gosaUnitTag'][0] == $tag) { + if ($ldap->getDN() != $this->orig_dn){ + $message[]= _("Another group of the same name already exists, saving or creating this group is not allowed. Please rename the group or remove the other group."); + break; + } + } } } - } - } - + } + /* Check ID */ if ($this->force_gid == "1"){ if (!tests::is_id($this->gidNumber)){ diff --git a/trunk/gosa-core/plugins/admin/groups/class_groupManagement.inc b/trunk/gosa-core/plugins/admin/groups/class_groupManagement.inc index 81c8bb8f9..c2ea563e8 100644 --- a/trunk/gosa-core/plugins/admin/groups/class_groupManagement.inc +++ b/trunk/gosa-core/plugins/admin/groups/class_groupManagement.inc @@ -56,6 +56,7 @@ class groupManagement extends plugin $this->ShowPrimaryCheckBox = true; } + echo "
" . var_dump($this) . "

"; /* Create dialog object */ $this->DivListGroup = new divListGroup($this->config,$this); $this->DivListGroup->DisableCheckBox("ShowPrimaryGroups",$this->ShowPrimaryCheckBox); -- 2.30.2