Commit d0a3d36f authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #5311 Reserved department names are now computed from object types directly

Showing with 16 additions and 18 deletions
+16 -18
...@@ -288,25 +288,21 @@ class tests { ...@@ -288,25 +288,21 @@ class tests {
* *
* \param string $base * \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", global $config;
preg_replace("/ou=(.*),/", "\\1", get_people_ou()), $reservedNames = array();
preg_replace("/ou=(.*),/", "\\1", get_groups_ou())); foreach ($config->data['OBJECTS'] as $type => $infos) {
$follwedNames['/ou=fai,ou=configs,ou=systems,/'] = array("fai","hooks","templates","scripts","disk","packages","variables","profiles"); if (isset($infos['ou'])) {
if ($infos['ou'] != '') {
/* Check if name is one of the reserved names */ if (preg_match('/ou=([^,]+),$/', $infos['ou'], $m)) {
if (in_array_ics($name, $reservedName)) { $reservedNames[] = $m[1];
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;
} }
} }
return FALSE;
return in_array_ics($name, array_unique($reservedNames));
} }
......
...@@ -166,8 +166,10 @@ class department extends simplePlugin ...@@ -166,8 +166,10 @@ class department extends simplePlugin
$namingAttr = static::$namingAttr; $namingAttr = static::$namingAttr;
if (tests::is_department_name_reserved($this->$namingAttr, $this->base)) { if ($namingAttr == 'ou') {
$message[] = msgPool::reserved(_("Name")); if (tests::is_department_name_reserved($this->$namingAttr)) {
$message[] = msgPool::reserved(_('Name'));
}
} }
return $message; return $message;
......
  • bmortier @bmortier

    mentioned in issue #1695 (closed)

    By Côme Chilliet on 2017-09-02T15:35:10 (imported from GitLab)

    ·

    mentioned in issue #1695 (closed)

    By Côme Chilliet on 2017-09-02T15:35:10 (imported from GitLab)

    Toggle commit list
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment