Code

Added release patch from glg.
[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       if(in_array('FAIpackageList',$attr['objectClass'])){
147         $tmp2[$cn]['FAIpackageList']['obj']   = 'FAIpackageList'; 
148         $tmp2[$cn]['FAIpackageList']['kzl']   = 'Pl';
149         $tmp2[$cn]['FAIpackageList']['sec']   = $attr['FAIdebianSection'];
150         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
151       }
152       if(in_array('FAItemplate',$attr['objectClass'])){
153         $tmp2[$cn]['FAItemplate']['obj']      = 'FAItemplate'; 
154         $tmp2[$cn]['FAItemplate']['kzl']      = 'T'; 
155         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
156       }
157       if(in_array('FAIvariable',$attr['objectClass'])){
158         $tmp2[$cn]['FAIvariable']['obj']      = 'FAIvariable'; 
159         $tmp2[$cn]['FAIvariable']['kzl']      = 'V'; 
160         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
161       }
162       if(in_array('FAIscript',$attr['objectClass'])){
163         $tmp2[$cn]['FAIscript']['obj']        = 'FAIscript'; 
164         $tmp2[$cn]['FAIscript']['kzl']        = 'S'; 
165         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
166       }
167       if(in_array('FAIhook',$attr['objectClass'])){
168         $tmp2[$cn]['FAIhook']['obj']          = 'FAIhook'; 
169         $tmp2[$cn]['FAIhook']['kzl']          = 'H'; 
170         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
171       }
172       if(in_array('FAIpartitionTable',$attr['objectClass'])){
173         $tmp2[$cn]['FAIpartitionTable']['obj']= 'FAIpartitionTable'; 
174         $tmp2[$cn]['FAIpartitionTable']['kzl']= 'Pt'; 
175         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
176       }
177       if(in_array('FAIprofile',$attr['objectClass'])){
178         $tmp2[$cn]['FAIprofile']['obj']= 'FAIprofile'; 
179         $tmp2[$cn]['FAIprofile']['kzl']= 'P'; 
180         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
181       }
182     }
183     if(is_array($this->FAIclasses)){
184       natcasesort($this->FAIclasses);
185     }
187     $this->FAIclassInfo = $tmp2;
189     if((isset($this->FAIclass))&&(!is_array($this->FAIclass))){
190       $tmp = array();
191       $tmp = split(" ",$this->FAIclass);
192       $tmp2 =array();  
193     
194       foreach($tmp as $class){
195         if( ":" == $class[0] ) {
196           $this->FAIrelease = substr( $class, 1 );
197         }
198         else
199           $tmp2[$class] = $class;
200       }
201       $this->FAIclass = $tmp2;
202     }
204     if(!is_array($this->FAIclass)){
205       $this->FAIclass =array();
206     }
208     $this->orig_dn= $this->dn;
209   }
211   /* Create array to display available classes/profiles in a selectbox */
212   function selectFriendlyClasses(){
213     $tmp=array();
214     foreach($this->FAIclasses as $class){
215       $str    = "";
216       $skip = false;
218       if(isset($this->FAIclassInfo[$class])){
219         foreach($this->FAIclassInfo[$class] as $objs){
220           $str .= $objs['kzl']." "; 
221         }
222       }
223       $tmp[$class] = $class."&nbsp; [".$str."]";
224     }
225     return($tmp);
226   }
228   function check()
229   {
230     $messages = array();
231     /* If there are packages selected, but no mirror show error */   
232     if(($this->FAIdebianMirror == "none")&&(count($this->FAIclass)>0)){
233       $messages[]=_("Please select a 'FAI server' or remove the 'FAI classes'.");
234     }
235     return($messages);
236   }
238   function execute()
239   {
240         /* Call parent execute */
241         plugin::execute();
243     /* Do we need to flip is_account state? */
244     if (isset($_POST['modify_state'])){
245       $this->is_account= !$this->is_account;
246     }
248     /* Do we represent a valid terminal? */
249     if (!$this->is_account && $this->parent == NULL){
250       $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
251         _("This 'dn' has no terminal features.")."</b>";
252       return ($display);
253     }
255     /* Add module */
256     if (isset ($_POST['add_module'])){
257       if ($_POST['module'] != "" && chkacl ($this->acl, "gotoModule") == ""){
258         $this->add_list ($this->gotoModules, $_POST['module']);
259       }
260     }
262     /* Delete module */
263     if (isset ($_POST['delete_module'])){
264       if (count($_POST['modules_list']) && chkacl ($this->acl, "gotoModule") == ""){
265         $this->del_list ($this->gotoModules, $_POST['modules_list']);
266       }
267     }
269     /* FAI class management */
270     if((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))){
271       $found = 0 ; 
273       /* If this new class/profile will attach a second partition table
274        * to our list of classes, abort and show a message.
275        */
276       foreach($this->FAIclass as $name){
277         if(isset($this->FAIclassInfo[$name])){
278           foreach($this->FAIclassInfo[$name] as $atr){
279             if($atr['obj'] == "FAIpartitionTable"){
280               $found ++ ; 
281             }
282           }
283         }
284       }
286       if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpartitionTable']))&&($found>0)){
287         print_red(_("There is already a profile in your selection that contain partition table configurations."));
288       }else{
289         $this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel'];
290       }
291     }
293     $sort = false;
294     foreach($_POST as $name => $val){
295       
296       $sort_type = false;
297       if((preg_match("/sort_up/",$name))&&(!$sort)){
298         $sort_type = "sort_up_";
299       }
300       if((preg_match("/sort_down/",$name))&&(!$sort)){
301         $sort_type = "sort_down_";
302       }
303     
304       if(($sort_type)&&(!$sort)){
305         $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name)));
306         $sort = true;
307         
308         $last = -1;
309         $change_down  = -1;
310  
311         /* Create array with numeric index */ 
312         $tmp = array();
313         foreach($this->FAIclass as $class){
314           $tmp [] = $class;
315         }
317         /* Walk trough array */
318         foreach($tmp as $key => $faiName){
319           if($faiName == $value){
320             if($sort_type == "sort_up_"){
321               if($last != -1){
322                  $change_down= $last;
323               }
324             }else{
325               if(isset($tmp[$key+1])){
326                 $change_down = $key;
327               }
328             }
329           }
330           $last = $key;
331         }
332  
333         $tmp2 = array();
334         $skip = false;    
335   
336         foreach($tmp as $ky => $vl){
338           if($ky == $change_down){
339             $skip = $vl;
340           }else{
341             $tmp2[$vl] = $vl;
342           }
343           if(($skip != false)&&($ky != $change_down)){
344             $tmp2[$skip]  = $skip;
345             $skip =false;
346           }
347         }   
348         $this->FAIclass = $tmp2; 
349       }
350   
351       if(preg_match("/fai_remove/i",$name)){
352         $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/fai_remove_/i","",$name)));
353         unset($this->FAIclass[$value]);
354       }
355     }
357     /* Delete selected class from our list */
358     if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){
359       if(isset($this->FAIclass[$_POST['FAIclassSel']])){
360         unset($this->FAIclass[$_POST['FAIclassSel']]);
361       }
362     }
364     /* Show main page */
365     $smarty= get_smarty();
367     /* In this section server shares will be defined
368      * A user can select one of the given shares and a mount point
369      *  and attach this combination to his setup.
370      */
371     $smarty->assign("gotoShareSelections",    $this->gotoShareSelections);
372     $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections));
374     /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry
375      * This entry will be, a combination of mountPoint and sharedefinitions
376      */
377     if(isset($_POST['gotoShareAdd'])){
378       /* We assign a share to this user, if we don't know where to mount the share */
379       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
380         print_red(_("You must specify a valid mount point."));
381       }else{
382         $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
383         $s_mount = $_POST['gotoShareMountPoint'];
384         /* Preparing the new assignment */
385         $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
386         $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
387       }
388     }
390     /* if the Post  gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected)
391      * If there is no defined share selected, we will abort the deletion without any message
392      */
393     if((isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){
394       unset($this->gotoShares[$_POST['gotoShare']]);
395     }
397     $smarty->assign("gotoShares",$this->printOutAssignedShares());
398     $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares()));
400     /* Arrays */
401     $smarty->assign("ldapservers", $this->config->data['SERVERS']['LDAP']);
402     $smarty->assign("gotoLdapServer_select", $this->gotoLdapServer);
403     $smarty->assign("gotoLdapServerACL", chkacl($this->acl, "gotoLdapServer"));
404     foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
405       $smarty->assign("$val", $this->$val);
406     }
408     /* Values */
409     foreach(array("gotoBootKernel", "customParameters", "gotoShare","FAIclasses","FAIclass","FAIdebianMirror","FAIrelease") as $val){
410       $smarty->assign($val, $this->$val);
411       $smarty->assign($val."ACL", chkacl($this->acl, $val));
412     }
414     $div = new divSelectBox("WSFAIscriptClasses");
415     
416     $div -> SetHeight("110");
418     $str_up     = " &nbsp;<input type='image' src='images/sort_up.png'    name='sort_up_%s'    value='%s'>";
419     $str_down   = " &nbsp;<input type='image' src='images/sort_down.png'  name='sort_down_%s'  value='%s'>";
420     $str_remove = " &nbsp;<input type='image' src='images/edittrash.png'  name='fai_remove_%s' value='%s'>";
421     $str_empty  = " &nbsp;<img src='images/empty.png' alt=\"\" width='7'>"; 
423     $i = 1;
425     foreach($this->FAIclass as $class){
426       if($i==1){
427         $str = $str_empty.$str_down.$str_remove;
428       }elseif($i == count($this->FAIclass)){
429         $str = $str_up.$str_empty.$str_remove;
430       }else{
431         $str = $str_up.$str_down.$str_remove;
432       }
433       $i ++ ; 
434     
435       $div->AddEntry(array(
436                        array("string"=>$class),
437                        array("string"=>preg_replace("/\%s/",base64_encode($class),$str),"attach"=>"style='width:50px;border-right:none;'")
438                     ));
439     }  
441     $smarty->assign("FAIScriptlist",$div->DrawList()); 
442     $smarty->assign("FAIdebianMirrors",$this->getFAIdebianMirrors());
443     $smarty->assign("FAIreleases",$this->getFAIreleases());
444     $smarty->assign("FAIrelease",$this->FAIrelease);
445     $smarty->assign("FAIclasses",$this->selectFriendlyClasses());
446     $smarty->assign("FAIclassesKeys",array_flip($this->selectFriendlyClasses()));
447     $smarty->assign("FAIclassKeys",$this->FAIclass);
449     /* Radio button group */
450     if (preg_match("/G/", $this->bootmode)) {
451       $smarty->assign("graphicalbootup", "checked");
452     } else {
453       $smarty->assign("graphicalbootup", "");
454     }
455     if (preg_match("/T/", $this->bootmode)) {
456       $smarty->assign("textbootup", "checked");
457     } else {
458       $smarty->assign("textbootup", "");
459     }
460     if (preg_match("/D/", $this->bootmode)) {
461       $smarty->assign("debugbootup", "checked");
462     } else {
463       $smarty->assign("debugbootup", "");
464     }
466     /* ACL's */
467     foreach (array("gotoKernelParameters", "gotoModules", "gotoFilesystem","FAIclass") as $value){
468       $smarty->assign($value."ACL", chkacl($this->acl, "$value"));
469     }
471     /* Show main page */
472     return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE,dirname(__FILE__))));
473   }
475   function remove_from_parent()
476   {
477     $this->handle_post_events("remove");
478   }
481   function getFAIdebianMirrors()
482   {
483     $ret = array();
484     $ret['auto']=_("automatic");
485     $secs  = array();
486     if(is_array($this->FAIclass)){
487       foreach($this->FAIclass as $classes){
488         if(isset($this->FAIclassInfo[ $classes]['FAIpackageList']['sec'])){
489           if(isset($this->FAIclassInfo[ $classes]['FAIpackageList']['sec']['count'])){
490             unset($this->FAIclassInfo[ $classes]['FAIpackageList']['sec']['count']);
491           }
492           if(is_array($this->FAIclassInfo[ $classes]['FAIpackageList']['sec'])){
493             foreach($this->FAIclassInfo[ $classes]['FAIpackageList']['sec'] as $sec => $value){
494               $secs[$value]= $value;
495             }
496           }
497         }
498       }
499     }
500     if(is_array($this->FAIdebianMirrors)){
501       foreach($this->FAIdebianMirrors as $mirr=>$sections){
502         $allok = true;
503         foreach($secs as $sec){
504           if(!in_array($sec,$sections)){
505             $allok = false;
506           }
507         }
508         if($allok){
509           $ret[$mirr]=$mirr;
510         }
511       }
512     }
513     return($ret);
514   }
516   function getFAIreleases() 
517   {
518     $ret = array();
519     if(is_array($this->FAIreleases)) {
520       foreach($this->FAIreleases as $mirr=>$releases){
521         if( $this->FAIdebianMirror == $mirr ) {
522           foreach ($releases as $release) 
523             $ret[$release] = $release;
524           return($ret);
525         }
526       }
527     }
528     return($ret);
529   }
531   /* Save data to object */
532   function save_object()
533   {
534     plugin::save_object();
536     /* Save group radio buttons */
537     if (chkacl ($this->acl, "bootmode") == "" && isset($_POST["bootmode"])){
538       $this->bootmode= $_POST["bootmode"];
539     }
541     /* Save kernel parameters */
542     if (chkacl ($this->acl, "gotoKernelParameters") == "" && isset($_POST["customParameters"])){
543       $this->customParameters= $_POST["customParameters"];
544     }
545   }
548   /* Save to LDAP */
549   function save()
550   {
552     /* Depending on the baseobject (Ogroup / WS) we
553      *  use another set of objectClasses
554      * In case of WS itself, we use  "array("GOhard", "FAIobject");"
555      * if we are currently editing from ogroup menu we use (array("gotWorkstationTemplate","GOhard", "FAIobject"))
556      */
557     if(isset($this->parent->by_object['ogroup'])){
558       $this->objectclasses = array("gotoWorkstationTemplate","GOhard", "FAIobject");
559     }elseif(isset($this->parent->by_object['workgeneric'])){
560       $this->objectclasses = array("GOhard", "FAIobject");
561     }else{
562       print "unknown";
563       exit();
564     }
566     /* Find proper terminal path for tftp configuration
567        FIXME: This is suboptimal when the default has changed to
568        another location! */
569     if ($this->gotoTerminalPath == "default"){
570       $ldap= $this->config->get_ldap_link();
572       /* Strip relevant part from dn, keep trailing ',' */
573       $tmp= preg_replace("/^cn=[^,]+,ou=terminals,ou=systems,/i", "", $this->dn);
574       $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp);
576       /* Walk from top to base and try to load default values for
577          'gotoTerminalPath'. Abort when an entry is found. */
578       while (TRUE){
579         $tmp= preg_replace ("/^[^,]+,/", "", $tmp);
581         $ldap->cat("cn=default,ou=terminals,ou=systems,$tmp".
582             $this->config->current['BASE']);
583         $attrs= $ldap->fetch();
584         if (isset($attrs['gotoTerminalPath'])){
585           $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0];
586           break;
587         }
589         /* Nothing left? */
590         if ($tmp == ""){
591           break;
592         }
593       }
594     }
596     /* Add semi automatic values */
597     // FIXME: LDAP Server may not be set here...
598     $this->gotoKernelParameters= "root=/dev/nfs nfsroot=".
599       $this->gotoTerminalPath.
600       ",ro,hard,nolock,fg,rsize=8192 ".
601       "ip=::::::dhcp ldap=".base64_encode($this->gotoLdapServer);
603     switch ($this->bootmode){
604       case "D":
605         $this->gotoKernelParameters.= " debug";
606       break;
607       case "G":
608         $this->gotoKernelParameters.= " splash=silent";
609       break;
610     }
611     if ($this->customParameters != ""){
612       $this->gotoKernelParameters.= " o ".$this->customParameters;
613     }
615     plugin::save();
617     unset( $this->attrs['FAIrelease'] );
618     
619     $str = "";
620     foreach($this->FAIclass as $class){
621       $str .= $class." ";
622     }
623     $str .= ":" . $this->FAIrelease;
624     $this->attrs['FAIclass']= "";
625     $this->attrs['FAIclass']= trim($str);
627     if(empty($this->attrs['FAIclass'])){
628       $this->attrs['FAIclass'] = array();
629     }
631     /* Add missing arrays */
632     foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){
633       if (isset ($this->$val) && count ($this->$val) != 0){
634     
635         $this->attrs["$val"]= array_unique($this->$val);
636       }
637       if(!isset($this->attrs["$val"])) $this->attrs["$val"]=array();
638     }
639     /* Strip out 'default' values */
640     if ($this->attrs['gotoLdapServer'] == "default"){
641       unset ($this->attrs['gotoLdapServer']);
642     }
644     /* if mirror == none stop saving this attribute */
645     if($this->FAIdebianMirror == "none"){
646       $this->FAIdebianMirror = "";
647     }
648     
649     if((count($this->attrs['FAIclass'])==0)&&(empty($this->FAIdebianMirror))){
650       $tmp = array();
651       foreach($this->attrs['objectClass'] as $class){
652         if($class != "FAIobject"){
653           $tmp[] = $class;
654         }
655       }
656       $this->attrs['objectClass']     = $tmp;
657       $this->attrs['FAIclass']        = array();
658       $this->attrs['FAIdebianMirror'] = array();
659     }
661     /* prepare share settings */
662     $tmp = array();
663     foreach($this->gotoShares as $name => $settings){
664       $tmp2= split("\|",$name);
665       $name = $tmp2[0];
666       $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint'];
667     }
668     $this->attrs['gotoShare']=$tmp;
670     $ldap= $this->config->get_ldap_link();
671     $ldap->cd($this->dn);
672     $this->cleanup();
673 $ldap->modify ($this->attrs); 
675     show_ldap_error($ldap->get_error());
676     $this->handle_post_events("modify");
677   }
679   /* Add value to array, check if unique */
680   function add_list (&$array, $value)
681   {
682     if ($value != ""){
683       $array[]= $value;
684       sort($array);
685       array_unique ($array);
686     }
687   }
690   /* Delete value to array, check if unique */
691   function del_list (&$array, $list)
692   {
693     $tmp= array();
694     foreach ($array as $mod){
695       if (!in_array($mod, $list)){
696         $tmp[]= $mod;
697       }
698     }
699     $array= $tmp;
700   }
702   /* Generate ListBox frindly output for the defined shares
703    * Possibly Add or remove an attribute here,
704    */
705   function printOutAssignedShares()
706   {
707     $a_return = array();
708     if(is_array($this->gotoShares)){
709       foreach($this->gotoShares as $share){
710         $a_return[$share['name']."|".$share['server']]= $share['name']." [".$share['server']."]";
711       }
712     }
713     return($a_return);
714   }
718 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
719 ?>