Code

Updated trunk, introduced gosa-core
[gosa.git] / plugins / admin / fai / class_faiPackageConfiguration.inc
1 <?php
3 class faiPackageConfiguration extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary        = "Manage server basic objects";
7   var $cli_description    = "Some longer text\nfor help";
8   var $cli_parameters     = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $ignore_account = TRUE;
12   var $attributes     = array();
13   var $objectclasses  = array();
15   var $Debconf_handle = NULL;
16   var $pkg_config ;
17   var $obj;
19   function faiPackageConfiguration (&$config, $dn= NULL,$obj,$path,$pkg_config)
20   {
21     plugin::plugin ($config, $dn);
22     $this->obj = $obj;
23     $this->Debconf_handle = new debconf();
24     $this->Debconf_handle->set_template_directory($path);
25     $this->Debconf_handle->set_package($this->obj);
26     $this->Debconf_handle->set_language(preg_replace('/_.*$/', '', get_browser_language()));
28     if( $this->Debconf_handle->load() ) {
29       $this->pkg_config = $pkg_config;
31       foreach($this->pkg_config as $var){
32         $this->Debconf_handle->SetDefault($var['Name'],$var['Value']);
33       }
34     }
35   }
37   function execute()
38   {
39     /* Call parent execute */
40     plugin::execute();
42     /* Fill templating stuff */
43     $smarty     = get_smarty();
44     $display = "";
45     $smarty->assign("headline", sprintf(_("Debconf information for package '%s'"), $this->obj));
47     $this->Debconf_handle->PostCheck();
49     $smarty->assign("Config",$this->Debconf_handle->get_dialog());
51     $display.= $smarty->fetch(get_template_path('faiPackageConfiguration.tpl', TRUE));
52     return($display);
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();
66     return ($message);
67   }
69   function save()
70   {
71     $this->Debconf_handle->PostCheck();
72     $pkgs = $this->Debconf_handle->template;
74     $tmp = array();
75     foreach($pkgs as $pkg){
76       $tmp[$this->obj][$pkg['Name']]['Value']= $pkg['Default'];
77       $tmp[$this->obj][$pkg['Name']]['Name'] = $pkg['Name'];
78       $tmp[$this->obj][$pkg['Name']]['Type'] = $pkg['Type'];
79     }
80     return($tmp);
81   }
82 }
83 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
84 ?>