From: psc Date: Thu, 29 Oct 2009 09:56:07 +0000 (+0000) Subject: Followup commit for #3200 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=84fd247175a3770d763da5c7599d14781c7a8656;p=gosa.git Followup commit for #3200 - Use release dn as search base when checking if a given classname is already used by another administrative unit. - Remove the unittag from the filter that is used to search for existing classes. This way every class is found that has the same name and it can not happen, that the error may not be shown under some circumstances. - As a side-effect of the previous change, the error might also be shown, if the classname is in use in the same administrative unit. But this is already handled by a standard duplicate check, so to avoid double error message, we only check for the classnames, if the previous check didn't trigger an error message. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@14703 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/trunk/gosa-plugins/fai/admin/fai/class_askClassName.inc b/trunk/gosa-plugins/fai/admin/fai/class_askClassName.inc index 6b9c49649..de302bd2a 100644 --- a/trunk/gosa-plugins/fai/admin/fai/class_askClassName.inc +++ b/trunk/gosa-plugins/fai/admin/fai/class_askClassName.inc @@ -149,33 +149,31 @@ class askClassName extends plugin if(in_array($this->ClassName,$this->forbidden)){ $message[]= msgPool::duplicated(_("Name")); } - - /* Check if the given ClassName is already used in another administrative unit */ - $parent_tag = $this->get_gosaUnitTag($this->parent->base); - - $ldap= $this->config->get_ldap_link(); - $filter = "(&(cn=".$this->ClassName.")(!(gosaUnitTag=".$parent_tag.")))"; - $ldap->search($filter, array("dn","gosaUnitTag")); - - if ($ldap->count() > 0) { - $entry = $ldap->fetch(); - - /* Find out which administrative unit is using the classname */ - $ldap->cd($this->config->current['BASE']); - $filter = "(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=".$entry['gosaUnitTag'][0]."))"; - $ldap->search($filter, array('dn', 'ou')); + else { + /* Check if the given ClassName is already used in another administrative unit */ + $ldap= $this->config->get_ldap_link(); + $filter = "(cn=".$this->ClassName.")"; + $ldap->cd($this->parent->fai_release); + $ldap->search($filter, array("dn","gosaUnitTag")); if ($ldap->count() > 0) { $entry = $ldap->fetch(); - $used_by = $entry['ou'][0]; - } else { - $used_by = $entry['gosaUnitTag'][0]; - } - - $message[]= sprintf(_("This FAI class name is already in use by the administrative unit '%s'."), $used_by); - - } + /* Find out which administrative unit is using the classname */ + $ldap->cd($this->config->current['BASE']); + $filter = "(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=".$entry['gosaUnitTag'][0]."))"; + $ldap->search($filter, array('dn', 'ou')); + + if ($ldap->count() > 0) { + $entry = $ldap->fetch(); + $used_by = $entry['ou'][0]; + } else { + $used_by = $entry['gosaUnitTag'][0]; + } + + $message[]= sprintf(_("This FAI class name is already in use by the administrative unit '%s'."), $used_by); + } + } return ($message); }