Code

Updated setup
[gosa.git] / setup / class_setupStep6.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 setup_step_6 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;
31   var $generic_settings  = array( "idgen"         => "{%sn}-{%givenName[2-4]}",
32                                   "idgen_active"  => FALSE,
33                                   "minid"         => "100",
34                                   "minid_active"  => FALSE,
35                                   "wws_ou"        => "ou=winstations",
36                                   "wws_ou_active" => FALSE,
37                                   "snapshot_active"=> FALSE,
38                                   "snapshot_base" => "ou=snapshots,%base%",
39                                   "snapshot_user" => "cn=ldapadmin,%base%",
40                                   "snapshot_password" => "",
41                                   "snapshot_server"   => "%connection%");
43   var $samba_settings    = array( "samba_sid"        => "0-815-4711",
44                                   "samba_sid_active" => FALSE,
45                                   "samba_rid"        => 1000,
46                                   "samba_rid_active" => FALSE); 
47   var $attributes = array("strict","governmentmode","sambaidmapping","minid","account_expiration");
49   function setup_step_6()
50   {
51     $this->s_title      = _("GOsa settings 2/2");
52     $this->s_title_long = _("GOsa generic settings, page 2/2");
53     $this->s_info       = _("This dialog allows you to setup GOsa behaviour");
54   }
56   
57   function execute()
58   {
59     /* Update snapshot values, with already collected values */
60     foreach($this->generic_settings as $key => $value){
61       foreach(array("snapshot_base","snapshot_user","snapshot_server") as $attr){
62         foreach($this->parent->captured_values as $replace_name => $replace_value){
63           if(is_string($replace_value))  {
64             $this->generic_settings[$attr] = preg_replace("/%".$replace_name."%/",$replace_value,$this->generic_settings[$attr]);
65           }
66         }
67       }
68     }
70     $smarty = get_smarty();
71     $smarty->assign("generic_settings",$this->generic_settings);
72     $smarty->assign("samba_settings",$this->samba_settings);
73     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
74         foreach($this->attributes as $attr){
75       $smarty->assign($attr,$this->$attr);
76     }
77     return($smarty -> fetch (get_template_path("../setup/setup_step6.tpl")));
78   }
80   function save_object()
81   {
82     if(isset($_POST['step6_posted'])){
84       /* Get attributes */
85       foreach($this->attributes as $attr){
86         if(isset($_POST[$attr])){
87           $this->$attr = validate($_POST[$attr]);
88         }
89       }
91       /* Generic settings */
92       if(isset($_POST['idgen_active'])){
93         $this->generic_settings['idgen_active'] = TRUE;
94         if(isset($_POST['idgen'])){
95           $this->generic_settings['idgen'] = $_POST['idgen'];
96         }
97       }else{
98         $this->generic_settings['idgen_active'] = FALSE;
99       }
100       if(isset($_POST['snapshot_active'])){
101         $this->generic_settings['snapshot_active'] = TRUE;
102         if(isset($_POST['snapshot_base'])){
103           $this->generic_settings['snapshot_base'] = $_POST['snapshot_base'];
104         }
105         if(isset($_POST['snapshot_user'])){
106           $this->generic_settings['snapshot_user'] = $_POST['snapshot_user'];
107         }
108         if(isset($_POST['snapshot_password'])){
109           $this->generic_settings['snapshot_password'] = $_POST['snapshot_password'];
110         }
111         if(isset($_POST['snapshot_server'])){
112           $this->generic_settings['snapshot_server'] = $_POST['snapshot_server'];
113         }
114       }else{
115         $this->generic_settings['snapshot_active'] = FALSE;
116       }
118       /* Samba settings */
119       if(isset($_POST['samba_sid_active'])){
120         $this->samba_settings['samba_sid_active'] = TRUE;
121         if(isset($_POST['samba_sid'])){
122           $this->samba_settings['samba_sid'] = $_POST['samba_sid'];
123         }
124       }else{
125         $this->samba_settings['samba_sid_active'] = FALSE;
126       }
127       if(isset($_POST['samba_rid_active'])){
128         $this->samba_settings['samba_rid_active'] = TRUE;
129         if(isset($_POST['samba_rid'])){
130           $this->samba_settings['samba_rid'] = $_POST['samba_rid'];
131         }
132       }else{
133         $this->samba_settings['samba_rid_active'] = FALSE;
134       }
136     }
137   }
139    /* Attributes that are interesting for configuration generation */
140   function get_attributes()
141   {
142     $tmp = setup_step::get_attributes();
143     foreach(array("samba_settings","generic_settings") as $attr){
144       $tmp[$attr]= $this->$attr;
145     }
146     return($tmp);
147   }
151 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
152 ?>