Code

Moved account_expiration from step2 to step1
[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( "wws_ou"        => "ou=winstations",
37                                   "wws_ou_active" => FALSE,
38                                   "snapshot_active"     => FALSE,
39                                   "snapshot_base"       => "ou=snapshots,%base%",
40                                   "snapshot_ldap_base"  => "%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_ldap_base","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['wws_ou_active'])){
117         $this->generic_settings['wws_ou_active'] = TRUE;
118         if(isset($_POST['wws_ou'])){
119           $this->generic_settings['wws_ou'] = $_POST['wws_ou'];
120         }
121       }else{
122         $this->generic_settings['wws_ou_active'] = FALSE;
123       }
125       if(isset($_POST['snapshot_active'])){
126         $this->generic_settings['snapshot_active'] = TRUE;
127         if(isset($_POST['snapshot_base'])){
128           $this->generic_settings['snapshot_base'] = $_POST['snapshot_base'];
129         }
130         if(isset($_POST['snapshot_user'])){
131           $this->generic_settings['snapshot_user'] = $_POST['snapshot_user'];
132         }
133         if(isset($_POST['snapshot_password'])){
134           $this->generic_settings['snapshot_password'] = $_POST['snapshot_password'];
135         }
136         if(isset($_POST['snapshot_server'])){
137           $this->generic_settings['snapshot_server'] = $_POST['snapshot_server'];
138         }
139         if(isset($_POST['snapshot_ldap_base'])){
140           $this->generic_settings['snapshot_ldap_base'] = $_POST['snapshot_ldap_base'];
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 ?>