Code

* Removed snapshot_ldap_base - where is it for?
[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 $strict         = TRUE;
28   var $header_image = "images/ldapserver.png";
30   var $cyrusunixstyle = FALSE;
31   var $mail       = "none";
32   var $mail_methods   = array();
33   var $mail_settings = array("vacationdir"        => "/etc/gosa/vacation",
34                              "vacationdir_active" => FALSE);
36   var $generic_settings  = array( "enableCopyPaste" => false,
37                                   "wws_ou"        => "ou=winstations",
38                                   "wws_ou_active" => FALSE,
39                                   "snapshot_active"     => FALSE,
40                                   "snapshot_base"       => "ou=snapshots,%base%",
41                                   "snapshot_user"       => "cn=ldapadmin,%base%",
42                                   "snapshot_password"   => "",
43                                   "snapshot_server"     => "%connection%");
45   var $samba_settings    = array( "samba_sid"        => "0-815-4711",
46                                   "samba_sid_active" => FALSE,
47                                   "samba_rid"        => 1000,
48                                   "samba_rid_active" => FALSE); 
50   var $attributes = array("strict","governmentmode","sambaidmapping","cyrusunixstyle","mail");
52   function Step_Config2()
53   {
54     $this->update_strings();
55     $tmp = $this->get_available_mail_classes();
56     foreach($tmp['name'] as $name){
57       $this->mail_methods[$name] = $name;
58     }
59   }
61  
62   function update_strings()
63   {
64     $this->s_title      = _("GOsa settings 2/3");
65     $this->s_title_long = _("GOsa settings 2/3");
66     $this->s_info       = _("Customize special parameters");
67   }
69  
70   function execute()
71   {
72     /* Update snapshot values, with already collected values */
73     foreach($this->generic_settings as $key => $value){
74       foreach(array("snapshot_base","snapshot_user","snapshot_server") as $attr){
75         foreach($this->parent->captured_values as $replace_name => $replace_value){
76           if(is_string($replace_value))  {
77             $this->generic_settings[$attr] = preg_replace("/%".$replace_name."%/",$replace_value,$this->generic_settings[$attr]);
78           }
79         }
80       }
81     }
83     $smarty = get_smarty();
84     $smarty->assign("generic_settings",$this->generic_settings);
85     $smarty->assign("mail_settings",$this->mail_settings);
86     $smarty->assign("mail_methods",$this->mail_methods);
87     $smarty->assign("samba_settings",$this->samba_settings);
88     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
89         foreach($this->attributes as $attr){
90       $smarty->assign($attr,$this->$attr);
91     }
92     return($smarty -> fetch (get_template_path("../setup/setup_config2.tpl")));
93   }
95   function save_object()
96   {
97     if(isset($_POST['step6_posted'])){
99       /* Get attributes */
100       foreach($this->attributes as $attr){
101         if(isset($_POST[$attr])){
102           $this->$attr = validate($_POST[$attr]);
103         }
104       }
106       /* Mail settings */
107       if(isset($_POST['vacationdir_active'])){
108         $this->mail_settings['vacationdir_active'] = TRUE;
109         if(isset($_POST['vacationdir'])){
110           $this->mail_settings['vacationdir'] = $_POST['vacationdir'];
111         }
112       }else{
113         $this->mail_settings['vacationdir_active'] = FALSE;
114       }
116       if(isset($_POST['enableCopyPaste'])){
117         $this->generic_settings['enableCopyPaste'] = $_POST['enableCopyPaste'];
118       }
120       if(isset($_POST['wws_ou_active'])){
121         $this->generic_settings['wws_ou_active'] = TRUE;
122         if(isset($_POST['wws_ou'])){
123           $this->generic_settings['wws_ou'] = $_POST['wws_ou'];
124         }
125       }else{
126         $this->generic_settings['wws_ou_active'] = FALSE;
127       }
129       if(isset($_POST['snapshot_active'])){
130         $this->generic_settings['snapshot_active'] = TRUE;
131         if(isset($_POST['snapshot_base'])){
132           $this->generic_settings['snapshot_base'] = $_POST['snapshot_base'];
133         }
134         if(isset($_POST['snapshot_user'])){
135           $this->generic_settings['snapshot_user'] = $_POST['snapshot_user'];
136         }
137         if(isset($_POST['snapshot_password'])){
138           $this->generic_settings['snapshot_password'] = $_POST['snapshot_password'];
139         }
140         if(isset($_POST['snapshot_server'])){
141           $this->generic_settings['snapshot_server'] = $_POST['snapshot_server'];
142         }
143       }else{
144         $this->generic_settings['snapshot_active'] = FALSE;
145       }
147       /* Samba settings */
148       if(isset($_POST['samba_sid_active'])){
149         $this->samba_settings['samba_sid_active'] = TRUE;
150         if(isset($_POST['samba_sid'])){
151           $this->samba_settings['samba_sid'] = $_POST['samba_sid'];
152         }
153       }else{
154         $this->samba_settings['samba_sid_active'] = FALSE;
155       }
156       if(isset($_POST['samba_rid_active'])){
157         $this->samba_settings['samba_rid_active'] = TRUE;
158         if(isset($_POST['samba_rid'])){
159           $this->samba_settings['samba_rid'] = $_POST['samba_rid'];
160         }
161       }else{
162         $this->samba_settings['samba_rid_active'] = FALSE;
163       }
165     }
167     $tmp = $this->check();
168     if(count($tmp) == 0){
169       $this->is_completed = TRUE;
170     }else{
171       $this->is_completed = FALSE;
172     }
173   }
176   function check()
177   {
178     $message = array();
179     return($message);
180   }
181   
183   /* Attributes that are interesting for configuration generation */
184   function get_attributes()
185   {
186     $tmp = setup_step::get_attributes();
187     foreach(array("samba_settings","generic_settings","mail_settings") as $attr){
188       $tmp[$attr]= $this->$attr;
189     }
190     return($tmp);
191   }
193 /* Returns the classnames auf the mail classes */
194   function get_available_mail_classes()
195   {
196     $dir = opendir( "../include");
197     $methods = array();
198     $suffix = "class_mail-methods-";
199     $lensuf = strlen($suffix);
200     $prefix = ".inc";
201     $lenpre = strlen($prefix);
202     $i = 0;
203     while (($file = readdir($dir)) !== false){
205       if(stristr($file,$suffix)) {
206         $lenfile = strlen($file);
207         $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
208         $methods['file'][$i] = $file;
209         $methods[$i]['file'] = $file;
210         $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
211         $i++;
212       }
213     }
214     return($methods);
215   }
219 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
220 ?>