Code

Updated FAI release/class selection
[gosa.git] / plugins / admin / systems / class_workstationStartup.inc
1 <?php
2 class workstartup extends plugin
3 {
4   /* CLI vars */
5   var $cli_summary= "Manage terminal startup options";
6   var $cli_description= "Some longer text\nfor help";
7   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
9   /* Generic terminal attributes */
10   var $bootmode             = "G";
11   var $goLdapServerList     = array("default");
12   var $gotoBootKernel       = "default";
13   var $gotoKernelParameters = "";
14   var $gotoLdapServer       = "";
15   var $gotoModules          = array();
16   var $gotoAutoFs           = array();
17   var $gotoFilesystem       = array();
18   var $gotoTerminalPath     = "";
19   var $FAIstatus            = "";
20   var $FAIclass             = array();
21   var $FAIclasses           = array();
22   var $FAIclassInfo         = array();
23   var $FAIdebianMirror      = "auto";
26   /* attribute list for save action */
27   var $attributes     = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "FAIclass", "FAIstatus", "gotoShare","FAIdebianMirror", "FAIrelease");
28   var $objectclasses  = array("GOhard", "FAIobject");
30   /* Share */
31   var $gotoShares         = array();// Currently Share Option
32   var $gotoShare          = "";     // currently selected Share Option
33   var $gotoShareSelections= array();// Available Shares for this account in Listbox format
34   var $gotoAvailableShares= array();// Available Shares for this account
36   /* Helper */
37   var $customParameters   = "";
38   var $orig_dn            = "";
39   var $ignore_account     = TRUE;
40   var $FAIdebianMirrors   = array();
41   var $FAIrelease         = "";
42   var $FAIreleases        = array();
44   function workstartup ($config, $dn= NULL)
45   {
46     plugin::plugin ($config, $dn);
48     /* Creating a list of valid Mirrors 
49      * none will not be saved to ldap.
50      */
51     $this->FAIdebianMirrors   = array();
52     $this->FAIreleases        = array();
54     $ldap   = $this->config->get_ldap_link();
55     $ldap->cd($this->config->current['BASE']);
56     $ldap->search("(objectClass=FAIrepositoryServer)",array("FAIrepository"));
57     
58     /* attach all attributes with "index => cn" to avoid multiple entries */
59     $ret = array();
60     $rels = array();
61     while($attr = $ldap->fetch()){
62       if(isset($attr['FAIrepository'])){
63         
64         unset($attr['FAIrepository']['count']);
66         foreach($attr['FAIrepository'] as $rep){
67           $tmp = split("\|",$rep);
68           $str = "";
69           if(count($tmp)==4){
70             $sections = split(",",$tmp[3]);
71             $str = $tmp[0];
72             $ret[$str]=$sections;
73             if( array_key_exists( $str, $rels ) ) {
74               if( "" == $this->FAIrelease )
75                 $this->FAIrelease = $tmp[2];
76               array_push( $rels[$str], $tmp[2] );
77             }
78             else $rels[$str] = array( $tmp[2] );
79           }
80         }
81       }
82     }
83     ksort($ret);
84     ksort($rels);
85     $this->FAIdebianMirrors = $ret;
86     $this->FAIreleases = $rels;
88     /* Get arrays */
89     foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
90       if (isset($this->attrs["$val"]["count"])){
91         for ($i= 0; $i<$this->attrs["count"]; $i++){
92           if (isset($this->attrs["$val"][$i])){
93             array_push($this->$val, $this->attrs["$val"][$i]);
94           }
95         }
96       }
97       sort ($this->$val);
98       $this->$val= array_unique($this->$val);
99     }
101     /* Parse Kernel Parameters to decide what boot mode is enabled */
102     if (preg_match("/ splash=silent/", $this->gotoKernelParameters)){
103       $this->bootmode= "G";
104     } elseif (preg_match("/ debug/", $this->gotoKernelParameters)){
105       $this->bootmode= "D";
106     } elseif ($this->gotoKernelParameters == "") {
107       $this->bootmode= "G";
108     } else {
109       $this->bootmode= "T";
110     }
111     if (preg_match("/ o /", $this->gotoKernelParameters)){
112       $this->customParameters= preg_replace ("/^.* o /", "", $this->gotoKernelParameters);
113     } else {
114       $this->customParameters= "";
115     }
117     /* Prepare Shares */
118     if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){
119       unset($this->attrs['gotoShare']['count']);
120       foreach($this->attrs['gotoShare'] as $share){
121         $tmp = $tmp2 = array();
122         $tmp = split("\|",$share);
123         $tmp2['server']      =$tmp[0];
124         $tmp2['name']        =$tmp[1];
125         $tmp2['mountPoint']  =$tmp[2];
126         $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2;
127       }
128     }
130     $this->gotoShareSelections= $config->getShareList(true);
131     $this->gotoAvailableShares= $config->getShareList(false);
132     $tmp2 = array();
133   
134     $ldap   = $this->config->get_ldap_link();
135     $ldap->cd($this->config->current['BASE']);
137     /* Search all FAI objects */
138     $ldap->search("(| (objectClass=FAIpackageList)(objectClass=FAItemplate)
139                       (objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)(objectClass=FAIprofile)
140                       (objectClass=FAIpartitionTable))",array("*"),true);
141     /* Sort all entries, and attach elementtype.
142      * To be able to show the types in the listbox.
143      */
144     while($attr = $ldap->fetch()){
145       $cn = $attr['cn'][0];
146       $tmp2[$cn]['REST'] = $attr;
147       if(in_array('FAIpackageList',$attr['objectClass'])){
148         $tmp2[$cn]['FAIpackageList']['obj']   = 'FAIpackageList'; 
149         $tmp2[$cn]['FAIpackageList']['kzl']   = 'Pl';
150         $tmp2[$cn]['FAIpackageList']['sec']   = $attr['FAIdebianSection'];
151         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
152       }
153       if(in_array('FAItemplate',$attr['objectClass'])){
154         $tmp2[$cn]['FAItemplate']['obj']      = 'FAItemplate'; 
155         $tmp2[$cn]['FAItemplate']['kzl']      = 'T'; 
156         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
157       }
158       if(in_array('FAIvariable',$attr['objectClass'])){
159         $tmp2[$cn]['FAIvariable']['obj']      = 'FAIvariable'; 
160         $tmp2[$cn]['FAIvariable']['kzl']      = 'V'; 
161         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
162       }
163       if(in_array('FAIscript',$attr['objectClass'])){
164         $tmp2[$cn]['FAIscript']['obj']        = 'FAIscript'; 
165         $tmp2[$cn]['FAIscript']['kzl']        = 'S'; 
166         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
167       }
168       if(in_array('FAIhook',$attr['objectClass'])){
169         $tmp2[$cn]['FAIhook']['obj']          = 'FAIhook'; 
170         $tmp2[$cn]['FAIhook']['kzl']          = 'H'; 
171         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
172       }
173       if(in_array('FAIpartitionTable',$attr['objectClass'])){
174         $tmp2[$cn]['FAIpartitionTable']['obj']= 'FAIpartitionTable'; 
175         $tmp2[$cn]['FAIpartitionTable']['kzl']= 'Pt'; 
176         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
177       }
178       if(in_array('FAIprofile',$attr['objectClass'])){
179         $tmp2[$cn]['FAIprofile']['obj']= 'FAIprofile'; 
180         $tmp2[$cn]['FAIprofile']['kzl']= 'P'; 
181         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
182       }
183     }
184     if(is_array($this->FAIclasses)){
185       natcasesort($this->FAIclasses);
186     }
188     $this->FAIclassInfo = $tmp2;
190     if((isset($this->FAIclass))&&(!is_array($this->FAIclass))){
191       $tmp = array();
192       $tmp = split(" ",$this->FAIclass);
193       $tmp2 =array();  
194     
195       foreach($tmp as $class){
196         if( ":" == $class[0] ) {
197           $this->FAIrelease = substr( $class, 1 );
198         }
199         else
200           $tmp2[$class] = $class;
201       }
202       $this->FAIclass = $tmp2;
203     }
205     if(!is_array($this->FAIclass)){
206       $this->FAIclass =array();
207     }
209     $this->orig_dn= $this->dn;
210   }
212   /* Create array to display available classes/profiles in a selectbox */
213   function selectFriendlyClasses(){
214     $tmp=array();
216     $tmp2 = $this->getFAIreleases();
217     if(!in_array($this->FAIrelease, $tmp2)){  
218       $this->FAIrelease = key($tmp2);
219     }
222     foreach($this->FAIclasses as $class){
223       //  (!preg_match("/ou=".$this->FAIrelease."/",$this->FAIclassInfo[$class]['REST']['dn']))
224       if(($this->FAIdebianMirror != "auto") && (stristr($this->FAIclassInfo[$class]['REST']['dn'],"ou=".$this->FAIrelease) == false)){
225         continue;
226       }
227       $str    = "";
228       $skip = false;
230       if(isset($this->FAIclassInfo[$class])){
231         foreach($this->FAIclassInfo[$class] as $objs){
232           if (isset($objs['kzl'])){
233             $str .= $objs['kzl']." "; 
234           }
235         }
236       }
237       $tmp[$class] = $class."&nbsp; [".$str."]";
238     }
239     return($tmp);
240   }
242   function check()
243   {
244     $messages = array();
245     /* If there are packages selected, but no mirror show error */   
246     if(($this->FAIdebianMirror == "none")&&(count($this->FAIclass)>0)){
247       $messages[]=_("Please select a 'FAI server' or remove the 'FAI classes'.");
248     }
249     return($messages);
250   }
252   function execute()
253   {
254         /* Call parent execute */
255         plugin::execute();
257     /* Do we need to flip is_account state? */
258     if (isset($_POST['modify_state'])){
259       $this->is_account= !$this->is_account;
260     }
262     /* Do we represent a valid terminal? */
263     if (!$this->is_account && $this->parent == NULL){
264       $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
265         _("This 'dn' has no terminal features.")."</b>";
266       return ($display);
267     }
269     /* Add module */
270     if (isset ($_POST['add_module'])){
271       if ($_POST['module'] != "" && chkacl ($this->acl, "gotoModule") == ""){
272         $this->add_list ($this->gotoModules, $_POST['module']);
273       }
274     }
276     /* Delete module */
277     if (isset ($_POST['delete_module'])){
278       if (count($_POST['modules_list']) && chkacl ($this->acl, "gotoModule") == ""){
279         $this->del_list ($this->gotoModules, $_POST['modules_list']);
280       }
281     }
283     /* FAI class management */
284     if((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))){
285       $found = 0 ; 
287       /* If this new class/profile will attach a second partition table
288        * to our list of classes, abort and show a message.
289        */
290       foreach($this->FAIclass as $name){
291         if(isset($this->FAIclassInfo[$name])){
292           foreach($this->FAIclassInfo[$name] as $atr){
293             if(isset($atr['obj'])){
294               if($atr['obj'] == "FAIpartitionTable"){
295                 $found ++ ; 
296               }
297             }
298           }
299         }
300       }
302       if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpartitionTable']))&&($found>0)){
303         print_red(_("There is already a profile in your selection that contain partition table configurations."));
304       }else{
305         $this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel'];
306       }
307     }
309     $sort = false;
310     foreach($_POST as $name => $val){
311       
312       $sort_type = false;
313       if((preg_match("/sort_up/",$name))&&(!$sort)){
314         $sort_type = "sort_up_";
315       }
316       if((preg_match("/sort_down/",$name))&&(!$sort)){
317         $sort_type = "sort_down_";
318       }
319     
320       if(($sort_type)&&(!$sort)){
321         $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name)));
322         $sort = true;
323         
324         $last = -1;
325         $change_down  = -1;
326  
327         /* Create array with numeric index */ 
328         $tmp = array();
329         foreach($this->FAIclass as $class){
330           $tmp [] = $class;
331         }
333         /* Walk trough array */
334         foreach($tmp as $key => $faiName){
335           if($faiName == $value){
336             if($sort_type == "sort_up_"){
337               if($last != -1){
338                  $change_down= $last;
339               }
340             }else{
341               if(isset($tmp[$key+1])){
342                 $change_down = $key;
343               }
344             }
345           }
346           $last = $key;
347         }
348  
349         $tmp2 = array();
350         $skip = false;    
351   
352         foreach($tmp as $ky => $vl){
354           if($ky == $change_down){
355             $skip = $vl;
356           }else{
357             $tmp2[$vl] = $vl;
358           }
359           if(($skip != false)&&($ky != $change_down)){
360             $tmp2[$skip]  = $skip;
361             $skip =false;
362           }
363         }   
364         $this->FAIclass = $tmp2; 
365       }
366   
367       if(preg_match("/fai_remove/i",$name)){
368         $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/fai_remove_/i","",$name)));
369         unset($this->FAIclass[$value]);
370       }
371     }
373     /* Delete selected class from our list */
374     if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){
375       if(isset($this->FAIclass[$_POST['FAIclassSel']])){
376         unset($this->FAIclass[$_POST['FAIclassSel']]);
377       }
378     }
380     /* Show main page */
381     $smarty= get_smarty();
383     /* In this section server shares will be defined
384      * A user can select one of the given shares and a mount point
385      *  and attach this combination to his setup.
386      */
387     $smarty->assign("gotoShareSelections",    $this->gotoShareSelections);
388     $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections));
390     /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry
391      * This entry will be, a combination of mountPoint and sharedefinitions
392      */
393     if(isset($_POST['gotoShareAdd'])){
394       /* We assign a share to this user, if we don't know where to mount the share */
395       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
396         print_red(_("You must specify a valid mount point."));
397       }else{
398         $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
399         $s_mount = $_POST['gotoShareMountPoint'];
400         /* Preparing the new assignment */
401         $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
402         $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
403       }
404     }
406     /* if the Post  gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected)
407      * If there is no defined share selected, we will abort the deletion without any message
408      */
409     if((isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){
410       unset($this->gotoShares[$_POST['gotoShare']]);
411     }
413     $smarty->assign("gotoShares",$this->printOutAssignedShares());
414     $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares()));
416     /* Arrays */
417     $smarty->assign("ldapservers", $this->config->data['SERVERS']['LDAP']);
418     $smarty->assign("gotoLdapServer_select", $this->gotoLdapServer);
419     $smarty->assign("gotoLdapServerACL", chkacl($this->acl, "gotoLdapServer"));
420     foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
421       $smarty->assign("$val", $this->$val);
422     }
424     /* Values */
425     foreach(array("gotoBootKernel", "customParameters", "gotoShare","FAIclasses","FAIclass","FAIdebianMirror","FAIrelease") as $val){
426       $smarty->assign($val, $this->$val);
427       $smarty->assign($val."ACL", chkacl($this->acl, $val));
428     }
430     $div = new divSelectBox("WSFAIscriptClasses");
431     
432     $div -> SetHeight("110");
434     $str_up     = " &nbsp;<input type='image' src='images/sort_up.png'    name='sort_up_%s'    value='%s'>";
435     $str_down   = " &nbsp;<input type='image' src='images/sort_down.png'  name='sort_down_%s'  value='%s'>";
436     $str_remove = " &nbsp;<input type='image' src='images/edittrash.png'  name='fai_remove_%s' value='%s'>";
437     $str_empty  = " &nbsp;<img src='images/empty.png' alt=\"\" width='7'>"; 
439     $i = 1;
441     foreach($this->FAIclass as $class){
442       if($i==1){
443         $str = $str_empty.$str_down.$str_remove;
444       }elseif($i == count($this->FAIclass)){
445         $str = $str_up.$str_empty.$str_remove;
446       }else{
447         $str = $str_up.$str_down.$str_remove;
448       }
449       $i ++ ; 
450     
451       $div->AddEntry(array(
452                        array("string"=>$class),
453                        array("string"=>preg_replace("/\%s/",base64_encode($class),$str),"attach"=>"style='width:50px;border-right:none;'")
454                     ));
455     }  
457     $smarty->assign("FAIScriptlist",$div->DrawList()); 
458     $smarty->assign("FAIdebianMirrors",$this->getFAIdebianMirrors());
459     $smarty->assign("FAIreleases",$this->getFAIreleases());
460     $smarty->assign("FAIrelease",$this->FAIrelease);
461     $smarty->assign("FAIclasses",$this->selectFriendlyClasses());
462     $smarty->assign("FAIclassesKeys",array_flip($this->selectFriendlyClasses()));
463     $smarty->assign("FAIclassKeys",$this->FAIclass);
465     /* Radio button group */
466     if (preg_match("/G/", $this->bootmode)) {
467       $smarty->assign("graphicalbootup", "checked");
468     } else {
469       $smarty->assign("graphicalbootup", "");
470     }
471     if (preg_match("/T/", $this->bootmode)) {
472       $smarty->assign("textbootup", "checked");
473     } else {
474       $smarty->assign("textbootup", "");
475     }
476     if (preg_match("/D/", $this->bootmode)) {
477       $smarty->assign("debugbootup", "checked");
478     } else {
479       $smarty->assign("debugbootup", "");
480     }
482     /* ACL's */
483     foreach (array("gotoKernelParameters", "gotoModules", "gotoFilesystem","FAIclass") as $value){
484       $smarty->assign($value."ACL", chkacl($this->acl, "$value"));
485     }
487     /* Show main page */
488     return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE,dirname(__FILE__))));
489   }
491   function remove_from_parent()
492   {
493     $this->handle_post_events("remove");
494   }
497   function getFAIdebianMirrors()
498   {
499     $ret = array();
500     $ret['auto']=_("automatic");
501     $secs  = array();
502     if(is_array($this->FAIclass)){
503       foreach($this->FAIclass as $classes){
504         if(isset($this->FAIclassInfo[ $classes]['FAIpackageList']['sec'])){
505           if(isset($this->FAIclassInfo[ $classes]['FAIpackageList']['sec']['count'])){
506             unset($this->FAIclassInfo[ $classes]['FAIpackageList']['sec']['count']);
507           }
508           if(is_array($this->FAIclassInfo[ $classes]['FAIpackageList']['sec'])){
509             foreach($this->FAIclassInfo[ $classes]['FAIpackageList']['sec'] as $sec => $value){
510               $secs[$value]= $value;
511             }
512           }
513         }
514       }
515     }
517     if(is_array($this->FAIdebianMirrors)){
518       foreach($this->FAIdebianMirrors as $mirr=>$sections){
519         $allok = true;
520         foreach($secs as $sec){
521           if(!in_array($sec,$sections)){
522             $allok = false;
523           }
524         }
525         if(count($this->FAIclass)){
526           if(!in_array($this->FAIrelease,$this->FAIreleases[$mirr])){
527             $allok = false; 
528           }
529         }
530         if($allok){
531           $ret[$mirr]=$mirr;
532         }
533       }
534     }
535     return($ret);
536   }
538   function getFAIreleases() 
539   {
540     $ret = array();
541     if(is_array($this->FAIreleases)) {
542       foreach($this->FAIreleases as $mirr=>$releases){
543         if( $this->FAIdebianMirror == $mirr ) {
544           foreach ($releases as $release) 
545             $ret[$release] = $release;
546           return($ret);
547         }
548       }
549     }
550     return($ret);
551   }
553   /* Save data to object */
554   function save_object()
555   {
556     plugin::save_object();
558     /* Save group radio buttons */
559     if (chkacl ($this->acl, "bootmode") == "" && isset($_POST["bootmode"])){
560       $this->bootmode= $_POST["bootmode"];
561     }
563     /* Save kernel parameters */
564     if (chkacl ($this->acl, "gotoKernelParameters") == "" && isset($_POST["customParameters"])){
565       $this->customParameters= $_POST["customParameters"];
566     }
567   }
570   /* Save to LDAP */
571   function save()
572   {
574     /* Depending on the baseobject (Ogroup / WS) we
575      *  use another set of objectClasses
576      * In case of WS itself, we use  "array("GOhard", "FAIobject");"
577      * if we are currently editing from ogroup menu we use (array("gotWorkstationTemplate","GOhard", "FAIobject"))
578      */
579     if(isset($this->parent->by_object['ogroup'])){
580       $this->objectclasses = array("gotoWorkstationTemplate","GOhard", "FAIobject");
581     }elseif(isset($this->parent->by_object['workgeneric'])){
582       $this->objectclasses = array("GOhard", "FAIobject");
583     }else{
584       print "Object Type Configuration : unknown";
585       exit();
586     }
588     /* Find proper terminal path for tftp configuration
589        FIXME: This is suboptimal when the default has changed to
590        another location! */
591     if ($this->gotoTerminalPath == "default"){
592       $ldap= $this->config->get_ldap_link();
594       /* Strip relevant part from dn, keep trailing ',' */
595       $tmp= preg_replace("/^cn=[^,]+,ou=terminals,ou=systems,/i", "", $this->dn);
596       $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp);
598       /* Walk from top to base and try to load default values for
599          'gotoTerminalPath'. Abort when an entry is found. */
600       while (TRUE){
601         $tmp= preg_replace ("/^[^,]+,/", "", $tmp);
603         $ldap->cat("cn=default,ou=terminals,ou=systems,$tmp".
604             $this->config->current['BASE']);
605         $attrs= $ldap->fetch();
606         if (isset($attrs['gotoTerminalPath'])){
607           $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0];
608           break;
609         }
611         /* Nothing left? */
612         if ($tmp == ""){
613           break;
614         }
615       }
616     }
618     /* Add semi automatic values */
619     // FIXME: LDAP Server may not be set here...
620     $this->gotoKernelParameters= "root=/dev/nfs nfsroot=".
621       $this->gotoTerminalPath.
622       ",ro,hard,nolock,fg,rsize=8192 ".
623       "ip=::::::dhcp ldap=".base64_encode($this->gotoLdapServer);
625     switch ($this->bootmode){
626       case "D":
627         $this->gotoKernelParameters.= " debug";
628       break;
629       case "G":
630         $this->gotoKernelParameters.= " splash=silent";
631       break;
632     }
633     if ($this->customParameters != ""){
634       $this->gotoKernelParameters.= " o ".$this->customParameters;
635     }
637     plugin::save();
639     unset( $this->attrs['FAIrelease'] );
640     
641     $str = "";
642     foreach($this->FAIclass as $class){
643       $str .= $class." ";
644     }
645     $str .= ":" . $this->FAIrelease;
646     $this->attrs['FAIclass']= "";
647     $this->attrs['FAIclass']= trim($str);
649     if(empty($this->attrs['FAIclass'])){
650       $this->attrs['FAIclass'] = array();
651     }
653     /* Add missing arrays */
654     foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){
655       if (isset ($this->$val) && count ($this->$val) != 0){
656     
657         $this->attrs["$val"]= array_unique($this->$val);
658       }
659       if(!isset($this->attrs["$val"])) $this->attrs["$val"]=array();
660     }
661     /* Strip out 'default' values */
662     if ($this->attrs['gotoLdapServer'] == "default"){
663       unset ($this->attrs['gotoLdapServer']);
664     }
666     /* if mirror == none stop saving this attribute */
667     if($this->FAIdebianMirror == "none"){
668       $this->FAIdebianMirror = "";
669     }
670     
671     if((count($this->attrs['FAIclass'])==0)&&(empty($this->FAIdebianMirror))){
672       $tmp = array();
673       foreach($this->attrs['objectClass'] as $class){
674         if($class != "FAIobject"){
675           $tmp[] = $class;
676         }
677       }
678       $this->attrs['objectClass']     = $tmp;
679       $this->attrs['FAIclass']        = array();
680       $this->attrs['FAIdebianMirror'] = array();
681     }
683     /* prepare share settings */
684     $tmp = array();
685     foreach($this->gotoShares as $name => $settings){
686       $tmp2= split("\|",$name);
687       $name = $tmp2[0];
688       $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint'];
689     }
690     $this->attrs['gotoShare']=$tmp;
692     $ldap= $this->config->get_ldap_link();
693     $ldap->cd($this->dn);
694     $this->cleanup();
695 $ldap->modify ($this->attrs); 
697     show_ldap_error($ldap->get_error());
698     $this->handle_post_events("modify");
699   }
701   /* Add value to array, check if unique */
702   function add_list (&$array, $value)
703   {
704     if ($value != ""){
705       $array[]= $value;
706       sort($array);
707       array_unique ($array);
708     }
709   }
712   /* Delete value to array, check if unique */
713   function del_list (&$array, $list)
714   {
715     $tmp= array();
716     foreach ($array as $mod){
717       if (!in_array($mod, $list)){
718         $tmp[]= $mod;
719       }
720     }
721     $array= $tmp;
722   }
724   /* Generate ListBox frindly output for the defined shares
725    * Possibly Add or remove an attribute here,
726    */
727   function printOutAssignedShares()
728   {
729     $a_return = array();
730     if(is_array($this->gotoShares)){
731       foreach($this->gotoShares as $share){
732         $a_return[$share['name']."|".$share['server']]= $share['name']." [".$share['server']."]";
733       }
734     }
735     return($a_return);
736   }
740 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
741 ?>