Code

Updated ACL category
[gosa.git] / gosa-core / plugins / admin / departments / class_departmentGeneric.inc
1 <?php
2 /*
3  * This code is part of GOsa (http://www.gosa-project.org)
4  * Copyright (C) 2003-2008 GONICUS GmbH
5  *
6  * ID: $$Id$$
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
23 class department extends plugin
24 {
25         /* department attributes */
26         var $ou= "";
27         var $description= "";
28         var $base= "";
29         var $st= "";
30         var $l= "";
31         var $postalAddress= "";
32         var $businessCategory= "";
33         var $telephoneNumber= "";
34         var $facsimileTelephoneNumber= "";
35         var $is_administrational_unit= false;
36         var $gosaUnitTag= "";
37   var $view_logged = FALSE;
39   var $type ="ou";
40   var $namingAttr = "ou";
42         /* Headpage attributes */
43         var $last_dep_sorting= "invalid";
44         var $departments= array();
45   var $must_be_tagged = false;
47         /* attribute list for save action */
48         var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress",
49                         "telephoneNumber", "facsimileTelephoneNumber", "gosaUnitTag");
50         var $objectclasses= array("top", "gosaDepartment", "organizationalUnit");
51   var $initially_was_tagged = false;
53   var $orig_base = "";
54   var $orig_ou = "";
56         function department (&$config, $dn)
57         {
59                 plugin::plugin($config, $dn);
60                 $this->is_account= TRUE;
61                 $this->ui= get_userinfo();
62                 $this->dn= $dn;
63                 $this->orig_dn= $dn;
65     /* Save current naming attribuet 
66      */
67     $nA      = $this->namingAttr;
68     $orig_nA = "orig_".$nA;
69     $this->$orig_nA = $this->$nA;
71                 $this->config= $config;
73                 /* Set base */
74                 if ($this->dn == "new"){
75                         $ui= get_userinfo();
76                         if(session::is_set('CurrentMainBase')){
77                                 $this->base = session::get('CurrentMainBase');
78                         }else{
79                                 $this->base= dn2base($ui->dn);
80                         }
81                 } else {
82                         $this->base= preg_replace ("/^[^,]+,/", "", $this->dn);
83                 }
85     $this->orig_base = $this->base;
87                 /* Is administrational Unit? */
88                 if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){
89                         $this->is_administrational_unit= true;
90       $this->initially_was_tagged = true;
91                 }
92         }
94         function execute()
95         {
96                 /* Call parent execute */
97                 plugin::execute();
99     /* Log view */
100     if($this->is_account && !$this->view_logged){
101       $this->view_logged = TRUE;
102       new log("view","department/".get_class($this),$this->dn);
103     }
105                 /* Reload departments */
106                 $this->config->get_departments($this->dn);
107                 $this->config->make_idepartments();
108                 $smarty= get_smarty();
110     $tmp = $this->plInfo();
111     foreach($tmp['plProvidedAcls'] as $name => $translation){
112       $smarty->assign($name."ACL",$this->getacl($name));
113     }
115     /* Hide base selector, if this object represents the base itself 
116      */
117     $smarty->assign("is_root_dse", FALSE);
118     if($this->dn == $this->config->current['BASE']){
119       $smarty->assign("is_root_dse", TRUE);
120       $nA = $this->namingAttr."ACL";
121       $smarty->assign($nA,$this->getacl($this->namingAttr,TRUE));
122     }
124                 /* Base select dialog */
125                 $once = true;
126                 foreach($_POST as $name => $value){
127                         if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){
128                                 $once = false;
129                                 $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
130                                 $this->dialog->setCurrentBase($this->base);
131                         }
132                 }
134                 /* Dialog handling */
135                 if(is_object($this->dialog)){
136                         /* Must be called before save_object */
137                         $this->dialog->save_object();
139                         if($this->dialog->isClosed()){
140                                 $this->dialog = false;
141                         }elseif($this->dialog->isSelected()){
143         /* A new base was selected, check if it is a valid one */
144         $tmp = $this->get_allowed_bases();
145         if(isset($tmp[$this->dialog->isSelected()])){
146           $this->base = $this->dialog->isSelected();
147         }
148   
149                                 $this->dialog= false;
150                         }else{
151                                 return($this->dialog->execute());
152                         }
153                 }
155                 /* Hide all departments, that are subtrees of this department */
156     $bases = $this->get_allowed_bases();
157                 if(($this->dn == "new")||($this->dn == "")){
158                         $tmp = $bases;
159                 }else{
160                         $tmp    = array();      
161                         foreach($bases as $dn=>$base){
162                                 $fixed = str_replace("/","\\",$this->dn);
163                                 /* Only attach departments which are not a subtree of this one */
164                                 if(!preg_match("/".$fixed."/",$dn)){
165                                         $tmp[$dn]=$base;
166                                 }
167                         }
168                 }
169                 $smarty->assign("bases", $tmp);
171                 foreach ($this->attributes as $val){
172                         $smarty->assign("$val", $this->$val);
173                 }
174                 $smarty->assign("base_select", $this->base);
176     /* Set admin unit flag */
177     if ($this->is_administrational_unit) {
178       $smarty->assign("gosaUnitTag", "checked");
179     } else {
180       $smarty->assign("gosaUnitTag", "");
181     }
183     $smarty->assign("dep_type",$this->type);
184     
186     $dep_types = departmentManagement::get_support_departments();
187     $tpl ="";
188     foreach($dep_types as $key => $data){
189       if($data['ATTR'] == $this->type){
190         $tpl = $data['TPL'];
191         break;
192       }
193     }
194     if($tpl == "") {
195       trigger_error("No template specified for container type '".$this->type."', please update epartmentManagement::get_support_departments().");
196       $tpl = "generic.tpl";
197     }
198                 return($smarty->fetch (get_template_path($tpl, TRUE)));
199         }
201         function clear_fields()
202         {
203                 $this->dn   = "";
204                 $this->base = "";
206                 foreach ($this->attributes as $val){
207                         $this->$val= "";
208                 }
209         }
211         function remove_from_parent()
212         {
213                 $ldap= $this->config->get_ldap_link();
214                 $ldap->cd ($this->dn);
215                 $ldap->rmdir_recursive($this->dn);
216     new log("remove","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
217     if (!$ldap->success()){
218       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
219     }
221                 /* Optionally execute a command after we're done */
222                 $this->handle_post_events('remove');
223         }
225         function must_be_tagged()
226         {
227                 return $this->must_be_tagged;
228         }
230         /* Save data to object */
231         function save_object()
232         {
233     if (isset($_POST['dep_generic_posted'])){
235       $nA = $this->namingAttr;
236       $old_nA = $this->$nA;
240       /* Create a base backup and reset the
241          base directly after calling plugin::save_object();
242          Base will be set seperatly a few lines below */
243       $base_tmp = $this->base;
244       plugin::save_object();
245       $this->base = $base_tmp;
247       /* Set new base if allowed */
248       $tmp = $this->get_allowed_bases();
249       if(isset($_POST['base'])){
250         if(isset($tmp[$_POST['base']])){
251           $this->base= $_POST['base'];
252         }
253       }
255       /* Save tagging flag */
256       if ($this->acl_is_writeable("gosaUnitTag")){
257         if (isset($_POST['is_administrational_unit'])){
258           $this->is_administrational_unit= true;
259         } else {
260           $this->is_administrational_unit= false;
261         }
262       }
264       /* If this is the root directory service entry (rootDSE)
265          then avoid changing the naming attribute of this entry.
266        */
267       if($this->dn == $this->config->current['BASE']){
268         $this->$nA = $old_nA;
269       }
270     }
271         }
274         /* Check values */
275         function check()
276         {
277                 /* Call common method to give check the hook */
278                 $message= plugin::check();
280                 /* Check for presence of this department */
281                 $ldap= $this->config->get_ldap_link();
282     $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
283     if ($this->orig_dn == "new" && $ldap->count()){
284                         $message[]= msgPool::duplicated(_("Name"));
285                 } elseif ($this->orig_dn != $this->dn && $ldap->count()){
286                         $message[]= msgPool::duplicated(_("Name"));
287                 }
289                 /* All required fields are set? */
290                 if ($this->ou == ""){
291                         $message[]= msgPool::required(_("Name"));
292                 }
293                 if ($this->description == ""){
294                         $message[]= msgPool::required(_("Description"));
295                 }
297     if(tests::is_department_name_reserved($this->ou,$this->base)){
298       $message[]= msgPool::reserved(_("Name"));
299     }
301                 if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
302                         $message[]= msgPool::invalid(_("Name"), $this->ou, "/[^#+:=>\\\\\/]/");
303                 }
304                 if (!tests::is_phone_nr($this->telephoneNumber)){
305                         $message[]= msgPool::invalid(_("Phone"), $this->telephoneNumber, "/[\/0-9 ()+*-]/");
306                 }
307                 if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){
308                         $message[]= msgPool::invalid(_("Fax"), $this->facsimileTelephoneNumber, "/[\/0-9 ()+*-]/");
309                 }
311     /* Check if we are allowed to create or move this object
312      */
313     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
314       $message[] = msgPool::permCreate();
315     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
316       $message[] = msgPool::permMove();
317     }
319     return $message;
320         }
323         /* Save to LDAP */
324         function save()
325         {
326                 $ldap= $this->config->get_ldap_link();
328     /* Ensure that ou is saved too, it is required by objectClass gosaDepartment 
329      */
330     $nA = $this->namingAttr;
331     $this->ou = $this->$nA;
333     /* Add tag objects if needed */
334     if ($this->is_administrational_unit){
336       /* If this wasn't tagged before add oc an reset unit tag */
337       if(!$this->initially_was_tagged){
338         $this->objectclasses[]= "gosaAdministrativeUnit";
339         $this->gosaUnitTag= "";
341         /* It seams that this method is called twice, 
342            set this to true. to avoid adding this oc twice */
343         $this->initially_was_tagged = true;
344       }
346       if ($this->gosaUnitTag == ""){
348         /* It's unlikely, but check if already used... */
349         $try= 5;
350         $ldap->cd($this->config->current['BASE']);
351         while ($try--){
353           /* Generate microtime stamp as tag */
354           list($usec, $sec)= explode(" ", microtime());
355           $time_stamp= preg_replace("/\./", "", $sec.$usec);
357           $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag"));
358           if ($ldap->count() == 0){
359             break;
360           }
361         }
362         if($try == 0) {
363           msg_dialog::display(_("Fatal error"), _("Cannot find an unused tag for this administrative unit!"), WARNING_DIALOG);
364           return;
365         }
366         $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
367       }
368     }
369     $this->skipTagging = TRUE;
370     plugin::save();
373     /* Remove tag information if needed */
374     if (!$this->is_administrational_unit && $this->initially_was_tagged){
375       $tmp= array();
377       /* Remove gosaAdministrativeUnit from this plugin */
378       $has_unit_tag= false;
379       foreach($this->attrs['objectClass'] as $oc){
380         if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
381           $tmp[]= $oc;
382         }
383         if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
384           $has_unit_tag= true;
385         }
386       }
387       $this->attrs['objectClass']= $tmp;
388       $this->attrs['gosaUnitTag']= array();
389       $this->gosaUnitTag = "";
390     }
393                 /* Write back to ldap */
394                 $ldap->cat($this->dn, array('dn'));
395                 $ldap->cd($this->dn);
397                 if ($ldap->count()){
398                         $this->cleanup();
399                         $ldap->modify ($this->attrs); 
400       new log("modify","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
401                         $this->handle_post_events('modify');
402                 } else {
403                         $ldap->add($this->attrs);
404                         $this->handle_post_events('add');
405       new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
406                 }
407     if (!$ldap->success()){
408       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
409     }
411     /* The parameter forces only to set must_be_tagged, and don't touch any objects 
412        This will be done later */
413     $this->tag_objects(true);
414     
415     /* Optionally execute a command after we're done */
416                 $this->postcreate();
417     return(false);
418         }
421         /* Tag objects to have the gosaAdministrativeUnitTag */
422         function tag_objects($OnlySetTagFlag = false)
423         {
424     if(!$OnlySetTagFlag){
425       $smarty= get_smarty();
426       /* Print out html introduction */
427       echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
428         <html>
429         <head>
430         <title></title>
431         <style type="text/css">@import url("themes/default/style.css");</style>
432         <script language="javascript" src="include/focus.js" type="text/javascript"></script>
433         </head>
434         <body style="background: none; margin:4px;" id="body" >
435         ';
436       echo "<h3>".sprintf(_("Tagging '%s'."),"<i>".@LDAP::fix($this->dn)."</i>")."</h3>";
437     }
439     $add= $this->is_administrational_unit;
440     $len= strlen($this->dn);
441     $ldap= $this->config->get_ldap_link();
442     $ldap->cd($this->dn);
443     if ($add){
444             $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
445                                                     $this->gosaUnitTag.')))', array('dn'));
446     } else {
447             $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
448     }
450     $objects = array();
451     while ($attrs= $ldap->fetch()){
452       $objects[] = $attrs;
453     }
454     foreach($objects as $attrs){
456             /* Skip self */
457             if ($attrs['dn'] == $this->dn){
458                     continue;
459             }
461             /* Check for confilicting administrative units */
462             $fix= true;
463             foreach ($this->config->adepartments as $key => $tag){
464                     /* This one is shorter than our dn, its not relevant... */
465                     if ($len >= strlen($key)){
466                             continue;
467                     }
469                     /* This one matches with the latter part. Break and don't fix this entry */
470                     if (preg_match('/(^|,)'.normalizePreg($key).'$/', $attrs['dn'])){
471                             $fix= false;
472                             break;
473                     }
474             }
476             /* Fix entry if needed */
477             if ($fix){
478                     if($OnlySetTagFlag){
479                             $this->must_be_tagged =true;
480                             return;
481                     }
482                     $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
483         echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
484             }
485     }
486     
487     if(!$OnlySetTagFlag){
488       $this->must_be_tagged = FALSE;
489             echo '<p class="seperator">&nbsp;</p>';
490       echo "<div style='width:100%;text-align:right;'>".
491         "<form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>".
492         "<br>".
493         "<input type='submit' name='back' value='"._("Continue")."'>".
494         "<input type='hidden' name='php_c_check' value='1'>".
495         "</form>".
496         "</div>";
497       echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
498     }
499         }
502         /* Move/Rename complete trees */
503         function recursive_move($src_dn, $dst_dn,$force = false)
504         {
505     /* Print header to have styles included */
506     $smarty= get_smarty();
508     echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
509       <html>
510       <head>
511       <title></title>
512       <style type="text/css">@import url("themes/default/style.css");</style>
513       <script language="javascript" src="include/focus.js" type="text/javascript"></script>
514       </head>
515       <body style="background: none; margin:4px;" id="body" >
516       ';
517     echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".@LDAP::fix($src_dn)."</i>","<i>".@LDAP::fix($dst_dn)."</i>")."</h3>";
520     /* Check if the destination entry exists */
521     $ldap= $this->config->get_ldap_link();
523     /* Check if destination exists - abort */
524     $ldap->cat($dst_dn, array('dn'));
525     if ($ldap->fetch()){
526       trigger_error("Recursive_move ".@LDAP::fix($dst_dn)." already exists.",
527           E_USER_WARNING);
528       echo sprintf("Recursive_move: '%s' already exists", @LDAP::fix($dst_dn))."<br>"; 
529       return (FALSE);
530     }
532     /* Perform a search for all objects to be moved */
533     $objects= array();
534     $ldap->cd($src_dn);
535     $ldap->search("(objectClass=*)", array("dn"));
536     while($attrs= $ldap->fetch()){
537       $dn= $attrs['dn'];
538       $objects[$dn]= strlen($dn);
539     }
541     /* Sort objects by indent level */
542     asort($objects);
543     reset($objects);
545     /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
546     foreach ($objects as $object => $len){
549       $src= str_replace("\\","\\\\",$object);
550       $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
551       $dst= str_replace($src_dn,$dst_dn,$object);
553       echo "<b>"._("Object").":</b> ".@LDAP::fix($src)."<br>";
555       $this->update_acls($object, $dst,TRUE);
557       if (!$this->copy($src, $dst)){
558         echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),@LDAP::fix($src))."</font>";
559         return (FALSE);
560       }
561       echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
562       flush();
563     }
565     /* Remove src_dn */
566     $ldap->cd($src_dn);
567     $ldap->recursive_remove();
568     $this->orig_dn  = $this->dn = $dst_dn;
569     $this->orig_base= $this->base;     
570     $this->entryCSN = getEntryCSN($this->dn);
572     echo '<p class="seperator">&nbsp;</p>';
574     echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
575       <br><input type='submit' name='back' value='"._("Continue")."'>
576       </form></div>";
578     echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
579     echo "</body></html>";
581     return (TRUE);
582   }
585   /* Return plugin informations for acl handling */ 
586   static function plInfo()
587   {
588     return (array("plShortName"   => _("Generic"),
589                   "plDescription" => _("Departments"),
590                   "plSelfModify"  => FALSE,
591                   "plPriority"    => 0,
592                   "plDepends"     => array(),
593                   "plSection"     => array("administration"),
594                   "plCategory"    => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))),
595             
596                   "plProvidedAcls" => array(
597                     "ou"                => _("Department name"),
598                     "description"       => _("Description"),
599                     "businessCategory"  => _("Category"),
600                     "base"              => _("Base"),
602                     "st"                => _("State"),
603                     "l"                 => _("Location"),
604                     "postalAddress"     => _("Address"),
605                     "telephoneNumber"   => _("Telephone"),
606                     "facsimileTelephoneNumber" => _("Fax"),
608                     "gosaUnitTag"       => _("Administrative settings"))
609                   ));
610   }
612   function handle_object_tagging($dn= "", $tag= "", $show= false)
613   {
614     /* No dn? Self-operation... */
615     if ($dn == ""){
616       $dn= $this->dn;
618       /* No tag? Find it yourself... */
619       if ($tag == ""){
620         $len= strlen($dn);
622         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
623         $relevant= array();
624         foreach ($this->config->adepartments as $key => $ntag){
626           /* This one is bigger than our dn, its not relevant... */
627           if ($len <= strlen($key)){
628             continue;
629           }
631           /* This one matches with the latter part. Break and don't fix this entry */
632           if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){
633             @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
634             $relevant[strlen($key)]= $ntag;
635             continue;
636           }
638         }
640         /* If we've some relevant tags to set, just get the longest one */
641         if (count($relevant)){
642           ksort($relevant);
643           $tmp= array_keys($relevant);
644           $idx= end($tmp);
645           $tag= $relevant[$idx];
646           $this->gosaUnitTag= $tag;
647         }
648       }
649     }
651     /* Set tag? */
652     if ($tag != ""){
653       /* Set objectclass and attribute */
654       $ldap= $this->config->get_ldap_link();
655       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
656       $attrs= $ldap->fetch();
657       if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
658         if ($show) {
659           echo sprintf(_("Object '%s' is already tagged"), @LDAP::fix($dn))."<br>";
660           flush();
661         }
662         return;
663       }
664       if (count($attrs)){
665         if ($show){
666           echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."<br>";
667           flush();
668         }
669         $nattrs= array("gosaUnitTag" => $tag);
670         $nattrs['objectClass']= array();
671         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
672           $oc= $attrs['objectClass'][$i];
673           if ($oc != "gosaAdministrativeUnitTag"){
674             $nattrs['objectClass'][]= $oc;
675           }
676         }
677         $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
678         $ldap->cd($dn);
679         $ldap->modify($nattrs);
680         if (!$ldap->success()){
681           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
682         }
683       } else {
684         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
685       }
687     } else {
688       /* Remove objectclass and attribute */
689       $ldap= $this->config->get_ldap_link();
690       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
691       $attrs= $ldap->fetch();
692       if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
693         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
694         return;
695       }
696       if (count($attrs)){
697         if ($show){
698           echo sprintf(_("Removing tag from object '%s'"), @LDAP::fix($dn))."<br>";
699           flush();
700         }
701         $nattrs= array("gosaUnitTag" => array());
702         $nattrs['objectClass']= array();
703         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
704           $oc= $attrs['objectClass'][$i];
705           if ($oc != "gosaAdministrativeUnitTag"){
706             $nattrs['objectClass'][]= $oc;
707           }
708         }
709         $ldap->cd($dn);
710         $ldap->modify($nattrs);
711         if (!$ldap->success()){
712           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
713         }
714       } else {
715         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
716       }
717     }
718   }
722 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
723 ?>