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