diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc
index 17efca80a22263730935585e70e710f3ee97ada6..c1ef6e11d3f79cbe72d45c8c033c54e1bf3be0cc 100644 (file)
foreach($_POST as $name => $value){
if(preg_match("/^chooseBase/",$name) && $once){
$once = false;
- $this->dialog = new baseSelectDialog($this->config);
+ $this->dialog = new baseSelectDialog($this->config,$this);
$this->dialog->setCurrentBase($this->base);
}
}
$ldap= $this->config->get_ldap_link();
$ldap->cd ($this->dn);
$ldap->recursive_remove();
- show_ldap_error($ldap->get_error(), _("Removing department failed"));
+ show_ldap_error($ldap->get_error(), sprintf(_("Removing of department with dn '%s' failed."),$this->dn));
/* Optionally execute a command after we're done */
$this->handle_post_events('remove');
function must_be_tagged()
{
- if((isset($this->attrs['gosaUnitTag'][0])) && ($this->is_administrational_unit)){
- $this->must_be_tagged = false;
- }elseif((!isset($this->attrs['gosaUnitTag'][0])) && (!$this->is_administrational_unit)){
- $this->must_be_tagged = false;
- }else{
- $this->must_be_tagged = true;
- }
return $this->must_be_tagged;
}
/* 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.");
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... */
}
$this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
}
- } else {
- $this->gosaUnitTag= "";
}
plugin::save();
$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();
}
}
$ldap->add($this->attrs);
$this->handle_post_events('add');
}
- show_ldap_error($ldap->get_error(), _("Saving department failed"));
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of department with dn '%s' failed."),$this->dn));
+
+ /* 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();
return(true);
} else {
$ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
}
+
while ($attrs= $ldap->fetch()){
/* Skip self */