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();
44 /* Fill templating stuff */
45 $smarty = get_smarty();
46 $display = "";
47 $smarty->assign("headline", sprintf(_("Debconf information for package '%s'"), $this->obj));
49 $this->Debconf_handle->PostCheck();
51 $smarty->assign("Config",$this->Debconf_handle->get_dialog());
53 $display.= $smarty->fetch(get_template_path('faiPackageConfiguration.tpl', TRUE));
54 return($display);
55 }
57 /* Save data to object */
58 function save_object()
59 {
60 }
62 /* Check supplied data */
63 function check()
64 {
65 /* Call common method to give check the hook */
66 $message= plugin::check();
68 return ($message);
69 }
71 function save()
72 {
73 $this->Debconf_handle->PostCheck();
74 $pkgs = $this->Debconf_handle->template;
76 $tmp = array();
77 foreach($pkgs as $pkg){
78 $tmp[$this->obj][$pkg['Name']]['Value']= $pkg['Default'];
79 $tmp[$this->obj][$pkg['Name']]['Name'] = $pkg['Name'];
80 $tmp[$this->obj][$pkg['Name']]['Type'] = $pkg['Type'];
81 }
82 return($tmp);
83 }
84 }
85 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
86 ?>