Code

f4344bc956f406d872946a4071c1d462d733f18e
[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 $orig_dn= "";
36         var $is_administrational_unit= false;
37         var $gosaUnitTag= "";
38   var $view_logged = FALSE;
39         var $rec_dst=false;     // Destination for recursive move
40         var $rec_src=false;     // Source for recursive move 
41         var $rec_cpy=false;     // Is recursive move requested ? 
43         /* Headpage attributes */
44         var $last_dep_sorting= "invalid";
45         var $departments= array();
47   var $must_be_tagged = false;
49         /* attribute list for save action */
50         var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress",
51                         "telephoneNumber", "facsimileTelephoneNumber", "gosaUnitTag");
52         var $objectclasses= array("top", "gosaDepartment", "organizationalUnit");
53   var $initially_was_tagged = false;
55   var $orig_base = "";
56   var $orig_ou = "";
58         function department (&$config, $dn)
59         {
61                 plugin::plugin($config, $dn);
62                 $this->is_account= TRUE;
63                 $this->ui= get_userinfo();
64                 $this->dn= $dn;
65                 $this->orig_dn= $dn;
66                 $this->orig_ou= $this->ou;
67                 $this->config= $config;
69                 /* Set base */
70                 if ($this->dn == "new"){
71                         $ui= get_userinfo();
72                         if(session::is_set('CurrentMainBase')){
73                                 $this->base = session::get('CurrentMainBase');
74                         }else{
75                                 $this->base= dn2base($ui->dn);
76                         }
77                 } else {
78                         $this->base= preg_replace ("/^[^,]+,/", "", $this->dn);
79                 }
81     $this->orig_base = $this->base;
83                 /* Is administrational Unit? */
84                 if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){
85                         $this->is_administrational_unit= true;
86       $this->initially_was_tagged = true;
87                 }
88         }
90         function execute()
91         {
92                 /* Call parent execute */
93                 plugin::execute();
95     /* Log view */
96     if($this->is_account && !$this->view_logged){
97       $this->view_logged = TRUE;
98       new log("view","department/".get_class($this),$this->dn);
99     }
101                 /* Reload departments */
102                 $this->config->get_departments($this->dn);
103                 $this->config->make_idepartments();
104                 $smarty= get_smarty();
106     $tmp = $this->plInfo();
107     foreach($tmp['plProvidedAcls'] as $name => $translation){
108       $smarty->assign($name."ACL",$this->getacl($name));
109     }
111                 /* Base select dialog */
112                 $once = true;
113                 foreach($_POST as $name => $value){
114                         if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){
115                                 $once = false;
116                                 $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
117                                 $this->dialog->setCurrentBase($this->base);
118                         }
119                 }
121                 /* Dialog handling */
122                 if(is_object($this->dialog)){
123                         /* Must be called before save_object */
124                         $this->dialog->save_object();
126                         if($this->dialog->isClosed()){
127                                 $this->dialog = false;
128                         }elseif($this->dialog->isSelected()){
130         /* A new base was selected, check if it is a valid one */
131         $tmp = $this->get_allowed_bases();
132         if(isset($tmp[$this->dialog->isSelected()])){
133           $this->base = $this->dialog->isSelected();
134         }
135   
136                                 $this->dialog= false;
137                         }else{
138                                 return($this->dialog->execute());
139                         }
140                 }
142                 /* Hide all departments, that are subtrees of this department */
143     $bases = $this->get_allowed_bases();
144                 if(($this->dn == "new")||($this->dn == "")){
145                         $tmp = $bases;
146                 }else{
147                         $tmp    = array();      
148                         foreach($bases as $dn=>$base){
149                                 $fixed = str_replace("/","\\",$this->dn);
150                                 /* Only attach departments which are not a subtree of this one */
151                                 if(!preg_match("/".$fixed."/",$dn)){
152                                         $tmp[$dn]=$base;
153                                 }
154                         }
155                 }
156                 $smarty->assign("bases", $tmp);
158                 foreach ($this->attributes as $val){
159                         $smarty->assign("$val", $this->$val);
160                 }
161                 $smarty->assign("base_select", $this->base);
163     /* Set admin unit flag */
164     if ($this->is_administrational_unit) {
165       $smarty->assign("unitTag", "checked");
166     } else {
167       $smarty->assign("unitTag", "");
168     }
170                 return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
171         }
173         function clear_fields()
174         {
175                 $this->dn   = "";
176                 $this->base = "";
178                 foreach ($this->attributes as $val){
179                         $this->$val= "";
180                 }
181         }
183         function remove_from_parent()
184         {
185                 $ldap= $this->config->get_ldap_link();
186                 $ldap->cd ($this->dn);
187                 $ldap->recursive_remove();
188     new log("remove","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
189     if (!$ldap->success()){
190       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
191     }
193                 /* Optionally execute a command after we're done */
194                 $this->handle_post_events('remove');
195         }
197         function must_be_tagged()
198         {
199                 return $this->must_be_tagged;
200         }
202         function am_i_moved()
203         {
204                 return $this->rec_cpy;
205         }
208         /* Save data to object */
209         function save_object()
210         {
211                 if (isset($_POST['dep_generic_posted'])){
213       /* Create a base backup and reset the
214          base directly after calling plugin::save_object();
215          Base will be set seperatly a few lines below */
216       $base_tmp = $this->base;
217       plugin::save_object();
218       $this->base = $base_tmp;
220       /* Set new base if allowed */
221       $tmp = $this->get_allowed_bases();
222       if(isset($_POST['base'])){
223         if(isset($tmp[$_POST['base']])){
224           $this->base= $_POST['base'];
225         }
226       }
228       /* Save tagging flag */
229       if ($this->acl_is_writeable("unitTag")){
230         if (isset($_POST['unitTag'])){
231           $this->is_administrational_unit= true;
232         } else {
233           $this->is_administrational_unit= false;
234         }
235       }
236     }
237         }
240         /* Check values */
241         function check()
242         {
243                 /* Call common method to give check the hook */
244                 $message= plugin::check();
246                 /* Check for presence of this department */
247                 $ldap= $this->config->get_ldap_link();
248     $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
249     if ($this->orig_dn == "new" && $ldap->count()){
250                         $message[]= msgPool::duplicated(_("Name"));
251                 } elseif ($this->orig_dn != $this->dn && !($attrs === FALSE)){
252                         $message[]= msgPool::duplicated(_("Name"));
253                 }
255                 /* All required fields are set? */
256                 if ($this->ou == ""){
257                         $message[]= _("Required field 'Name' is not set.");
258                         $message[]= msgPool::required(_("Name"));
259                 }
260                 if ($this->description == ""){
261                         $message[]= _("Required field 'Description' is not set.");
262                         $message[]= msgPool::required(_("Description"));
263                 }
265     if(tests::is_department_name_reserved($this->ou,$this->base)){
266       $message[]= msgPool::reserved(_("Name"));
267     }
269                 if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
270                         $message[]= msgPool::invalid(_("Name"), $this->ou, "/[^#+:=>\\\\\/]/");
271                 }
272                 if (!tests::is_phone_nr($this->telephoneNumber)){
273                         $message[]= msgPool::invalid(_("Phone"), $this->telephoneNumber, "/[\/0-9 ()+*-]/");
274                 }
275                 if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){
276                         $message[]= msgPool::invalid(_("Fax"), $this->facsimileTelephoneNumber, "/[\/0-9 ()+*-]/");
277                 }
279                 return $message;
280         }
283         /* Save to LDAP */
284         function save()
285         {
286                 $ldap= $this->config->get_ldap_link();
288     /* Add tag objects if needed */
289     if ($this->is_administrational_unit){
291       /* If this wasn't tagged before add oc an reset unit tag */
292       if(!$this->initially_was_tagged){
293         $this->objectclasses[]= "gosaAdministrativeUnit";
294         $this->gosaUnitTag= "";
296         /* It seams that this method is called twice, 
297            set this to true. to avoid adding this oc twice */
298         $this->initially_was_tagged = true;
299       }
301       if ($this->gosaUnitTag == ""){
303         /* It's unlikely, but check if already used... */
304         $try= 5;
305         $ldap->cd($this->config->current['BASE']);
306         while ($try--){
308           /* Generate microtime stamp as tag */
309           list($usec, $sec)= explode(" ", microtime());
310           $time_stamp= preg_replace("/\./", "", $sec.$usec);
312           $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag"));
313           if ($ldap->count() == 0){
314             break;
315           }
316         }
317         if($try == 0) {
318           msg_dialog::display(_("Fatal error"), _("Cannot find an unused tag for this administrative unit!"), WARNING_DIALOG);
319           return;
320         }
321         $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
322       }
323     }
324     $this->skipTagging = TRUE;
325     plugin::save();
327     /* Remove tag information if needed */
328     if (!$this->is_administrational_unit){
329       $tmp= array();
331       /* Remove gosaAdministrativeUnit from this plugin */
332       foreach($this->attrs['objectClass'] as $oc){
333         if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
334           $tmp[]= $oc;
335         }
336       }
337       $this->attrs['objectClass']= $tmp;
338     }
340     /* Do we need to remove the tag itself? */
341     $has_unit_tag= false;
342     foreach($this->attrs['objectClass'] as $oc){
343       if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
344         $has_unit_tag= true;
345       }
346     }
347     if ($has_unit_tag == false && $this->is_administrational_unit == false){
348       $this->attrs['gosaUnitTag']= array();
349       $this->gosaUnitTag = "";
350     } else {
351       $this->attrs['gosaUnitTag']= $this->gosaUnitTag;
352     }
354                 /* Write back to ldap */
355                 $ldap->cat($this->dn, array('dn'));
356                 $ldap->cd($this->dn);
358                 if ($ldap->count()){
359                         $this->cleanup();
360                         $ldap->modify ($this->attrs); 
361       new log("modify","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
362                         $this->handle_post_events('modify');
363                 } else {
364                         $ldap->add($this->attrs);
365                         $this->handle_post_events('add');
366       new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
367                 }
368     if (!$ldap->success()){
369       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
370     }
372     /* The parameter forces only to set must_be_tagged, and don't touch any objects 
373        This will be done later */
374     $this->tag_objects(true);
375     
376     /* Optionally execute a command after we're done */
377                 $this->postcreate();
378     return(false);
379         }
382   function ShowMoveFrame()
383   {
384     $smarty = get_smarty();
385     $smarty->assign("src","?plug=".$_GET['plug']."&amp;PerformRecMove&no_output_compression");
386     $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.");
387     $display=  $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE));
388     return($display);
389   }
391   function ShowTagFrame()
392   {
393     $smarty = get_smarty();
394     $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment&no_output_compression");
395     $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.");
396     $display=  $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE));
397     return($display);
398   }
400         /* Tag objects to have the gosaAdministrativeUnitTag */
401         function tag_objects($OnlySetTagFlag = false)
402         {
403     if(!$OnlySetTagFlag){
404       $smarty= get_smarty();
405       /* Print out html introduction */
406       echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
407         <html>
408         <head>
409         <title></title>
410         <style type="text/css">@import url("themes/default/style.css");</style>
411         <script language="javascript" src="include/focus.js" type="text/javascript"></script>
412         </head>
413         <body style="background: none; margin:4px;" id="body" >
414         ';
415       echo "<h3>".sprintf(_("Tagging '%s'."),"<i>".@LDAP::fix($this->dn)."</i>")."</h3>";
416     }
418     $add= $this->is_administrational_unit;
419     $len= strlen($this->dn);
420     $ldap= $this->config->get_ldap_link();
421     $ldap->cd($this->dn);
422     if ($add){
423             $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
424                                                     $this->gosaUnitTag.')))', array('dn'));
425     } else {
426             $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
427     }
429     $objects = array();
430     while ($attrs= $ldap->fetch()){
431       $objects[] = $attrs;
432     }
433     foreach($objects as $attrs){
435             /* Skip self */
436             if ($attrs['dn'] == $this->dn){
437                     continue;
438             }
440             /* Check for confilicting administrative units */
441             $fix= true;
442             foreach ($this->config->adepartments as $key => $tag){
443                     /* This one is shorter than our dn, its not relevant... */
444                     if ($len >= strlen($key)){
445                             continue;
446                     }
448                     /* This one matches with the latter part. Break and don't fix this entry */
449                     if (preg_match('/(^|,)'.normalizePreg($key).'$/', $attrs['dn'])){
450                             $fix= false;
451                             break;
452                     }
453             }
455             /* Fix entry if needed */
456             if ($fix){
457                     if($OnlySetTagFlag){
458                             $this->must_be_tagged =true;
459                             return;
460                     }
461                     $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
462             }
463     }
464     if(!$OnlySetTagFlag){
465             echo '<p class="seperator">&nbsp;</p>';
466             echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
467                     <br><input type='submit' name='back' value='"._("Continue")."'>
468                     </form></div>";
469     }
470         }
473         /* Move/Rename complete trees */
474         function recursive_move($src_dn, $dst_dn,$force = false)
475         {
476     /* If force == false prepare to recursive move this object from src to dst 
477         on the next call. */
478                 if(!$force){
479                         $this->rec_cpy  = true;
480                         $this->rec_src  = $src_dn;
481                         $this->rec_dst  = $dst_dn;
482                 }else{
484       /* If this is called, but not wanted, abort */
485                         if(!$this->rec_cpy){ 
486                                 return;
487                         }
489                         $src_dn = $this->rec_src;
490                         $dst_dn = $this->rec_dst;
492                         /* Print header to have styles included */
493                         $smarty= get_smarty();
495       echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
496         <html>
497         <head>
498         <title></title>
499         <style type="text/css">@import url("themes/default/style.css");</style>
500         <script language="javascript" src="include/focus.js" type="text/javascript"></script>
501         </head>
502         <body style="background: none; margin:4px;" id="body" >
503         ';
504                         echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".@LDAP::fix($src_dn)."</i>","<i>".@LDAP::fix($dst_dn)."</i>")."</h3>";
507                         /* Check if the destination entry exists */
508                         $ldap= $this->config->get_ldap_link();
510                         /* Check if destination exists - abort */
511                         $ldap->cat($dst_dn, array('dn'));
512                         if ($ldap->fetch()){
513                                 trigger_error("Recursive_move ".@LDAP::fix($dst_dn)." already exists.",
514                                                 E_USER_WARNING);
515                                 echo sprintf("Recursive_move: '%s' already exists", @LDAP::fix($dst_dn))."<br>"; 
516                                 return (FALSE);
517                         }
519                         /* Perform a search for all objects to be moved */
520                         $objects= array();
521                         $ldap->cd($src_dn);
522                         $ldap->search("(objectClass=*)", array("dn"));
523                         while($attrs= $ldap->fetch()){
524                                 $dn= $attrs['dn'];
525                                 $objects[$dn]= strlen($dn);
526                         }
528                         /* Sort objects by indent level */
529                         asort($objects);
530                         reset($objects);
532                         /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
533                         foreach ($objects as $object => $len){
536                                 $src= str_replace("\\","\\\\",$object);
537                                 $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
538                                 $dst= str_replace($src_dn,$dst_dn,$object);
540                                 echo "<b>"._("Object").":</b> ".@LDAP::fix($src)."<br>";
542         $this->update_acls($object, $dst,TRUE);
544                                 if (!$this->copy($src, $dst)){
545                                         echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),@LDAP::fix($src))."</font>";
546                                         return (FALSE);
547                                 }
548         echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
549                                 flush();
550                         }
552                         /* Remove src_dn */
553                         $ldap->cd($src_dn);
554                         $ldap->recursive_remove();
555       $this->dn = $this->rec_dst;
556                         $this->rec_src = $this->rec_dst = "";
557                         $this->rec_cpy =false;
559                         echo '<p class="seperator">&nbsp;</p>';
561                         echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
562                                 <br><input type='submit' name='back' value='"._("Continue")."'>
563                                 </form></div>";
565       echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
566                         echo "</body></html>";
568                         return (TRUE);
569                 }
570         }
573   /* Return plugin informations for acl handling */ 
574   static function plInfo()
575   {
576     return (array("plShortName"   => _("Generic"),
577                   "plDescription" => _("Departments"),
578                   "plSelfModify"  => FALSE,
579                   "plPriority"    => 0,
580                   "plDepends"     => array(),
581                   "plSection"     => array("admin"),
582                   "plCategory"    => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))),
583             
584                   "plProvidedAcls" => array(
585                     "description"       => _("Description"),
586                     "c"                 => _("Country"),
587                     "base"              => _("Base"),
588                     "l"                 => _("Location"),
589                     "telephoneNumber"   => _("Telephone"),
590                     "ou"                => _("Department name"),
591                     "businessCategory"  => _("Category"),
592                     "st"                => _("State"),
593                     "postalAddress"     => _("Address"),
594                     "gosaUnitTag"       => _("Administrative settings"),
595                     "facsimileTelephoneNumber" => _("Fax"))
596                   ));
597   }
599   function handle_object_tagging($dn= "", $tag= "", $show= false)
600   {
601     /* No dn? Self-operation... */
602     if ($dn == ""){
603       $dn= $this->dn;
605       /* No tag? Find it yourself... */
606       if ($tag == ""){
607         $len= strlen($dn);
609         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
610         $relevant= array();
611         foreach ($this->config->adepartments as $key => $ntag){
613           /* This one is bigger than our dn, its not relevant... */
614           if ($len <= strlen($key)){
615             continue;
616           }
618           /* This one matches with the latter part. Break and don't fix this entry */
619           if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){
620             @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
621             $relevant[strlen($key)]= $ntag;
622             continue;
623           }
625         }
627         /* If we've some relevant tags to set, just get the longest one */
628         if (count($relevant)){
629           ksort($relevant);
630           $tmp= array_keys($relevant);
631           $idx= end($tmp);
632           $tag= $relevant[$idx];
633           $this->gosaUnitTag= $tag;
634         }
635       }
636     }
638     /* Set tag? */
639     if ($tag != ""){
640       /* Set objectclass and attribute */
641       $ldap= $this->config->get_ldap_link();
642       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
643       $attrs= $ldap->fetch();
644       if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
645         if ($show) {
646           echo sprintf(_("Object '%s' is already tagged"), @LDAP::fix($dn))."<br>";
647           flush();
648         }
649         return;
650       }
651       if (count($attrs)){
652         if ($show){
653           echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."<br>";
654           flush();
655         }
656         $nattrs= array("gosaUnitTag" => $tag);
657         $nattrs['objectClass']= array();
658         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
659           $oc= $attrs['objectClass'][$i];
660           if ($oc != "gosaAdministrativeUnitTag"){
661             $nattrs['objectClass'][]= $oc;
662           }
663         }
664         $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
665         $ldap->cd($dn);
666         $ldap->modify($nattrs);
667         if (!$ldap->success()){
668           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
669         }
670       } else {
671         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
672       }
674     } else {
675       /* Remove objectclass and attribute */
676       $ldap= $this->config->get_ldap_link();
677       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
678       $attrs= $ldap->fetch();
679       if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
680         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
681         return;
682       }
683       if (count($attrs)){
684         if ($show){
685           echo sprintf(_("Removing tag from object '%s'"), @LDAP::fix($dn))."<br>";
686           flush();
687         }
688         $nattrs= array("gosaUnitTag" => array());
689         $nattrs['objectClass']= array();
690         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
691           $oc= $attrs['objectClass'][$i];
692           if ($oc != "gosaAdministrativeUnitTag"){
693             $nattrs['objectClass'][]= $oc;
694           }
695         }
696         $ldap->cd($dn);
697         $ldap->modify($nattrs);
698         if (!$ldap->success()){
699           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
700         }
701       } else {
702         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
703       }
704     }
706   }
710 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
711 ?>