Code

Added error message
[gosa.git] / gosa-plugins / fai / admin / fai / class_faiPackageConfiguration.inc
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("package","template"),array($this->obj));
25     if($q->is_error()){
26       msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG);
27     }
28     $tpl = "";
29     if(isset($ret['ANSWER1']) && isset($ret['ANSWER1']['TEMPLATE'])){
30       $tpl = base64_decode($ret['ANSWER1']['TEMPLATE']);
31     }
32     $this->Debconf_handle = new debconf(preg_replace('/_.*$/', '', get_browser_language()));
33     $this->Debconf_handle->load_from_string($tpl);
34     if($this->Debconf_handle->has_template()){
35       foreach($this->pkg_config as $var){
36         $this->Debconf_handle->SetDefault($var['Name'],$var['Value']);
37       }
38     }
39   }
42   function execute()
43   {
44     /* Call parent execute */
45     plugin::execute();
47     /* Fill templating stuff */
48     $smarty     = get_smarty();
49     $smarty->assign("headline", sprintf(_("Debconf information for package '%s'"), $this->obj));
50     $this->Debconf_handle->PostCheck();
51     $smarty->assign("Config",$this->Debconf_handle->get_dialog());
52     return($smarty->fetch(get_template_path('faiPackageConfiguration.tpl', TRUE)));
53   }
55   /* Save data to object */
56   function save_object()
57   {
58   }
60   /* Check supplied data */
61   function check()
62   {
63     /* Call common method to give check the hook */
64     $message= plugin::check();
65     return ($message);
66   }
68   function save()
69   {
70     $this->Debconf_handle->PostCheck();
71     $pkgs = $this->Debconf_handle->template;
72     $tmp = array();
73     foreach($pkgs as $pkg){
74       $tmp[$this->obj][$pkg['Name']]['Value']= $pkg['Default'];
75       $tmp[$this->obj][$pkg['Name']]['Name'] = $pkg['Name'];
76       $tmp[$this->obj][$pkg['Name']]['Type'] = $pkg['Type'];
77     }
78     return($tmp);
79   }
80 }
81 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
82 ?>