Code

Updated layout
[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 $strict         = TRUE;
26   var $governmentmode = FALSE;
27   var $sambaidmapping = FALSE;
28   var $minid          = 100;       
29   var $account_expiration  =FALSE;
30   var $header_image = "images/ldapserver.png";
32   var $generic_settings  = array( "idgen"         => "{%sn}-{%givenName[2-4]}",
33                                   "idgen_active"  => FALSE,
34                                   "minid"         => "100",
35                                   "minid_active"  => FALSE,
36                                   "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); 
49   var $attributes = array("strict","governmentmode","sambaidmapping","account_expiration");
51   function Step_Config2()
52   {
53     $this->update_strings();
54   }
56  
57   function update_strings()
58   {
59     $this->s_title      = _("GOsa settings 2/3");
60     $this->s_title_long = _("GOsa settings 2/3");
61     $this->s_info       = _("Customize special parameters");
62   }
64  
65   function execute()
66   {
67     /* Update snapshot values, with already collected values */
68     foreach($this->generic_settings as $key => $value){
69       foreach(array("snapshot_ldap_base","snapshot_base","snapshot_user","snapshot_server") as $attr){
70         foreach($this->parent->captured_values as $replace_name => $replace_value){
71           if(is_string($replace_value))  {
72             $this->generic_settings[$attr] = preg_replace("/%".$replace_name."%/",$replace_value,$this->generic_settings[$attr]);
73           }
74         }
75       }
76     }
78     $smarty = get_smarty();
79     $smarty->assign("generic_settings",$this->generic_settings);
80     $smarty->assign("samba_settings",$this->samba_settings);
81     $smarty->assign("warnings" ,$this->check());
82     $smarty->assign("warnings_cnt" ,count($this->check()));
83     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
84         foreach($this->attributes as $attr){
85       $smarty->assign($attr,$this->$attr);
86     }
87     return($smarty -> fetch (get_template_path("../setup/setup_config2.tpl")));
88   }
90   function save_object()
91   {
92     if(isset($_POST['step6_posted'])){
94       /* Get attributes */
95       foreach($this->attributes as $attr){
96         if(isset($_POST[$attr])){
97           $this->$attr = validate($_POST[$attr]);
98         }
99       }
101       if(isset($_POST['minid_active'])){
102         $this->generic_settings['minid_active'] = TRUE;
103         if(isset($_POST['minid'])){
104           $this->generic_settings['minid'] = $_POST['minid'];
105         }
106       }else{
107         $this->generic_settings['minid_active'] = FALSE;
108       }
110       if(isset($_POST['wws_ou_active'])){
111         $this->generic_settings['wws_ou_active'] = TRUE;
112         if(isset($_POST['wws_ou'])){
113           $this->generic_settings['wws_ou'] = $_POST['wws_ou'];
114         }
115       }else{
116         $this->generic_settings['wws_ou_active'] = FALSE;
117       }
119       /* Generic settings */
120       if(isset($_POST['idgen_active'])){
121         $this->generic_settings['idgen_active'] = TRUE;
122         if(isset($_POST['idgen'])){
123           $this->generic_settings['idgen'] = $_POST['idgen'];
124         }
125       }else{
126         $this->generic_settings['idgen_active'] = FALSE;
127       }
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         if(isset($_POST['snapshot_ldap_base'])){
143           $this->generic_settings['snapshot_ldap_base'] = $_POST['snapshot_ldap_base'];
144         }
145       }else{
146         $this->generic_settings['snapshot_active'] = FALSE;
147       }
149       /* Samba settings */
150       if(isset($_POST['samba_sid_active'])){
151         $this->samba_settings['samba_sid_active'] = TRUE;
152         if(isset($_POST['samba_sid'])){
153           $this->samba_settings['samba_sid'] = $_POST['samba_sid'];
154         }
155       }else{
156         $this->samba_settings['samba_sid_active'] = FALSE;
157       }
158       if(isset($_POST['samba_rid_active'])){
159         $this->samba_settings['samba_rid_active'] = TRUE;
160         if(isset($_POST['samba_rid'])){
161           $this->samba_settings['samba_rid'] = $_POST['samba_rid'];
162         }
163       }else{
164         $this->samba_settings['samba_rid_active'] = FALSE;
165       }
167     }
169     $tmp = $this->check();
170     if(count($tmp) == 0){
171       $this->is_completed = TRUE;
172     }else{
173       $this->is_completed = FALSE;
174     }
175   }
178   function check()
179   {
180     $message = array();
181     
182     if(isset($this->generic_settings['minid_active']) && !is_numeric($this->generic_settings['minid'])){
183       $message[] = sprintf(_("The specified value for '%s' must be a numeric value"),_("GID / UID min id"));
184     }
185   
186     return($message);
187   }
188   
190   /* Attributes that are interesting for configuration generation */
191   function get_attributes()
192   {
193     $tmp = setup_step::get_attributes();
194     foreach(array("samba_settings","generic_settings") as $attr){
195       $tmp[$attr]= $this->$attr;
196     }
197     return($tmp);
198   }
202 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
203 ?>