Code

eaa4c8f8d6fd558af5936390e30736736b9a391d
[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   /* Ldap server list */
10   var $gotoLdapServers    = array();
11   var $gotoLdapServerList = array();
12   var $gotoLdap_inherit   = FALSE;
14   /* Generic terminal attributes */
15   var $bootmode             = "G";
16   var $gotoBootKernel       = "default-inherited";
17   var $gotoKernelParameters = "";
18   var $gotoLdapServer       = "default-inherited";
19   var $gotoModules          = array();
20   var $gotoAutoFs           = array();
21   var $gotoFilesystem       = array();
22   var $gotoTerminalPath     = "";
23   var $FAIstatus            = "";
24   var $gotoBootKernels      = array();
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  
41   /* FAI class selection */ 
42   var $FAIclass           = array();
43   var $FAIclasses         = array();
44   var $FAIclassInfo       = array();
45   var $FAIrelease         = "";
46   var $FAIdebianMirror    = "auto";
48   var $unresolved_classes = array();
49   var $view_logged        = FALSE;
50   
51   /* FAI class selection */
52   var $InheritedFAIclass           = array();
53   var $InheritedFAIrelease         = "";
54   var $InheritedFAIdebianMirror    = "auto";
56   /* Contains all possible server/release/class settings */
57   var $FAIServRepConfig   = array();
59   var $CopyPasteVars = array("gotoModules","gotoShares");
61   var $fai_activated = FALSE;
63   var $member_of_ogroup   = FALSE;
65   function workstartup (&$config, $dn= NULL, $parent= NULL)
66   {
67     /* Check if FAI is active */
68     $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs'));
69     if(!empty($tmp)){
70       $this->fai_activated = TRUE;
71     }else{
72       $this->attributes = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "gotoShare");
73       $this->objectclasses  = array("GOhard");
74     }
76     plugin::plugin ($config, $dn, $parent);
78     if(!isset($this->parent->by_object['ogroup'])){
79       $ldap = $this->config->get_ldap_link();
80       $ldap->cd ($this->config->current['BASE']);
81       $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))",array("cn"));
82       $this->member_of_ogroup = $ldap->count() >= 1;
83     }
85     /* Creating a list of valid Mirrors 
86      * none will not be saved to ldap.
87      */
88     $ldap   = $this->config->get_ldap_link();
89     $ldap->cd($this->config->current['BASE']);
91     foreach($this->config->data['SERVERS']['LDAP'] as $server) {
92       $this->gotoLdapServerList[]= $server; 
93     }
94  
95     if(isset($this->attrs['gotoLdapServer'])){
96       unset($this->attrs['gotoLdapServer']['count']);
97       sort($this->attrs['gotoLdapServer']);
98       foreach($this->attrs['gotoLdapServer'] as $value){
99         $this->gotoLdapServers[] = preg_replace("/^[0-9]*:/","",$value);
100       }
101     }
102     if(!count($this->gotoLdapServers)){ 
103       $this->gotoLdap_inherit = TRUE;
104     }
106     /* FAI Initialization
107        Skip this if FAI is not activated 
108      */
109       if($this->fai_activated) {
111       $_SESSION['getAvailableClassesForThisRelease_CACHE'] = array();
112       $_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'] = array();
114       /* Search all FAI objects */
115       $ldap->search("(|(objectClass=FAIpackageList)(objectClass=FAItemplate)(objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)(objectClass=FAIprofile)(objectClass=FAIpartitionTable))",array("cn","objectClass","FAIdebianSection",'description'));
116       /* Sort all entries, and attach elementtype.
117        * To be able to show the types in the listbox.
118        */
119       while($attr = $ldap->fetch()){
120         $cn = $attr['cn'][0];
121       
122         if(!isset($attr['description'])){
123           $attr['description'][0] ="";
124         }
126         $_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'][] = $attr;
127    
128         if(in_array('FAIpackageList',$attr['objectClass'])){
129           $tmp2[$cn]['FAIpackageList']['obj']   = 'FAIpackageList'; 
130           $tmp2[$cn]['FAIpackageList']['kzl']   = 'Pl';
131           $tmp2[$cn]['FAIpackageList']['sec']   = $attr['FAIdebianSection'];
132           $tmp2[$cn]['FAIpackageList']['desc']  = $attr['description'];
133           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
134         }
135         if(in_array('FAItemplate',$attr['objectClass'])){
136           $tmp2[$cn]['FAItemplate']['obj']      = 'FAItemplate'; 
137           $tmp2[$cn]['FAItemplate']['kzl']      = 'T'; 
138           $tmp2[$cn]['FAItemplate']['desc']  = $attr['description'];
139           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
140         }
141         if(in_array('FAIvariable',$attr['objectClass'])){
142           $tmp2[$cn]['FAIvariable']['obj']      = 'FAIvariable'; 
143           $tmp2[$cn]['FAIvariable']['kzl']      = 'V'; 
144           $tmp2[$cn]['FAIvariable']['desc']  = $attr['description'];
145           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
146         }
147         if(in_array('FAIscript',$attr['objectClass'])){
148           $tmp2[$cn]['FAIscript']['obj']        = 'FAIscript'; 
149           $tmp2[$cn]['FAIscript']['kzl']        = 'S'; 
150           $tmp2[$cn]['FAIscript']['desc']  = $attr['description'];
151           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
152         }
153         if(in_array('FAIhook',$attr['objectClass'])){
154           $tmp2[$cn]['FAIhook']['obj']          = 'FAIhook'; 
155           $tmp2[$cn]['FAIhook']['kzl']          = 'H'; 
156           $tmp2[$cn]['FAIhook']['desc']  = $attr['description'];
157           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
158         }
159         if(in_array('FAIpartitionTable',$attr['objectClass'])){
160           $tmp2[$cn]['FAIpartitionTable']['obj']= 'FAIpartitionTable'; 
161           $tmp2[$cn]['FAIpartitionTable']['kzl']= 'Pt'; 
162           $tmp2[$cn]['FAIpartitionTable']['desc']  = $attr['description'];
163           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
164         }
165         if(in_array('FAIprofile',$attr['objectClass'])){
166           $tmp2[$cn]['FAIprofile']['obj']= 'FAIprofile'; 
167           $tmp2[$cn]['FAIprofile']['kzl']= 'P'; 
168           $tmp2[$cn]['FAIprofile']['desc']  = $attr['description'];
169           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
170         }
171       }
172       if(is_array($this->FAIclasses)){
173         natcasesort($this->FAIclasses);
174       }
176       if(isset($tmp2)){
177         $this->FAIclassInfo = $tmp2;
178       } else {
179         $this->FAIclassInfo = array();
180       }
182       /* Build up an array like this one :
183           [$url]['SERVER'] = 'srv1-002';
184           [$url]['RELEASE']['siga/rc9.0.2']
185                                              ['SECTIONS'][0] "main";
186                                              ['SECTIONS'][1] "non-free";
187           [$url]['RELEASE']['siga/rc9.0.2']
188                                              ['PACKAGES'][0] "pkg1";
189                                              ['PACKAGES'][1] "postfix";
190        */
192       $ldap->search("(&(FAIrepository=*)(objectClass=FAIrepositoryServer))",array("FAIrepository"));
193       $test = array();
194       while($attr = $ldap->fetch()){
195         if(isset($attr['FAIrepository'])){
197           unset($attr['FAIrepository']['count']);
199           foreach($attr['FAIrepository'] as $rep){
200             $tmp = split("\|",$rep);
202             if(count($tmp)==4){
203               $sections = split(",",$tmp[3]);
204               $release  = $tmp[2];
205               $server   = $tmp[1];
206               $url      = $tmp[0];
207              
208               $test[$url]['RELEASE'][$release]['SECTIONS'] = $sections;
209       
210               /* Result will be cached
211                */
212               $test[$url]['RELEASE'][$release]['PACKAGES'] = $this->getAvailableClassesForThisRelease($release);
213               $test[$url]['SERVER'] = $server;
215               /* auto gets all releases/classes 
216                */
217               $test['auto']['RELEASE'][$release]['SECTION'] = $sections;
218               $test['auto']['RELEASE'][$release]['PACKAGES'] = $this->getAvailableClassesForThisRelease($release);
219             }
220           }
221         }
222       }
223       
224       /* Add possible elements from hook */
225       $lines= $this->GetHookElements();
226       foreach ($lines as $hline){
227         $entries= split(";", $hline);
228         if (isset($entries[1]) && !isset($test[$entries[1]])){
229           $test[$entries[1]]['RELEASE']= array();
231           /* Split releases */
232           if (isset($entries[2])){
233             $releases= split(",", $entries[2]);
235             foreach ($releases as $release){
236               $rname= preg_replace('/:.*$/', '', $release);
237               $sections= split(':', preg_replace('/^[^:]+:([^|]+)|.*$/', '\1', $release));
238               $classes= split('\|', preg_replace('/^[^|]+\|(.*)$/', '\1', $release));
239               $test[$entries[1]]['RELEASE'][$rname]= array();
240               $test[$entries[1]]['RELEASE'][$rname]['SECTION']= $sections;
241               foreach ($classes as $class){
242                 if ($class != ""){
243                   $test[$entries[1]]['RELEASE'][$rname]['PACKAGES'][$class]= $class;
244                 }
245               }
246             }
247           }
248         }
249       }
250       
251       $this->FAIServRepConfig= $test;
253       if((isset($this->FAIclass))&&(!is_array($this->FAIclass))){
254         $tmp = array();
255         $tmp = split(" ",$this->FAIclass);
256         $tmp2 =array();  
258         foreach($tmp as $class){
259           if( ":" == $class[0] ) {
260             $this->FAIrelease = substr( $class, 1 );
261           }
262           else
263             $tmp2[$class] = $class;
264         }
265         $this->FAIclass = $tmp2;
266       }
268       if(!is_array($this->FAIclass)){
269         $this->FAIclass =array();
270       }
271     }// END of FAI initialization stuff 
274     /* Get arrays */
275     foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
276       if (isset($this->attrs["$val"]["count"])){
277         for ($i= 0; $i<$this->attrs["count"]; $i++){
278           if (isset($this->attrs["$val"][$i])){
279             array_push($this->$val, $this->attrs["$val"][$i]);
280           }
281         }
282       }
283       sort ($this->$val);
284       $this->$val= array_unique($this->$val);
285     }
287     /* Parse Kernel Parameters to decide what boot mode is enabled */
288     if (preg_match("/ splash=silent/", $this->gotoKernelParameters)){
289       $this->bootmode= "G";
290     } elseif (preg_match("/ debug/", $this->gotoKernelParameters)){
291       $this->bootmode= "D";
292     } elseif ($this->gotoKernelParameters == "") {
293       $this->bootmode= "G";
294     } else {
295       $this->bootmode= "T";
296     }
297     if (preg_match("/ o /", $this->gotoKernelParameters)){
298       $this->customParameters= preg_replace ("/^.* o /", "", $this->gotoKernelParameters);
299     } else {
300       $this->customParameters= "";
301     }
303     /* Prepare Shares */
304     if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){
305       unset($this->attrs['gotoShare']['count']);
306       foreach($this->attrs['gotoShare'] as $share){
307         $tmp = $tmp2 = array();
308         $tmp = split("\|",$share);
309         $tmp2['server']      =$tmp[0];
310         $tmp2['name']        =$tmp[1];
311         $tmp2['mountPoint']  =$tmp[2];
312         $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2;
313       }
314     }
316     $this->gotoShareSelections= $config->getShareList(true);
317     $this->gotoAvailableShares= $config->getShareList(false);
318     $tmp2 = array();
319   
321     $this->orig_dn= $this->dn;
323     /* Handle inheritance value "default" */
324     $this->gotoBootKernels= array("default-inherited" => '['._("inherited").']');
326     /* Load hardware list */
327     if ($this->member_of_ogroup){
329       if(count($this->FAIclass)==0 && $this->FAIrelease == ""){
330         $this->FAIdebianMirror = "inherited";
331       }
333       if($this->fai_activated){
334         $map= array("gotoBootKernel","FAIclass","FAIdebianMirror");
335       }else{
336         $map= array("gotoBootKernel");
337       }
338       $attrs= $ldap->fetch();
340       foreach ($map as $name){
341         if (!isset($attrs[$name][0])){
342           continue;
343         }
345         switch ($name){
346           case 'gotoBootKernel':
347             $this->gotoBootKernels['default-inherited']=  _("inherited").' ['.$attrs[$name][0].']' ;
348             break;
350           case 'FAIclass':
351             $str = split(":",$attrs[$name][0]);
352             $this->InheritedFAIclass    = split("\ ",trim($str[0]));
353             $this->InheritedFAIrelease  = trim($str[1]);
354             break;
356           case 'FAIdebianMirror':
357             $this->InheritedFAIdebianMirror = $attrs[$name][0];
358             break;
359         }
360       }
361     }
363     /* Get list of boot kernels */
364     if (isset($this->config->data['TABS'])){
365       $command= $this->config->search(get_class($this), "KERNELS",array('tabs'));
367       if (!check_command($command)){
368         $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command,
369             get_class($this));
370       } else {
371         $fh= popen($command, "r");
372         while (!feof($fh)) {
373           $buffer= trim(fgets($fh, 256));
374           
375           if(!empty($buffer)){
376           
377             $name=$value = $buffer;
379             if(preg_match("/:/",$buffer)){
380               $name = preg_replace("/:.*$/","",$buffer);
381               $value= preg_replace("/^.*:/","",$buffer);
382               $this->gotoBootKernels[$name]= $name.":".$value;
383             }else{
384               $this->gotoBootKernels[$name]= $value;
385             }
386           }
388         }
389         pclose($fh);
390       }
391     }
393     /* Turn to default, if we've nothing to inherit */
394     if (!isset($this->gotoBootKernels['default-inherited']) && $this->gotoBootKernel == "default-inherited"){
395       $this->gotoBootKernel= "default";
396     }
397   }
399   
400   /* This class is called by the contrucktor ONLY.
401    *   It return the available classes for each 
402    *    Server / Release combination ... 
403    *   (Release specifies which classes are available) 
404    */
405   function getAvailableClassesForThisRelease($release)
406   {
407     /* There could be more than one server providing this release,
408         so use cached result if available
409      */ 
410     if(isset($_SESSION['getAvailableClassesForThisRelease_CACHE'][$release]))  {
411       return($_SESSION['getAvailableClassesForThisRelease_CACHE'][$release]);
412     }
414     $test2  = array();
415     $bb     = $this->generateDNSyn($release).$_SESSION['CurrentMainBase'];
416     $ldap   = $this->config->get_ldap_link();
417     $ldap->cd($this->config->current['BASE']);
418   
419     /* Get classes fpr given release */
420     $p_classes = get_all_objects_for_given_base($bb,
421         "(|(objectClass=FAIpackageList)(objectClass=FAItemplate)".
422           "(objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)".
423           "(objectClass=FAIprofile)(objectClass=FAIpartitionTable))");
425     /* Create list of classes */
426     foreach($p_classes as $class){
427       $ldap->cat($class['dn'],array("cn"));
428       $attr = $ldap->fetch();
429       $test2[$attr['cn'][0]] = $attr['cn'][0];
430     }
431     $_SESSION['getAvailableClassesForThisRelease_CACHE'][$release] = $test2;
432     return($test2);
433   }
436   /*  Create array to display available classes/profiles in a selectbox 
437    *   This function only displays the available classes.
438    *   If a class is available is defined by these facts : 
439    *     1. Is this class available for the selected release ?
440    *       - if it is available, check if the release is available for the selected server 
441    *         (done by $this->getFAIreleases())
442    *     2. Is this class currently not assigned to $this->FAIclass
443    */
444   function selectFriendlyClasses(){
445     $tmp=array();
447     if($this->FAIdebianMirror == "inherited") return($tmp);
449     /* check if the current release exists,
450         else select the first one ..
451      */
452     $tmp2 = $this->getFAIreleases();
453     if(!isset($tmp2[$this->FAIrelease]) || !$tmp2[$this->FAIrelease]['USE']){
454       foreach($tmp2 as $key => $data){
455         if($data['USE']){
456           $this->FAIrelease = $key;
457         }
458       }
459     }
460     if(!in_array($this->FAIrelease, $tmp2)){
461 #  $this->FAIrelease = key($tmp2);
462     }
464     /* Get all Packages for this server/release combination
465      */
466     if(!isset($this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'][$this->FAIrelease]['PACKAGES'])){
467       $pkgs = array();
468       print_red(_("There are packages in your configuration, which can't be resolved with current server/release settings."));
469     }else{
470       $pkgs = $this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'][$this->FAIrelease]['PACKAGES'];
471     }
473     /* Check each and every single class name 
474      */
475     foreach($pkgs as $pkg){
476   
477       /* Class already assigned to the classes list ?
478        * If not ... go on
479        */
480       if(!in_array($pkg,$this->FAIclass)){
481         
482         /* Create the displayed list entry value
483             HKLMOP [-Pl P V T-] or something like that 
484          */
485         $str = "";
486         foreach($this->FAIclassInfo[$pkg] as $entry){
487           if(isset($entry['kzl'])){
488             $str .= $entry['kzl']." ";
489           }
490         }
491         
492         /* Append class if everyting was fine
493          */        
494         $tmp[$pkg] = $pkg." [-".trim($str)."-]";
495       }
496     }
497     /* Just sort and return new classes list ...
498        ( possibly we should cache the result ... )
499      */
500     natcasesort ($tmp);
501     return($tmp);
502   }
504   function check()
505   {
506     $messages = array();
507     
508     /* Call common method to give check the hook */
509     $messages= plugin::check();
511     /* If there are packages selected, but no mirror show error */   
512     if(($this->FAIdebianMirror == "none")&&(count($this->FAIclass)>0)){
513       $messages[]=_("Please select a 'FAI server' or remove the 'FAI classes'.");
514     }
516     return($messages);
517   }
519   function execute()
520   {
522         /* Call parent execute */
523         plugin::execute();
525     if($this->is_account && !$this->view_logged){
526       $this->view_logged = TRUE;
527       new log("view","workstation/".get_class($this),$this->dn);
528     }
530     /* Do we need to flip is_account state? */
531     if(isset($_POST['modify_state'])){
532       if($this->is_account && $this->acl_is_removeable()){
533         $this->is_account= FALSE;
534       }elseif(!$this->is_account && $this->acl_is_createable()){
535         $this->is_account= TRUE;
536       }
537     }
539     /* Do we represent a valid terminal? */
540     if (!$this->is_account && $this->parent === NULL){
541       $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
542         _("This 'dn' has no terminal features.")."</b>";
543       return ($display);
544     }
546     /* Add module */
547     if (isset ($_POST['add_module'])){
548       if ($_POST['module'] != "" && $this->acl_is_writeable("gotoModule")){
549         $this->add_list ($this->gotoModules, $_POST['module']);
550       }
551     }
553     /* Delete module */
554     if (isset ($_POST['delete_module'])){
555       if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoModule")){
556         $this->del_list ($this->gotoModules, $_POST['modules_list']);
557       }
558     }
560     /* FAI class management */
561     if($this->fai_activated){
562       if(((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))) && ($this->acl_is_writeable("FAIclass"))){
563         $found = 0 ; 
565         /* If this new class/profile will attach a second partition table
566          * to our list of classes, abort and show a message.
567          */
568         foreach($this->FAIclass as $name){
569           if(isset($this->FAIclassInfo[$name])){
570             foreach($this->FAIclassInfo[$name] as $atr){
571               if(isset($atr['obj'])){
572                 if($atr['obj'] == "FAIpartitionTable"){
573                   $found ++ ; 
574                 }
575               }
576             }
577           }
578         }
580         if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpartitionTable']))&&($found>0)){
581           print_red(_("There is already a profile in your selection that contain partition table configurations."));
582         }else{
583           $this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel'];
584         }
585       }
587       $sort = false;
589       /* Move one used class class one position up or down */
590       if($this->acl_is_writeable("FAIclass")){
591         foreach($_POST as $name => $val){
593           $sort_type = false;
594           if((preg_match("/sort_up/",$name))&&(!$sort)){
595             $sort_type = "sort_up_";
596           }
597           if((preg_match("/sort_down/",$name))&&(!$sort)){
598             $sort_type = "sort_down_";
599           }
601           if(($sort_type)&&(!$sort)){
602             $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name)));
603             $sort = true;
605             $last = -1;
606             $change_down  = -1;
608             /* Create array with numeric index */ 
609             $tmp = array();
610             foreach($this->FAIclass as $class){
611               $tmp [] = $class;
612             }
614             /* Walk trough array */
615             foreach($tmp as $key => $faiName){
616               if($faiName == $value){
617                 if($sort_type == "sort_up_"){
618                   if($last != -1){
619                     $change_down= $last;
620                   }
621                 }else{
622                   if(isset($tmp[$key+1])){
623                     $change_down = $key;
624                   }
625                 }
626               }
627               $last = $key;
628             }
630             $tmp2 = array();
631             $skip = false;    
633             foreach($tmp as $ky => $vl){
635               if($ky == $change_down){
636                 $skip = $vl;
637               }else{
638                 $tmp2[$vl] = $vl;
639               }
640               if(($skip != false)&&($ky != $change_down)){
641                 $tmp2[$skip]  = $skip;
642                 $skip =false;
643               }
644             }   
645             $this->FAIclass = $tmp2; 
646           }
648           if(preg_match("/fai_remove/i",$name)){
649             $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/fai_remove_/i","",$name)));
650             unset($this->FAIclass[$value]);
651           }
652         }
653       }
655       /* Delete selected class from our list */
656       if($this->acl_is_writeable("FAIclass")){
657         if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){
658           if(isset($this->FAIclass[$_POST['FAIclassSel']])){
659             unset($this->FAIclass[$_POST['FAIclassSel']]);
660           }
661         }
662       }
663     }// END fai handling
665     /* Show main page */
666     $smarty= get_smarty();
668     /* Assign ACLs to smarty */
669     $tmp = $this->plInfo();
670     foreach($tmp['plProvidedAcls'] as $name => $translation){
671       $smarty->assign($name."ACL",$this->getacl($name));
672     } 
674     /* In this section server shares will be defined
675      * A user can select one of the given shares and a mount point
676      *  and attach this combination to his setup.
677      */
678     $smarty->assign("gotoShareSelections",    $this->gotoShareSelections);
679     $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections));
681     /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry
682      * This entry will be, a combination of mountPoint and sharedefinitions
683      */
684     if((isset($_POST['gotoShareAdd'])) && ($this->acl_is_writeable("gotoShare"))) {
685       /* We assign a share to this user, if we don't know where to mount the share */
686       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
687         print_red(_("You must specify a valid mount point."));
688       }else{
689         if(count($this->gotoAvailableShares)){
690           $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
691           $s_mount = $_POST['gotoShareMountPoint'];
692           /* Preparing the new assignment */
693           $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
694           $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
695         }
696       }
697     }
699     /* if the Post  gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected)
700      * If there is no defined share selected, we will abort the deletion without any message
701      */
702     if(($this->acl_is_writeable("gotoShare"))&& (isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){
703       unset($this->gotoShares[$_POST['gotoShare']]);
704     }
706     $smarty->assign("gotoShares",$this->printOutAssignedShares());
707     $smarty->assign("gotoSharesCount",count($this->printOutAssignedShares()));
708     $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares()));
709     $smarty->assign("gotoBootKernels",$this->gotoBootKernels);
711     /* Create divSelectBox for ldap server selection
712      */
713     $SelectBoxLdapServer = new divSelectBox("LdapServer");
714     $SelectBoxLdapServer->SetHeight(130);
716     /* Add new ldap server to the list */
717     if(!$this->gotoLdap_inherit && isset($_POST['add_ldap_server']) && isset($_POST['ldap_server_to_add'])){
718       if(isset($this->gotoLdapServerList[$_POST['ldap_server_to_add']])){
719         $to_add = $this->gotoLdapServerList[$_POST['ldap_server_to_add']];
720         if(!in_array($to_add,$this->gotoLdapServers)){
721           $this->gotoLdapServers[] = $to_add;
722         }
723       }
724     }
725     
726     /* Move ldap servers up and down */
727     if(!$this->gotoLdap_inherit){
728       foreach($_POST as $name => $value){
729         if(preg_match("/sort_ldap_up_/",$name)){
730           $id = preg_replace("/^sort_ldap_up_([0-9]*)_(x|y)$/","\\1",$name);
731           $from =  $id;  
732           $to   =  $id -1;
733           $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to);
734           if($tmp){
735             $this->gotoLdapServers = $tmp;
736           }
737           break;
738         }
739         if(preg_match("/sort_ldap_down_/",$name)){
740           $id = preg_replace("/^sort_ldap_down_([0-9]*)_(x|y)$/","\\1",$name);
741           $from =  $id;  
742           $to   =  $id +1;
743           $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to);
744           if($tmp){
745             $this->gotoLdapServers = $tmp;
746           }
747           break;
748         }
749         if(preg_match("/gotoLdapRemove_/",$name)){
750           $id = preg_replace("/^gotoLdapRemove_([0-9]*)_(x|y)$/","\\1",$name);
751           $value = $this->gotoLdapServers[$id];
752           $this->gotoLdapServers = array_remove_entries(array($value),$this->gotoLdapServers);
753           break;
754         }
755       } 
756     }
757   
758     /* Add Entries 
759      */
760     foreach($this->gotoLdapServers as $key => $server){
761       if(!in_array($server,$this->gotoLdapServerList)){
762         $server = $server."&nbsp;<font style='color:red'>(missing)</font>";
763       }
765       $SelectBoxLdapServer->AddEntry(
766           array(array("string" => $server),
767             array("string" => 
768               "<input class='center' type='image' src='images/sort_up.png' name='sort_ldap_up_".$key."'>&nbsp;".
769               "<input class='center' type='image' src='images/sort_down.png' name='sort_ldap_down_".$key."'>&nbsp;".
770               "<input class='center' type='image' src='images/edittrash.png' name='gotoLdapRemove_".$key."'>",
771               "attach" => "style='text-align:right;width:40px;border-right:0px;'")));
772     }    
774     if($this->gotoLdap_inherit){
775       $smarty->assign("gotoLdapServerACL_inherit", preg_replace("/w/","",$this->getacl("gotoLdapServer")));;
776     }else{
777       $smarty->assign("gotoLdapServerACL_inherit", $this->getacl("gotoLdapServer"));
778     }
779     
780     $list = array();
781     foreach($this->gotoLdapServerList as $key => $entry){
782       if(!in_array($entry,$this->gotoLdapServers)){
783         $list[$key] = $entry;
784       }
785     }
786     $smarty->assign("gotoLdapServers",    $SelectBoxLdapServer->DrawList());
787     $smarty->assign("gotoLdapServerList", $list);
788     $smarty->assign("gotoLdap_inherit",   $this->gotoLdap_inherit);
789     $smarty->assign("JS",  $_SESSION['js']);
791     foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
792       $smarty->assign("$val", $this->$val);
793     }
795     /* Values */
796     foreach(array("gotoBootKernel", "customParameters", "gotoShare","FAIclasses","FAIclass","FAIdebianMirror","FAIrelease") as $val){
797       $smarty->assign($val, $this->$val);
798     }
800     $smarty->assign("fai_activated",$this->fai_activated);
802     /* Create FAI output */
803     if($this->fai_activated){
804       $smarty->assign("FAIdebianMirrors",$this->getFAIdebianMirrors());
805       $smarty->assign("FAIdebianMirror",$this->FAIdebianMirror);
806       $smarty->assign("FAIreleases",$this->getFAIreleases());
807       $smarty->assign("FAIrelease",$this->FAIrelease);
808       $smarty->assign("FAIclasses",$this->selectFriendlyClasses());
809       $smarty->assign("FAIclassesKeys",array_flip($this->selectFriendlyClasses()));
810       $smarty->assign("FAIclassKeys",$this->FAIclass);
812       $inheritedRelease = array();
813       if(!empty($this->InheritedFAIrelease)){
814         $inheritedRelease[$this->InheritedFAIrelease]= $this->InheritedFAIrelease;
815       } 
816       $smarty->assign("InheritedFAIrelease",$inheritedRelease);
818       $div = new divSelectBox("WSFAIscriptClasses");
819       $div -> SetHeight("110");
820       $str_up     = " &nbsp;<input type='image' src='images/sort_up.png'    name='sort_up_%s'    value='%s'>";
821       $str_down   = " &nbsp;<input type='image' src='images/sort_down.png'  name='sort_down_%s'  value='%s'>";
822       $str_remove = " &nbsp;<input type='image' src='images/edittrash.png'  name='fai_remove_%s' value='%s'>";
823       $str_empty  = " &nbsp;<img src='images/empty.png' alt=\"\" width='7'>"; 
825       $i = 1;
827       if($this->FAIdebianMirror == "inherited"){
828         $tmp = $this->InheritedFAIclass;
829       }else{
830         $tmp = $this->FAIclass;
831       }
833       foreach($tmp as $class){
835         $marker = "";
836         if(in_array_ics($class,$this->unresolved_classes)){
837           $marker = "&nbsp;<font color='red'>("._("Not available in current setup").")</font>";
838         }
840         if($this->FAIdebianMirror == "inherited"){
841           $str = "";
842         }else{
843           if($i==1){
844             $str = $str_empty.$str_down.$str_remove;
845           }elseif($i == count($this->FAIclass)){
846             $str = $str_up.$str_empty.$str_remove;
847           }else{
848             $str = $str_up.$str_down.$str_remove;
849           }
850         }
851         $i ++ ; 
852   
853         $desc = ""; 
854         foreach($this->FAIclassInfo[$class] as $types ){
855           if(isset($types['desc'][0])){
856             $desc.= $types['desc'][0]." ";
857           }
858         }
859         if(!empty($desc)){
860           $desc = "&nbsp;[".trim($desc)."]";
861         }        
863         $div->AddEntry(array(
864               array("string"=>$class.$desc.$marker),
865               array("string"=>preg_replace("/\%s/",base64_encode($class),$str),"attach"=>"style='width:50px;border-right:none;'")
866               ));
867       }  
868       $smarty->assign("FAIScriptlist",$div->DrawList()); 
869     }// END FAI output generation 
871     /* Radio button group */
872     if (preg_match("/G/", $this->bootmode)) {
873       $smarty->assign("graphicalbootup", "checked");
874     } else {
875       $smarty->assign("graphicalbootup", "");
876     }
877     if (preg_match("/T/", $this->bootmode)) {
878       $smarty->assign("textbootup", "checked");
879     } else {
880       $smarty->assign("textbootup", "");
881     }
882     if (preg_match("/D/", $this->bootmode)) {
883       $smarty->assign("debugbootup", "checked");
884     } else {
885       $smarty->assign("debugbootup", "");
886     }
888     /* Show main page */
889     return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE,dirname(__FILE__))));
890   }
892   function remove_from_parent()
893   {
894     $this->handle_post_events("remove");
895     new log("remove","workstation/".get_class($this),$this->dn);
896   }
898   function generateDNSyn($release)
899   {
900     $str = "";
901     $tmp = split("\/",$release);
902     $tmp = array_reverse($tmp);
904     $base = "ou=fai,ou=configs,ou=systems,";   
905     foreach($tmp as $departmentname){
906       
907       $str .= ",ou=".$departmentname;
908     }
909     $str = preg_replace("/^,/","",($str.",".$base));
910     
911     return($str);
912   }
914   function getFAIdebianMirrors()
915   {
916     $ret = array();
918     /* Only add inherit option, if we are part in an object group 
919      */
920     if($this->member_of_ogroup)    {
921       $ret['inherited']['NAME']="["._("inherited")."]";
922       $ret['inherited']['USE'] = TRUE;
923     }
925     $ret['auto']['NAME']=_("automatic");
926     $ret['auto']['USE'] = TRUE;
927     $secs  = array();
929     /* Walk through all available servers 
930         and check if they support the currently selected classes
931         if not, dont't add them to our list
932      */
933     foreach($this->FAIServRepConfig as $mirror => $rest){
934       $use = false;
935       if(count($this->FAIclass) == 0){
936         $use = true;
937       }else{
938         $tmp = $this->getFAIreleases();
939         foreach($tmp as $release => $data){
940           if(isset($rest['RELEASE'][$release])){
941             $use = $data['USE']; 
942           }
943         } 
944       }
946       /* If current server, doesn't support this class
947           remove it from list
948        */
949       $ret[$mirror]['NAME'] = $mirror;
950       $ret[$mirror]['USE'] = $use;
951     }
952     return($ret);
953   }
955   function getFAIreleases() 
956   {
957     $ret = array();
959     if($this->FAIdebianMirror == "inherited") {
960       return(array());
961     }
963     if(!isset($this->FAIServRepConfig[$this->FAIdebianMirror])){
964       $this->FAIdebianMirror = "auto";
965     }
967     $errorClasses = array();
968     if(isset($this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'])) {
969       foreach($this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'] as $release => $sections){
970         $use = true;
972         if(!count($this->FAIclass) == 0){
973           foreach($this->FAIclass as $class){
974             if(!in_array($class, $sections['PACKAGES'])){
975               $use = false;
976               $errorClasses[$class] = $class;
977             }else{
978               if(isset($errorClasses[$class])){
979                 unset($errorClasses[$class]);
980               }
981             }
982           }
983         }
984         $ret[$release]['NAME']=$release;
985         $ret[$release]['USE']=$use;
986       }
987     }
989     if((count($ret) == 0 ) && ($this->FAIdebianMirror != "auto")){
990       $eClasses = " ";
991       foreach($errorClasses as $class){
992         $eClasses .= $class." ";
993       }
995       print_red(sprintf(_("Can't resolve one or more of the given FAIclass(es) [%s] in FAI server '%s'. Server was reset to 'auto'."),$eClasses, $this->FAIdebianMirror));
996       $this->FAIdebianMirror = "auto";
997       return($this->getFAIreleases());
998     }elseif((count($ret) == 0 ) && ($this->FAIdebianMirror == "auto")){
1000       $eClasses = " ";
1001       foreach($errorClasses as $class){
1002         $eClasses .= $class." ";
1003       }
1005       $eClasses = preg_replace("/  */","",$eClasses);
1006      
1007       if(!empty($eClasses)) {
1009         $this->unresolved_classes = $errorClasses;
1010         $this->FAIdebianMirror = "auto";
1011         print_red(sprintf(_("Can't resolve the given FAIclass(es) [%s] anyway, please check your FAI configurations, possibly some classes where deleted or renamed. Server was reset to 'auto'."),$eClasses));
1012       }
1013     }
1014     return($ret);
1015   }
1017   /* Save data to object */
1018   function save_object()
1019   {
1020     plugin::save_object();
1022     if(isset($_POST['WorkstationStarttabPosted'])){
1023       if(isset($_POST['gotoLdap_inherit'])){
1024         $this->gotoLdap_inherit = TRUE;
1025       }else{
1026         $this->gotoLdap_inherit = FALSE;
1027       }
1029       /* Save group radio buttons */
1030       if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){
1031         $this->bootmode= $_POST["bootmode"];
1032       }
1034       /* Save kernel parameters */
1035       if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){
1036         $this->customParameters= $_POST["customParameters"];
1037       }
1038     }
1039   }
1042   /* Save to LDAP */
1043   function save()
1044   {
1046     /* Depending on the baseobject (Ogroup / WS) we
1047      *  use another set of objectClasses
1048      * In case of WS itself, we use  "array("GOhard", "FAIobject");"
1049      * if we are currently editing from ogroup menu we use (array("gotWorkstationTemplate","GOhard", "FAIobject"))
1050      */
1051     if(isset($this->parent->by_object['ogroup'])){
1052       $this->objectclasses = array("gotoWorkstationTemplate");
1053     }elseif(isset($this->parent->by_object['workgeneric'])){
1054       $this->objectclasses = array("GOhard");
1055     }elseif(isset($this->parent->by_object['servgeneric'])){
1056       $this->objectclasses = array("GOhard","gotoWorkstationTemplate");
1057     }else{
1058       print "Object Type Configuration : unknown";
1059       exit();
1060     }
1062     /* Append FAI class */
1063     if($this->fai_activated){
1064       $this->objectclasses[]  = "FAIobject";
1065     }
1067     /* Find proper terminal path for tftp configuration
1068        FIXME: This is suboptimal when the default has changed to
1069        another location! */
1070     if (($this->gotoTerminalPath == "default")){
1071       $ldap= $this->config->get_ldap_link();
1073       /* Strip relevant part from dn, keep trailing ',' */
1074       $tmp= preg_replace("/^cn=[^,]+,ou=terminals,ou=systems,/i", "", $this->dn);
1075       $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp);
1077       /* Walk from top to base and try to load default values for
1078          'gotoTerminalPath'. Abort when an entry is found. */
1079       while (TRUE){
1080         $tmp= preg_replace ("/^[^,]+,/", "", $tmp);
1082         $ldap->cat("cn=default,ou=terminals,ou=systems,$tmp".
1083             $this->config->current['BASE'], array('gotoTerminalPath'));
1084         $attrs= $ldap->fetch();
1085         if (isset($attrs['gotoTerminalPath'])){
1086           $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0];
1087           break;
1088         }
1090         /* Nothing left? */
1091         if ($tmp == ""){
1092           break;
1093         }
1094       }
1095     }
1097     /* Add semi automatic values */
1098     // FIXME: LDAP Server may not be set here...
1099     $this->gotoKernelParameters= "ldap=".base64_encode($this->gotoLdapServer);
1101     switch ($this->bootmode){
1102       case "D":
1103         $this->gotoKernelParameters.= " debug";
1104       break;
1105       case "G":
1106         $this->gotoKernelParameters.= " splash=silent";
1107       break;
1108     }
1109     if ($this->customParameters != ""){
1110       $this->gotoKernelParameters.= " o ".$this->customParameters;
1111     }
1113     plugin::save();
1115     unset( $this->attrs['FAIrelease'] );
1116     
1117     $str = "";
1119     /* Skip FAI attribute handling if not necessary */
1120     if($this->fai_activated){
1121       if($this->FAIdebianMirror == "inherited"){
1122         $this->attrs['FAIclass'] = $this->attrs['FAIrelease'] =  $this->attrs['FAIdebianMirror'] = array(); 
1123       }else{
1124         foreach($this->FAIclass as $class){
1125           $str .= $class." ";
1126         }
1127         $str .= ":" . $this->FAIrelease;
1128         $this->attrs['FAIclass']= "";
1129         $this->attrs['FAIclass']= trim($str);
1131         if(empty($this->attrs['FAIclass'])){
1132           $this->attrs['FAIclass'] = array();
1133         }
1134       }
1135     }
1136   
1137     /* Add missing arrays */
1138     foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){
1139       if (isset ($this->$val) && count ($this->$val) != 0){
1140     
1141         $this->attrs["$val"]= array_unique($this->$val);
1142       }
1143       if(!isset($this->attrs["$val"])) $this->attrs["$val"]=array();
1144     }
1146     /* Prepare list of ldap servers */
1147     $this->attrs['gotoLdapServer'] = array();
1148     if(!$this->gotoLdap_inherit){
1149       $i = 0;
1150       foreach($this->gotoLdapServers as $server){
1151         $i ++;
1152         $this->attrs['gotoLdapServer'][] = $i.":".$server;
1153       }
1154     }
1156     if (($this->attrs['gotoBootKernel'] == "default-inherited") || ($this->attrs['gotoBootKernel'] == "%default%")){
1157       $this->attrs['gotoBootKernel']= array();
1158     }
1160     /* if mirror == none stop saving this attribute */
1161     if($this->FAIdebianMirror == "none"){
1162       $this->FAIdebianMirror = "";
1163     }
1164    
1165     /* Get FAIstate from object, the generic tab could have changed it during execute */
1166     $ldap= $this->config->get_ldap_link();
1167     $ldap->cd($this->dn);
1170     /* Skip FAI attribute handling if not necessary */
1171     if($this->fai_activated){
1172       $ldap->cat($this->dn,array("FAIstate"));
1173       $checkFAIstate = $ldap->fetch();
1175       /* Remove FAI objects if no FAI class is selected */ 
1176       if((count($this->FAIclass)==0) && (!isset($checkFAIstate['FAIstate']))){
1177         $this->attrs['FAIclass']        = array();
1178         $this->attrs['FAIdebianMirror'] = array();
1179       }
1180     }
1183     /* prepare share settings */
1184     $tmp = array();
1185     foreach($this->gotoShares as $name => $settings){
1186       $tmp2= split("\|",$name);
1187       $name = $tmp2[0];
1188       $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint'];
1189     }
1190     $this->attrs['gotoShare']=$tmp;
1192     $this->cleanup();
1193     $ldap->modify ($this->attrs); 
1194     new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1196     show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/startup with dn '%s' failed."),$this->dn));
1197     $this->handle_post_events("modify");
1198   }
1200   /* Add value to array, check if unique */
1201   function add_list (&$array, $value)
1202   {
1203     if ($value != ""){
1204       $array[]= $value;
1205       sort($array);
1206       array_unique ($array);
1207     }
1208   }
1211   /* Delete value to array, check if unique */
1212   function del_list (&$array, $list)
1213   {
1214     $tmp= array();
1215     foreach ($array as $mod){
1216       if (!in_array($mod, $list)){
1217         $tmp[]= $mod;
1218       }
1219     }
1220     $array= $tmp;
1221   }
1223   /* Generate ListBox frindly output for the defined shares
1224    * Possibly Add or remove an attribute here,
1225    */
1226   function printOutAssignedShares()
1227   {
1228     $a_return = array();
1229     if(is_array($this->gotoShares)){
1230       foreach($this->gotoShares as $share){
1231         $a_return[$share['name']."|".$share['server']]= $share['name']." [".$share['server']."]";
1232       }
1233     }
1234     return($a_return);
1235   }
1238   function GetHookElements()
1239   {
1240     $ret = array();
1241     $cmd= $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs'));
1242     if(!empty($cmd)){
1243       $res = shell_exec($cmd);
1244       $res2 = trim($res);
1245       if((!$res)){
1246         print_red(sprintf(_("Can't execute specified REPOSITORY_HOOK '%s' please check your gosa.conf."),$cmd));
1247       }elseif(empty($res2)){
1248         print_red(sprintf(_("The specified REPOSITORY_HOOK '%s', specified in your gosa.conf, returns an empty string."),$cmd));
1249       }else{
1250         $tmp = split("\n",$res);
1251         foreach($tmp as $line){
1252           if(empty($line)) continue;
1253           $ret[]= $line;
1254         }
1255       }
1256     }
1257     return($ret);
1258   }
1261   function PrepareForCopyPaste($source)
1262   {
1263     plugin::PrepareForCopyPaste($source);    
1265     $source_o = new workstartup ($this->config, $source['dn']);
1266     
1267     foreach(array("gotoModules", "gotoAutoFs", "gotoFilesystem","gotoKernelParameters","gotoShares","customParameters") as $attr){
1268       $this->$attr = $source_o->$attr;
1269     }
1270   }
1272   
1273   function array_switch_item($ar,$from,$to)
1274   {
1275     if(!is_array($ar)){
1276       return(false);
1277     }
1278     if(!isset($ar[$from])){
1279       return(false);
1280     }
1281     if(!isset($ar[$to])){
1282       return(false);
1283     }
1285     $tmp = $ar[$from];
1286     $ar[$from] = $ar[$to];    
1287     $ar[$to] = $tmp;    
1288     return($ar);
1289   }
1292   /* Return plugin informations for acl handling */ 
1293   function plInfo()
1294   {
1295     return (array( 
1296           "plShortName"   => _("Startup"),
1297           "plDescription" => _("System startup"),
1298           "plSelfModify"  => FALSE,
1299           "plDepends"     => array(),
1300           "plPriority"    => 9,
1301           "plSection"     => array("administration"),           
1302           "plCategory"    => array("workstation","server","ogroups"),
1304           "plProvidedAcls"=> array(
1305             "gotoLdapServer"        => _("Ldap server"),
1306             "gotoBootKernel"        => _("Boot kernel"),
1307             "gotoKernelParameters"  => _("Kernel parameter"),
1309             "gotoModules"           => _("Kernel modules"),
1310             "gotoShare"             => _("Shares"),
1312             "FAIclass"              => _("FAI classes"),
1313             "FAIdebianMirror"       => _("Debian mirror"),
1314             "FAIrelease"            => _("Debian release"),
1316             "FAIstatus"             => _("FAI status flag")) // #FIXME is this acl realy necessary ?
1317           ));
1318   }
1321 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1322 ?>