Code

Added rfc2307bis
[gosa.git] / setup / class_setupStep_Config2.inc
1 <?php
3 /*
4    This code is part of GOsa (https://gosa.gonicus.de)
5    Copyright (C) 2007 Fabian Hickert
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 */
23 class Step_Config2 extends setup_step
24 {
25   var $governmentmode = FALSE;
26   var $sambaidmapping = FALSE;
27   var $header_image = "images/ldapserver.png";
29   var $cyrusunixstyle = FALSE;
30   var $mail       = "none";
31   var $mail_methods   = array();
32   var $mail_settings = array("vacationdir"        => "/etc/gosa/vacation",
33                              "vacationdir_active" => FALSE);
35   var $generic_settings  = array( "enableCopyPaste" => false,
36                                   "wws_ou"        => "ou=winstations",
37                                   "wws_ou_active" => FALSE,
38                                   "snapshot_active"     => FALSE,
39                                   "snapshot_base"       => "ou=snapshots,%base%",
40                                   "snapshot_user"       => "cn=ldapadmin,%base%",
41                                   "snapshot_password"   => "",
42                                   "snapshot_server"     => "%connection%");
44   var $samba_settings    = array( "samba_sid"        => "0-815-4711",
45                                   "samba_sid_active" => FALSE,
46                                   "samba_rid"        => 1000,
47                                   "samba_rid_active" => FALSE); 
49   var $attributes = array("governmentmode","sambaidmapping","cyrusunixstyle","mail");
51   function Step_Config2()
52   {
53     $this->update_strings();
54     $tmp = $this->get_available_mail_classes();
55     foreach($tmp['name'] as $name){
56       $this->mail_methods[$name] = $name;
57     }
58   }
60  
61   function update_strings()
62   {
63     $this->s_title      = _("GOsa settings 2/3");
64     $this->s_title_long = _("GOsa settings 2/3");
65     $this->s_info       = _("Customize special parameters");
66   }
68  
69   function execute()
70   {
71     /* Update snapshot values, with already collected values */
72     foreach($this->generic_settings as $key => $value){
73       foreach(array("snapshot_base","snapshot_user","snapshot_server") as $attr){
74         foreach($this->parent->captured_values as $replace_name => $replace_value){
75           if(is_string($replace_value))  {
76             $this->generic_settings[$attr] = preg_replace("/%".$replace_name."%/",$replace_value,$this->generic_settings[$attr]);
77           }
78         }
79       }
80     }
82     $smarty = get_smarty();
83     $smarty->assign("generic_settings",$this->generic_settings);
84     $smarty->assign("mail_settings",$this->mail_settings);
85     $smarty->assign("mail_methods",$this->mail_methods);
86     $smarty->assign("samba_settings",$this->samba_settings);
87     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
88         foreach($this->attributes as $attr){
89       $smarty->assign($attr,$this->$attr);
90     }
91     return($smarty -> fetch (get_template_path("../setup/setup_config2.tpl")));
92   }
94   function save_object()
95   {
96     if(isset($_POST['step6_posted'])){
98       /* Get attributes */
99       foreach($this->attributes as $attr){
100         if(isset($_POST[$attr])){
101           $this->$attr = validate($_POST[$attr]);
102         }
103       }
105       /* Mail settings */
106       if(isset($_POST['vacationdir_active'])){
107         $this->mail_settings['vacationdir_active'] = TRUE;
108         if(isset($_POST['vacationdir'])){
109           $this->mail_settings['vacationdir'] = $_POST['vacationdir'];
110         }
111       }else{
112         $this->mail_settings['vacationdir_active'] = FALSE;
113       }
115       if(isset($_POST['enableCopyPaste'])){
116         $this->generic_settings['enableCopyPaste'] = $_POST['enableCopyPaste'];
117       }
119       if(isset($_POST['wws_ou_active'])){
120         $this->generic_settings['wws_ou_active'] = TRUE;
121         if(isset($_POST['wws_ou'])){
122           $this->generic_settings['wws_ou'] = $_POST['wws_ou'];
123         }
124       }else{
125         $this->generic_settings['wws_ou_active'] = FALSE;
126       }
128       if(isset($_POST['snapshot_active'])){
129         $this->generic_settings['snapshot_active'] = TRUE;
130         if(isset($_POST['snapshot_base'])){
131           $this->generic_settings['snapshot_base'] = $_POST['snapshot_base'];
132         }
133         if(isset($_POST['snapshot_user'])){
134           $this->generic_settings['snapshot_user'] = $_POST['snapshot_user'];
135         }
136         if(isset($_POST['snapshot_password'])){
137           $this->generic_settings['snapshot_password'] = $_POST['snapshot_password'];
138         }
139         if(isset($_POST['snapshot_server'])){
140           $this->generic_settings['snapshot_server'] = $_POST['snapshot_server'];
141         }
142       }else{
143         $this->generic_settings['snapshot_active'] = FALSE;
144       }
146       /* Samba settings */
147       if(isset($_POST['samba_sid_active'])){
148         $this->samba_settings['samba_sid_active'] = TRUE;
149         if(isset($_POST['samba_sid'])){
150           $this->samba_settings['samba_sid'] = $_POST['samba_sid'];
151         }
152       }else{
153         $this->samba_settings['samba_sid_active'] = FALSE;
154       }
155       if(isset($_POST['samba_rid_active'])){
156         $this->samba_settings['samba_rid_active'] = TRUE;
157         if(isset($_POST['samba_rid'])){
158           $this->samba_settings['samba_rid'] = $_POST['samba_rid'];
159         }
160       }else{
161         $this->samba_settings['samba_rid_active'] = FALSE;
162       }
164     }
166     $tmp = $this->check();
167     if(count($tmp) == 0){
168       $this->is_completed = TRUE;
169     }else{
170       $this->is_completed = FALSE;
171     }
172   }
175   function check()
176   {
177     $message = array();
178     return($message);
179   }
180   
182   /* Attributes that are interesting for configuration generation */
183   function get_attributes()
184   {
185     $tmp = setup_step::get_attributes();
186     foreach(array("samba_settings","generic_settings","mail_settings") as $attr){
187       $tmp[$attr]= $this->$attr;
188     }
189     return($tmp);
190   }
192 /* Returns the classnames auf the mail classes */
193   function get_available_mail_classes()
194   {
195     $dir = opendir( "../include");
196     $methods = array();
197     $suffix = "class_mail-methods-";
198     $lensuf = strlen($suffix);
199     $prefix = ".inc";
200     $lenpre = strlen($prefix);
201     $i = 0;
202     while (($file = readdir($dir)) !== false){
204       if(stristr($file,$suffix)) {
205         $lenfile = strlen($file);
206         $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
207         $methods['file'][$i] = $file;
208         $methods[$i]['file'] = $file;
209         $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
210         $i++;
211       }
212     }
213     return($methods);
214   }
218 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
219 ?>