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 we are allowed to create or move this object
316 */
317 if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
318 $message[] = msgPool::permCreate();
319 }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
320 $message[] = msgPool::permMove();
321 }
323 return $message;
324 }
327 /* Save to LDAP */
328 function save()
329 {
330 $ldap= $this->config->get_ldap_link();
332 /* Ensure that ou is saved too, it is required by objectClass gosaDepartment
333 */
334 $nA = $this->namingAttr;
335 $this->ou = $this->$nA;
337 /* Add tag objects if needed */
338 if ($this->is_administrational_unit){
340 /* If this wasn't tagged before add oc an reset unit tag */
341 if(!$this->initially_was_tagged){
342 $this->objectclasses[]= "gosaAdministrativeUnit";
343 $this->gosaUnitTag= "";
345 /* It seams that this method is called twice,
346 set this to true. to avoid adding this oc twice */
347 $this->initially_was_tagged = true;
348 }
350 if ($this->gosaUnitTag == ""){
352 /* It's unlikely, but check if already used... */
353 $try= 5;
354 $ldap->cd($this->config->current['BASE']);
355 while ($try--){
357 /* Generate microtime stamp as tag */
358 list($usec, $sec)= explode(" ", microtime());
359 $time_stamp= preg_replace("/\./", "", $sec.$usec);
361 $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag"));
362 if ($ldap->count() == 0){
363 break;
364 }
365 }
366 if($try == 0) {
367 msg_dialog::display(_("Fatal error"), _("Cannot find an unused tag for this administrative unit!"), WARNING_DIALOG);
368 return;
369 }
370 $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
371 }
372 }
373 $this->skipTagging = TRUE;
374 plugin::save();
376 /* Remove tag information if needed */
377 if (!$this->is_administrational_unit && $this->initially_was_tagged){
378 $tmp= array();
380 /* Remove gosaAdministrativeUnit from this plugin */
381 foreach($this->attrs['objectClass'] as $oc){
382 if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
383 continue;
384 }
385 if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
386 $tmp[]= $oc;
387 }
388 }
389 $this->attrs['objectClass']= $tmp;
390 $this->attrs['gosaUnitTag']= array();
391 $this->gosaUnitTag = "";
392 }
395 /* Write back to ldap */
396 $ldap->cat($this->dn, array('dn'));
397 $ldap->cd($this->dn);
399 if ($ldap->count()){
400 $this->cleanup();
401 $ldap->modify ($this->attrs);
402 new log("modify","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
403 $this->handle_post_events('modify');
404 } else {
405 $ldap->add($this->attrs);
406 $this->handle_post_events('add');
407 new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
408 }
409 if (!$ldap->success()){
410 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
411 }
413 /* The parameter forces only to set must_be_tagged, and don't touch any objects
414 This will be done later */
415 $this->tag_objects(true);
417 /* Optionally execute a command after we're done */
418 $this->postcreate();
419 return(false);
420 }
423 /* Tag objects to have the gosaAdministrativeUnitTag */
424 function tag_objects($OnlySetTagFlag = false)
425 {
426 if(!$OnlySetTagFlag){
427 $smarty= get_smarty();
428 /* Print out html introduction */
429 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
430 <html>
431 <head>
432 <title></title>
433 <style type="text/css">@import url("themes/default/style.css");</style>
434 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
435 </head>
436 <body style="background: none; margin:4px;" id="body" >
437 ';
438 echo "<h3>".sprintf(_("Tagging '%s'."),"<i>".LDAP::fix($this->dn)."</i>")."</h3>";
439 }
441 $add= $this->is_administrational_unit;
442 $len= strlen($this->dn);
443 $ldap= $this->config->get_ldap_link();
444 $ldap->cd($this->dn);
445 if ($add){
446 $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
447 $this->gosaUnitTag.')))', array('dn'));
448 } else {
449 $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
450 }
452 $objects = array();
453 while ($attrs= $ldap->fetch()){
454 $objects[] = $attrs;
455 }
456 foreach($objects as $attrs){
458 /* Skip self */
459 if ($attrs['dn'] == $this->dn){
460 continue;
461 }
463 /* Check for confilicting administrative units */
464 $fix= true;
465 foreach ($this->config->adepartments as $key => $tag){
466 /* This one is shorter than our dn, its not relevant... */
467 if ($len >= strlen($key)){
468 continue;
469 }
471 /* This one matches with the latter part. Break and don't fix this entry */
472 if (preg_match('/(^|,)'.preg_quote($key, '/').'$/', $attrs['dn'])){
473 $fix= false;
474 break;
475 }
476 }
478 /* Fix entry if needed */
479 if ($fix){
480 if($OnlySetTagFlag){
481 $this->must_be_tagged =true;
482 return;
483 }
484 $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
485 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
486 }
487 }
489 if(!$OnlySetTagFlag){
490 $this->must_be_tagged = FALSE;
491 echo '<p class="seperator"> </p>';
492 echo "<div style='width:100%;text-align:right;'>".
493 "<form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>".
494 "<br>".
495 "<input type='submit' name='back' value='"._("Continue")."'>".
496 "<input type='hidden' name='php_c_check' value='1'>".
497 "</form>".
498 "</div>";
499 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
500 }
501 }
504 /* Move/Rename complete trees */
505 function recursive_move($src_dn, $dst_dn,$force = false)
506 {
507 /* Print header to have styles included */
508 $smarty= get_smarty();
510 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
511 <html>
512 <head>
513 <title></title>
514 <style type="text/css">@import url("themes/default/style.css");</style>
515 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
516 </head>
517 <body style="background: none; margin:4px;" id="body" >
518 ';
519 echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".LDAP::fix($src_dn)."</i>","<i>".LDAP::fix($dst_dn)."</i>")."</h3>";
522 /* Check if the destination entry exists */
523 $ldap= $this->config->get_ldap_link();
525 /* Check if destination exists - abort */
526 $ldap->cat($dst_dn, array('dn'));
527 if ($ldap->fetch()){
528 trigger_error("Recursive_move ".LDAP::fix($dst_dn)." already exists.",
529 E_USER_WARNING);
530 echo sprintf("Recursive_move: '%s' already exists", LDAP::fix($dst_dn))."<br>";
531 return (FALSE);
532 }
534 /* Perform a search for all objects to be moved */
535 $objects= array();
536 $ldap->cd($src_dn);
537 $ldap->search("(objectClass=*)", array("dn"));
538 while($attrs= $ldap->fetch()){
539 $dn= $attrs['dn'];
540 $objects[$dn]= strlen($dn);
541 }
543 /* Sort objects by indent level */
544 asort($objects);
545 reset($objects);
547 /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
548 foreach ($objects as $object => $len){
551 $src= str_replace("\\","\\\\",$object);
552 $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
553 $dst= str_replace($src_dn,$dst_dn,$object);
555 echo "<b>"._("Object").":</b> ".LDAP::fix($src)."<br>";
557 $this->update_acls($object, $dst,TRUE);
559 if (!$this->copy($src, $dst)){
560 echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),LDAP::fix($src))."</font>";
561 return (FALSE);
562 }
563 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
564 flush();
565 }
567 /* Remove src_dn */
568 $ldap->cd($src_dn);
569 $ldap->recursive_remove();
570 $this->orig_dn = $this->dn = $dst_dn;
571 $this->orig_base= $this->base;
572 $this->entryCSN = getEntryCSN($this->dn);
574 echo '<p class="seperator"> </p>';
576 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
577 <br><input type='submit' name='back' value='"._("Continue")."'>
578 </form></div>";
580 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
581 echo "</body></html>";
583 return (TRUE);
584 }
587 /* Return plugin informations for acl handling */
588 static function plInfo()
589 {
590 return (array("plShortName" => _("Generic"),
591 "plDescription" => _("Departments"),
592 "plSelfModify" => FALSE,
593 "plPriority" => 0,
594 "plDepends" => array(),
595 "plSection" => array("administration"),
596 "plCategory" => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))),
598 "plProvidedAcls" => array(
599 "ou" => _("Department name"),
600 "description" => _("Description"),
601 "businessCategory" => _("Category"),
602 "base" => _("Base"),
604 "st" => _("State"),
605 "l" => _("Location"),
606 "postalAddress" => _("Address"),
607 "telephoneNumber" => _("Telephone"),
608 "facsimileTelephoneNumber" => _("Fax"),
610 "gosaUnitTag" => _("Administrative settings"))
611 ));
612 }
614 function handle_object_tagging($dn= "", $tag= "", $show= false)
615 {
616 /* No dn? Self-operation... */
617 if ($dn == ""){
618 $dn= $this->dn;
620 /* No tag? Find it yourself... */
621 if ($tag == ""){
622 $len= strlen($dn);
624 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
625 $relevant= array();
626 foreach ($this->config->adepartments as $key => $ntag){
628 /* This one is bigger than our dn, its not relevant... */
629 if ($len <= strlen($key)){
630 continue;
631 }
633 /* This one matches with the latter part. Break and don't fix this entry */
634 if (preg_match('/(^|,)'.preg_quote($key, '/').'$/', $dn)){
635 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
636 $relevant[strlen($key)]= $ntag;
637 continue;
638 }
640 }
642 /* If we've some relevant tags to set, just get the longest one */
643 if (count($relevant)){
644 ksort($relevant);
645 $tmp= array_keys($relevant);
646 $idx= end($tmp);
647 $tag= $relevant[$idx];
648 $this->gosaUnitTag= $tag;
649 }
650 }
651 }
653 /* Set tag? */
654 if ($tag != ""){
655 /* Set objectclass and attribute */
656 $ldap= $this->config->get_ldap_link();
657 $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
658 $attrs= $ldap->fetch();
659 if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
660 if ($show) {
661 echo sprintf(_("Object '%s' is already tagged"), LDAP::fix($dn))."<br>";
662 flush();
663 }
664 return;
665 }
666 if (count($attrs)){
667 if ($show){
668 echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, LDAP::fix($dn))."<br>";
669 flush();
670 }
671 $nattrs= array("gosaUnitTag" => $tag);
672 $nattrs['objectClass']= array();
673 for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
674 $oc= $attrs['objectClass'][$i];
675 if ($oc != "gosaAdministrativeUnitTag"){
676 $nattrs['objectClass'][]= $oc;
677 }
678 }
679 $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
680 $ldap->cd($dn);
681 $ldap->modify($nattrs);
682 if (!$ldap->success()){
683 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
684 }
685 } else {
686 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
687 }
689 } else {
690 /* Remove objectclass and attribute */
691 $ldap= $this->config->get_ldap_link();
692 $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
693 $attrs= $ldap->fetch();
694 if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
695 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
696 return;
697 }
698 if (count($attrs)){
699 if ($show){
700 echo sprintf(_("Removing tag from object '%s'"), LDAP::fix($dn))."<br>";
701 flush();
702 }
703 $nattrs= array("gosaUnitTag" => array());
704 $nattrs['objectClass']= array();
705 for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
706 $oc= $attrs['objectClass'][$i];
707 if ($oc != "gosaAdministrativeUnitTag"){
708 $nattrs['objectClass'][]= $oc;
709 }
710 }
711 $ldap->cd($dn);
712 $ldap->modify($nattrs);
713 if (!$ldap->success()){
714 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
715 }
716 } else {
717 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
718 }
719 }
720 }
722 }
724 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
725 ?>