Code

Fix problems with empty boot params by partially reverting
[gosa.git] / trunk / gosa-plugins / goto / admin / systems / goto / class_workstationStartup.inc
1 <?php
2 class workstartup extends plugin
3 {
4   /* Ldap server list */
5   var $gotoLdapServers    = array();
6   var $gotoLdapServerList = array();
7   var $gotoLdap_inherit   = FALSE;
9   /* Generic terminal attributes */
10   var $bootmode             = "G";
11   var $gotoBootKernel       = "default-inherited";
12   var $gotoKernelParameters = "";
13   var $gotoLdapServer       = "default-inherited";
14   var $gotoModules          = array();
15   var $gotoAutoFs           = array();
16   var $gotoFilesystem       = array();
17   var $gotoTerminalPath     = "";
18   var $gotoBootKernels      = array();
20   /* attribute list for save action */
21   var $attributes           = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", 
22                                     "FAIclass", "FAIstatus", "gotoShare","FAIdebianMirror", "FAIrelease");
23   var $objectclasses        = array("GOhard", "FAIobject");
25   /* Share */
26   var $gotoShares         = array();// Currently Share Option
27   var $gotoShare          = "";     // currently selected Share Option
28   var $gotoShareSelections= array();// Available Shares for this account in Listbox format
29   var $gotoAvailableShares= array();// Available Shares for this account
31   /* Helper */
32   var $orig_dn            = "";
33   var $ignore_account     = TRUE;
34  
35   /* FAI class selection */ 
36   var $FAIclass           = array();  // The currently selected classes 
37   var $FAIrelease           = "";
38   var $FAIdebianMirror      = "auto";
39   var $si_active            = FALSE;
40   var $si_fai_action_failed = FALSE;
42   var $cache              = array(); // Used as cache in fai mehtods
44   var $FAIstatus          = "";
45   var $FAIclasses         = array();
47   var $view_logged        = FALSE;
48   
49   /* FAI class selection */
50   var $InheritedFAIclass       = array();
51   var $InheritedFAIrelease     = "";
52   var $InheritedFAIdebianMirror= "auto";
54   var $CopyPasteVars    = array("gotoModules","gotoShares");
55   var $fai_activated    = FALSE;
56   var $o_group_dn       = "";
57   var $member_of_ogroup = FALSE;
59   function workstartup (&$config, $dn= NULL, $parent= NULL)
60   {
61     /* Check if FAI is active */
62     $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs'));
63     if(!empty($tmp) && class_available("faiManagement")){
64       $this->fai_activated = TRUE;
65     }else{
66       $this->attributes = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "gotoShare");
67       $this->objectclasses  = array("GOhard");
68     }
70     plugin::plugin ($config, $dn, $parent);
72     /* Check for si daemon */
73     $this->si_active = $this->config->get_cfg_value("gosaSupportURI") != "";
75     /* Check object group membership */
76     if(!isset($this->parent->by_object['ogroup'])){
77       $ldap = $this->config->get_ldap_link();
78       $ldap->cd ($this->config->current['BASE']);
79       $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",array("cn","dn"));
80       if($ldap->count()){
81         $this->member_of_ogroup = TRUE;
82         $attrs = $ldap->fetch();
83         $this->o_group_dn = $attrs['dn'];
84       }
85     }
87     /* Creating a list of valid Mirrors 
88      * none will not be saved to ldap.
89      */
90     $ldap   = $this->config->get_ldap_link();
91     $ldap->cd($this->config->current['BASE']);
92     $ui = get_userinfo();
93     foreach($this->config->data['SERVERS']['LDAP'] as $dn => $data){
94       if($ui->get_category_permissions($data['dn'],"server",TRUE)){
95         for($i = 0; $i < $data['goLdapBase']['count']; $i ++){
96           $name = $data["cn"][0].":".$data["goLdapBase"][$i];
97           $this->gotoLdapServerList[]= $name; 
98         }
99       }
100     }
102     /* Get list of assigned ldap servers 
103      */ 
104     if(isset($this->attrs['gotoLdapServer'])){
105       unset($this->attrs['gotoLdapServer']['count']);
106       sort($this->attrs['gotoLdapServer']);
107       foreach($this->attrs['gotoLdapServer'] as $value){
108         $this->gotoLdapServers[] = preg_replace("/^[0-9]*:/","",$value);
109       }
110     } 
111     natcasesort($this->gotoLdapServerList);
113     if(!count($this->gotoLdapServers) && $this->member_of_ogroup){ 
114       $this->gotoLdap_inherit = TRUE;
115     }
117     /* FAI Initialization
118        Skip this if FAI is not activated 
119      */
120     if($this->fai_activated) {
122       /* Parse used FAIclasses (stored as string).
123        * The single classes are seperated by ' '.
124        * There is also the release type given, after first
125        *  occurrence of ':'.
126        */
127       $this->FAIclass =array();
128       if(isset($this->attrs['FAIclass'][0])){
129         $tmp = split(" ",$this->attrs['FAIclass'][0]);
130         $tmp2 =array();  
132         foreach($tmp as $class){
133           if( ":" == $class[0] ) {
134             $this->FAIrelease = trim(substr($class, 1));
135           }else{
136             $tmp2[$class] = $class;
137           }
138         }
139         $this->FAIclass = $tmp2;
140       }
141     }
143     /* Get arrays */
144     foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
145       if (isset($this->attrs["$val"]["count"])){
146         for ($i= 0; $i<$this->attrs["count"]; $i++){
147           if (isset($this->attrs["$val"][$i])){
148             array_push($this->$val, $this->attrs["$val"][$i]);
149           }
150         }
151       }
152       sort ($this->$val);
153       $this->$val= array_unique($this->$val);
154     }
156     /* Prepare Shares */
157     if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){
158       unset($this->attrs['gotoShare']['count']);
159       foreach($this->attrs['gotoShare'] as $share){
160         $tmp = $tmp2 = array();
161         $tmp = split("\|",$share);
162         $tmp2['server']      =$tmp[0];
163         $tmp2['name']        =$tmp[1];
164         $tmp2['mountPoint']  =$tmp[2];
165         $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2;
166       }
167     }
169     $this->gotoShareSelections= $config->getShareList(true);
170     $this->gotoAvailableShares= $config->getShareList(false);
171     $tmp2 = array();
172   
174     $this->orig_dn= $this->dn;
176     /* Handle inheritance value "default" */
177     if ($this->member_of_ogroup){
178       $this->gotoBootKernels= array("default-inherited" => '['._("inherited").']'); 
179     }
181     /* If we are member in an object group,
182      *  we have to handle inherited values.
183      * So you can see what is inherited.
184      */
185     if ($this->member_of_ogroup){
187       if(count($this->FAIclass)==0 && $this->FAIrelease == ""){
188         $this->FAIdebianMirror = "inherited";
189       }
191       if($this->fai_activated){
192         $map= array("gotoBootKernel","FAIclass","FAIdebianMirror");
193       }else{
194         $map= array("gotoBootKernel");
195       }
197       $ldap = $this->config->get_ldap_link();
198       $ldap->cat($this->o_group_dn);
199       $attrs= $ldap->fetch();
201       foreach ($map as $name){
202         if (!isset($attrs[$name][0])){
203           continue;
204         }
206         switch ($name){
207           case 'gotoBootKernel':
208             $this->gotoBootKernels['default-inherited']=  _("inherited").' ['.$attrs[$name][0].']' ;
209             break;
211           case 'FAIclass':
212             $str = split(":",$attrs[$name][0]);
213             $this->InheritedFAIclass    = split("\ ",trim($str[0]));
214             $this->InheritedFAIrelease  = trim($str[1]);
215             break;
217           case 'FAIdebianMirror':
218             $this->InheritedFAIdebianMirror = $attrs[$name][0];
219             break;
220         }
221       }
222     }
224     $this->update_fai_cache();
226     if($this->fai_activated && !$this->si_fai_action_failed && $this->si_active){
228       /* Check if the current mirror is available 
229        */
230       if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror])){
231         if(count($this->FAIclass)){
232           msg_dialog::display(_("Error"), sprintf(_("FAI mirror '%s' is not available - setting to mirror 'auto'!"), $this->FAIdebianMirror), ERROR_DIALOG);
233         }
234         $this->FAIdebianMirror = "auto";
235         $this->FAIrelease = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
236         $this->cache['CLASSES'] = array();
237         $this->update_fai_cache();
238       }
239   
240       /* Check if the current mirror is available 
241        */
242       if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
243         $new_release = key($this->cache['SERVERS'][$this->FAIdebianMirror]); 
244         if(count($this->FAIclass)){
245           msg_dialog::display(_("Error"), sprintf(_("FAI release '%s' is not available on mirror '%s' - setting to release '%s'!"), $this->FAIrelease, $this->FAIdebianMirror,$new_release), ERROR_DIALOG);
246         }
247         $this->FAIrelease = $new_release;
248         $this->cache['CLASSES'] = array();
249         $this->update_fai_cache();
250       }
251     }
252   }
254   
255   function check()
256   {
257     $messages = array();
258     
259     /* Call common method to give check the hook */
260     $messages= plugin::check();
262     /* If there are packages selected, but no mirror show error */   
263     if(($this->FAIdebianMirror == "none")&&(count($this->FAIclass)>0)){
264       $messages[]=_("Please select a 'FAI server' or remove the 'FAI classes'.");
265     }
267     return($messages);
268   }
270   function execute()
271   {
272         /* Call parent execute */
273         plugin::execute();
275     if($this->is_account && !$this->view_logged){
276       $this->view_logged = TRUE;
277       new log("view","workstation/".get_class($this),$this->dn);
278     }
280     /* Do we represent a valid terminal? */
281     if (!$this->is_account && $this->parent === NULL){
282       $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle>&nbsp;<b>".
283         msgPool::noValidExtension(_("workstation"))."</b>";
284       return ($display);
285     }
287     /* Add module */
288     if (isset ($_POST['add_module'])){
289       if ($_POST['module'] != "" && $this->acl_is_writeable("gotoModules")){
290         $this->add_list ($this->gotoModules, $_POST['module']);
291       }
292     }
294     /* Delete module */
295     if (isset ($_POST['delete_module'])){
296       if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoModules")){
297         $this->del_list ($this->gotoModules, $_POST['modules_list']);
298       }
299     }
301     /* FAI class management */
302     if($this->fai_activated){
303       if(((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))) && ($this->acl_is_writeable("FAIclass"))){
304         $found = 0 ; 
306         /* If this new class/profile will attach a second partition table
307          * to our list of classes, abort and show a message.
308          */
309         foreach($this->FAIclass as $name){
310           if(isset($this->FAIclassInfo[$name])){
311             foreach($this->FAIclassInfo[$name] as $atr){
312               if(isset($atr['obj'])){
313                 if($atr['obj'] == "FAIpartitionTable"){
314                   $found ++ ; 
315                 }
316               }
317             }
318           }
319         }
321         if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpartitionTable']))&&($found>0)){
322           msg_dialog::display(_("Error"), _("There is already a profile containing a partition table in your configuration!") , ERROR_DIALOG);
323         }else{
324           $this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel'];
325         }
326       }
328       $sort = false;
330       /* Move one used class class one position up or down */
331       if($this->acl_is_writeable("FAIclass")){
332         foreach($_POST as $name => $val){
334           $sort_type = false;
335           if((preg_match("/sort_up/",$name))&&(!$sort)){
336             $sort_type = "sort_up_";
337           }
338           if((preg_match("/sort_down/",$name))&&(!$sort)){
339             $sort_type = "sort_down_";
340           }
342           if(($sort_type)&&(!$sort)){
343             $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name)));
344             $sort = true;
346             $last = -1;
347             $change_down  = -1;
349             /* Create array with numeric index */ 
350             $tmp = array();
351             foreach($this->FAIclass as $class){
352               $tmp [] = $class;
353             }
355             /* Walk trough array */
356             foreach($tmp as $key => $faiName){
357               if($faiName == $value){
358                 if($sort_type == "sort_up_"){
359                   if($last != -1){
360                     $change_down= $last;
361                   }
362                 }else{
363                   if(isset($tmp[$key+1])){
364                     $change_down = $key;
365                   }
366                 }
367               }
368               $last = $key;
369             }
371             $tmp2 = array();
372             $skip = false;    
374             foreach($tmp as $ky => $vl){
376               if($ky == $change_down){
377                 $skip = $vl;
378               }else{
379                 $tmp2[$vl] = $vl;
380               }
381               if(($skip != false)&&($ky != $change_down)){
382                 $tmp2[$skip]  = $skip;
383                 $skip =false;
384               }
385             }   
386             $this->FAIclass = $tmp2; 
387           }
389           if(preg_match("/fai_remove/i",$name)){
390             $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/fai_remove_/i","",$name)));
391             unset($this->FAIclass[$value]);
392           }
393         }
394       }
396       /* Delete selected class from our list */
397       if($this->acl_is_writeable("FAIclass")){
398         if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){
399           if(isset($this->FAIclass[$_POST['FAIclassSel']])){
400             unset($this->FAIclass[$_POST['FAIclassSel']]);
401           }
402         }
403       }
404     }// END fai handling
406     /* Show main page */
407     $smarty= get_smarty();
409     /* Assign ACLs to smarty */
410     $tmp = $this->plInfo();
411     foreach($tmp['plProvidedAcls'] as $name => $translation){
412       $smarty->assign($name."ACL",$this->getacl($name));
413     } 
415     $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
417     /* In this section server shares will be defined
418      * A user can select one of the given shares and a mount point
419      *  and attach this combination to his setup.
420      */
421     $smarty->assign("gotoShareSelections",    $this->gotoShareSelections);
422     $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections));
424     /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry
425      * This entry will be, a combination of mountPoint and sharedefinitions
426      */
427     if((isset($_POST['gotoShareAdd'])) && isset($_POST['gotoShareSelection']) && ($this->acl_is_writeable("gotoShare"))) {
428       /* We assign a share to this user, if we don't know where to mount the share */
429       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
430         msg_dialog::display(_("Error"), msgPool::required(_("Mount point")), ERROR_DIALOG);
431       }else{
432     
433         if(isset($this->gotoAvailableShares[$_POST['gotoShareSelection']])){
434           $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
435           $s_mount = $_POST['gotoShareMountPoint'];
436           /* Preparing the new assignment */
437           $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
438           $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
439         }
440       }
441     }
443     /* if the Post  gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected)
444      * If there is no defined share selected, we will abort the deletion without any message
445      */
446     if(($this->acl_is_writeable("gotoShare"))&& (isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){
447       unset($this->gotoShares[$_POST['gotoShare']]);
448     }
450     $smarty->assign("gotoShares",$this->printOutAssignedShares());
451     $smarty->assign("gotoSharesCount",count($this->printOutAssignedShares()));
452     $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares()));
453     $smarty->assign("gotoBootKernels",$this->gotoBootKernels);
455     /* Create divSelectBox for ldap server selection
456      */
457     $SelectBoxLdapServer = new divSelectBox("LdapServer");
458     $SelectBoxLdapServer->SetHeight(130);
460     /* Add new ldap server to the list */
461     if($this->acl_is_writeable("gotoLdapServer") && 
462         !$this->gotoLdap_inherit && 
463         isset($_POST['add_ldap_server']) && 
464         isset($_POST['ldap_server_to_add'])){
465       if(isset($this->gotoLdapServerList[$_POST['ldap_server_to_add']])){
466         $to_add = $this->gotoLdapServerList[$_POST['ldap_server_to_add']];
467         if(!in_array($to_add,$this->gotoLdapServers)){
468           $this->gotoLdapServers[] = $to_add;
469         }
470       }
471     }
472     
473     /* Move ldap servers up and down */
474     if(!$this->gotoLdap_inherit && $this->acl_is_writeable("gotoLdapServer")){
475       foreach($_POST as $name => $value){
476         if(preg_match("/sort_ldap_up_/",$name)){
477           $id = preg_replace("/^sort_ldap_up_([0-9]*)_(x|y)$/","\\1",$name);
478           $from =  $id;  
479           $to   =  $id -1;
480           $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to);
481           if($tmp){
482             $this->gotoLdapServers = $tmp;
483           }
484           break;
485         }
486         if(preg_match("/sort_ldap_down_/",$name)){
487           $id = preg_replace("/^sort_ldap_down_([0-9]*)_(x|y)$/","\\1",$name);
488           $from =  $id;  
489           $to   =  $id +1;
490           $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to);
491           if($tmp){
492             $this->gotoLdapServers = $tmp;
493           }
494           break;
495         }
496         if(preg_match("/gotoLdapRemove_/",$name)){
497           $id = preg_replace("/^gotoLdapRemove_([0-9]*)_(x|y)$/","\\1",$name);
498           $value = $this->gotoLdapServers[$id];
499           $this->gotoLdapServers = array_remove_entries(array($value),$this->gotoLdapServers);
500           break;
501         }
502       } 
503     }
504   
505     /* Add Entries */
506     if($this->acl_is_readable("gotoLdapServer")){
508       foreach($this->gotoLdapServers as $key => $server){
510         /* Announce missing entries */
511         if(!in_array($server,$this->gotoLdapServerList)){
512           $server = $server."&nbsp;<font style='color:red'>(missing)</font>";
513         }
515         /* Convert old style entry */
516         if (!preg_match('%:ldaps?://%', $server)){
517           $server= "ldap://".preg_replace('/^([^:]+):/', '\1/', $server);
519         /* Beautify new style entries */
520       } else {
521         $server= preg_replace("/^[^:]+:/", "", $server);
522       }
524       $SelectBoxLdapServer->AddEntry(
525           array(array("string" => $server),
526             array("string" => 
527               "<input class='center' type='image' src='images/lists/sort-up.png' name='sort_ldap_up_".$key."'>&nbsp;".
528               "<input class='center' type='image' src='images/lists/sort-down.png' name='sort_ldap_down_".$key."'>&nbsp;".
529               "<input class='center' type='image' src='images/lists/trash.png' name='gotoLdapRemove_".$key."'>",
530               "attach" => "style='text-align:right;width:40px;border-right:0px;'")));
531       }    
532     }    
534     if($this->gotoLdap_inherit){
535       $smarty->assign("gotoLdapServerACL_inherit", preg_replace("/w/","",$this->getacl("gotoLdapServer")));;
536     }else{
537       $smarty->assign("gotoLdapServerACL_inherit", $this->getacl("gotoLdapServer"));
538     }
539     
540     $list = array();
541     foreach($this->gotoLdapServerList as $key => $entry){
542       if(!in_array($entry,$this->gotoLdapServers)){
544         /* Convert old style entry */
545         if (!preg_match('%:ldap[s]*://%', $entry)){
546           $entry= "ldap://".preg_replace('/^([^:]+):/', '\1/', $entry);
548         /* Beautify new style entries */
549         } else {
550           $entry= preg_replace("/^[^:]+:/", "", $entry);
551         }
553         $list[$key] = $entry;
554       }
555     }
556     $smarty->assign("gotoLdapServers",    $SelectBoxLdapServer->DrawList());
557     $smarty->assign("gotoLdapServerList", $list);
558     $smarty->assign("gotoLdap_inherit",   $this->gotoLdap_inherit);
559     $smarty->assign("JS",  session::get('js'));
561     foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
562       $smarty->assign("$val", $this->$val);
563     }
565     /* Values */
566     foreach(array("gotoBootKernel","gotoShare","FAIclasses","FAIclass","FAIdebianMirror","FAIrelease") as $val){
567       $smarty->assign($val, $this->$val);
568     }
570     $smarty->assign("fai_activated",$this->fai_activated);
572     /* Create FAI output */
573     $this->update_fai_cache();
574     $smarty->assign("si_fai_action_failed",$this->si_fai_action_failed);
575     $smarty->assign("si_active",$this->si_active);
577     $div = new divSelectBox("WSFAIscriptClasses");
578     $div -> SetHeight("110");
579   
580     if(!$this->si_fai_action_failed && $this->si_active && $this->fai_activated){
582       $smarty->assign("FAIservers"  , $this->cache['SERVERS']);
583       $smarty->assign("FAIdebianMirror",$this->FAIdebianMirror);
584       $smarty->assign("FAIrelease"  , $this->FAIrelease);
585       $smarty->assign("FAIclasses"  , $this->selectable_classes());
587       /* Get classes for release from cache.
588        * Or build cache
589        */
590       if($this->FAIdebianMirror == "inherited"){
591         $release = $this->InheritedFAIrelease;
592       }else{
593         $release = $this->FAIrelease;
594       }
596       $smarty->assign("gotoBootKernels",$this->cache['KERNELS'][$release]);
597       $smarty->assign("InheritedFAIrelease",$this->InheritedFAIrelease);
599       $str_empty  = " &nbsp;<img src='images/empty.png' alt=\"\" width='7'>"; 
600       if($this->acl_is_writeable("FAIclass")){
601         $str_up     = " &nbsp;<input type='image' src='images/lists/sort-up.png'    name='sort_up_%s'    value='%s'>";
602         $str_down   = " &nbsp;<input type='image' src='images/lists/sort-down.png'  name='sort_down_%s'  value='%s'>";
603         $str_remove = " &nbsp;<input type='image' src='images/lists/trash.png'  name='fai_remove_%s' value='%s'>";
604       }else{
605         $str_up=$str_down=$str_remove=$str_empty;
606       }
608       /* Get classes */
609       if($this->FAIdebianMirror == "inherited"){
610         $tmp = $this->InheritedFAIclass;
611       }else{
612         $tmp = $this->FAIclass;
613       }
615       /* Get invalid classes */
616       $invalid = $this->get_invalid_classes($tmp);
618       /* Draw every single entry */
619       $i = 1;
620       if($this->acl_is_readable("FAIclass")){
621         foreach($tmp as $class){
623           /* Mark invalid classes. (Not in selected release)
624            */
625           $marker = "";
626           if(in_array_ics($class,$invalid)){
627             $marker = "&nbsp;<font color='red'>("._("Not available in current setup").")</font>";
628           }
630           /* Create up/down priority icons  
631            * Skip this, if we have inherited the FAI classes.
632            */
633           if($this->FAIdebianMirror == "inherited"){
634             $str = "";
635           }else{
636             if($i==1){
637               $str = $str_empty.$str_down.$str_remove;
638             }elseif($i == count($this->FAIclass)){
639               $str = $str_up.$str_empty.$str_remove;
640             }else{
641               $str = $str_up.$str_down.$str_remove;
642             }
643           }
644           $i ++ ; 
646           /* Get Description tag 
647            *  There may be several FAI objects with the same class name, 
648            *   use the description from FAIprofile, if possible.
649            */  
650           $desc = ""; 
651           if(isset($this->cache['CLASSES'][$this->FAIrelease][$class])){
652             foreach($this->cache['CLASSES'][$this->FAIrelease][$class] as $types ){
653               if(isset($types['Desc'])){
654                 $desc= $types['Desc'];
655                 if($types['Type'] == "FAIprofile"){
656                   break;
657                 }
658               }
659             }
660           }
661           if(!empty($desc)){
662             $desc = "&nbsp;[".trim($desc)."]";
663           }        
665           $div->AddEntry(array(
666                 array("string"=>$class.$desc.$marker),
667                 array("string"=>preg_replace("/\%s/",base64_encode($class),$str),"attach"=>"style='width:50px;border-right:none;'")
668                 ));
669         }  
670       }// END FAI output generation 
671     }// END FAI output generation 
672     $smarty->assign("FAIScriptlist",$div->DrawList()); 
674     /* Radio button group */
675     if (preg_match("/G/", $this->bootmode)) {
676       $smarty->assign("graphicalbootup", "checked");
677     } else {
678       $smarty->assign("graphicalbootup", "");
679     }
680     if (preg_match("/T/", $this->bootmode)) {
681       $smarty->assign("textbootup", "checked");
682     } else {
683       $smarty->assign("textbootup", "");
684     }
685     if (preg_match("/D/", $this->bootmode)) {
686       $smarty->assign("debugbootup", "checked");
687     } else {
688       $smarty->assign("debugbootup", "");
689     }
691     /* Show main page */
692     $smarty->assign("gotoKernelParameters",$this->gotoKernelParameters);
693     return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE,dirname(__FILE__))));
694   }
697   function remove_from_parent()
698   {
699     $this->handle_post_events("remove");
700     new log("remove","workstation/".get_class($this),$this->dn);
701   }
704   /* Save data to object */
705   function save_object()
706   {
707     $old_mirror  = $this->FAIdebianMirror;
708     plugin::save_object();
710     /* Update release */
711     if($old_mirror != $this->FAIdebianMirror){
712       if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
713         $this->FAIrelease      = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
714       }
715     }
717     if(isset($_POST['WorkstationStarttabPosted'])){
718       if(isset($_POST['gotoLdap_inherit'])){
719         $this->gotoLdap_inherit = TRUE;
720       }else{
721         $this->gotoLdap_inherit = FALSE;
722       }
724       /* Save group radio buttons */
725       if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){
726         $this->bootmode= $_POST["bootmode"];
727       }
728     }
729   }
732   /* Save to LDAP */
733   function save()
734   {
736     /* Depending on the baseobject (Ogroup / WS) we
737      *  use another set of objectClasses
738      * In case of WS itself, we use  "array("GOhard", "FAIobject");"
739      * if we are currently editing from ogroup menu we use (array("gotWorkstationTemplate","GOhard", "FAIobject"))
740      */
741     if(isset($this->parent->by_object['ogroup'])){
742       $this->objectclasses = array("gotoWorkstationTemplate");
743     }elseif(isset($this->parent->by_object['workgeneric'])){
744       $this->objectclasses = array("GOhard");
745     }elseif(isset($this->parent->by_object['servgeneric'])){
746       $this->objectclasses = array("GOhard","gotoWorkstationTemplate");
747     }else{
748       msg_dialog::display(_("Fatal error"),
749           "Object Type Configuration is unknown. Please contact the GOsa developers.",
750           FATAL_ERROR_DIALOG);
751       exit();
752     }
754     /* Append FAI class */
755     if($this->fai_activated){
756       $this->objectclasses[]  = "FAIobject";
757     }
759     /* Find proper terminal path for tftp configuration
760        FIXME: This is suboptimal when the default has changed to
761        another location! */
762     if (($this->gotoTerminalPath == "default")){
763       $ldap= $this->config->get_ldap_link();
765       /* Strip relevant part from dn, keep trailing ',' */
766       $tmp= preg_replace("/^cn=[^,]+,".get_ou('terminalRDN')."/i", "", $this->dn);
767       $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp);
769       /* Walk from top to base and try to load default values for
770          'gotoTerminalPath'. Abort when an entry is found. */
771       while (TRUE){
772         $tmp= preg_replace ("/^[^,]+,/", "", $tmp);
774         $ldap->cat("cn=default,".get_ou('terminalRDN').$tmp.
775             $this->config->current['BASE'], array('gotoTerminalPath'));
776         $attrs= $ldap->fetch();
777         if (isset($attrs['gotoTerminalPath'])){
778           $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0];
779           break;
780         }
782         /* Nothing left? */
783         if ($tmp == ""){
784           break;
785         }
786       }
787     }
789     if ($this->gotoKernelParameters == "") {
790       /* Add semi automatic values if empty */
791       // FIXME: LDAP Server may not be set here...
792       $this->gotoKernelParameters= "ldap=".base64_encode($this->gotoLdapServer);
793       
794       switch ($this->bootmode){
795         case "D":
796           $this->gotoKernelParameters.= " debug";
797         break;
798         case "G":
799           $this->gotoKernelParameters.= " splash=silent";
800         break;
801       }
802     }
804     plugin::save();
806     unset( $this->attrs['FAIrelease'] );
807     $str = "";
809     /* Skip FAI attribute handling if not necessary */
810     if($this->fai_activated && !$this->si_fai_action_failed){
811       if($this->FAIdebianMirror == "inherited"){
812         $this->attrs['FAIclass'] = $this->attrs['FAIrelease'] =  $this->attrs['FAIdebianMirror'] = array();
813       }else{
814         foreach($this->FAIclass as $class){
815           $str .= $class." ";
816         }
817         $str = trim($str);
818         if(empty($this->attrs['FAIclass'])){
819           $this->attrs['FAIclass'] = array();
820         }else{
821           $this->attrs['FAIclass']= $str." :".$this->FAIrelease;
822         }
823       }
824     }
826     /* Add missing arrays */
827     foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){
828       if (isset ($this->$val) && count ($this->$val) != 0){
829     
830         $this->attrs["$val"]= array_unique($this->$val);
831       }
832       if(!isset($this->attrs["$val"])) $this->attrs["$val"]=array();
833     }
835     /* Prepare list of ldap servers */
836     $this->attrs['gotoLdapServer'] = array();
837     if(!$this->gotoLdap_inherit){
838       $i = 0;
839       foreach($this->gotoLdapServers as $server){
840         $i ++;
841         $this->attrs['gotoLdapServer'][] = $i.":".$server;
842       }
843     }
845     if ($this->attrs['gotoBootKernel'] == "default-inherited"){
846       $this->attrs['gotoBootKernel']= array();
847     }
849     /* if mirror == none stop saving this attribute */
850     if($this->FAIdebianMirror == "none"){
851       $this->FAIdebianMirror = "";
852     }
853    
854     /* Get FAIstate from object, the generic tab could have changed it during execute */
855     $ldap= $this->config->get_ldap_link();
856     $ldap->cd($this->dn);
859     /* Skip FAI attribute handling if not necessary */
860     if($this->fai_activated && !$this->si_fai_action_failed && $this->si_active){
861       $ldap->cat($this->dn,array("FAIstate"));
862       $checkFAIstate = $ldap->fetch();
864       /* Remove FAI objects if no FAI class is selected */ 
865       if((count($this->FAIclass)==0) && (!isset($checkFAIstate['FAIstate']))){
866         $this->attrs['FAIclass']        = array();
867         $this->attrs['FAIdebianMirror'] = array();
868       }
869     }else{
871       /* Don't touch FAI objects if something went wrong with the si daemon.
872        */
873       if(isset($this->attrs['FAIclass'])) unset($this->attrs['FAIclass']);
874       if(isset($this->attrs['FAIdebianMirror'])) unset($this->attrs['FAIdebianMirror']);
875     }
877     /* prepare share settings */
878     $tmp = array();
879     foreach($this->gotoShares as $name => $settings){
880       $tmp2= split("\|",$name);
881       $name = $tmp2[0];
882       $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint'];
883     }
884     $this->attrs['gotoShare']=$tmp;
885     $this->cleanup();
886     $ldap->modify ($this->attrs); 
887     new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
889     if (!$ldap->success()){
890       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
891     }
892     $this->handle_post_events("modify");
894     /* Check if LDAP server has changed */
895     if ((isset($this->attrs['gotoLdapServer']) && class_available("DaemonEvent")) || $this->gotoLdap_inherit){
896       $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
897       $o_queue = new gosaSupportDaemon();
898       if(isset($events['TRIGGERED']['DaemonEvent_reload_ldap_config'])){
899         $evt = $events['TRIGGERED']['DaemonEvent_reload_ldap_config'];
900         $macs = array();
901     
902         /* Get list of macAddresses 
903          */
904         if(isset($this->parent->by_object['ogroup'])){
905         
906           /* If we are an object group, add all member macs 
907            */
908           $p = $this->parent->by_object['ogroup'];
909           foreach($p->memberList as $dn => $obj){
910             if(isset($p->objcache[$dn]['macAddress']) && !empty($p->objcache[$dn]['macAddress'])){
911               $macs[] = $p->objcache[$dn]['macAddress'];
912             }
913           }
914         }elseif(isset($this->parent->by_object['workgeneric']->netConfigDNS->macAddress)){
916           /* We are a workstation. Add current mac.
917            */
918           $mac = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
919           if(!empty($mac)){
920             $macs[] = $mac;
921           }          
922         }elseif(isset($this->parent->by_object['servgeneric']->netConfigDNS->macAddress)){
924           /* We are a server. Add current mac.
925            */
926           $mac = $this->parent->by_object['servgeneric']->netConfigDNS->macAddress;
927           if(!empty($mac)){
928             $macs[] = $mac;
929           }          
930         }
932         /* Trigger event for all member objects 
933          */
934         foreach($macs as $mac){
935           $tmp = new $evt['CLASS_NAME']($this->config);
936           $tmp->set_type(TRIGGERED_EVENT);
937           $tmp->add_targets(array($mac));
938           if(!$o_queue->append($tmp)){
939             msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
940           }
941         }
942       }
943     }
944   }
947   /* Add value to array, check if unique */
948   function add_list (&$array, $value)
949   {
950     if ($value != ""){
951       $array[]= $value;
952       sort($array);
953       array_unique ($array);
954     }
955   }
958   /* Delete value to array, check if unique */
959   function del_list (&$array, $list)
960   {
961     $tmp= array();
962     foreach ($array as $mod){
963       if (!in_array($mod, $list)){
964         $tmp[]= $mod;
965       }
966     }
967     $array= $tmp;
968   }
970   /* Generate ListBox frindly output for the defined shares
971    * Possibly Add or remove an attribute here,
972    */
973   function printOutAssignedShares()
974   {
975     $a_return = array();
976     if(is_array($this->gotoShares)){
977       foreach($this->gotoShares as $share){
978         $a_return[$share['name']."|".$share['server']]= $share['name']." [".$share['server']."]";
979       }
980     }
981     return($a_return);
982   }
986   function PrepareForCopyPaste($source)
987   {
988     plugin::PrepareForCopyPaste($source);    
989     $source_o = new workstartup ($this->config, $source['dn']);
990     foreach(array("FAIclass","gotoModules", "gotoAutoFs", "gotoFilesystem",
991           "gotoKernelParameters","gotoShares") as $attr){
992       $this->$attr = $source_o->$attr;
993     }
994   }
996   
997   function array_switch_item($ar,$from,$to)
998   {
999     if(!is_array($ar)){
1000       return(false);
1001     }
1002     if(!isset($ar[$from])){
1003       return(false);
1004     }
1005     if(!isset($ar[$to])){
1006       return(false);
1007     }
1009     $tmp = $ar[$from];
1010     $ar[$from] = $ar[$to];    
1011     $ar[$to] = $tmp;    
1012     return($ar);
1013   }
1016   /* Return plugin informations for acl handling */ 
1017   static function plInfo()
1018   {
1019     return (array( 
1020           "plShortName"   => _("Startup"),
1021           "plDescription" => _("System startup"),
1022           "plSelfModify"  => FALSE,
1023           "plDepends"     => array(),
1024           "plPriority"    => 9,
1025           "plSection"     => array("administration"),           
1026           "plCategory"    => array("workstation","server","ogroups"),
1028           "plProvidedAcls"=> array(
1029             "gotoLdapServer"        => _("Ldap server"),
1030             "gotoBootKernel"        => _("Boot kernel"),
1031             "gotoKernelParameters"  => _("Kernel parameter"),
1033             "gotoModules"           => _("Kernel modules"),
1034             "gotoShare"             => _("Shares"),
1036             "FAIclass"              => _("FAI classes"),
1037             "FAIdebianMirror"       => _("Debian mirror"),
1038             "FAIrelease"            => _("Debian release"),
1040             "FAIstatus"             => _("FAI status flag")) // #FIXME is this acl realy necessary ?
1041           ));
1042   }
1045   /* Updates release dns 
1046    *  and reads all classes for the current release, 
1047    *  if not already done ($this->cache).
1048    */
1049   function update_fai_cache($first_call = FALSE)
1050   {
1051     $force = FALSE;
1052     if(!$this->si_active) return; 
1053     $start = microtime(TRUE);  
1055     if($this->si_fai_action_failed && !isset($_POST['fai_si_retry'])) return;
1057     $this->si_fai_action_failed = FALSE;
1059     /* Get the list of available servers and their releases. 
1060      */
1061     if($force || !isset($this->cache['SERVERS'])){
1063       $o_queue = new gosaSupportDaemon();
1064       $tmp = $o_queue->FAI_get_server();
1065       if($o_queue->is_error()){
1066         msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
1067         $this->si_fai_action_failed = TRUE;
1068         $this->cache = array();
1069         return;
1070       }else{
1072         foreach($tmp as $entry){
1073           $rel = $entry['FAI_RELEASE'];
1074           $this->cache['SERVERS']['auto'][$rel] = $rel;
1075           $this->cache['SERVERS'][$entry['SERVER']][$rel] = $rel;
1076           uksort($this->cache['SERVERS']['auto'], 'strnatcasecmp');
1077           uksort($this->cache['SERVERS'][$entry['SERVER']], 'strnatcasecmp');
1078         }
1079       }
1080     }
1082     /* Ensure that our selection is valid, else we get several PHP warnings 
1083         if there is no FAI configuration at all.
1084      */
1085     if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror])){
1086       $this->cache['SERVERS'][$this->FAIdebianMirror][''] ='';
1087     }
1089     /* Build up arrays, without checks */
1090     if(!$first_call){
1092       /* Check if the selected mirror is available */
1093       if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror])){
1094         $this->FAIdebianMirror = "auto";
1095         $this->FAIrelease      = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
1096         trigger_error("There was a problem with the selected FAIdebianMirror. This mirror ('".$this->FAIdebianMirror."') is not available");
1097       }
1099       /* Check if the selected release is available */
1100       if($this->FAIdebianMirror != "inherited" && !isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
1102         if($this->FAIrelease != ""){
1103           trigger_error("There was a problem with the selected FAIrelease. This release ('".$this->FAIrelease."') is not available");
1104         }
1105         $this->FAIrelease = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
1106       }
1107     }
1109     /* Get classes for release from cache. 
1110      * Or build cache
1111      */
1112     if($this->FAIdebianMirror == "inherited"){
1113       $release = $this->InheritedFAIrelease;
1114     }else{
1115       $release = $this->FAIrelease;
1116     }
1118     if($force || !isset($this->cache['CLASSES'][$release]) && $release != ""){
1120       /* Get the list of available servers and their releases.
1121        */
1122       $o_queue = new gosaSupportDaemon();
1123       $tmp = $o_queue->FAI_get_classes($release);
1124       $this->cache['CLASSES'][$release] = array();
1125       if($o_queue->is_error()){
1126         msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
1127         $this->si_fai_action_failed = TRUE;
1128         $this->cache=array();
1129         return;
1130       }else{
1131         foreach($tmp as $entry){
1132           $class = $entry['CLASS'];
1133           $this->cache['CLASSES'][$release][$class] = $this->analyse_fai_object($entry); 
1134         }
1135       }
1137       /* Add object caught from external hook
1138        */
1139       $lines= $this->GetHookElements();
1140       foreach ($lines as $hline){
1141         $entries= split(";", $hline);
1142         $server = $entries['0'];
1143         $url    = $entries['1'];
1144         if (!empty($url)){
1146           /* Split releases */
1147           if (isset($entries[2])){
1148             $releases= split(",", $entries[2]);
1150             foreach ($releases as $release_data){
1151               $release_c  = preg_replace('/:.*$/', '', $release_data);
1152               $sections_c = split(':', preg_replace('/^[^:]+:([^|]+)|.*$/', '\1', $release_data));
1153               $classes_c  = split('\|', preg_replace('/^[^|]+\|(.*)$/', '\1', $release_data));
1155               if($release_c == $release){
1156                 $this->cache['SERVERS'][$url][$release_c]=$release_c;
1157                 $this->cache['SERVERS']['auto'][$release_c]=$release_c; 
1158                 foreach ($classes_c as $class){
1159                   if ($class != ""){
1160                     $this->cache['CLASSES'][$release_c][$class]= array();
1161                   }
1162                 }
1163               }
1164             }
1165           }
1166         }
1167       }
1168       uksort($this->cache['SERVERS'], 'strnatcasecmp');
1170       /* Only add inherit option, if we are part in an object group
1171        */
1172       if($this->member_of_ogroup){
1173         $this->cache['SERVERS'] = array_merge(array('inherited' => array()),$this->cache['SERVERS']);
1174       }
1175     }
1177     /* Get list of available kernel for this release 
1178      */
1179     if(!isset($this->cache['KERNELS'])) $this->cache['KERNELS'] = array();
1181     if($force || !isset($this->cache['KERNELS'][$release])){
1182       $o_queue = new gosaSupportDaemon();
1183       $tmp = $o_queue->FAI_get_kernels($release);
1184       $this->cache['KERNELS'][$release] = array();
1185       foreach($this->gotoBootKernels as $name => $default){
1186         $this->cache['KERNELS'][$release][$name] = $default;
1187       }
1188       foreach($tmp as $kernel){
1189         if(empty($kernel)) continue;
1190         $this->cache['KERNELS'][$release][$kernel]=$kernel;
1191       }
1192       ksort($this->cache['KERNELS'][$release]);
1193     }
1194   }
1197   /* This function return an array containing all 
1198    *  invalid classes for the selected server/release
1199    */
1200   function get_invalid_classes($classes)
1201   {
1202     $this->update_fai_cache();
1203     if($this->FAIdebianMirror == "inherited" && isset($this->cache['CLASSES'][$this->InheritedFAIrelease])){
1204       $release_classes = $this->cache['CLASSES'][$this->InheritedFAIrelease];
1205     }elseif(isset($this->cache['CLASSES'][$this->FAIrelease])){
1206       $release_classes = $this->cache['CLASSES'][$this->FAIrelease];
1207     }else{
1208       $release_classes = array();
1209     }
1212     /* Detect all classes that are not valid 
1213      *  for the selected release 
1214      */
1215     $NA = array();
1216     foreach($classes as $class){
1217       if(!isset($release_classes[$class])){
1218         $NA[] = $class;
1219       }
1220     }
1221     return($NA);
1222   }  
1224   
1225   /* Get all selectable classes for the ui select box
1226    */
1227   function selectable_classes()
1228   {
1229     $this->update_fai_cache();
1231     if($this->FAIdebianMirror == "inherited" && isset($this->cache['CLASSES'][$this->InheritedFAIrelease])){
1232       $classes = $this->cache['CLASSES'][$this->InheritedFAIrelease];
1233     }elseif(isset($this->cache['CLASSES'][$this->FAIrelease])){
1234       $classes = $this->cache['CLASSES'][$this->FAIrelease];
1235     }else{
1236       $classes = array();
1237     }
1239     $Abbr ="";
1240     $ret= array();
1241     foreach($classes as $class_name => $class_types){
1242       if(!in_array($class_name,$this->FAIclass)){
1243         foreach($class_types as $type){
1244           if(!preg_match("/".$type['Abbr']."/",$Abbr)){
1245             $Abbr .= $type['Abbr']." ";
1246           }
1247         }
1248         $ret[$class_name] = trim($Abbr);
1249       }
1250     }
1251     uksort($ret, 'strnatcasecmp');
1252     return($ret);
1253   }
1256   /* Analyse FAI object and return an array with usefull informations like 
1257    *  FAIobject type.
1258    */
1259   function analyse_fai_object($attr)
1260   {
1261     $tmp = array();
1262     switch($attr['TYPE']){
1264       case 'FAIpackageList':
1265         $tmp["Type"]= 'FAIpackageList';
1266         $tmp["Abbr"]= 'Pl';
1267         break;
1268       case 'FAItemplate': 
1269         $tmp["Type"]= 'FAItemplate'; 
1270         $tmp["Abbr"]= 'T'; 
1271         break;
1272       case 'FAIvariable':
1273         $tmp["Type"]= 'FAIvariable'; 
1274         $tmp["Abbr"]= 'V'; 
1275         break;
1276       case 'FAIscript':
1277         $tmp["Type"]= 'FAIscript'; 
1278         $tmp["Abbr"]= 'S'; 
1279         break;
1280       case 'FAIhook':
1281         $tmp["Type"]= 'FAIhook'; 
1282         $tmp["Abbr"]= 'H'; 
1283         break;
1284       case 'FAIpartitionTable':
1285         $tmp["Type"]= 'FAIpartitionTable'; 
1286         $tmp["Abbr"]= 'Pt'; 
1287         break;
1288       case 'FAIprofile':
1289         $tmp["Type"]= 'FAIprofile'; 
1290         $tmp["Abbr"]= 'P'; 
1291         break;
1292       default: trigger_error("Unknown FAI object type!");;
1293     }
1294     return($tmp);
1295   }
1298   /* Return repository hook output, if possible.
1299    */
1300   function GetHookElements()
1301   {
1302     $ret = array();
1303     $cmd= $this->config->search("servrepository", "repositoryBranchHook",array('tabs'));
1304     if(!empty($cmd)){
1305       $res = shell_exec($cmd);
1306       $res2 = trim($res);
1307       if((!$res)){
1308         msg_dialog::display(_("Configuration error"), msgPool::cmdexecfailed("repositoryBranchHook", $cmd), ERROR_DIALOG);
1309       }elseif(empty($res2)){
1310         msg_dialog::display(_("Configuration error"), _("'repositoryBranchHook' returned no result!"), ERROR_DIALOG);
1311       }else{
1312         $tmp = split("\n",$res);
1313         foreach($tmp as $line){
1314           if(empty($line)) continue;
1315           $ret[]= $line;
1316         }
1317       }
1318     }
1319     return($ret);
1320   }
1323   /* This function creates the release name out of a dn 
1324    *  e.g. "ou=1.0rc2,ou=siga,ou=fai,..." => "siga/1.0rc2"
1325    */
1326   function dn_to_release_name($dn)
1327   {
1328     $relevant = preg_replace("/,".preg_quote(get_ou("faiBaseRDN"), '/').".*$/","",$dn);
1329     $parts    = array_reverse(split("\,",$relevant));
1330     $str ="";
1331     foreach($parts as $part){
1332       $str .= preg_replace("/^ou=/","",$part)."/";
1333     }
1334     return(preg_replace("/\/$/","",$str)); 
1335   }
1338 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1339 ?>