Code

Fixed typo
[gosa.git] / 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 $customParameters   = "";
33   var $orig_dn            = "";
34   var $ignore_account     = TRUE;
35  
36   /* FAI class selection */ 
37   var $FAIclass           = array();  // The currently selected classes 
38   var $FAIrelease         = "";
39   var $FAIdebianMirror    = "auto";
41   var $cache              = array(); // Used as cache in fai mehtods
43   var $FAIstatus          = "";
44   var $FAIclasses         = array();
46   var $view_logged        = FALSE;
47   
48   /* FAI class selection */
49   var $InheritedFAIclass       = array();
50   var $InheritedFAIrelease     = "";
51   var $InheritedFAIdebianMirror= "auto";
53   var $CopyPasteVars    = array("gotoModules","gotoShares");
54   var $fai_activated    = FALSE;
55   var $o_group_dn       = "";
56   var $member_of_ogroup = FALSE;
58   function workstartup (&$config, $dn= NULL, $parent= NULL)
59   {
60     /* Check if FAI is active */
61     $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs'));
62     if(!empty($tmp)){
63       $this->fai_activated = TRUE;
64     }else{
65       $this->attributes = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "gotoShare");
66       $this->objectclasses  = array("GOhard");
67     }
69     plugin::plugin ($config, $dn, $parent);
71     /* Check object group membership */
72     if(!isset($this->parent->by_object['ogroup'])){
73       $ldap = $this->config->get_ldap_link();
74       $ldap->cd ($this->config->current['BASE']);
75       $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",array("cn","dn"));
76       if($ldap->count()){
77         $this->member_of_ogroup = TRUE;
78         $attrs = $ldap->fetch();
79         $this->o_group_dn = $attrs['dn'];
80       }
81     }
83     /* Creating a list of valid Mirrors 
84      * none will not be saved to ldap.
85      */
86     $ldap   = $this->config->get_ldap_link();
87     $ldap->cd($this->config->current['BASE']);
88     foreach($this->config->data['SERVERS']['LDAP'] as $server) {
89       $this->gotoLdapServerList[]= $server; 
90     }
92     /* Get list of assigned ldap servers 
93      */ 
94     if(isset($this->attrs['gotoLdapServer'])){
95       unset($this->attrs['gotoLdapServer']['count']);
96       sort($this->attrs['gotoLdapServer']);
97       foreach($this->attrs['gotoLdapServer'] as $value){
98         $this->gotoLdapServers[] = preg_replace("/^[0-9]*:/","",$value);
99       }
100     }
101     if(!count($this->gotoLdapServers) && $this->member_of_ogroup){ 
102       $this->gotoLdap_inherit = TRUE;
103     }
105     /* FAI Initialization
106        Skip this if FAI is not activated 
107      */
108     if($this->fai_activated) {
110       $this->update_fai_cache(TRUE);
112       /* Parse used FAIclasses (stored as string).
113        * The single classes are seperated by ' '.
114        * There is also the release type given, after first
115        *  occurrence of ':'.
116        */
117       $this->FAIclass =array();
118       if(isset($this->attrs['FAIclass'][0])){
119         $tmp = split(" ",$this->attrs['FAIclass'][0]);
120         $tmp2 =array();  
122         foreach($tmp as $class){
123           if( ":" == $class[0] ) {
124             $this->FAIrelease = trim(substr($class, 1));
125           }else{
126             $tmp2[$class] = $class;
127           }
128         }
129         $this->FAIclass = $tmp2;
130       }
131     }
133     /* Get arrays */
134     foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
135       if (isset($this->attrs["$val"]["count"])){
136         for ($i= 0; $i<$this->attrs["count"]; $i++){
137           if (isset($this->attrs["$val"][$i])){
138             array_push($this->$val, $this->attrs["$val"][$i]);
139           }
140         }
141       }
142       sort ($this->$val);
143       $this->$val= array_unique($this->$val);
144     }
146     /* Parse Kernel Parameters to decide what boot mode is enabled */
147     if (preg_match("/ splash=silent/", $this->gotoKernelParameters)){
148       $this->bootmode= "G";
149     } elseif (preg_match("/ debug/", $this->gotoKernelParameters)){
150       $this->bootmode= "D";
151     } elseif ($this->gotoKernelParameters == "") {
152       $this->bootmode= "G";
153     } else {
154       $this->bootmode= "T";
155     }
156     if (preg_match("/ o /", $this->gotoKernelParameters)){
157       $this->customParameters= preg_replace ("/^.* o /", "", $this->gotoKernelParameters);
158     } else {
159       $this->customParameters= "";
160     }
162     /* Prepare Shares */
163     if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){
164       unset($this->attrs['gotoShare']['count']);
165       foreach($this->attrs['gotoShare'] as $share){
166         $tmp = $tmp2 = array();
167         $tmp = split("\|",$share);
168         $tmp2['server']      =$tmp[0];
169         $tmp2['name']        =$tmp[1];
170         $tmp2['mountPoint']  =$tmp[2];
171         $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2;
172       }
173     }
175     $this->gotoShareSelections= $config->getShareList(true);
176     $this->gotoAvailableShares= $config->getShareList(false);
177     $tmp2 = array();
178   
180     $this->orig_dn= $this->dn;
182     /* Handle inheritance value "default" */
183     if ($this->member_of_ogroup){
184       $this->gotoBootKernels= array("default-inherited" => '['._("inherited").']'); 
185     }
187     /* If we are member in an object group,
188      *  we have to handle inherited values.
189      * So you can see what is inherited.
190      */
191     if ($this->member_of_ogroup){
193       if(count($this->FAIclass)==0 && $this->FAIrelease == ""){
194         $this->FAIdebianMirror = "inherited";
195       }
197       if($this->fai_activated){
198         $map= array("gotoBootKernel","FAIclass","FAIdebianMirror");
199       }else{
200         $map= array("gotoBootKernel");
201       }
203       $ldap = $this->config->get_ldap_link();
204       $ldap->cat($this->o_group_dn);
205       $attrs= $ldap->fetch();
207       foreach ($map as $name){
208         if (!isset($attrs[$name][0])){
209           continue;
210         }
212         switch ($name){
213           case 'gotoBootKernel':
214             $this->gotoBootKernels['default-inherited']=  _("inherited").' ['.$attrs[$name][0].']' ;
215             break;
217           case 'FAIclass':
218             $str = split(":",$attrs[$name][0]);
219             $this->InheritedFAIclass    = split("\ ",trim($str[0]));
220             $this->InheritedFAIrelease  = trim($str[1]);
221             break;
223           case 'FAIdebianMirror':
224             $this->InheritedFAIdebianMirror = $attrs[$name][0];
225             break;
226         }
227       }
228     }
231     if($this->fai_activated){
233       /* Check if the current mirror is available 
234        */
235       if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror])){
236         if(count($this->FAIclass)){
237           msg_dialog::display(_("Error"), sprintf(_("FAI mirror '%s' is not available - setting to mirror 'auto'!"), $this->FAIdebianMirror), ERROR_DIALOG);
238         }
239         $this->FAIdebianMirror = "auto";
240         $this->FAIrelease = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
241         $this->cache =array();
242         $this->update_fai_cache();
243         
244       }
245   
246       /* Check if the current mirror is available 
247        */
248       if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
249         $new_release = key($this->cache['SERVERS'][$this->FAIdebianMirror]); 
250         if(count($this->FAIclass)){
251           msg_dialog(_("Error"), sprintf(_("FAI release '%s' is not available on mirror '%s' - setting to release '%s'!"), $this->FAIrelease, $this->FAIdebianmirror), ERROR_DIALOG);
252         }
253         $this->FAIrelease = $new_release;
254         $this->cache =array();
255         $this->update_fai_cache();
256       }
257     }
259     /* Get list of boot kernels */
260     if (isset($this->config->data['TABS'])){
261       $command= $this->config->search(get_class($this), "KERNELS",array('tabs'));
262       if (!check_command($command)){
263         $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command,
264             get_class($this));
265       } else {
266         $fh= popen($command, "r");
267         while (!feof($fh)) {
268           $buffer= trim(fgets($fh, 256));
269           if(!empty($buffer)){
270             $name=$value = $buffer;
271             if(preg_match("/:/",$buffer)){
272               $name = preg_replace("/:.*$/","",$buffer);
273               $value= preg_replace("/^.*:/","",$buffer);
274               $this->gotoBootKernels[$name]= $name.":".$value;
275             }else{
276               $this->gotoBootKernels[$name]= $value;
277             }
278           }
279         }
280         pclose($fh);
281       }
282     }
284     /* Turn to default, if we've nothing to inherit */
285     if (!isset($this->gotoBootKernels['default-inherited']) && $this->gotoBootKernel == "default-inherited"){
286       $this->gotoBootKernel= "default";
287     }
288   }
290   
291   function check()
292   {
293     $messages = array();
294     
295     /* Call common method to give check the hook */
296     $messages= plugin::check();
298     /* If there are packages selected, but no mirror show error */   
299     if(($this->FAIdebianMirror == "none")&&(count($this->FAIclass)>0)){
300       $messages[]=_("Please select a 'FAI server' or remove the 'FAI classes'.");
301     }
303     return($messages);
304   }
306   function execute()
307   {
308         /* Call parent execute */
309         plugin::execute();
311     if($this->is_account && !$this->view_logged){
312       $this->view_logged = TRUE;
313       new log("view","workstation/".get_class($this),$this->dn);
314     }
316     /* Do we need to flip is_account state? */
317     if(isset($_POST['modify_state'])){
318       if($this->is_account && $this->acl_is_removeable()){
319         $this->is_account= FALSE;
320       }elseif(!$this->is_account && $this->acl_is_createable()){
321         $this->is_account= TRUE;
322       }
323     }
325     /* Do we represent a valid terminal? */
326     if (!$this->is_account && $this->parent === NULL){
327       $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
328         msgPool::noValidExtension(_("workstation"))."</b>";
329       return ($display);
330     }
332     /* Add module */
333     if (isset ($_POST['add_module'])){
334       if ($_POST['module'] != "" && $this->acl_is_writeable("gotoModule")){
335         $this->add_list ($this->gotoModules, $_POST['module']);
336       }
337     }
339     /* Delete module */
340     if (isset ($_POST['delete_module'])){
341       if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoModule")){
342         $this->del_list ($this->gotoModules, $_POST['modules_list']);
343       }
344     }
346     /* FAI class management */
347     if($this->fai_activated){
348       if(((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))) && ($this->acl_is_writeable("FAIclass"))){
349         $found = 0 ; 
351         /* If this new class/profile will attach a second partition table
352          * to our list of classes, abort and show a message.
353          */
354         foreach($this->FAIclass as $name){
355           if(isset($this->FAIclassInfo[$name])){
356             foreach($this->FAIclassInfo[$name] as $atr){
357               if(isset($atr['obj'])){
358                 if($atr['obj'] == "FAIpartitionTable"){
359                   $found ++ ; 
360                 }
361               }
362             }
363           }
364         }
366         if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpartitionTable']))&&($found>0)){
367           msg_dialog(_("Error"), _("There is already a profile containing a partition table in your configuration!") , ERROR_DIALOG);
368         }else{
369           $this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel'];
370         }
371       }
373       $sort = false;
375       /* Move one used class class one position up or down */
376       if($this->acl_is_writeable("FAIclass")){
377         foreach($_POST as $name => $val){
379           $sort_type = false;
380           if((preg_match("/sort_up/",$name))&&(!$sort)){
381             $sort_type = "sort_up_";
382           }
383           if((preg_match("/sort_down/",$name))&&(!$sort)){
384             $sort_type = "sort_down_";
385           }
387           if(($sort_type)&&(!$sort)){
388             $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name)));
389             $sort = true;
391             $last = -1;
392             $change_down  = -1;
394             /* Create array with numeric index */ 
395             $tmp = array();
396             foreach($this->FAIclass as $class){
397               $tmp [] = $class;
398             }
400             /* Walk trough array */
401             foreach($tmp as $key => $faiName){
402               if($faiName == $value){
403                 if($sort_type == "sort_up_"){
404                   if($last != -1){
405                     $change_down= $last;
406                   }
407                 }else{
408                   if(isset($tmp[$key+1])){
409                     $change_down = $key;
410                   }
411                 }
412               }
413               $last = $key;
414             }
416             $tmp2 = array();
417             $skip = false;    
419             foreach($tmp as $ky => $vl){
421               if($ky == $change_down){
422                 $skip = $vl;
423               }else{
424                 $tmp2[$vl] = $vl;
425               }
426               if(($skip != false)&&($ky != $change_down)){
427                 $tmp2[$skip]  = $skip;
428                 $skip =false;
429               }
430             }   
431             $this->FAIclass = $tmp2; 
432           }
434           if(preg_match("/fai_remove/i",$name)){
435             $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/fai_remove_/i","",$name)));
436             unset($this->FAIclass[$value]);
437           }
438         }
439       }
441       /* Delete selected class from our list */
442       if($this->acl_is_writeable("FAIclass")){
443         if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){
444           if(isset($this->FAIclass[$_POST['FAIclassSel']])){
445             unset($this->FAIclass[$_POST['FAIclassSel']]);
446           }
447         }
448       }
449     }// END fai handling
451     /* Show main page */
452     $smarty= get_smarty();
454     /* Assign ACLs to smarty */
455     $tmp = $this->plInfo();
456     foreach($tmp['plProvidedAcls'] as $name => $translation){
457       $smarty->assign($name."ACL",$this->getacl($name));
458     } 
460     $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
462     /* In this section server shares will be defined
463      * A user can select one of the given shares and a mount point
464      *  and attach this combination to his setup.
465      */
466     $smarty->assign("gotoShareSelections",    $this->gotoShareSelections);
467     $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections));
469     /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry
470      * This entry will be, a combination of mountPoint and sharedefinitions
471      */
472     if((isset($_POST['gotoShareAdd'])) && ($this->acl_is_writeable("gotoShare"))) {
473       /* We assign a share to this user, if we don't know where to mount the share */
474       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
475         msg_dialog(_("Error"), msgPool::required(_("Mount point")), ERROR_DIALOG);
476       }else{
477         if(count($this->gotoAvailableShares)){
478           $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
479           $s_mount = $_POST['gotoShareMountPoint'];
480           /* Preparing the new assignment */
481           $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
482           $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
483         }
484       }
485     }
487     /* if the Post  gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected)
488      * If there is no defined share selected, we will abort the deletion without any message
489      */
490     if(($this->acl_is_writeable("gotoShare"))&& (isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){
491       unset($this->gotoShares[$_POST['gotoShare']]);
492     }
494     $smarty->assign("gotoShares",$this->printOutAssignedShares());
495     $smarty->assign("gotoSharesCount",count($this->printOutAssignedShares()));
496     $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares()));
497     $smarty->assign("gotoBootKernels",$this->gotoBootKernels);
499     /* Create divSelectBox for ldap server selection
500      */
501     $SelectBoxLdapServer = new divSelectBox("LdapServer");
502     $SelectBoxLdapServer->SetHeight(130);
504     /* Add new ldap server to the list */
505     if(!$this->gotoLdap_inherit && isset($_POST['add_ldap_server']) && isset($_POST['ldap_server_to_add'])){
506       if(isset($this->gotoLdapServerList[$_POST['ldap_server_to_add']])){
507         $to_add = $this->gotoLdapServerList[$_POST['ldap_server_to_add']];
508         if(!in_array($to_add,$this->gotoLdapServers)){
509           $this->gotoLdapServers[] = $to_add;
510         }
511       }
512     }
513     
514     /* Move ldap servers up and down */
515     if(!$this->gotoLdap_inherit){
516       foreach($_POST as $name => $value){
517         if(preg_match("/sort_ldap_up_/",$name)){
518           $id = preg_replace("/^sort_ldap_up_([0-9]*)_(x|y)$/","\\1",$name);
519           $from =  $id;  
520           $to   =  $id -1;
521           $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to);
522           if($tmp){
523             $this->gotoLdapServers = $tmp;
524           }
525           break;
526         }
527         if(preg_match("/sort_ldap_down_/",$name)){
528           $id = preg_replace("/^sort_ldap_down_([0-9]*)_(x|y)$/","\\1",$name);
529           $from =  $id;  
530           $to   =  $id +1;
531           $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to);
532           if($tmp){
533             $this->gotoLdapServers = $tmp;
534           }
535           break;
536         }
537         if(preg_match("/gotoLdapRemove_/",$name)){
538           $id = preg_replace("/^gotoLdapRemove_([0-9]*)_(x|y)$/","\\1",$name);
539           $value = $this->gotoLdapServers[$id];
540           $this->gotoLdapServers = array_remove_entries(array($value),$this->gotoLdapServers);
541           break;
542         }
543       } 
544     }
545   
546     /* Add Entries */
547     foreach($this->gotoLdapServers as $key => $server){
548       /* Announce missing entries */
549       if(!in_array($server,$this->gotoLdapServerList)){
550         $server = $server."&nbsp;<font style='color:red'>(missing)</font>";
551       }
553       /* Convert old style entry */
554       if (!preg_match('%:ldap://%', $server)){
555         $server= "ldap://".preg_replace('/^([^:]+):/', '\1/', $server);
557       /* Beautify new style entries */
558       } else {
559         $server= preg_replace("/^[^:]+:/", "", $server);
560       }
562       $SelectBoxLdapServer->AddEntry(
563           array(array("string" => $server),
564             array("string" => 
565               "<input class='center' type='image' src='images/sort_up.png' name='sort_ldap_up_".$key."'>&nbsp;".
566               "<input class='center' type='image' src='images/sort_down.png' name='sort_ldap_down_".$key."'>&nbsp;".
567               "<input class='center' type='image' src='images/edittrash.png' name='gotoLdapRemove_".$key."'>",
568               "attach" => "style='text-align:right;width:40px;border-right:0px;'")));
569     }    
571     if($this->gotoLdap_inherit){
572       $smarty->assign("gotoLdapServerACL_inherit", preg_replace("/w/","",$this->getacl("gotoLdapServer")));;
573     }else{
574       $smarty->assign("gotoLdapServerACL_inherit", $this->getacl("gotoLdapServer"));
575     }
576     
577     $list = array();
578     foreach($this->gotoLdapServerList as $key => $entry){
579       if(!in_array($entry,$this->gotoLdapServers)){
581         /* Convert old style entry */
582         if (!preg_match('%:ldap://%', $entry)){
583           $entry= "ldap://".preg_replace('/^([^:]+):/', '\1/', $entry);
585         /* Beautify new style entries */
586         } else {
587           $entry= preg_replace("/^[^:]+:/", "", $entry);
588         }
590         $list[$key] = $entry;
591       }
592     }
593     $smarty->assign("gotoLdapServers",    $SelectBoxLdapServer->DrawList());
594     $smarty->assign("gotoLdapServerList", $list);
595     $smarty->assign("gotoLdap_inherit",   $this->gotoLdap_inherit);
596     $smarty->assign("JS",  session::get('js'));
598     foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
599       $smarty->assign("$val", $this->$val);
600     }
602     /* Values */
603     foreach(array("gotoBootKernel", "customParameters", "gotoShare","FAIclasses","FAIclass","FAIdebianMirror","FAIrelease") as $val){
604       $smarty->assign($val, $this->$val);
605     }
607     $smarty->assign("fai_activated",$this->fai_activated);
609     /* Create FAI output */
610     if($this->fai_activated){
612       $this->update_fai_cache();
614       $smarty->assign("FAIservers"  , $this->cache['SERVERS']);
615       $smarty->assign("FAIdebianMirror",$this->FAIdebianMirror);
616       $smarty->assign("FAIrelease"  , $this->FAIrelease);
617       $smarty->assign("FAIclasses"  , $this->selectable_classes());
619       $smarty->assign("InheritedFAIrelease",$this->InheritedFAIrelease);
621       $div = new divSelectBox("WSFAIscriptClasses");
622       $div -> SetHeight("110");
623       $str_up     = " &nbsp;<input type='image' src='images/sort_up.png'    name='sort_up_%s'    value='%s'>";
624       $str_down   = " &nbsp;<input type='image' src='images/sort_down.png'  name='sort_down_%s'  value='%s'>";
625       $str_remove = " &nbsp;<input type='image' src='images/edittrash.png'  name='fai_remove_%s' value='%s'>";
626       $str_empty  = " &nbsp;<img src='images/empty.png' alt=\"\" width='7'>"; 
628       /* Get classes */
629       if($this->FAIdebianMirror == "inherited"){
630         $tmp = $this->InheritedFAIclass;
631       }else{
632         $tmp = $this->FAIclass;
633       }
635       /* Get invalid classes */
636       $invalid = $this->get_invalid_classes($tmp);
638       /* Draw every single entry */
639       $i = 1;
640       foreach($tmp as $class){
642         /* Mark invalid classes. (Not in selected release)
643          */
644         $marker = "";
645         if(in_array_ics($class,$invalid)){
646           $marker = "&nbsp;<font color='red'>("._("Not available in current setup").")</font>";
647         }
649         /* Create up/down priority icons  
650          * Skip this, if we have inherited the FAI classes.
651          */
652         if($this->FAIdebianMirror == "inherited"){
653           $str = "";
654         }else{
655           if($i==1){
656             $str = $str_empty.$str_down.$str_remove;
657           }elseif($i == count($this->FAIclass)){
658             $str = $str_up.$str_empty.$str_remove;
659           }else{
660             $str = $str_up.$str_down.$str_remove;
661           }
662         }
663         $i ++ ; 
665         /* Get Description tag 
666          *  There may be several FAI objects with the same class name, 
667          *   use the description from FAIprofile, if possible.
668          */  
669         $desc = ""; 
670         if(isset($this->cache['CLASSES'][$this->FAIrelease][$class])){
671           foreach($this->cache['CLASSES'][$this->FAIrelease][$class] as $types ){
672             if(isset($types['Desc'])){
673               $desc= $types['Desc'];
674               if($types['Type'] == "FAIprofile"){
675                 break;
676               }
677             }
678           }
679         }
680         if(!empty($desc)){
681           $desc = "&nbsp;[".trim($desc)."]";
682         }        
684         $div->AddEntry(array(
685               array("string"=>$class.$desc.$marker),
686               array("string"=>preg_replace("/\%s/",base64_encode($class),$str),"attach"=>"style='width:50px;border-right:none;'")
687               ));
688       }  
689       $smarty->assign("FAIScriptlist",$div->DrawList()); 
690     }// END FAI output generation 
692     /* Radio button group */
693     if (preg_match("/G/", $this->bootmode)) {
694       $smarty->assign("graphicalbootup", "checked");
695     } else {
696       $smarty->assign("graphicalbootup", "");
697     }
698     if (preg_match("/T/", $this->bootmode)) {
699       $smarty->assign("textbootup", "checked");
700     } else {
701       $smarty->assign("textbootup", "");
702     }
703     if (preg_match("/D/", $this->bootmode)) {
704       $smarty->assign("debugbootup", "checked");
705     } else {
706       $smarty->assign("debugbootup", "");
707     }
709     /* Show main page */
710     return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE,dirname(__FILE__))));
711   }
714   function remove_from_parent()
715   {
716     $this->handle_post_events("remove");
717     new log("remove","workstation/".get_class($this),$this->dn);
718   }
721   /* Save data to object */
722   function save_object()
723   {
724     $old_mirror  = $this->FAIdebianMirror;
725     plugin::save_object();
727     /* Update release */
728     if($old_mirror != $this->FAIdebianMirror){
729       if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
730         $this->FAIrelease      = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
731       }
732     }
734     if(isset($_POST['WorkstationStarttabPosted'])){
735       if(isset($_POST['gotoLdap_inherit'])){
736         $this->gotoLdap_inherit = TRUE;
737       }else{
738         $this->gotoLdap_inherit = FALSE;
739       }
741       /* Save group radio buttons */
742       if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){
743         $this->bootmode= $_POST["bootmode"];
744       }
746       /* Save kernel parameters */
747       if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){
748         $this->customParameters= $_POST["customParameters"];
749       }
750     }
751   }
754   /* Save to LDAP */
755   function save()
756   {
758     /* Depending on the baseobject (Ogroup / WS) we
759      *  use another set of objectClasses
760      * In case of WS itself, we use  "array("GOhard", "FAIobject");"
761      * if we are currently editing from ogroup menu we use (array("gotWorkstationTemplate","GOhard", "FAIobject"))
762      */
763     if(isset($this->parent->by_object['ogroup'])){
764       $this->objectclasses = array("gotoWorkstationTemplate");
765     }elseif(isset($this->parent->by_object['workgeneric'])){
766       $this->objectclasses = array("GOhard");
767     }elseif(isset($this->parent->by_object['servgeneric'])){
768       $this->objectclasses = array("GOhard","gotoWorkstationTemplate");
769     }else{
770       print "Object Type Configuration : unknown";
771       exit();
772     }
774     /* Append FAI class */
775     if($this->fai_activated){
776       $this->objectclasses[]  = "FAIobject";
777     }
779     /* Find proper terminal path for tftp configuration
780        FIXME: This is suboptimal when the default has changed to
781        another location! */
782     if (($this->gotoTerminalPath == "default")){
783       $ldap= $this->config->get_ldap_link();
785       /* Strip relevant part from dn, keep trailing ',' */
786       $tmp= preg_replace("/^cn=[^,]+,".get_ou('terminalou')."/i", "", $this->dn);
787       $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp);
789       /* Walk from top to base and try to load default values for
790          'gotoTerminalPath'. Abort when an entry is found. */
791       while (TRUE){
792         $tmp= preg_replace ("/^[^,]+,/", "", $tmp);
794         $ldap->cat("cn=default,".get_ou('terminalou').$tmp.
795             $this->config->current['BASE'], array('gotoTerminalPath'));
796         $attrs= $ldap->fetch();
797         if (isset($attrs['gotoTerminalPath'])){
798           $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0];
799           break;
800         }
802         /* Nothing left? */
803         if ($tmp == ""){
804           break;
805         }
806       }
807     }
809     /* Add semi automatic values */
810     // FIXME: LDAP Server may not be set here...
811     $this->gotoKernelParameters= "ldap=".base64_encode($this->gotoLdapServer);
813     switch ($this->bootmode){
814       case "D":
815         $this->gotoKernelParameters.= " debug";
816       break;
817       case "G":
818         $this->gotoKernelParameters.= " splash=silent";
819       break;
820     }
821     if ($this->customParameters != ""){
822       $this->gotoKernelParameters.= " o ".$this->customParameters;
823     }
825     plugin::save();
827     unset( $this->attrs['FAIrelease'] );
828     
829     $str = "";
831     /* Skip FAI attribute handling if not necessary */
832     if($this->fai_activated){
833       if($this->FAIdebianMirror == "inherited"){
834         $this->attrs['FAIclass'] = $this->attrs['FAIrelease'] =  $this->attrs['FAIdebianMirror'] = array(); 
835       }else{
836         foreach($this->FAIclass as $class){
837           $str .= $class." ";
838         }
839         $str .= ":" . $this->FAIrelease;
840         $this->attrs['FAIclass']= "";
841         $this->attrs['FAIclass']= trim($str);
843         if(empty($this->attrs['FAIclass'])){
844           $this->attrs['FAIclass'] = array();
845         }
846       }
847     }
848   
849     /* Add missing arrays */
850     foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){
851       if (isset ($this->$val) && count ($this->$val) != 0){
852     
853         $this->attrs["$val"]= array_unique($this->$val);
854       }
855       if(!isset($this->attrs["$val"])) $this->attrs["$val"]=array();
856     }
858     /* Prepare list of ldap servers */
859     $this->attrs['gotoLdapServer'] = array();
860     if(!$this->gotoLdap_inherit){
861       $i = 0;
862       foreach($this->gotoLdapServers as $server){
863         $i ++;
864         $this->attrs['gotoLdapServer'][] = $i.":".$server;
865       }
866     }
868     /* Check if LDAP server has changed */
869     $ldap_changed= false;
870     if (isset($this->saved_attributes['gotoLdapServer'])){
871       if (isset($this->attrs['gotoLdapServer']) && $this->attrs['gotoLdapServer'] != $this->saved_attributes['gotoLdapServer']){
872         $ldap_changed= true;
873       }
874     } else {
875       if (isset($this->attrs['gotoLdapServer'])){
876         $ldap_changed= true;
877       }
878     }
880     if (($this->attrs['gotoBootKernel'] == "default-inherited") || ($this->attrs['gotoBootKernel'] == "%default%")){
881       $this->attrs['gotoBootKernel']= array();
882     }
884     /* if mirror == none stop saving this attribute */
885     if($this->FAIdebianMirror == "none"){
886       $this->FAIdebianMirror = "";
887     }
888    
889     /* Get FAIstate from object, the generic tab could have changed it during execute */
890     $ldap= $this->config->get_ldap_link();
891     $ldap->cd($this->dn);
894     /* Skip FAI attribute handling if not necessary */
895     if($this->fai_activated){
896       $ldap->cat($this->dn,array("FAIstate"));
897       $checkFAIstate = $ldap->fetch();
899       /* Remove FAI objects if no FAI class is selected */ 
900       if((count($this->FAIclass)==0) && (!isset($checkFAIstate['FAIstate']))){
901         $this->attrs['FAIclass']        = array();
902         $this->attrs['FAIdebianMirror'] = array();
903       }
904     }
907     /* prepare share settings */
908     $tmp = array();
909     foreach($this->gotoShares as $name => $settings){
910       $tmp2= split("\|",$name);
911       $name = $tmp2[0];
912       $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint'];
913     }
914     $this->attrs['gotoShare']=$tmp;
916     $this->cleanup();
917     $ldap->modify ($this->attrs); 
918     new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
920     if (!$ldap->success()){
921       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
922     }
923     $this->handle_post_events("modify");
925     /* Check if LDAP server has changed */
926     if ($ldap_changed && class_available("DaemonEvent")){
927       $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
928       $o_queue = new gosaSupportDaemon();
929       if(isset($events['TRIGGERED']['DaemonEvent_reload_ldap_config'])){
930         $evt = $events['TRIGGERED']['DaemonEvent_reload_ldap_config'];
931         $macs = array();
932     
933         /* Get list of macAddresses 
934          */
935         if(isset($this->parent->by_object['ogroup'])){
936         
937           /* If we are an object group, add all member macs 
938            */
939           $p = $this->parent->by_object['ogroup'];
940           foreach($p->memberList as $dn => $obj){
941             if(isset($p->objcache[$dn]['macAddress']) && !empty($p->objcache[$dn]['macAddress'])){
942               $macs[] = $p->objcache[$dn]['macAddress'];
943             }
944           }
945         }elseif(isset($this->parent->by_object['workgeneric']->netConfigDNS->macAddress)){
947           /* We are a workstation. Add current mac.
948            */
949           $mac = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
950           if(!empty($mac)){
951             $macs[] = $mac;
952           }          
953         }
955         /* Trigger event for all member objects 
956          */
957         foreach($macs as $mac){
958           $tmp = new $evt['CLASS_NAME']($this->config);
959           $tmp->set_type(TRIGGERED_EVENT);
960           $tmp->add_targets(array($mac));
961           if(!$o_queue->append($tmp)){
962             msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
963           }
964         }
965       }
966     }
967   }
970   /* Add value to array, check if unique */
971   function add_list (&$array, $value)
972   {
973     if ($value != ""){
974       $array[]= $value;
975       sort($array);
976       array_unique ($array);
977     }
978   }
981   /* Delete value to array, check if unique */
982   function del_list (&$array, $list)
983   {
984     $tmp= array();
985     foreach ($array as $mod){
986       if (!in_array($mod, $list)){
987         $tmp[]= $mod;
988       }
989     }
990     $array= $tmp;
991   }
993   /* Generate ListBox frindly output for the defined shares
994    * Possibly Add or remove an attribute here,
995    */
996   function printOutAssignedShares()
997   {
998     $a_return = array();
999     if(is_array($this->gotoShares)){
1000       foreach($this->gotoShares as $share){
1001         $a_return[$share['name']."|".$share['server']]= $share['name']." [".$share['server']."]";
1002       }
1003     }
1004     return($a_return);
1005   }
1009   function PrepareForCopyPaste($source)
1010   {
1011     plugin::PrepareForCopyPaste($source);    
1012     $source_o = new workstartup ($this->config, $source['dn']);
1013     foreach(array("FAIclass","gotoModules", "gotoAutoFs", "gotoFilesystem",
1014           "gotoKernelParameters","gotoShares","customParameters") as $attr){
1015       $this->$attr = $source_o->$attr;
1016     }
1017   }
1019   
1020   function array_switch_item($ar,$from,$to)
1021   {
1022     if(!is_array($ar)){
1023       return(false);
1024     }
1025     if(!isset($ar[$from])){
1026       return(false);
1027     }
1028     if(!isset($ar[$to])){
1029       return(false);
1030     }
1032     $tmp = $ar[$from];
1033     $ar[$from] = $ar[$to];    
1034     $ar[$to] = $tmp;    
1035     return($ar);
1036   }
1039   /* Return plugin informations for acl handling */ 
1040   static function plInfo()
1041   {
1042     return (array( 
1043           "plShortName"   => _("Startup"),
1044           "plDescription" => _("System startup"),
1045           "plSelfModify"  => FALSE,
1046           "plDepends"     => array(),
1047           "plPriority"    => 9,
1048           "plSection"     => array("administration"),           
1049           "plCategory"    => array("workstation","server","ogroups"),
1051           "plProvidedAcls"=> array(
1052             "gotoLdapServer"        => _("Ldap server"),
1053             "gotoBootKernel"        => _("Boot kernel"),
1054             "gotoKernelParameters"  => _("Kernel parameter"),
1056             "gotoModules"           => _("Kernel modules"),
1057             "gotoShare"             => _("Shares"),
1059             "FAIclass"              => _("FAI classes"),
1060             "FAIdebianMirror"       => _("Debian mirror"),
1061             "FAIrelease"            => _("Debian release"),
1063             "FAIstatus"             => _("FAI status flag")) // #FIXME is this acl realy necessary ?
1064           ));
1065   }
1068   /* Updates release dns 
1069    *  and reads all classes for the current release, 
1070    *  if not already done ($this->cache).
1071    */
1072   function update_fai_cache($first_call = FALSE)
1073   {
1074     $force = FALSE;
1076     /* Get the list of available servers and their releases. 
1077      */
1078     if($force || !isset($this->cache['SERVERS'])){
1080       /* Only add inherit option, if we are part in an object group
1081        */
1082       if($this->member_of_ogroup){
1083         $this->cache['SERVERS']['inherited']=array();
1084       }
1086       $o_queue = new gosaSupportDaemon();
1087       $tmp = $o_queue->FAI_get_server();  
1088       foreach($tmp as $entry){
1089         $rel = $entry['RELEASE'];
1090         $this->cache['SERVERS']['auto'][$rel] = $rel;
1091         $this->cache['SERVERS'][$entry['SERVER']][$rel] = $rel;
1092       }
1093     }
1095     /* Build up arrays, without checks */
1096     if(!$first_call){
1098       /* Check if the selected mirror is available */
1099       if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror])){
1100         $this->FAIdebianMirror = "auto";
1101         $this->FAIrelease      = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
1102         trigger_error("There was a problem with the selected FAIdebianMirror. This mirror ('".$this->FAIdebianMirror."') is not available");
1103       }
1105       /* Check if the selected release is available */
1106       if($this->FAIdebianMirror != "inherited" && !isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
1107         trigger_error("There was a problem with the selected FAIrelease. This release ('".$this->FAIrelease."') is not available");
1108         $this->FAIrelease = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
1109       }
1110     }
1112     /* Get classes for release from cache. 
1113      * Or build cache
1114      */
1115     if($this->FAIdebianMirror == "inherited"){
1116       $release = $this->InheritedFAIrelease;
1117     }else{
1118       $release = $this->FAIrelease;
1119     }
1120     if($force || !isset($this->cache['CLASSES'][$release])){
1124 #   Currently not working here, it seems that my FAI environment is not
1125 #   configured to support GOsa-si FAI - Packages
1127 #     /* Get the list of available servers and their releases.
1128 #      */
1129 #     if($force || !isset($this->cache['SERVERS'])){
1131 #       /* Only add inherit option, if we are part in an object group
1132 #        */
1133 #       if($this->member_of_ogroup){
1134 #         $this->cache['SERVERS']['inherited']=array();
1135 #       }
1137 #       $o_queue = new gosaSupportDaemon();
1138 #       $tmp = $o_queue->FAI_get_classes();
1139 #       print_a($tmp);
1140 #       echo $o_queue->get_error();
1141 #     }
1152       /*  Create a list of available releases.
1153        *  $this->cache['RELEASE_DNS'][ou=siga...,c=de]         = "siga";
1154        *  $this->cache['RELEASE_DNS'][ou=siga,ou=rc1,...,c=de] = "siga/rc1";
1155        */
1156       if($force || !isset($this->cache['RELEASE_DNS'])){
1157         $this->cache['RELEASE_DNS'] = array();
1158         $fai_ou_parts = preg_replace("/\/.*$/","",$this->FAIrelease);
1160         $tmp = get_sub_list("(objectClass=FAIbranch)","",get_ou("faiou"),
1161                 $this->config->current['BASE'],array("ou"),GL_NO_ACL_CHECK | GL_SUBSEARCH);
1163         foreach($tmp as $attrs){
1164           if(preg_match("/".normalizePreg(get_ou("faiou"))."/",$attrs['dn'])){
1165             $this->cache['RELEASE_DNS'][$attrs['dn']] = $this->dn_to_release_name($attrs['dn']);
1166           }
1167         }
1168       }
1170       /* Create list of available classes for the currenlty selected release.
1171        */
1172       $base = array_search($release,$this->cache['RELEASE_DNS']);
1173       $this->cache['CLASSES'][$release] = array();
1175       if(class_exists("FAI")){
1176         if(!empty($base)){
1177           $filter = "(|(objectClass=FAIpackageList)(objectClass=FAItemplate)(objectClass=FAIvariable)".
1178             "(objectClass=FAIscript)(objectClass=FAIhook)(objectClass=FAIprofile)".
1179             "(objectClass=FAIpartitionTable))";
1180           $list = FAI::get_all_objects_for_given_base($base,$filter,TRUE);
1181           foreach($list as $attrs){
1182             $info = $this->analyse_fai_object($attrs);
1183             if(count($info)){
1184               $this->cache['CLASSES'][$release][$attrs['cn'][0]][] = $info;
1185             }
1186           }
1187         }
1188       }else{
1189         msg_dialog(_("Configuration error"), _("Missing FAI plugin extension!"), ERROR_DIALOG);
1190       }
1192       /* Add object caught from external hook
1193        */
1194       $lines= $this->GetHookElements();
1195       foreach ($lines as $hline){
1196         $entries= split(";", $hline);
1197         $server = $entries['0'];
1198         $url    = $entries['1'];
1199         if (!empty($url)){
1200           
1201           /* Split releases */
1202           if (isset($entries[2])){
1203             $releases= split(",", $entries[2]);
1205             foreach ($releases as $release_data){
1206               $release= preg_replace('/:.*$/', '', $release_data);
1207               $sections = split(':', preg_replace('/^[^:]+:([^|]+)|.*$/', '\1', $release_data));
1208               $classes  = split('\|', preg_replace('/^[^|]+\|(.*)$/', '\1', $release_data));
1209               $this->cache['SERVERS'][$url][$release]=$release;
1210               $this->cache['SERVERS']['auto'][$release]=$release; 
1211               foreach ($classes as $class){
1212                 if ($class != ""){
1213                   $this->cache['CLASSES'][$release][$class]= array();
1214                 }
1215               }
1216             }
1217           }
1218         }
1219       }
1220     }
1221   }
1224   /* This function return an array containing all 
1225    *  invalid classes for the selected server/release
1226    */
1227   function get_invalid_classes($classes)
1228   {
1229     $this->update_fai_cache();
1230     if($this->FAIdebianMirror == "inherited"){
1231       $release_classes = $this->cache['CLASSES'][$this->InheritedFAIrelease];
1232     }else{
1233       $release_classes = $this->cache['CLASSES'][$this->FAIrelease];
1234     }
1237     /* Detect all classes that are not valid 
1238      *  for the selected release 
1239      */
1240     $NA = array();
1241     foreach($classes as $class){
1242       if(!isset($release_classes[$class])){
1243         $NA[] = $class;
1244       }
1245     }
1246     return($NA);
1247   }  
1249   
1250   /* Get all selectable classes for the ui select box
1251    */
1252   function selectable_classes()
1253   {
1254     $this->update_fai_cache();
1256     if($this->FAIdebianMirror == "inherited"){
1257       $classes = $this->cache['CLASSES'][$this->InheritedFAIrelease];
1258     }else{
1259       $classes = $this->cache['CLASSES'][$this->FAIrelease];
1260     }
1262     $Abbr ="";
1263     $ret= array();
1264     foreach($classes as $class_name => $class_types){
1265       if(!in_array($class_name,$this->FAIclass)){
1266         foreach($class_types as $type){
1267           if(!preg_match("/".$type['Abbr']."/",$Abbr)){
1268             $Abbr .= $type['Abbr']." ";
1269           }
1270         }
1271         $ret[$class_name] = trim($Abbr);
1272       }
1273     }
1274     uksort($ret, 'strnatcasecmp');
1275     return($ret);
1276   }
1279   /* Analyse FAI object and return an array with usefull informations like 
1280    *  FAIobject type.
1281    */
1282   function analyse_fai_object($attr)
1283   {
1284     $tmp2 = array();
1285     if(!isset($attr['description'])){
1286       $attr['description'][0] ="";
1287     }
1288     if(in_array('FAIpackageList',$attr['objectClass'])){
1289       $tmp2["Type"]   = 'FAIpackageList'; 
1290       $tmp2["Abbr"]   = 'Pl';
1291       $tmp2["Desc"]  = $attr['description'][0];
1292     }
1293     if(in_array('FAItemplate',$attr['objectClass'])){
1294       $tmp2["Type"]      = 'FAItemplate'; 
1295       $tmp2["Abbr"]      = 'T'; 
1296       $tmp2["Desc"]  = $attr['description'][0];
1297     }
1298     if(in_array('FAIvariable',$attr['objectClass'])){
1299       $tmp2["Type"]      = 'FAIvariable'; 
1300       $tmp2["Abbr"]      = 'V'; 
1301       $tmp2["Desc"]  = $attr['description'][0];
1302     }
1303     if(in_array('FAIscript',$attr['objectClass'])){
1304       $tmp2["Type"]        = 'FAIscript'; 
1305       $tmp2["Abbr"]        = 'S'; 
1306       $tmp2["Desc"]  = $attr['description'][0];
1307     }
1308     if(in_array('FAIhook',$attr['objectClass'])){
1309       $tmp2["Type"]          = 'FAIhook'; 
1310       $tmp2["Abbr"]          = 'H'; 
1311       $tmp2["Desc"]  = $attr['description'][0];
1312     }
1313     if(in_array('FAIpartitionTable',$attr['objectClass'])){
1314       $tmp2["Type"]= 'FAIpartitionTable'; 
1315       $tmp2["Abbr"]= 'Pt'; 
1316       $tmp2["Desc"]  = $attr['description'][0];
1317     }
1318     if(in_array('FAIprofile',$attr['objectClass'])){
1319       $tmp2["Type"]= 'FAIprofile'; 
1320       $tmp2["Abbr"]= 'P'; 
1321       $tmp2["Desc"]  = $attr['description'][0];
1322     }
1323     return($tmp2);
1324   }
1327   /* Return repository hook output, if possible.
1328    */
1329   function GetHookElements()
1330   {
1331     $ret = array();
1332     $cmd= $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs'));
1333     if(!empty($cmd)){
1334       $res = shell_exec($cmd);
1335       $res2 = trim($res);
1336       if((!$res)){
1337         msg_dialog(_("Configuration error"), msgPool::cmdexecfailed("REPOSITORY_HOOK", $cmd), ERROR_DIALOG);
1338       }elseif(empty($res2)){
1339         msg_dialog(_("Configuration error"), _("REPOSITORY_HOOK returned no result!"), ERROR_DIALOG);
1340       }else{
1341         $tmp = split("\n",$res);
1342         foreach($tmp as $line){
1343           if(empty($line)) continue;
1344           $ret[]= $line;
1345         }
1346       }
1347     }
1348     return($ret);
1349   }
1352   /* This function creates the release name out of a dn 
1353    *  e.g. "ou=1.0rc2,ou=siga,ou=fai,..." => "siga/1.0rc2"
1354    */
1355   function dn_to_release_name($dn)
1356   {
1357     $relevant = preg_replace("/,".normalizePreg(get_ou("faiou")).".*$/","",$dn);
1358     $parts    = array_reverse(split("\,",$relevant));
1359     $str ="";
1360     foreach($parts as $part){
1361       $str .= preg_replace("/^ou=/","",$part)."/";
1362     }
1363     return(preg_replace("/\/$/","",$str)); 
1364   }
1367 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1368 ?>