diff --git a/include/class_tests.inc b/include/class_tests.inc index a968bd4b0c76a6208e1ed6f9c8b8518a8e5d39b3..d4cf1f7c141a463afac1041c65a10473a80fb55b 100644 --- a/include/class_tests.inc +++ b/include/class_tests.inc @@ -288,25 +288,21 @@ class tests { * * \param string $base */ - public static function is_department_name_reserved($name, $base) + public static function is_department_name_reserved($name) { - $reservedName = array("systems","apps","incomming","internal","accounts","fax","addressbook", - preg_replace("/ou=(.*),/", "\\1", get_people_ou()), - preg_replace("/ou=(.*),/", "\\1", get_groups_ou())); - $follwedNames['/ou=fai,ou=configs,ou=systems,/'] = array("fai","hooks","templates","scripts","disk","packages","variables","profiles"); - - /* Check if name is one of the reserved names */ - if (in_array_ics($name, $reservedName)) { - return TRUE; - } - - /* Check all follow combinations if name is in array && parent base == array_key, return false*/ - foreach ($follwedNames as $key => $names) { - if ((in_array_ics($name, $names)) && (preg_match($key, $base))) { - return TRUE; + global $config; + $reservedNames = array(); + foreach ($config->data['OBJECTS'] as $type => $infos) { + if (isset($infos['ou'])) { + if ($infos['ou'] != '') { + if (preg_match('/ou=([^,]+),$/', $infos['ou'], $m)) { + $reservedNames[] = $m[1]; + } + } } } - return FALSE; + + return in_array_ics($name, array_unique($reservedNames)); } diff --git a/plugins/admin/departments/class_department.inc b/plugins/admin/departments/class_department.inc index ba60d428123fa9815005afa1ab139711c2fbfe51..510c431a9f555dcafc8a22aa0ab8ac9299f056e3 100644 --- a/plugins/admin/departments/class_department.inc +++ b/plugins/admin/departments/class_department.inc @@ -166,8 +166,10 @@ class department extends simplePlugin $namingAttr = static::$namingAttr; - if (tests::is_department_name_reserved($this->$namingAttr, $this->base)) { - $message[] = msgPool::reserved(_("Name")); + if ($namingAttr == 'ou') { + if (tests::is_department_name_reserved($this->$namingAttr)) { + $message[] = msgPool::reserved(_('Name')); + } } return $message;