X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fdepartments%2Fclass_departmentGeneric.inc;h=5205da94447f99145248934c108fc8bb617b3a91;hb=99b0a430dfa6d1cfad04ccf0302e1fbff0b02e28;hp=df8c51e78fba7c40606b8c74a0adce06897cbea5;hpb=b0550597dff0a710a253f24f11cefa6341ddfefa;p=gosa.git diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc index df8c51e78..5205da944 100644 --- a/plugins/admin/departments/class_departmentGeneric.inc +++ b/plugins/admin/departments/class_departmentGeneric.inc @@ -221,8 +221,8 @@ class department extends plugin /* Check for presence of this department */ $ldap= $this->config->get_ldap_link(); - $attrs= $ldap->cat ($this->dn, array('dn')); - if ($this->orig_dn == "new" && !($attrs === FALSE)){ + $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn')); + if ($this->orig_dn == "new" && $ldap->count()){ $message[]= _("Department with that 'Name' already exists."); } elseif ($this->orig_dn != $this->dn && !($attrs === FALSE)){ $message[]= _("Department with that 'Name' already exists."); @@ -236,17 +236,9 @@ class department extends plugin $message[]= _("Required field 'Description' is not set."); } - /* Validate and modify - or: spaghetti rules! */ - $SkipNames = array( "incoming","apps","systems","fai","config", - preg_replace("/ou=(.*),/","\\1",get_people_ou()), - preg_replace("/ou=(.*),/","\\1",get_groups_ou()) - ); - foreach($SkipNames as $name){ - if ($this->ou == $name){ - $message[]= sprintf(_("The field 'Name' contains the reserved word '%s'. Please choose another name."),$name); - } - } - + if(is_department_name_reserved($this->ou,$this->base)){ + $message[]= sprintf(_("The field 'Name' contains the reserved word '%s'. Please choose another name."),$this->ou); + } if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){ $message[]= _("The field 'Name' contains invalid characters."); @@ -271,7 +263,9 @@ class department extends plugin if ($this->is_administrational_unit){ if(!in_array_ics("gosaAdministrativeUnit",$this->objectclasses)){ $this->objectclasses[]= "gosaAdministrativeUnit"; + $this->gosaUnitTag= ""; } + if ($this->gosaUnitTag == ""){ /* It's unlikely, but check if already used... */ @@ -294,8 +288,6 @@ class department extends plugin } $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec); } - } else { - $this->gosaUnitTag= ""; } plugin::save(); @@ -305,13 +297,18 @@ class department extends plugin $tmp= array(); /* Remove gosaAdministrativeUnit from this plugin */ + $has_unit_tag= false; foreach($this->attrs['objectClass'] as $oc){ if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){ $tmp[]= $oc; } + if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){ + $has_unit_tag= true; + } } $this->attrs['objectClass']= $tmp; - if(isset($this->attrs['gosaUnitTag'])){ + + if(!$has_unit_tag && isset($this->attrs['gosaUnitTag'])){ $this->attrs['gosaUnitTag']= array(); } } @@ -336,6 +333,11 @@ class department extends plugin /* The parameter forces only to set must_be_tagged, and don't touch any objects This will be done later */ $this->tag_objects(true); + + /* Fix tagging if needed */ + if (!$this->is_administrational_unit){ + $this->handle_object_tagging(); + } /* Optionally execute a command after we're done */ $this->postcreate(); @@ -381,6 +383,7 @@ class department extends plugin } else { $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn')); } + while ($attrs= $ldap->fetch()){ /* Skip self */ @@ -445,7 +448,7 @@ class department extends plugin echo "".$smarty->fetch(get_template_path('headers.tpl')); echo ""; - echo "

".sprintf(_("Moving '%s' to '%s'"),"".$src_dn."","".$dst_dn."")."

"; + echo "

".sprintf(_("Moving '%s' to '%s'"),"".@LDAP::fix($src_dn)."","".@LDAP::fix($dst_dn)."")."

"; /* Check if the destination entry exists */ @@ -454,9 +457,9 @@ class department extends plugin /* Check if destination exists - abort */ $ldap->cat($dst_dn, array('dn')); if ($ldap->fetch()){ - trigger_error("Recursive_move $dst_dn already exists.", + trigger_error("Recursive_move ".@LDAP::fix($dst_dn)." already exists.", E_USER_WARNING); - echo sprintf("Recursive_move: '%s' already exists", $dst_dn)."
"; + echo sprintf("Recursive_move: '%s' already exists", @LDAP::fix($dst_dn))."
"; return (FALSE); } @@ -481,10 +484,10 @@ class department extends plugin $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object); $dst= str_replace($src_dn,$dst_dn,$object); - echo ""._("Object").": $src
"; + echo ""._("Object").": ".@LDAP::fix($src)."
"; if (!$this->copy($src, $dst)){ - echo "
".sprintf(_("FAILED to copy %s, aborting operation"),$src)."
"; + echo "
".sprintf(_("FAILED to copy %s, aborting operation"),@LDAP::fix($src))."
"; return (FALSE); }