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 ="organizationalUnit";
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");
51 /* Do not append the structural object classes here, they are added dynamically in the constructor */
52 var $objectclasses= array("top", "gosaDepartment");
53 var $structuralOC = array("organizationalUnit");
55 var $initially_was_tagged = false;
56 var $orig_base = "";
57 var $orig_ou = "";
58 var $baseSelector;
60 function department (&$config, $dn)
61 {
62 /* Add the default structural obejct class 'locality' if this is a new entry
63 */
64 $ldap = $config->get_ldap_link();
65 $ldap->cd($config->current['BASE']);
66 if($dn == "" || $dn == "new" || !$ldap->dn_exists($dn)){
67 $this->objectclasses = array_merge($this->structuralOC,$this->objectclasses);
68 }else{
69 $ldap->cat($dn, array("structuralObjectClass"));
70 $attrs= $ldap->fetch();
71 if(isset($attrs['structuralObjectClass']['count'])){
72 for($i = 0 ; $i < $attrs['structuralObjectClass']['count'] ; $i++){
73 $this->objectclasses[] = $attrs['structuralObjectClass'][$i];
74 }
75 }else{
77 /* Could not detect structural object class for this object, fall back to the default 'locality'
78 */
79 $this->objectclasses = array_merge($this->structuralOC,$this->objectclasses);
80 }
81 }
82 $this->objectclasses = array_unique($this->objectclasses);
84 plugin::plugin($config, $dn);
85 $this->is_account= TRUE;
86 $this->ui= get_userinfo();
87 $this->dn= $dn;
88 $this->orig_dn= $dn;
90 /* Save current naming attribuet
91 */
92 $nA = $this->namingAttr;
93 $orig_nA = "orig_".$nA;
94 $this->$orig_nA = $this->$nA;
96 $this->config= $config;
98 /* Set base */
99 if ($this->dn == "new"){
100 $ui= get_userinfo();
101 if(session::is_set('CurrentMainBase')){
102 $this->base = session::get('CurrentMainBase');
103 }else{
104 $this->base= dn2base($ui->dn);
105 }
106 } else {
107 $this->base= preg_replace ("/^[^,]+,/", "", $this->dn);
108 }
110 $this->orig_base = $this->base;
112 /* Is administrational Unit? */
113 if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){
114 $this->is_administrational_unit= true;
115 $this->initially_was_tagged = true;
116 }
118 /* Instanciate base selector */
119 $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
120 $this->baseSelector->setSubmitButton(false);
121 $this->baseSelector->setHeight(300);
122 $this->baseSelector->update(true);
123 }
125 function execute()
126 {
127 /* Call parent execute */
128 plugin::execute();
130 /* Log view */
131 if($this->is_account && !$this->view_logged){
132 $this->view_logged = TRUE;
133 new log("view","department/".get_class($this),$this->dn);
134 }
136 /* Reload departments */
137 $this->config->get_departments($this->dn);
138 $this->config->make_idepartments();
139 $smarty= get_smarty();
140 $smarty->assign("usePrototype", "true");
142 $tmp = $this->plInfo();
143 foreach($tmp['plProvidedAcls'] as $name => $translation){
144 $smarty->assign($name."ACL",$this->getacl($name));
145 }
147 /* Hide base selector, if this object represents the base itself
148 */
149 $smarty->assign("is_root_dse", FALSE);
150 if($this->dn == $this->config->current['BASE']){
151 $smarty->assign("is_root_dse", TRUE);
152 $nA = $this->namingAttr."ACL";
153 $smarty->assign($nA,$this->getacl($this->namingAttr,TRUE));
154 }
156 /* Hide all departments, that are subtrees of this department */
157 $bases = $this->get_allowed_bases();
158 if(($this->dn == "new")||($this->dn == "")){
159 $tmp = $bases;
160 }else{
161 $tmp = array();
162 foreach($bases as $dn=>$base){
163 /* Only attach departments which are not a subtree of this one */
164 if(!preg_match("/".preg_quote($this->dn)."/",$dn)){
165 $tmp[$dn]=$base;
166 }
167 }
168 }
169 $this->baseSelector->setBases($tmp);
171 foreach ($this->attributes as $val){
172 $smarty->assign("$val", $this->$val);
173 }
174 $smarty->assign("base", $this->baseSelector->render());
176 /* Set admin unit flag */
177 if ($this->is_administrational_unit) {
178 $smarty->assign("gosaUnitTag", "checked");
179 } else {
180 $smarty->assign("gosaUnitTag", "");
181 }
183 $smarty->assign("dep_type",$this->type);
186 $dep_types = departmentManagement::get_support_departments();
187 $tpl ="";
188 foreach($dep_types as $key => $data){
189 if($data['OC'] == $this->type){
190 $tpl = $data['TPL'];
191 break;
192 }
193 }
194 if($tpl == "") {
195 trigger_error("No template specified for container type '".$this->type."', please update epartmentManagement::get_support_departments().");
196 $tpl = "generic.tpl";
197 }
198 return($smarty->fetch (get_template_path($tpl, TRUE)));
199 }
201 function clear_fields()
202 {
203 $this->dn = "";
204 $this->base = "";
206 foreach ($this->attributes as $val){
207 $this->$val= "";
208 }
209 }
211 function remove_from_parent()
212 {
213 $ldap= $this->config->get_ldap_link();
214 $ldap->cd ($this->dn);
215 $ldap->rmdir_recursive($this->dn);
216 new log("remove","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
217 if (!$ldap->success()){
218 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
219 }
221 /* Optionally execute a command after we're done */
222 $this->handle_post_events('remove');
223 }
225 function must_be_tagged()
226 {
227 return $this->must_be_tagged;
228 }
230 /* Save data to object */
231 function save_object()
232 {
233 if (isset($_POST['dep_generic_posted'])){
235 $nA = $this->namingAttr;
236 $old_nA = $this->$nA;
240 /* Create a base backup and reset the
241 base directly after calling plugin::save_object();
242 Base will be set seperatly a few lines below */
243 $base_tmp = $this->base;
244 plugin::save_object();
245 $this->base = $base_tmp;
247 /* Refresh base */
248 if ($this->acl_is_moveable($this->base)){
249 if (!$this->baseSelector->update()) {
250 msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
251 }
252 if ($this->base != $this->baseSelector->getBase()) {
253 $this->base= $this->baseSelector->getBase();
254 $this->is_modified= TRUE;
255 }
256 }
259 /* Save tagging flag */
260 if ($this->acl_is_writeable("gosaUnitTag")){
261 if (isset($_POST['is_administrational_unit'])){
262 $this->is_administrational_unit= true;
263 } else {
264 $this->is_administrational_unit= false;
265 }
266 }
268 /* If this is the root directory service entry then avoid
269 changing the naming attribute of this entry.
270 */
271 if($this->dn == $this->config->current['BASE']){
272 $this->$nA = $old_nA;
273 }
274 }
275 }
278 /* Check values */
279 function check()
280 {
281 /* Call common method to give check the hook */
282 $message= plugin::check();
284 /* Check for presence of this department */
285 $ldap= $this->config->get_ldap_link();
286 $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
287 if ($this->orig_dn == "new" && $ldap->count()){
288 $message[]= msgPool::duplicated(_("Name"));
289 } elseif ($this->orig_dn != $this->dn && $ldap->count()){
290 $message[]= msgPool::duplicated(_("Name"));
291 }
293 /* All required fields are set? */
294 if ($this->ou == ""){
295 $message[]= msgPool::required(_("Name"));
296 }
297 if ($this->description == ""){
298 $message[]= msgPool::required(_("Description"));
299 }
301 if(tests::is_department_name_reserved($this->ou,$this->base)){
302 $message[]= msgPool::reserved(_("Name"));
303 }
305 if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
306 $message[]= msgPool::invalid(_("Name"), $this->ou, "/[^#+:=>\\\\\/]/");
307 }
308 if (!tests::is_phone_nr($this->telephoneNumber)){
309 $message[]= msgPool::invalid(_("Phone"), $this->telephoneNumber, "/[\/0-9 ()+*-]/");
310 }
311 if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){
312 $message[]= msgPool::invalid(_("Fax"), $this->facsimileTelephoneNumber, "/[\/0-9 ()+*-]/");
313 }
315 // Check if a wrong base was supplied
316 if(!$this->baseSelector->checkLastBaseUpdate()){
317 $message[]= msgPool::check_base();;
318 }
320 /* Check if we are allowed to create or move this object
321 */
322 if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
323 $message[] = msgPool::permCreate();
324 }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
325 $message[] = msgPool::permMove();
326 }
328 return $message;
329 }
332 /* Save to LDAP */
333 function save()
334 {
335 $ldap= $this->config->get_ldap_link();
337 /* Ensure that ou is saved too, it is required by objectClass gosaDepartment
338 */
339 $nA = $this->namingAttr;
340 $this->ou = $this->$nA;
342 /* Add tag objects if needed */
343 if ($this->is_administrational_unit){
345 /* If this wasn't tagged before add oc an reset unit tag */
346 if(!$this->initially_was_tagged){
347 $this->objectclasses[]= "gosaAdministrativeUnit";
348 $this->gosaUnitTag= "";
350 /* It seams that this method is called twice,
351 set this to true. to avoid adding this oc twice */
352 $this->initially_was_tagged = true;
353 }
355 if ($this->gosaUnitTag == ""){
357 /* It's unlikely, but check if already used... */
358 $try= 5;
359 $ldap->cd($this->config->current['BASE']);
360 while ($try--){
362 /* Generate microtime stamp as tag */
363 list($usec, $sec)= explode(" ", microtime());
364 $time_stamp= preg_replace("/\./", "", $sec.$usec);
366 $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag"));
367 if ($ldap->count() == 0){
368 break;
369 }
370 }
371 if($try == 0) {
372 msg_dialog::display(_("Fatal error"), _("Cannot find an unused tag for this administrative unit!"), WARNING_DIALOG);
373 return;
374 }
375 $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
376 }
377 }
378 $this->skipTagging = TRUE;
379 plugin::save();
381 /* Remove tag information if needed */
382 if (!$this->is_administrational_unit && $this->initially_was_tagged){
383 $tmp= array();
385 /* Remove gosaAdministrativeUnit from this plugin */
386 foreach($this->attrs['objectClass'] as $oc){
387 if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
388 continue;
389 }
390 if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
391 $tmp[]= $oc;
392 }
393 }
394 $this->attrs['objectClass']= $tmp;
395 $this->attrs['gosaUnitTag']= array();
396 $this->gosaUnitTag = "";
397 }
400 /* Write back to ldap */
401 $ldap->cat($this->dn, array('dn'));
402 $ldap->cd($this->dn);
404 if ($ldap->count()){
405 $this->cleanup();
406 $ldap->modify ($this->attrs);
407 new log("modify","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
408 $this->handle_post_events('modify');
409 } else {
410 $ldap->add($this->attrs);
411 $this->handle_post_events('add');
412 new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
413 }
414 if (!$ldap->success()){
415 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
416 }
418 /* The parameter forces only to set must_be_tagged, and don't touch any objects
419 This will be done later */
420 $this->tag_objects(true);
422 /* Optionally execute a command after we're done */
423 $this->postcreate();
424 return(false);
425 }
428 /* Tag objects to have the gosaAdministrativeUnitTag */
429 function tag_objects($OnlySetTagFlag = false)
430 {
431 if(!$OnlySetTagFlag){
432 $smarty= get_smarty();
433 /* Print out html introduction */
434 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
435 <html>
436 <head>
437 <title></title>
438 <style type="text/css">@import url("themes/default/style.css");</style>
439 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
440 </head>
441 <body style="background: none; margin:4px;" id="body" >
442 ';
443 echo "<h3>".sprintf(_("Tagging '%s'."),"<i>".LDAP::fix($this->dn)."</i>")."</h3>";
444 }
446 $add= $this->is_administrational_unit;
447 $len= strlen($this->dn);
448 $ldap= $this->config->get_ldap_link();
449 $ldap->cd($this->dn);
450 if ($add){
451 $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
452 $this->gosaUnitTag.')))', array('dn'));
453 } else {
454 $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
455 }
457 $objects = array();
458 while ($attrs= $ldap->fetch()){
459 $objects[] = $attrs;
460 }
461 foreach($objects as $attrs){
463 /* Skip self */
464 if ($attrs['dn'] == $this->dn){
465 continue;
466 }
468 /* Check for confilicting administrative units */
469 $fix= true;
470 foreach ($this->config->adepartments as $key => $tag){
471 /* This one is shorter than our dn, its not relevant... */
472 if ($len >= strlen($key)){
473 continue;
474 }
476 /* This one matches with the latter part. Break and don't fix this entry */
477 if (preg_match('/(^|,)'.preg_quote($key, '/').'$/', $attrs['dn'])){
478 $fix= false;
479 break;
480 }
481 }
483 /* Fix entry if needed */
484 if ($fix){
485 if($OnlySetTagFlag){
486 $this->must_be_tagged =true;
487 return;
488 }
489 $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
490 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
491 }
492 }
494 if(!$OnlySetTagFlag){
495 $this->must_be_tagged = FALSE;
496 echo '<p class="seperator"> </p>';
497 echo "<div style='width:100%;text-align:right;'>".
498 "<form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>".
499 "<br>".
500 "<input type='submit' name='back' value='"._("Continue")."'>".
501 "<input type='hidden' name='php_c_check' value='1'>".
502 "</form>".
503 "</div>";
504 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
505 }
506 }
509 /* Move/Rename complete trees */
510 function recursive_move($src_dn, $dst_dn,$force = false)
511 {
512 /* Print header to have styles included */
513 $smarty= get_smarty();
515 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
516 <html>
517 <head>
518 <title></title>
519 <style type="text/css">@import url("themes/default/style.css");</style>
520 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
521 </head>
522 <body style="background: none; margin:4px;" id="body" >
523 ';
524 echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".LDAP::fix($src_dn)."</i>","<i>".LDAP::fix($dst_dn)."</i>")."</h3>";
527 /* Check if the destination entry exists */
528 $ldap= $this->config->get_ldap_link();
530 /* Check if destination exists - abort */
531 $ldap->cat($dst_dn, array('dn'));
532 if ($ldap->fetch()){
533 trigger_error("Recursive_move ".LDAP::fix($dst_dn)." already exists.",
534 E_USER_WARNING);
535 echo sprintf("Recursive_move: '%s' already exists", LDAP::fix($dst_dn))."<br>";
536 return (FALSE);
537 }
539 /* Perform a search for all objects to be moved */
540 $objects= array();
541 $ldap->cd($src_dn);
542 $ldap->search("(objectClass=*)", array("dn"));
543 while($attrs= $ldap->fetch()){
544 $dn= $attrs['dn'];
545 $objects[$dn]= strlen($dn);
546 }
548 /* Sort objects by indent level */
549 asort($objects);
550 reset($objects);
552 /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
553 foreach ($objects as $object => $len){
556 $src= str_replace("\\","\\\\",$object);
557 $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
558 $dst= str_replace($src_dn,$dst_dn,$object);
560 echo "<b>"._("Object").":</b> ".LDAP::fix($src)."<br>";
562 $this->update_acls($object, $dst,TRUE);
564 if (!$this->copy($src, $dst)){
565 echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),LDAP::fix($src))."</font>";
566 return (FALSE);
567 }
568 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
569 flush();
570 }
572 /* Remove src_dn */
573 $ldap->cd($src_dn);
574 $ldap->recursive_remove();
575 $this->orig_dn = $this->dn = $dst_dn;
576 $this->orig_base= $this->base;
577 $this->entryCSN = getEntryCSN($this->dn);
579 echo '<p class="seperator"> </p>';
581 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
582 <br><input type='submit' name='back' value='"._("Continue")."'>
583 </form></div>";
585 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
586 echo "</body></html>";
588 return (TRUE);
589 }
592 /* Return plugin informations for acl handling */
593 static function plInfo()
594 {
595 return (array("plShortName" => _("Generic"),
596 "plDescription" => _("Departments"),
597 "plSelfModify" => FALSE,
598 "plPriority" => 0,
599 "plDepends" => array(),
600 "plSection" => array("administration"),
601 "plCategory" => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))),
603 "plProvidedAcls" => array(
604 "ou" => _("Department name"),
605 "description" => _("Description"),
606 "businessCategory" => _("Category"),
607 "base" => _("Base"),
609 "st" => _("State"),
610 "l" => _("Location"),
611 "postalAddress" => _("Address"),
612 "telephoneNumber" => _("Telephone"),
613 "facsimileTelephoneNumber" => _("Fax"),
615 "gosaUnitTag" => _("Administrative settings"))
616 ));
617 }
619 function handle_object_tagging($dn= "", $tag= "", $show= false)
620 {
621 /* No dn? Self-operation... */
622 if ($dn == ""){
623 $dn= $this->dn;
625 /* No tag? Find it yourself... */
626 if ($tag == ""){
627 $len= strlen($dn);
629 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
630 $relevant= array();
631 foreach ($this->config->adepartments as $key => $ntag){
633 /* This one is bigger than our dn, its not relevant... */
634 if ($len <= strlen($key)){
635 continue;
636 }
638 /* This one matches with the latter part. Break and don't fix this entry */
639 if (preg_match('/(^|,)'.preg_quote($key, '/').'$/', $dn)){
640 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
641 $relevant[strlen($key)]= $ntag;
642 continue;
643 }
645 }
647 /* If we've some relevant tags to set, just get the longest one */
648 if (count($relevant)){
649 ksort($relevant);
650 $tmp= array_keys($relevant);
651 $idx= end($tmp);
652 $tag= $relevant[$idx];
653 $this->gosaUnitTag= $tag;
654 }
655 }
656 }
658 /* Set tag? */
659 if ($tag != ""){
660 /* Set objectclass and attribute */
661 $ldap= $this->config->get_ldap_link();
662 $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
663 $attrs= $ldap->fetch();
664 if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
665 if ($show) {
666 echo sprintf(_("Object '%s' is already tagged"), LDAP::fix($dn))."<br>";
667 flush();
668 }
669 return;
670 }
671 if (count($attrs)){
672 if ($show){
673 echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, LDAP::fix($dn))."<br>";
674 flush();
675 }
676 $nattrs= array("gosaUnitTag" => $tag);
677 $nattrs['objectClass']= array();
678 for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
679 $oc= $attrs['objectClass'][$i];
680 if ($oc != "gosaAdministrativeUnitTag"){
681 $nattrs['objectClass'][]= $oc;
682 }
683 }
684 $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
685 $ldap->cd($dn);
686 $ldap->modify($nattrs);
687 if (!$ldap->success()){
688 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
689 }
690 } else {
691 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
692 }
694 } else {
695 /* Remove objectclass and attribute */
696 $ldap= $this->config->get_ldap_link();
697 $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
698 $attrs= $ldap->fetch();
699 if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
700 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
701 return;
702 }
703 if (count($attrs)){
704 if ($show){
705 echo sprintf(_("Removing tag from object '%s'"), LDAP::fix($dn))."<br>";
706 flush();
707 }
708 $nattrs= array("gosaUnitTag" => array());
709 $nattrs['objectClass']= array();
710 for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
711 $oc= $attrs['objectClass'][$i];
712 if ($oc != "gosaAdministrativeUnitTag"){
713 $nattrs['objectClass'][]= $oc;
714 }
715 }
716 $ldap->cd($dn);
717 $ldap->modify($nattrs);
718 if (!$ldap->success()){
719 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
720 }
721 } else {
722 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
723 }
724 }
725 }
727 }
729 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
730 ?>