Code

Updated locales
[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 echo 3;
200                 return $this->must_be_tagged;
201         }
203         function am_i_moved()
204         {
205                 return $this->rec_cpy;
206         }
209         /* Save data to object */
210         function save_object()
211         {
212                 if (isset($_POST['dep_generic_posted'])){
214       /* Create a base backup and reset the
215          base directly after calling plugin::save_object();
216          Base will be set seperatly a few lines below */
217       $base_tmp = $this->base;
218       plugin::save_object();
219       $this->base = $base_tmp;
221       /* Set new base if allowed */
222       $tmp = $this->get_allowed_bases();
223       if(isset($_POST['base'])){
224         if(isset($tmp[$_POST['base']])){
225           $this->base= $_POST['base'];
226         }
227       }
229       /* Save tagging flag */
230       if ($this->acl_is_writeable("unitTag")){
231         if (isset($_POST['unitTag'])){
232           $this->is_administrational_unit= true;
233         } else {
234           $this->is_administrational_unit= false;
235         }
236       }
237     }
238         }
241         /* Check values */
242         function check()
243         {
244                 /* Call common method to give check the hook */
245                 $message= plugin::check();
247                 /* Check for presence of this department */
248                 $ldap= $this->config->get_ldap_link();
249     $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
250     if ($this->orig_dn == "new" && $ldap->count()){
251                         $message[]= msgPool::duplicated(_("Name"));
252                 } elseif ($this->orig_dn != $this->dn && !($attrs === FALSE)){
253                         $message[]= msgPool::duplicated(_("Name"));
254                 }
256                 /* All required fields are set? */
257                 if ($this->ou == ""){
258                         $message[]= _("Required field 'Name' is not set.");
259                         $message[]= msgPool::required(_("Name"));
260                 }
261                 if ($this->description == ""){
262                         $message[]= _("Required field 'Description' is not set.");
263                         $message[]= msgPool::required(_("Description"));
264                 }
266     if(tests::is_department_name_reserved($this->ou,$this->base)){
267       $message[]= msgPool::reserved(_("Name"));
268     }
270                 if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
271                         $message[]= msgPool::invalid(_("Name"), $this->ou, "/[^#+:=>\\\\\/]/");
272                 }
273                 if (!tests::is_phone_nr($this->telephoneNumber)){
274                         $message[]= msgPool::invalid(_("Phone"), $this->telephoneNumber, "/[\/0-9 ()+*-]/");
275                 }
276                 if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){
277                         $message[]= msgPool::invalid(_("Fax"), $this->facsimileTelephoneNumber, "/[\/0-9 ()+*-]/");
278                 }
280                 return $message;
281         }
284         /* Save to LDAP */
285         function save()
286         {
287                 $ldap= $this->config->get_ldap_link();
289     /* Add tag objects if needed */
290     if ($this->is_administrational_unit){
292       /* If this wasn't tagged before add oc an reset unit tag */
293       if(!$this->initially_was_tagged){
294         $this->objectclasses[]= "gosaAdministrativeUnit";
295         $this->gosaUnitTag= "";
297         /* It seams that this method is called twice, 
298            set this to true. to avoid adding this oc twice */
299         $this->initially_was_tagged = true;
300       }
302       if ($this->gosaUnitTag == ""){
304         /* It's unlikely, but check if already used... */
305         $try= 5;
306         $ldap->cd($this->config->current['BASE']);
307         while ($try--){
309           /* Generate microtime stamp as tag */
310           list($usec, $sec)= explode(" ", microtime());
311           $time_stamp= preg_replace("/\./", "", $sec.$usec);
313           $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag"));
314           if ($ldap->count() == 0){
315             break;
316           }
317         }
318         if($try == 0) {
319           msg_dialog::display(_("Fatal error"), _("Cannot find an unused tag for this administrative unit!"), WARNING_DIALOG);
320           return;
321         }
322         $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
323       }
324     }
325     $this->skipTagging = TRUE;
326     plugin::save();
328     /* Remove tag information if needed */
329     if (!$this->is_administrational_unit){
330       $tmp= array();
332       /* Remove gosaAdministrativeUnit from this plugin */
333       foreach($this->attrs['objectClass'] as $oc){
334         if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
335           $tmp[]= $oc;
336         }
337       }
338       $this->attrs['objectClass']= $tmp;
339     }
341     /* Do we need to remove the tag itself? */
342     $has_unit_tag= false;
343     foreach($this->attrs['objectClass'] as $oc){
344       if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
345         $has_unit_tag= true;
346       }
347     }
348     if ($has_unit_tag == false && $this->is_administrational_unit == false){
349       $this->attrs['gosaUnitTag']= array();
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");
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");
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     while ($attrs= $ldap->fetch()){
431             /* Skip self */
432             if ($attrs['dn'] == $this->dn){
433                     continue;
434             }
436             /* Check for confilicting administrative units */
437             $fix= true;
438             foreach ($this->config->adepartments as $key => $tag){
439                     /* This one is shorter than our dn, its not relevant... */
440                     if ($len >= strlen($key)){
441                             continue;
442                     }
444                     /* This one matches with the latter part. Break and don't fix this entry */
445                     if (preg_match('/(^|,)'.normalizePreg($key).'$/', $attrs['dn'])){
446                             $fix= false;
447                             break;
448                     }
449             }
451             /* Fix entry if needed */
452             if ($fix){
453 echo "1";
454                     if($OnlySetTagFlag){
455 echo "2";
456                             $this->must_be_tagged =true;
457                             return;
458                     }
459                     $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
460             }
461     }
462     if(!$OnlySetTagFlag){
463             echo '<p class="seperator">&nbsp;</p>';
464             echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
465                     <br><input type='submit' name='back' value='"._("Continue")."'>
466                     </form></div>";
467     }
468         }
471         /* Move/Rename complete trees */
472         function recursive_move($src_dn, $dst_dn,$force = false)
473         {
474     /* If force == false prepare to recursive move this object from src to dst 
475         on the next call. */
476                 if(!$force){
477                         $this->rec_cpy  = true;
478                         $this->rec_src  = $src_dn;
479                         $this->rec_dst  = $dst_dn;
480                 }else{
482       /* If this is called, but not wanted, abort */
483                         if(!$this->rec_cpy){ 
484                                 return;
485                         }
487                         $src_dn = $this->rec_src;
488                         $dst_dn = $this->rec_dst;
490                         /* Print header to have styles included */
491                         $smarty= get_smarty();
493       echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
494         <html>
495         <head>
496         <title></title>
497         <style type="text/css">@import url("themes/default/style.css");</style>
498         <script language="javascript" src="include/focus.js" type="text/javascript"></script>
499         </head>
500         <body style="background: none; margin:4px;" id="body" >
501         ';
502                         echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".@LDAP::fix($src_dn)."</i>","<i>".@LDAP::fix($dst_dn)."</i>")."</h3>";
505                         /* Check if the destination entry exists */
506                         $ldap= $this->config->get_ldap_link();
508                         /* Check if destination exists - abort */
509                         $ldap->cat($dst_dn, array('dn'));
510                         if ($ldap->fetch()){
511                                 trigger_error("Recursive_move ".@LDAP::fix($dst_dn)." already exists.",
512                                                 E_USER_WARNING);
513                                 echo sprintf("Recursive_move: '%s' already exists", @LDAP::fix($dst_dn))."<br>"; 
514                                 return (FALSE);
515                         }
517                         /* Perform a search for all objects to be moved */
518                         $objects= array();
519                         $ldap->cd($src_dn);
520                         $ldap->search("(objectClass=*)", array("dn"));
521                         while($attrs= $ldap->fetch()){
522                                 $dn= $attrs['dn'];
523                                 $objects[$dn]= strlen($dn);
524                         }
526                         /* Sort objects by indent level */
527                         asort($objects);
528                         reset($objects);
530                         /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
531                         foreach ($objects as $object => $len){
534                                 $src= str_replace("\\","\\\\",$object);
535                                 $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
536                                 $dst= str_replace($src_dn,$dst_dn,$object);
538                                 echo "<b>"._("Object").":</b> ".@LDAP::fix($src)."<br>";
540         $this->update_acls($object, $dst,TRUE);
542                                 if (!$this->copy($src, $dst)){
543                                         echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),@LDAP::fix($src))."</font>";
544                                         return (FALSE);
545                                 }
546         echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
547                                 flush();
548                         }
550                         /* Remove src_dn */
551                         $ldap->cd($src_dn);
552                         $ldap->recursive_remove();
553       $this->dn = $this->rec_dst;
554                         $this->rec_src = $this->rec_dst = "";
555                         $this->rec_cpy =false;
557                         echo '<p class="seperator">&nbsp;</p>';
559                         echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
560                                 <br><input type='submit' name='back' value='"._("Continue")."'>
561                                 </form></div>";
563       echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
564                         echo "</body></html>";
566                         return (TRUE);
567                 }
568         }
571   /* Return plugin informations for acl handling */ 
572   static function plInfo()
573   {
574     return (array("plShortName"   => _("Generic"),
575                   "plDescription" => _("Departments"),
576                   "plSelfModify"  => FALSE,
577                   "plPriority"    => 0,
578                   "plDepends"     => array(),
579                   "plSection"     => array("admin"),
580                   "plCategory"    => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))),
581             
582                   "plProvidedAcls" => array(
583                     "description"       => _("Description"),
584                     "c"                 => _("Country"),
585                     "base"              => _("Base"),
586                     "l"                 => _("Location"),
587                     "telephoneNumber"   => _("Telephone"),
588                     "ou"                => _("Department name"),
589                     "businessCategory"  => _("Category"),
590                     "st"                => _("State"),
591                     "postalAddress"     => _("Address"),
592                     "gosaUnitTag"       => _("Administrative settings"),
593                     "facsimileTelephoneNumber" => _("Fax"))
594                   ));
595   }
597   function handle_object_tagging($dn= "", $tag= "", $show= false)
598   {
599     /* No dn? Self-operation... */
600     if ($dn == ""){
601       $dn= $this->dn;
603       /* No tag? Find it yourself... */
604       if ($tag == ""){
605         $len= strlen($dn);
607         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
608         $relevant= array();
609         foreach ($this->config->adepartments as $key => $ntag){
611           /* This one is bigger than our dn, its not relevant... */
612           if ($len <= strlen($key)){
613             continue;
614           }
616           /* This one matches with the latter part. Break and don't fix this entry */
617           if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){
618             @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
619             $relevant[strlen($key)]= $ntag;
620             continue;
621           }
623         }
625         /* If we've some relevant tags to set, just get the longest one */
626         if (count($relevant)){
627           ksort($relevant);
628           $tmp= array_keys($relevant);
629           $idx= end($tmp);
630           $tag= $relevant[$idx];
631           $this->gosaUnitTag= $tag;
632         }
633       }
634     }
636     /* Set tag? */
637     if ($tag != ""){
638       /* Set objectclass and attribute */
639       $ldap= $this->config->get_ldap_link();
640       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
641       $attrs= $ldap->fetch();
642       if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
643         if ($show) {
644           echo sprintf(_("Object '%s' is already tagged"), @LDAP::fix($dn))."<br>";
645           flush();
646         }
647         return;
648       }
649       if (count($attrs)){
650         if ($show){
651           echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."<br>";
652           flush();
653         }
654         $nattrs= array("gosaUnitTag" => $tag);
655         $nattrs['objectClass']= array();
656         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
657           $oc= $attrs['objectClass'][$i];
658           if ($oc != "gosaAdministrativeUnitTag"){
659             $nattrs['objectClass'][]= $oc;
660           }
661         }
662         $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
663         $ldap->cd($dn);
664         $ldap->modify($nattrs);
665         if (!$ldap->success()){
666           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
667         }
668       } else {
669         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
670       }
672     } else {
673       /* Remove objectclass and attribute */
674       $ldap= $this->config->get_ldap_link();
675       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
676       $attrs= $ldap->fetch();
677       if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
678         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
679         return;
680       }
681       if (count($attrs)){
682         if ($show){
683           echo sprintf(_("Removing tag from object '%s'"), @LDAP::fix($dn))."<br>";
684           flush();
685         }
686         $nattrs= array("gosaUnitTag" => array());
687         $nattrs['objectClass']= array();
688         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
689           $oc= $attrs['objectClass'][$i];
690           if ($oc != "gosaAdministrativeUnitTag"){
691             $nattrs['objectClass'][]= $oc;
692           }
693         }
694         $ldap->cd($dn);
695         $ldap->modify($nattrs);
696         if (!$ldap->success()){
697           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
698         }
699       } else {
700         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
701       }
702     }
704   }
708 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
709 ?>