1 <?php
3 class faiPackageConfiguration extends plugin
4 {
5 /* attribute list for save action */
6 var $ignore_account = TRUE;
7 var $attributes = array();
8 var $objectclasses = array();
10 var $Debconf_handle = NULL;
11 var $pkg_config ;
12 var $obj;
13 var $release;
15 function faiPackageConfiguration (&$config, $dn= NULL,$obj,$release,$pkg_config)
16 {
17 plugin::plugin ($config, $dn);
18 $this->obj = $obj;
19 $this->release = $release;
20 $this->pkg_config = $pkg_config;
22 /* Read pkg debconf info */
23 $q = new gosaSupportDaemon();
24 $ret = $q->FAI_get_packages($this->release,array("*"),$this->obj);
25 $tpl = "";
26 if(isset($ret['ANSWER1']) && isset($ret['ANSWER1']['TEMPLATE'])){
27 $tpl = base64_decode($ret['ANSWER1']['TEMPLATE']);
28 }
29 $this->Debconf_handle = new debconf(preg_replace('/_.*$/', '', get_browser_language()));
30 $this->Debconf_handle->load_from_string($tpl);
31 if($this->Debconf_handle->has_template()){
32 foreach($this->pkg_config as $var){
33 $this->Debconf_handle->SetDefault($var['Name'],$var['Value']);
34 }
35 }
36 }
38 function execute()
39 {
40 /* Call parent execute */
41 plugin::execute();
43 /* Fill templating stuff */
44 $smarty = get_smarty();
45 $smarty->assign("headline", sprintf(_("Debconf information for package '%s'"), $this->obj));
46 $this->Debconf_handle->PostCheck();
47 $smarty->assign("Config",$this->Debconf_handle->get_dialog());
48 return($smarty->fetch(get_template_path('faiPackageConfiguration.tpl', TRUE)));
49 }
51 /* Save data to object */
52 function save_object()
53 {
54 }
56 /* Check supplied data */
57 function check()
58 {
59 /* Call common method to give check the hook */
60 $message= plugin::check();
61 return ($message);
62 }
64 function save()
65 {
66 $this->Debconf_handle->PostCheck();
67 $pkgs = $this->Debconf_handle->template;
68 $tmp = array();
69 foreach($pkgs as $pkg){
70 $tmp[$this->obj][$pkg['Name']]['Value']= $pkg['Default'];
71 $tmp[$this->obj][$pkg['Name']]['Name'] = $pkg['Name'];
72 $tmp[$this->obj][$pkg['Name']]['Type'] = $pkg['Type'];
73 }
74 return($tmp);
75 }
76 }
77 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
78 ?>