Code

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