Code

03cedf2dc19ecc5fbd78bf9da26c721a89eb62d5
[gosa.git] / gosa-core / plugins / admin / departments / class_departmentGeneric.inc
1 <?php
2 /*
3   This code is part of GOsa (https://gosa.gonicus.de)
4   Copyright (C) 2003  Cajus Pollmeier
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2 of the License, or
9   (at your option) any later version.
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
21 class department extends plugin
22 {
23         /* department attributes */
24         var $ou= "";
25         var $description= "";
26         var $base= "";
27         var $st= "";
28         var $l= "";
29         var $postalAddress= "";
30         var $businessCategory= "";
31         var $telephoneNumber= "";
32         var $facsimileTelephoneNumber= "";
33         var $orig_dn= "";
34         var $is_administrational_unit= false;
35         var $gosaUnitTag= "";
36   var $view_logged = FALSE;
37         var $rec_dst=false;     // Destination for recursive move
38         var $rec_src=false;     // Source for recursive move 
39         var $rec_cpy=false;     // Is recursive move requested ? 
41         /* Headpage attributes */
42         var $last_dep_sorting= "invalid";
43         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   
54   /* Temporary disable the Unit Tag functionalityi.
55      This is not used anymore, cause of the new acl implementation. 
56      Setting this to TRUE will disable 
57       all POST / GET activity, "Department tagging" and the checkbox within the generic template.
58    */
59   var $UnitTagDiabled     = TRUE;
60   var $orig_base = "";
61   var $orig_ou = "";
63         function department (&$config, $dn)
64         {
66                 plugin::plugin($config, $dn);
67                 $this->is_account= TRUE;
68                 $this->ui= get_userinfo();
69                 $this->dn= $dn;
70                 $this->orig_dn= $dn;
71                 $this->orig_ou= $this->ou;
72                 $this->config= $config;
74                 /* Set base */
75                 if ($this->dn == "new"){
76                         $ui= get_userinfo();
77                         if(session::is_set('CurrentMainBase')){
78                                 $this->base = session::get('CurrentMainBase');
79                         }else{
80                                 $this->base= dn2base($ui->dn);
81                         }
82                 } else {
83                         $this->base= preg_replace ("/^[^,]+,/", "", $this->dn);
84                 }
86     $this->orig_base = $this->base;
88                 /* Is administrational Unit? */
89                 if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){
90                         $this->is_administrational_unit= true;
91       $this->initially_was_tagged = true;
92                 }
93         }
95         function execute()
96         {
97                 /* Call parent execute */
98                 plugin::execute();
100     /* Log view */
101     if($this->is_account && !$this->view_logged){
102       $this->view_logged = TRUE;
103       new log("view","department/".get_class($this),$this->dn);
104     }
106                 /* Reload departments */
107                 $this->config->get_departments($this->dn);
108                 $this->config->make_idepartments();
109                 $smarty= get_smarty();
111     $tmp = $this->plInfo();
112     foreach($tmp['plProvidedAcls'] as $name => $translation){
113       $smarty->assign($name."ACL",$this->getacl($name));
114     }
116                 /* Base select dialog */
117                 $once = true;
118                 foreach($_POST as $name => $value){
119                         if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){
120                                 $once = false;
121                                 $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
122                                 $this->dialog->setCurrentBase($this->base);
123                         }
124                 }
126                 /* Dialog handling */
127                 if(is_object($this->dialog)){
128                         /* Must be called before save_object */
129                         $this->dialog->save_object();
131                         if($this->dialog->isClosed()){
132                                 $this->dialog = false;
133                         }elseif($this->dialog->isSelected()){
135         /* A new base was selected, check if it is a valid one */
136         $tmp = $this->get_allowed_bases();
137         if(isset($tmp[$this->dialog->isSelected()])){
138           $this->base = $this->dialog->isSelected();
139         }
140   
141                                 $this->dialog= false;
142                         }else{
143                                 return($this->dialog->execute());
144                         }
145                 }
147                 /* Hide all departments, that are subtrees of this department */
148     $bases = $this->get_allowed_bases();
149                 if(($this->dn == "new")||($this->dn == "")){
150                         $tmp = $bases;
151                 }else{
152                         $tmp    = array();      
153                         foreach($bases as $dn=>$base){
154                                 $fixed = str_replace("/","\\",$this->dn);
155                                 /* Only attach departments which are not a subtree of this one */
156                                 if(!preg_match("/".$fixed."/",$dn)){
157                                         $tmp[$dn]=$base;
158                                 }
159                         }
160                 }
161                 $smarty->assign("bases", $tmp);
163                 foreach ($this->attributes as $val){
164                         $smarty->assign("$val", $this->$val);
165                 }
166                 $smarty->assign("base_select", $this->base);
168     /* Set admin unit flag */
169     $smarty->assign("UnitTagDiabled",$this->UnitTagDiabled);
170     if(!$this->UnitTagDiabled){
171       if ($this->is_administrational_unit) {
172         $smarty->assign("unitTag", "checked");
173       } else {
174         $smarty->assign("unitTag", "");
175       }
176     }
178                 return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
179         }
181         function clear_fields()
182         {
183                 $this->dn   = "";
184                 $this->base = "";
186                 foreach ($this->attributes as $val){
187                         $this->$val= "";
188                 }
189         }
191         function remove_from_parent()
192         {
193                 $ldap= $this->config->get_ldap_link();
194                 $ldap->cd ($this->dn);
195                 $ldap->recursive_remove();
196     new log("remove","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
197     show_ldap_error($ldap->get_error(), sprintf(_("Removing of department with dn '%s' failed."),$this->dn));
199                 /* Optionally execute a command after we're done */
200                 $this->handle_post_events('remove');
201         }
203         function must_be_tagged()
204         {
205                 return $this->must_be_tagged;
206         }
208         function am_i_moved()
209         {
210                 return $this->rec_cpy;
211         }
214         /* Save data to object */
215         function save_object()
216         {
217                 if (isset($_POST['dep_generic_posted'])){
219       /* Create a base backup and reset the
220          base directly after calling plugin::save_object();
221          Base will be set seperatly a few lines below */
222       $base_tmp = $this->base;
223       plugin::save_object();
224       $this->base = $base_tmp;
226       /* Set new base if allowed */
227       $tmp = $this->get_allowed_bases();
228       if(isset($_POST['base'])){
229         if(isset($tmp[$_POST['base']])){
230           $this->base= $_POST['base'];
231         }
232       }
234       /* Save tagging flag */
235       if(!$this->UnitTagDiabled){
236         if ($this->acl_is_writeable("unitTag")){
237           if (isset($_POST['unitTag'])){
238             $this->is_administrational_unit= true;
239           } else {
240             $this->is_administrational_unit= false;
241           }
242         }
243       }
244     }
245         }
248         /* Check values */
249         function check()
250         {
251                 /* Call common method to give check the hook */
252                 $message= plugin::check();
254                 /* Check for presence of this department */
255                 $ldap= $this->config->get_ldap_link();
256     $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
257     if ($this->orig_dn == "new" && $ldap->count()){
258                         $message[]= _("Department with that 'Name' already exists.");
259                 } elseif ($this->orig_dn != $this->dn && !($attrs === FALSE)){
260                         $message[]= _("Department with that 'Name' already exists.");
261                 }
263                 /* All required fields are set? */
264                 if ($this->ou == ""){
265                         $message[]= _("Required field 'Name' is not set.");
266                 }
267                 if ($this->description == ""){
268                         $message[]= _("Required field 'Description' is not set.");
269                 }
271     if(tests::is_department_name_reserved($this->ou,$this->base)){
272       $message[]= sprintf(_("The field 'Name' contains the reserved word '%s'. Please choose another name."),$this->ou);
273     }
275                 if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
276                         $message[]= _("The field 'Name' contains invalid characters.");
277                 }
278                 if (!tests::is_phone_nr($this->telephoneNumber)){
279                         $message[]= _("The field 'Phone' contains an invalid phone number.");
280                 }
281                 if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){
282                         $message[]= _("The field 'Fax' contains an invalid phone number.");
283                 }
285                 return $message;
286         }
289         /* Save to LDAP */
290         function save()
291         {
292                 $ldap= $this->config->get_ldap_link();
294     if(!$this->UnitTagDiabled){
296       /* Add tag objects if needed */
297       if ($this->is_administrational_unit){
299         /* If this wasn't tagged before add oc an reset unit tag */
300         if(!$this->initially_was_tagged){
301           $this->objectclasses[]= "gosaAdministrativeUnit";
302           $this->gosaUnitTag= "";
304           /* It seams that this method is called twice, 
305              set this to true. to avoid adding this oc twice */
306           $this->initially_was_tagged = true;
307         }
309         if ($this->gosaUnitTag == ""){
311           /* It's unlikely, but check if already used... */
312           $try= 5;
313           $ldap->cd($this->config->current['BASE']);
314           while ($try--){
316             /* Generate microtime stamp as tag */
317             list($usec, $sec)= explode(" ", microtime());
318             $time_stamp= preg_replace("/\./", "", $sec.$usec);
320             $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag"));
321             if ($ldap->count() == 0){
322               break;
323             }
324           }
325           if($try == 0) {
326             print_red(_("Fatal error: Can't find an unused tag to mark the administrative unit!"));
327             return;
328           }
329           $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
330         }
331       }
332     }
333                 plugin::save();
335     if(!$this->UnitTagDiabled){
337       /* Remove tag information if needed */
338       if (!$this->is_administrational_unit){
339         $tmp= array();
341         /* Remove gosaAdministrativeUnit from this plugin */
342         $has_unit_tag= false;
343         foreach($this->attrs['objectClass'] as $oc){
344           if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
345             $tmp[]= $oc;
346           }
347           if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
348             $has_unit_tag= true;
349           }
350         }
351         $this->attrs['objectClass']= $tmp;
353         if(!$has_unit_tag && isset($this->attrs['gosaUnitTag'])){
354           $this->attrs['gosaUnitTag']= array();
355         }
356         $this->gosaUnitTag = "";
357       }
358     }
360                 /* Write back to ldap */
361                 $ldap= $this->config->get_ldap_link();
362                 $ldap->cat($this->dn, array('dn'));
363                 $a= $ldap->fetch();
364                 $ldap->cd($this->dn);
366                 if (count($a)){
367                         $this->cleanup();
368                         $ldap->modify ($this->attrs); 
369       new log("modify","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
370                         $this->handle_post_events('modify');
371                 } else {
372                         $ldap->add($this->attrs);
373                         $this->handle_post_events('add');
374       new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
375                 }
376     show_ldap_error($ldap->get_error(), sprintf(_("Saving of department with dn '%s' failed."),$this->dn));
379     if(!$this->UnitTagDiabled){
380       /* The parameter forces only to set must_be_tagged, and don't touch any objects 
381          This will be done later */
382       $this->tag_objects(true);
383     }
384     
385     /* Optionally execute a command after we're done */
386                 $this->postcreate();
387     return(false);
388         }
391   function ShowMoveFrame()
392   {
393     $smarty = get_smarty();
394     $smarty->assign("src","?plug=".$_GET['plug']."&amp;PerformRecMove");
395     $smarty->assign("message","As soon as the move operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog.");
396     $display=  $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE));
397     return($display);
398   }
400   function ShowTagFrame()
401   {
402     $smarty = get_smarty();
403     $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment");
404     $smarty->assign("message","As soon as the tag operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog.");
405     $display=  $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE));
406     return($display);
407   }
409         /* Tag objects to have the gosaAdministrativeUnitTag */
410         function tag_objects($OnlySetTagFlag = false)
411         {
412     if(!$OnlySetTagFlag){
413       $smarty= get_smarty();
414       /* Print out html introduction */
415       echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
416         <html>
417         <head>
418         <title></title>
419         <style type="text/css">@import url("themes/default/style.css");</style>
420         <script language="javascript" src="include/focus.js" type="text/javascript"></script>
421         </head>
422         <body style="background: none; margin:4px;" id="body" >
423         ';
424       echo "<h3>".sprintf(_("Tagging '%s'."),"<i>".@LDAP::fix($this->dn)."</i>")."</h3>";
425     }
427     $add= $this->is_administrational_unit;
428     $len= strlen($this->dn);
429     $ldap= $this->config->get_ldap_link();
430     $ldap->cd($this->dn);
431     if ($add){
432             $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
433                                                     $this->gosaUnitTag.')))', array('dn'));
434     } else {
435             $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
436     }
438     while ($attrs= $ldap->fetch()){
440             /* Skip self */
441             if ($attrs['dn'] == $this->dn){
442                     continue;
443             }
445             /* Check for confilicting administrative units */
446             $fix= true;
447             foreach ($this->config->adepartments as $key => $tag){
448                     /* This one is shorter than our dn, its not relevant... */
449                     if ($len >= strlen($key)){
450                             continue;
451                     }
453                     /* This one matches with the latter part. Break and don't fix this entry */
454                     if (preg_match('/(^|,)'.normalizePreg($key).'$/', $attrs['dn'])){
455                             $fix= false;
456                             break;
457                     }
458             }
460             /* Fix entry if needed */
461             if ($fix){
462                     if($OnlySetTagFlag){
463                             $this->must_be_tagged =true;
464                             return;
465                     }
466                     $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
467             }
468     }
469     if(!$OnlySetTagFlag){
470             echo '<p class="seperator">&nbsp;</p>';
471             echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
472                     <br><input type='submit' name='back' value='"._("Continue")."'>
473                     </form></div>";
474     }
475         }
478         /* Move/Rename complete trees */
479         function recursive_move($src_dn, $dst_dn,$force = false)
480         {
481     /* If force == false prepare to recursive move this object from src to dst 
482         on the next call. */
483                 if(!$force){
484                         $this->rec_cpy  = true;
485                         $this->rec_src  = $src_dn;
486                         $this->rec_dst  = $dst_dn;
487                 }else{
489       /* If this is called, but not wanted, abort */
490                         if(!$this->rec_cpy){ 
491                                 return;
492                         }
494                         $src_dn = $this->rec_src;
495                         $dst_dn = $this->rec_dst;
497                         /* Print header to have styles included */
498                         $smarty= get_smarty();
500       echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
501         <html>
502         <head>
503         <title></title>
504         <style type="text/css">@import url("themes/default/style.css");</style>
505         <script language="javascript" src="include/focus.js" type="text/javascript"></script>
506         </head>
507         <body style="background: none; margin:4px;" id="body" >
508         ';
509                         echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".@LDAP::fix($src_dn)."</i>","<i>".@LDAP::fix($dst_dn)."</i>")."</h3>";
512                         /* Check if the destination entry exists */
513                         $ldap= $this->config->get_ldap_link();
515                         /* Check if destination exists - abort */
516                         $ldap->cat($dst_dn, array('dn'));
517                         if ($ldap->fetch()){
518                                 trigger_error("Recursive_move ".@LDAP::fix($dst_dn)." already exists.",
519                                                 E_USER_WARNING);
520                                 echo sprintf("Recursive_move: '%s' already exists", @LDAP::fix($dst_dn))."<br>"; 
521                                 return (FALSE);
522                         }
524                         /* Perform a search for all objects to be moved */
525                         $objects= array();
526                         $ldap->cd($src_dn);
527                         $ldap->search("(objectClass=*)", array("dn"));
528                         while($attrs= $ldap->fetch()){
529                                 $dn= $attrs['dn'];
530                                 $objects[$dn]= strlen($dn);
531                         }
533                         /* Sort objects by indent level */
534                         asort($objects);
535                         reset($objects);
537                         /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
538                         foreach ($objects as $object => $len){
541                                 $src= str_replace("\\","\\\\",$object);
542                                 $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
543                                 $dst= str_replace($src_dn,$dst_dn,$object);
545                                 echo "<b>"._("Object").":</b> ".@LDAP::fix($src)."<br>";
547         $this->update_acls($object, $dst,TRUE);
549                                 if (!$this->copy($src, $dst)){
550                                         echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),@LDAP::fix($src))."</font>";
551                                         return (FALSE);
552                                 }
553         echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
554                                 flush();
555                         }
557                         /* Remove src_dn */
558                         $ldap->cd($src_dn);
559                         $ldap->recursive_remove();
560       $this->dn = $this->rec_dst;
561                         $this->rec_src = $this->rec_dst = "";
562                         $this->rec_cpy =false;
564                         echo '<p class="seperator">&nbsp;</p>';
566                         echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
567                                 <br><input type='submit' name='back' value='"._("Continue")."'>
568                                 </form></div>";
570       echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
571                         echo "</body></html>";
573                         return (TRUE);
574                 }
575         }
578   /* Return plugin informations for acl handling */ 
579   static function plInfo()
580   {
581     return (array("plShortName"   => _("Generic"),
582                   "plDescription" => _("Departments"),
583                   "plSelfModify"  => FALSE,
584                   "plPriority"    => 0,
585                   "plDepends"     => array(),
586                   "plSection"     => array("admin"),
587                   "plCategory"    => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))),
588             
589                   "plProvidedAcls" => array(
590                     "description"       => _("Description"),
591                     "c"                 => _("Country"),
592                     "base"              => _("Base"),
593                     "l"                 => _("Location"),
594                     "telephoneNumber"   => _("Telephone"),
595                     "ou"                => _("Department name"),
596                     "businessCategory"  => _("Category"),
597                     "st"                => _("State"),
598                     "postalAddress"     => _("Address"),
599                     "gosaUnitTag"       => _("Administrative settings"),
600                     "facsimileTelephoneNumber" => _("Fax"))
601                   ));
602   }
604   function handle_object_tagging($dn= "", $tag= "", $show= false)
605   {
606     /* No dn? Self-operation... */
607     if ($dn == ""){
608       $dn= $this->dn;
610       /* No tag? Find it yourself... */
611       if ($tag == ""){
612         $len= strlen($dn);
614         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
615         $relevant= array();
616         foreach ($this->config->adepartments as $key => $ntag){
618           /* This one is bigger than our dn, its not relevant... */
619           if ($len <= strlen($key)){
620             continue;
621           }
623           /* This one matches with the latter part. Break and don't fix this entry */
624           if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){
625             @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
626             $relevant[strlen($key)]= $ntag;
627             continue;
628           }
630         }
632         /* If we've some relevant tags to set, just get the longest one */
633         if (count($relevant)){
634           ksort($relevant);
635           $tmp= array_keys($relevant);
636           $idx= end($tmp);
637           $tag= $relevant[$idx];
638           $this->gosaUnitTag= $tag;
639         }
640       }
641     }
643     /* Set tag? */
644     if ($tag != ""){
645       /* Set objectclass and attribute */
646       $ldap= $this->config->get_ldap_link();
647       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
648       $attrs= $ldap->fetch();
649       if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
650         if ($show) {
651           echo sprintf(_("Object '%s' is already tagged"), @LDAP::fix($dn))."<br>";
652           flush();
653         }
654         return;
655       }
656       if (count($attrs)){
657         if ($show){
658           echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."<br>";
659           flush();
660         }
661         $nattrs= array("gosaUnitTag" => $tag);
662         $nattrs['objectClass']= array();
663         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
664           $oc= $attrs['objectClass'][$i];
665           if ($oc != "gosaAdministrativeUnitTag"){
666             $nattrs['objectClass'][]= $oc;
667           }
668         }
669         $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
670         $ldap->cd($dn);
671         $ldap->modify($nattrs);
672         show_ldap_error($ldap->get_error(), sprintf(_("Handle object tagging with dn '%s' failed."),$dn));
673       } else {
674         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
675       }
677     } else {
678       /* Remove objectclass and attribute */
679       $ldap= $this->config->get_ldap_link();
680       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
681       $attrs= $ldap->fetch();
682       if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
683         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
684         return;
685       }
686       if (count($attrs)){
687         if ($show){
688           echo sprintf(_("Removing tag from object '%s'"), @LDAP::fix($dn))."<br>";
689           flush();
690         }
691         $nattrs= array("gosaUnitTag" => array());
692         $nattrs['objectClass']= array();
693         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
694           $oc= $attrs['objectClass'][$i];
695           if ($oc != "gosaAdministrativeUnitTag"){
696             $nattrs['objectClass'][]= $oc;
697           }
698         }
699         $ldap->cd($dn);
700         $ldap->modify($nattrs);
701         show_ldap_error($ldap->get_error(), sprintf(_("Handle object tagging with dn '%s' failed."),$dn));
702       } else {
703         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
704       }
705     }
707   }
711 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
712 ?>