diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc
index f31c70f338708d8f36c233a0736a686aded17e2a..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();
- $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
- if ($this->orig_dn == "new" && $ldap->count()){
+ $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.");
return $message;
}
-
- /* Prepare Unit tag */
- function prepare_unit_tag()
- {
+
+ /* Save to LDAP */
+ function save()
+ {
$ldap= $this->config->get_ldap_link();
+
/* Add tag objects if needed */
if ($this->is_administrational_unit){
if(!in_array_ics("gosaAdministrativeUnit",$this->objectclasses)){
$this->objectclasses[]= "gosaAdministrativeUnit";
- $this->gosaUnitTag= "";
+ $this->gosaUnitTag= "";
}
+
if ($this->gosaUnitTag == ""){
/* It's unlikely, but check if already used... */
}
$this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
}
- }else{
- $this->gosaUnitTag = "";
- }
- }
-
+ }
- /* Save to LDAP */
- function save()
- {
- $ldap= $this->config->get_ldap_link();
- $this->prepare_unit_tag();
plugin::save();
/* Remove tag information if needed */
if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
$tmp[]= $oc;
}
- if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
- $has_unit_tag= true;
- }
+ if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
+ $has_unit_tag= true;
+ }
}
$this->attrs['objectClass']= $tmp;
$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);
/* Tag objects to have the gosaAdministrativeUnitTag */
function tag_objects($OnlySetTagFlag = false)
{
- $this->prepare_unit_tag();
-
if(!$OnlySetTagFlag){
$smarty= get_smarty();
echo "<!-- headers.tpl-->".$smarty->fetch(get_template_path('headers.tpl'));
} else {
$ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
}
+
while ($attrs= $ldap->fetch()){
/* Skip self */