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 /* Refresh base */
234 if ($this->acl_is_moveable($this->base)){
235 if (!$this->baseSelector->update()) {
236 msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
237 }
238 if ($this->base != $this->baseSelector->getBase()) {
239 $this->base= $this->baseSelector->getBase();
240 $this->is_modified= TRUE;
241 }
242 }
244 if (isset($_POST['dep_generic_posted'])){
246 $nA = $this->namingAttr;
247 $old_nA = $this->$nA;
251 /* Create a base backup and reset the
252 base directly after calling plugin::save_object();
253 Base will be set seperatly a few lines below */
254 $base_tmp = $this->base;
255 plugin::save_object();
256 $this->base = $base_tmp;
258 /* Save tagging flag */
259 if ($this->acl_is_writeable("gosaUnitTag")){
260 if (isset($_POST['is_administrational_unit'])){
261 $this->is_administrational_unit= true;
262 } else {
263 $this->is_administrational_unit= false;
264 }
265 }
267 /* If this is the root directory service entry then avoid
268 changing the naming attribute of this entry.
269 */
270 if($this->dn == $this->config->current['BASE']){
271 $this->$nA = $old_nA;
272 }
273 }
274 }
277 /* Check values */
278 function check()
279 {
280 /* Call common method to give check the hook */
281 $message= plugin::check();
283 /* Check for presence of this department */
284 $ldap= $this->config->get_ldap_link();
285 $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
286 if ($this->orig_dn == "new" && $ldap->count()){
287 $message[]= msgPool::duplicated(_("Name"));
288 } elseif ($this->orig_dn != $this->dn && $ldap->count()){
289 $message[]= msgPool::duplicated(_("Name"));
290 }
292 /* All required fields are set? */
293 if ($this->ou == ""){
294 $message[]= msgPool::required(_("Name"));
295 }
296 if ($this->description == ""){
297 $message[]= msgPool::required(_("Description"));
298 }
300 if(tests::is_department_name_reserved($this->ou,$this->base)){
301 $message[]= msgPool::reserved(_("Name"));
302 }
304 if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
305 $message[]= msgPool::invalid(_("Name"), $this->ou, "/[^#+:=>\\\\\/]/");
306 }
307 if (!tests::is_phone_nr($this->telephoneNumber)){
308 $message[]= msgPool::invalid(_("Phone"), $this->telephoneNumber, "/[\/0-9 ()+*-]/");
309 }
310 if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){
311 $message[]= msgPool::invalid(_("Fax"), $this->facsimileTelephoneNumber, "/[\/0-9 ()+*-]/");
312 }
314 /* Check if we are allowed to create or move this object
315 */
316 if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
317 $message[] = msgPool::permCreate();
318 }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
319 $message[] = msgPool::permMove();
320 }
322 return $message;
323 }
326 /* Save to LDAP */
327 function save()
328 {
329 $ldap= $this->config->get_ldap_link();
331 /* Ensure that ou is saved too, it is required by objectClass gosaDepartment
332 */
333 $nA = $this->namingAttr;
334 $this->ou = $this->$nA;
336 /* Add tag objects if needed */
337 if ($this->is_administrational_unit){
339 /* If this wasn't tagged before add oc an reset unit tag */
340 if(!$this->initially_was_tagged){
341 $this->objectclasses[]= "gosaAdministrativeUnit";
342 $this->gosaUnitTag= "";
344 /* It seams that this method is called twice,
345 set this to true. to avoid adding this oc twice */
346 $this->initially_was_tagged = true;
347 }
349 if ($this->gosaUnitTag == ""){
351 /* It's unlikely, but check if already used... */
352 $try= 5;
353 $ldap->cd($this->config->current['BASE']);
354 while ($try--){
356 /* Generate microtime stamp as tag */
357 list($usec, $sec)= explode(" ", microtime());
358 $time_stamp= preg_replace("/\./", "", $sec.$usec);
360 $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag"));
361 if ($ldap->count() == 0){
362 break;
363 }
364 }
365 if($try == 0) {
366 msg_dialog::display(_("Fatal error"), _("Cannot find an unused tag for this administrative unit!"), WARNING_DIALOG);
367 return;
368 }
369 $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
370 }
371 }
372 $this->skipTagging = TRUE;
373 plugin::save();
375 /* Remove tag information if needed */
376 if (!$this->is_administrational_unit && $this->initially_was_tagged){
377 $tmp= array();
379 /* Remove gosaAdministrativeUnit from this plugin */
380 foreach($this->attrs['objectClass'] as $oc){
381 if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
382 continue;
383 }
384 if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
385 $tmp[]= $oc;
386 }
387 }
388 $this->attrs['objectClass']= $tmp;
389 $this->attrs['gosaUnitTag']= array();
390 $this->gosaUnitTag = "";
391 }
394 /* Write back to ldap */
395 $ldap->cat($this->dn, array('dn'));
396 $ldap->cd($this->dn);
398 if ($ldap->count()){
399 $this->cleanup();
400 $ldap->modify ($this->attrs);
401 new log("modify","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
402 $this->handle_post_events('modify');
403 } else {
404 $ldap->add($this->attrs);
405 $this->handle_post_events('add');
406 new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
407 }
408 if (!$ldap->success()){
409 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
410 }
412 /* The parameter forces only to set must_be_tagged, and don't touch any objects
413 This will be done later */
414 $this->tag_objects(true);
416 /* Optionally execute a command after we're done */
417 $this->postcreate();
418 return(false);
419 }
422 /* Tag objects to have the gosaAdministrativeUnitTag */
423 function tag_objects($OnlySetTagFlag = false)
424 {
425 if(!$OnlySetTagFlag){
426 $smarty= get_smarty();
427 /* Print out html introduction */
428 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
429 <html>
430 <head>
431 <title></title>
432 <style type="text/css">@import url("themes/default/style.css");</style>
433 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
434 </head>
435 <body style="background: none; margin:4px;" id="body" >
436 ';
437 echo "<h3>".sprintf(_("Tagging '%s'."),"<i>".LDAP::fix($this->dn)."</i>")."</h3>";
438 }
440 $add= $this->is_administrational_unit;
441 $len= strlen($this->dn);
442 $ldap= $this->config->get_ldap_link();
443 $ldap->cd($this->dn);
444 if ($add){
445 $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
446 $this->gosaUnitTag.')))', array('dn'));
447 } else {
448 $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
449 }
451 $objects = array();
452 while ($attrs= $ldap->fetch()){
453 $objects[] = $attrs;
454 }
455 foreach($objects as $attrs){
457 /* Skip self */
458 if ($attrs['dn'] == $this->dn){
459 continue;
460 }
462 /* Check for confilicting administrative units */
463 $fix= true;
464 foreach ($this->config->adepartments as $key => $tag){
465 /* This one is shorter than our dn, its not relevant... */
466 if ($len >= strlen($key)){
467 continue;
468 }
470 /* This one matches with the latter part. Break and don't fix this entry */
471 if (preg_match('/(^|,)'.preg_quote($key, '/').'$/', $attrs['dn'])){
472 $fix= false;
473 break;
474 }
475 }
477 /* Fix entry if needed */
478 if ($fix){
479 if($OnlySetTagFlag){
480 $this->must_be_tagged =true;
481 return;
482 }
483 $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
484 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
485 }
486 }
488 if(!$OnlySetTagFlag){
489 $this->must_be_tagged = FALSE;
490 echo '<p class="seperator"> </p>';
491 echo "<div style='width:100%;text-align:right;'>".
492 "<form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>".
493 "<br>".
494 "<input type='submit' name='back' value='"._("Continue")."'>".
495 "<input type='hidden' name='php_c_check' value='1'>".
496 "</form>".
497 "</div>";
498 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
499 }
500 }
503 /* Move/Rename complete trees */
504 function recursive_move($src_dn, $dst_dn,$force = false)
505 {
506 /* Print header to have styles included */
507 $smarty= get_smarty();
509 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
510 <html>
511 <head>
512 <title></title>
513 <style type="text/css">@import url("themes/default/style.css");</style>
514 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
515 </head>
516 <body style="background: none; margin:4px;" id="body" >
517 ';
518 echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".LDAP::fix($src_dn)."</i>","<i>".LDAP::fix($dst_dn)."</i>")."</h3>";
521 /* Check if the destination entry exists */
522 $ldap= $this->config->get_ldap_link();
524 /* Check if destination exists - abort */
525 $ldap->cat($dst_dn, array('dn'));
526 if ($ldap->fetch()){
527 trigger_error("Recursive_move ".LDAP::fix($dst_dn)." already exists.",
528 E_USER_WARNING);
529 echo sprintf("Recursive_move: '%s' already exists", LDAP::fix($dst_dn))."<br>";
530 return (FALSE);
531 }
533 /* Perform a search for all objects to be moved */
534 $objects= array();
535 $ldap->cd($src_dn);
536 $ldap->search("(objectClass=*)", array("dn"));
537 while($attrs= $ldap->fetch()){
538 $dn= $attrs['dn'];
539 $objects[$dn]= strlen($dn);
540 }
542 /* Sort objects by indent level */
543 asort($objects);
544 reset($objects);
546 /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
547 foreach ($objects as $object => $len){
550 $src= str_replace("\\","\\\\",$object);
551 $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
552 $dst= str_replace($src_dn,$dst_dn,$object);
554 echo "<b>"._("Object").":</b> ".LDAP::fix($src)."<br>";
556 $this->update_acls($object, $dst,TRUE);
558 if (!$this->copy($src, $dst)){
559 echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),LDAP::fix($src))."</font>";
560 return (FALSE);
561 }
562 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
563 flush();
564 }
566 /* Remove src_dn */
567 $ldap->cd($src_dn);
568 $ldap->recursive_remove();
569 $this->orig_dn = $this->dn = $dst_dn;
570 $this->orig_base= $this->base;
571 $this->entryCSN = getEntryCSN($this->dn);
573 echo '<p class="seperator"> </p>';
575 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
576 <br><input type='submit' name='back' value='"._("Continue")."'>
577 </form></div>";
579 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
580 echo "</body></html>";
582 return (TRUE);
583 }
586 /* Return plugin informations for acl handling */
587 static function plInfo()
588 {
589 return (array("plShortName" => _("Generic"),
590 "plDescription" => _("Departments"),
591 "plSelfModify" => FALSE,
592 "plPriority" => 0,
593 "plDepends" => array(),
594 "plSection" => array("administration"),
595 "plCategory" => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))),
597 "plProvidedAcls" => array(
598 "ou" => _("Department name"),
599 "description" => _("Description"),
600 "businessCategory" => _("Category"),
601 "base" => _("Base"),
603 "st" => _("State"),
604 "l" => _("Location"),
605 "postalAddress" => _("Address"),
606 "telephoneNumber" => _("Telephone"),
607 "facsimileTelephoneNumber" => _("Fax"),
609 "gosaUnitTag" => _("Administrative settings"))
610 ));
611 }
613 function handle_object_tagging($dn= "", $tag= "", $show= false)
614 {
615 /* No dn? Self-operation... */
616 if ($dn == ""){
617 $dn= $this->dn;
619 /* No tag? Find it yourself... */
620 if ($tag == ""){
621 $len= strlen($dn);
623 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
624 $relevant= array();
625 foreach ($this->config->adepartments as $key => $ntag){
627 /* This one is bigger than our dn, its not relevant... */
628 if ($len <= strlen($key)){
629 continue;
630 }
632 /* This one matches with the latter part. Break and don't fix this entry */
633 if (preg_match('/(^|,)'.preg_quote($key, '/').'$/', $dn)){
634 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
635 $relevant[strlen($key)]= $ntag;
636 continue;
637 }
639 }
641 /* If we've some relevant tags to set, just get the longest one */
642 if (count($relevant)){
643 ksort($relevant);
644 $tmp= array_keys($relevant);
645 $idx= end($tmp);
646 $tag= $relevant[$idx];
647 $this->gosaUnitTag= $tag;
648 }
649 }
650 }
652 /* Set tag? */
653 if ($tag != ""){
654 /* Set objectclass and attribute */
655 $ldap= $this->config->get_ldap_link();
656 $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
657 $attrs= $ldap->fetch();
658 if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
659 if ($show) {
660 echo sprintf(_("Object '%s' is already tagged"), LDAP::fix($dn))."<br>";
661 flush();
662 }
663 return;
664 }
665 if (count($attrs)){
666 if ($show){
667 echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, LDAP::fix($dn))."<br>";
668 flush();
669 }
670 $nattrs= array("gosaUnitTag" => $tag);
671 $nattrs['objectClass']= array();
672 for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
673 $oc= $attrs['objectClass'][$i];
674 if ($oc != "gosaAdministrativeUnitTag"){
675 $nattrs['objectClass'][]= $oc;
676 }
677 }
678 $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
679 $ldap->cd($dn);
680 $ldap->modify($nattrs);
681 if (!$ldap->success()){
682 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
683 }
684 } else {
685 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
686 }
688 } else {
689 /* Remove objectclass and attribute */
690 $ldap= $this->config->get_ldap_link();
691 $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
692 $attrs= $ldap->fetch();
693 if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
694 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
695 return;
696 }
697 if (count($attrs)){
698 if ($show){
699 echo sprintf(_("Removing tag from object '%s'"), LDAP::fix($dn))."<br>";
700 flush();
701 }
702 $nattrs= array("gosaUnitTag" => array());
703 $nattrs['objectClass']= array();
704 for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
705 $oc= $attrs['objectClass'][$i];
706 if ($oc != "gosaAdministrativeUnitTag"){
707 $nattrs['objectClass'][]= $oc;
708 }
709 }
710 $ldap->cd($dn);
711 $ldap->modify($nattrs);
712 if (!$ldap->success()){
713 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
714 }
715 } else {
716 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
717 }
718 }
719 }
721 }
723 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
724 ?>