Code

Udpated regex quote
[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                                 /* Only attach departments which are not a subtree of this one */
163         if(!preg_match("/".preg_quote($this->dn)."/",$dn)){
164                                         $tmp[$dn]=$base;
165                                 }
166                         }
167                 }
168                 $smarty->assign("bases", $tmp);
170                 foreach ($this->attributes as $val){
171                         $smarty->assign("$val", $this->$val);
172                 }
173                 $smarty->assign("base_select", $this->base);
175     /* Set admin unit flag */
176     if ($this->is_administrational_unit) {
177       $smarty->assign("gosaUnitTag", "checked");
178     } else {
179       $smarty->assign("gosaUnitTag", "");
180     }
182     $smarty->assign("dep_type",$this->type);
183     
185     $dep_types = departmentManagement::get_support_departments();
186     $tpl ="";
187     foreach($dep_types as $key => $data){
188       if($data['ATTR'] == $this->type){
189         $tpl = $data['TPL'];
190         break;
191       }
192     }
193     if($tpl == "") {
194       trigger_error("No template specified for container type '".$this->type."', please update epartmentManagement::get_support_departments().");
195       $tpl = "generic.tpl";
196     }
197                 return($smarty->fetch (get_template_path($tpl, TRUE)));
198         }
200         function clear_fields()
201         {
202                 $this->dn   = "";
203                 $this->base = "";
205                 foreach ($this->attributes as $val){
206                         $this->$val= "";
207                 }
208         }
210         function remove_from_parent()
211         {
212                 $ldap= $this->config->get_ldap_link();
213                 $ldap->cd ($this->dn);
214                 $ldap->rmdir_recursive($this->dn);
215     new log("remove","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
216     if (!$ldap->success()){
217       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
218     }
220                 /* Optionally execute a command after we're done */
221                 $this->handle_post_events('remove');
222         }
224         function must_be_tagged()
225         {
226                 return $this->must_be_tagged;
227         }
229         /* Save data to object */
230         function save_object()
231         {
232     if (isset($_POST['dep_generic_posted'])){
234       $nA = $this->namingAttr;
235       $old_nA = $this->$nA;
239       /* Create a base backup and reset the
240          base directly after calling plugin::save_object();
241          Base will be set seperatly a few lines below */
242       $base_tmp = $this->base;
243       plugin::save_object();
244       $this->base = $base_tmp;
246       /* Set new base if allowed */
247       $tmp = $this->get_allowed_bases();
248       if(isset($_POST['base'])){
249         if(isset($tmp[$_POST['base']])){
250           $this->base= $_POST['base'];
251         }
252       }
254       /* Save tagging flag */
255       if ($this->acl_is_writeable("gosaUnitTag")){
256         if (isset($_POST['is_administrational_unit'])){
257           $this->is_administrational_unit= true;
258         } else {
259           $this->is_administrational_unit= false;
260         }
261       }
263       /* If this is the root directory service entry (rootDSE)
264          then avoid changing the naming attribute of this entry.
265        */
266       if($this->dn == $this->config->current['BASE']){
267         $this->$nA = $old_nA;
268       }
269     }
270         }
273         /* Check values */
274         function check()
275         {
276                 /* Call common method to give check the hook */
277                 $message= plugin::check();
279                 /* Check for presence of this department */
280                 $ldap= $this->config->get_ldap_link();
281     $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
282     if ($this->orig_dn == "new" && $ldap->count()){
283                         $message[]= msgPool::duplicated(_("Name"));
284                 } elseif ($this->orig_dn != $this->dn && $ldap->count()){
285                         $message[]= msgPool::duplicated(_("Name"));
286                 }
288                 /* All required fields are set? */
289                 if ($this->ou == ""){
290                         $message[]= msgPool::required(_("Name"));
291                 }
292                 if ($this->description == ""){
293                         $message[]= msgPool::required(_("Description"));
294                 }
296     if(tests::is_department_name_reserved($this->ou,$this->base)){
297       $message[]= msgPool::reserved(_("Name"));
298     }
300                 if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
301                         $message[]= msgPool::invalid(_("Name"), $this->ou, "/[^#+:=>\\\\\/]/");
302                 }
303                 if (!tests::is_phone_nr($this->telephoneNumber)){
304                         $message[]= msgPool::invalid(_("Phone"), $this->telephoneNumber, "/[\/0-9 ()+*-]/");
305                 }
306                 if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){
307                         $message[]= msgPool::invalid(_("Fax"), $this->facsimileTelephoneNumber, "/[\/0-9 ()+*-]/");
308                 }
310     /* Check if we are allowed to create or move this object
311      */
312     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
313       $message[] = msgPool::permCreate();
314     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
315       $message[] = msgPool::permMove();
316     }
318     return $message;
319         }
322         /* Save to LDAP */
323         function save()
324         {
325                 $ldap= $this->config->get_ldap_link();
327     /* Ensure that ou is saved too, it is required by objectClass gosaDepartment 
328      */
329     $nA = $this->namingAttr;
330     $this->ou = $this->$nA;
332     /* Add tag objects if needed */
333     if ($this->is_administrational_unit){
335       /* If this wasn't tagged before add oc an reset unit tag */
336       if(!$this->initially_was_tagged){
337         $this->objectclasses[]= "gosaAdministrativeUnit";
338         $this->gosaUnitTag= "";
340         /* It seams that this method is called twice, 
341            set this to true. to avoid adding this oc twice */
342         $this->initially_was_tagged = true;
343       }
345       if ($this->gosaUnitTag == ""){
347         /* It's unlikely, but check if already used... */
348         $try= 5;
349         $ldap->cd($this->config->current['BASE']);
350         while ($try--){
352           /* Generate microtime stamp as tag */
353           list($usec, $sec)= explode(" ", microtime());
354           $time_stamp= preg_replace("/\./", "", $sec.$usec);
356           $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag"));
357           if ($ldap->count() == 0){
358             break;
359           }
360         }
361         if($try == 0) {
362           msg_dialog::display(_("Fatal error"), _("Cannot find an unused tag for this administrative unit!"), WARNING_DIALOG);
363           return;
364         }
365         $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
366       }
367     }
368     $this->skipTagging = TRUE;
369     plugin::save();
372     /* Remove tag information if needed */
373     if (!$this->is_administrational_unit && $this->initially_was_tagged){
374       $tmp= array();
376       /* Remove gosaAdministrativeUnit from this plugin */
377       $has_unit_tag= false;
378       foreach($this->attrs['objectClass'] as $oc){
379         if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
380           $tmp[]= $oc;
381         }
382         if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
383           $has_unit_tag= true;
384         }
385       }
386       $this->attrs['objectClass']= $tmp;
387       $this->attrs['gosaUnitTag']= array();
388       $this->gosaUnitTag = "";
389     }
392                 /* Write back to ldap */
393                 $ldap->cat($this->dn, array('dn'));
394                 $ldap->cd($this->dn);
396                 if ($ldap->count()){
397                         $this->cleanup();
398                         $ldap->modify ($this->attrs); 
399       new log("modify","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
400                         $this->handle_post_events('modify');
401                 } else {
402                         $ldap->add($this->attrs);
403                         $this->handle_post_events('add');
404       new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
405                 }
406     if (!$ldap->success()){
407       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
408     }
410     /* The parameter forces only to set must_be_tagged, and don't touch any objects 
411        This will be done later */
412     $this->tag_objects(true);
413     
414     /* Optionally execute a command after we're done */
415                 $this->postcreate();
416     return(false);
417         }
420         /* Tag objects to have the gosaAdministrativeUnitTag */
421         function tag_objects($OnlySetTagFlag = false)
422         {
423     if(!$OnlySetTagFlag){
424       $smarty= get_smarty();
425       /* Print out html introduction */
426       echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
427         <html>
428         <head>
429         <title></title>
430         <style type="text/css">@import url("themes/default/style.css");</style>
431         <script language="javascript" src="include/focus.js" type="text/javascript"></script>
432         </head>
433         <body style="background: none; margin:4px;" id="body" >
434         ';
435       echo "<h3>".sprintf(_("Tagging '%s'."),"<i>".LDAP::fix($this->dn)."</i>")."</h3>";
436     }
438     $add= $this->is_administrational_unit;
439     $len= strlen($this->dn);
440     $ldap= $this->config->get_ldap_link();
441     $ldap->cd($this->dn);
442     if ($add){
443             $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
444                                                     $this->gosaUnitTag.')))', array('dn'));
445     } else {
446             $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
447     }
449     $objects = array();
450     while ($attrs= $ldap->fetch()){
451       $objects[] = $attrs;
452     }
453     foreach($objects as $attrs){
455             /* Skip self */
456             if ($attrs['dn'] == $this->dn){
457                     continue;
458             }
460             /* Check for confilicting administrative units */
461             $fix= true;
462             foreach ($this->config->adepartments as $key => $tag){
463                     /* This one is shorter than our dn, its not relevant... */
464                     if ($len >= strlen($key)){
465                             continue;
466                     }
468                     /* This one matches with the latter part. Break and don't fix this entry */
469                     if (preg_match('/(^|,)'.preg_quote($key, '/').'$/', $attrs['dn'])){
470                             $fix= false;
471                             break;
472                     }
473             }
475             /* Fix entry if needed */
476             if ($fix){
477                     if($OnlySetTagFlag){
478                             $this->must_be_tagged =true;
479                             return;
480                     }
481                     $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
482         echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
483             }
484     }
485     
486     if(!$OnlySetTagFlag){
487       $this->must_be_tagged = FALSE;
488             echo '<p class="seperator">&nbsp;</p>';
489       echo "<div style='width:100%;text-align:right;'>".
490         "<form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>".
491         "<br>".
492         "<input type='submit' name='back' value='"._("Continue")."'>".
493         "<input type='hidden' name='php_c_check' value='1'>".
494         "</form>".
495         "</div>";
496       echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
497     }
498         }
501         /* Move/Rename complete trees */
502         function recursive_move($src_dn, $dst_dn,$force = false)
503         {
504     /* Print header to have styles included */
505     $smarty= get_smarty();
507     echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
508       <html>
509       <head>
510       <title></title>
511       <style type="text/css">@import url("themes/default/style.css");</style>
512       <script language="javascript" src="include/focus.js" type="text/javascript"></script>
513       </head>
514       <body style="background: none; margin:4px;" id="body" >
515       ';
516     echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".LDAP::fix($src_dn)."</i>","<i>".LDAP::fix($dst_dn)."</i>")."</h3>";
519     /* Check if the destination entry exists */
520     $ldap= $this->config->get_ldap_link();
522     /* Check if destination exists - abort */
523     $ldap->cat($dst_dn, array('dn'));
524     if ($ldap->fetch()){
525       trigger_error("Recursive_move ".LDAP::fix($dst_dn)." already exists.",
526           E_USER_WARNING);
527       echo sprintf("Recursive_move: '%s' already exists", LDAP::fix($dst_dn))."<br>"; 
528       return (FALSE);
529     }
531     /* Perform a search for all objects to be moved */
532     $objects= array();
533     $ldap->cd($src_dn);
534     $ldap->search("(objectClass=*)", array("dn"));
535     while($attrs= $ldap->fetch()){
536       $dn= $attrs['dn'];
537       $objects[$dn]= strlen($dn);
538     }
540     /* Sort objects by indent level */
541     asort($objects);
542     reset($objects);
544     /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
545     foreach ($objects as $object => $len){
548       $src= str_replace("\\","\\\\",$object);
549       $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
550       $dst= str_replace($src_dn,$dst_dn,$object);
552       echo "<b>"._("Object").":</b> ".LDAP::fix($src)."<br>";
554       $this->update_acls($object, $dst,TRUE);
556       if (!$this->copy($src, $dst)){
557         echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),LDAP::fix($src))."</font>";
558         return (FALSE);
559       }
560       echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
561       flush();
562     }
564     /* Remove src_dn */
565     $ldap->cd($src_dn);
566     $ldap->recursive_remove();
567     $this->orig_dn  = $this->dn = $dst_dn;
568     $this->orig_base= $this->base;     
569     $this->entryCSN = getEntryCSN($this->dn);
571     echo '<p class="seperator">&nbsp;</p>';
573     echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
574       <br><input type='submit' name='back' value='"._("Continue")."'>
575       </form></div>";
577     echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
578     echo "</body></html>";
580     return (TRUE);
581   }
584   /* Return plugin informations for acl handling */ 
585   static function plInfo()
586   {
587     return (array("plShortName"   => _("Generic"),
588                   "plDescription" => _("Departments"),
589                   "plSelfModify"  => FALSE,
590                   "plPriority"    => 0,
591                   "plDepends"     => array(),
592                   "plSection"     => array("administration"),
593                   "plCategory"    => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))),
594             
595                   "plProvidedAcls" => array(
596                     "ou"                => _("Department name"),
597                     "description"       => _("Description"),
598                     "businessCategory"  => _("Category"),
599                     "base"              => _("Base"),
601                     "st"                => _("State"),
602                     "l"                 => _("Location"),
603                     "postalAddress"     => _("Address"),
604                     "telephoneNumber"   => _("Telephone"),
605                     "facsimileTelephoneNumber" => _("Fax"),
607                     "gosaUnitTag"       => _("Administrative settings"))
608                   ));
609   }
611   function handle_object_tagging($dn= "", $tag= "", $show= false)
612   {
613     /* No dn? Self-operation... */
614     if ($dn == ""){
615       $dn= $this->dn;
617       /* No tag? Find it yourself... */
618       if ($tag == ""){
619         $len= strlen($dn);
621         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
622         $relevant= array();
623         foreach ($this->config->adepartments as $key => $ntag){
625           /* This one is bigger than our dn, its not relevant... */
626           if ($len <= strlen($key)){
627             continue;
628           }
630           /* This one matches with the latter part. Break and don't fix this entry */
631           if (preg_match('/(^|,)'.preg_quote($key, '/').'$/', $dn)){
632             @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
633             $relevant[strlen($key)]= $ntag;
634             continue;
635           }
637         }
639         /* If we've some relevant tags to set, just get the longest one */
640         if (count($relevant)){
641           ksort($relevant);
642           $tmp= array_keys($relevant);
643           $idx= end($tmp);
644           $tag= $relevant[$idx];
645           $this->gosaUnitTag= $tag;
646         }
647       }
648     }
650     /* Set tag? */
651     if ($tag != ""){
652       /* Set objectclass and attribute */
653       $ldap= $this->config->get_ldap_link();
654       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
655       $attrs= $ldap->fetch();
656       if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
657         if ($show) {
658           echo sprintf(_("Object '%s' is already tagged"), LDAP::fix($dn))."<br>";
659           flush();
660         }
661         return;
662       }
663       if (count($attrs)){
664         if ($show){
665           echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, LDAP::fix($dn))."<br>";
666           flush();
667         }
668         $nattrs= array("gosaUnitTag" => $tag);
669         $nattrs['objectClass']= array();
670         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
671           $oc= $attrs['objectClass'][$i];
672           if ($oc != "gosaAdministrativeUnitTag"){
673             $nattrs['objectClass'][]= $oc;
674           }
675         }
676         $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
677         $ldap->cd($dn);
678         $ldap->modify($nattrs);
679         if (!$ldap->success()){
680           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
681         }
682       } else {
683         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
684       }
686     } else {
687       /* Remove objectclass and attribute */
688       $ldap= $this->config->get_ldap_link();
689       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
690       $attrs= $ldap->fetch();
691       if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
692         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
693         return;
694       }
695       if (count($attrs)){
696         if ($show){
697           echo sprintf(_("Removing tag from object '%s'"), LDAP::fix($dn))."<br>";
698           flush();
699         }
700         $nattrs= array("gosaUnitTag" => array());
701         $nattrs['objectClass']= array();
702         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
703           $oc= $attrs['objectClass'][$i];
704           if ($oc != "gosaAdministrativeUnitTag"){
705             $nattrs['objectClass'][]= $oc;
706           }
707         }
708         $ldap->cd($dn);
709         $ldap->modify($nattrs);
710         if (!$ldap->success()){
711           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
712         }
713       } else {
714         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
715       }
716     }
717   }
721 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
722 ?>