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;
16 /*! \brief Configure a FAI package entry.
17 @param Object $config GOsa configuration object;
18 @param String The DN of the current package.
19 @param String The package name (e.g. apache)
20 @param String The release name (e.g. edge)
21 @param Array The current package configuration.
22 */
23 function faiPackageConfiguration (&$config, $dn= NULL,$obj,$release,$pkg_config)
24 {
25 plugin::plugin ($config, $dn);
26 $this->obj = $obj;
27 $this->release = $release;
28 $this->pkg_config = $pkg_config;
30 /* Read pkg debconf info from gosaSupportDaemon
31 */
32 $q = new gosaSupportDaemon();
33 $ret = $q->FAI_get_packages($this->release,array("package","template"),array($this->obj));
34 if($q->is_error()){
35 msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG);
36 }
38 /* If we do not get a useable answer, use an empty template
39 */
40 $tpl = "";
41 if(isset($ret['ANSWER1']) && isset($ret['ANSWER1']['TEMPLATE'])){
42 $tpl = base64_decode($ret['ANSWER1']['TEMPLATE']);
43 }
45 /* Create package configuration mask
46 */
47 $this->Debconf_handle = new debconf(preg_replace('/_.*$/', '', get_browser_language()));
48 $this->Debconf_handle->load_from_string($tpl);
49 if($this->Debconf_handle->has_template()){
50 foreach($this->pkg_config as $var){
51 $this->Debconf_handle->SetDefault($var['Name'],$var['Value']);
52 }
53 }
54 }
57 /*! \brief Returns a html interface, that allow to modify
58 the package attributes.
59 @return String HTML content/ui for this plugin
60 */
61 function execute()
62 {
63 /* Call parent execute */
64 plugin::execute();
66 /* Fill templating stuff */
67 $smarty = get_smarty();
68 $smarty->assign("headline", sprintf(_("Debconf information for package '%s'"), $this->obj));
69 $this->Debconf_handle->PostCheck();
70 $smarty->assign("Config",$this->Debconf_handle->get_dialog());
71 return($smarty->fetch(get_template_path('faiPackageConfiguration.tpl', TRUE)));
72 }
75 /* Save data to object */
76 function save_object()
77 {
78 }
80 /* Check supplied data */
81 function check()
82 {
83 /* Call common method to give check the hook */
84 $message= plugin::check();
85 return ($message);
86 }
89 /*! \brief Returns an array with all configured attributes
90 @return Array All configured attributes.
91 */
92 function save()
93 {
94 $this->Debconf_handle->PostCheck();
95 $pkgs = $this->Debconf_handle->template;
96 $tmp = array();
97 foreach($pkgs as $pkg){
98 $tmp[$this->obj][$pkg['Name']]['Value']= $pkg['Default'];
99 $tmp[$this->obj][$pkg['Name']]['Name'] = $pkg['Name'];
100 $tmp[$this->obj][$pkg['Name']]['Type'] = $pkg['Type'];
101 }
102 return($tmp);
103 }
104 }
105 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
106 ?>