Code

Updated semantics
[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("warnings" ,$this->check());
74     $smarty->assign("warnings_cnt" ,count($this->check()));
75     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
76         foreach($this->attributes as $attr){
77       $smarty->assign($attr,$this->$attr);
78     }
79     return($smarty -> fetch (get_template_path("../setup/setup_step6.tpl")));
80   }
82   function save_object()
83   {
84     if(isset($_POST['step6_posted'])){
86       /* Get attributes */
87       foreach($this->attributes as $attr){
88         if(isset($_POST[$attr])){
89           $this->$attr = validate($_POST[$attr]);
90         }
91       }
93       /* Generic settings */
94       if(isset($_POST['idgen_active'])){
95         $this->generic_settings['idgen_active'] = TRUE;
96         if(isset($_POST['idgen'])){
97           $this->generic_settings['idgen'] = $_POST['idgen'];
98         }
99       }else{
100         $this->generic_settings['idgen_active'] = FALSE;
101       }
102       if(isset($_POST['snapshot_active'])){
103         $this->generic_settings['snapshot_active'] = TRUE;
104         if(isset($_POST['snapshot_base'])){
105           $this->generic_settings['snapshot_base'] = $_POST['snapshot_base'];
106         }
107         if(isset($_POST['snapshot_user'])){
108           $this->generic_settings['snapshot_user'] = $_POST['snapshot_user'];
109         }
110         if(isset($_POST['snapshot_password'])){
111           $this->generic_settings['snapshot_password'] = $_POST['snapshot_password'];
112         }
113         if(isset($_POST['snapshot_server'])){
114           $this->generic_settings['snapshot_server'] = $_POST['snapshot_server'];
115         }
116       }else{
117         $this->generic_settings['snapshot_active'] = FALSE;
118       }
120       /* Samba settings */
121       if(isset($_POST['samba_sid_active'])){
122         $this->samba_settings['samba_sid_active'] = TRUE;
123         if(isset($_POST['samba_sid'])){
124           $this->samba_settings['samba_sid'] = $_POST['samba_sid'];
125         }
126       }else{
127         $this->samba_settings['samba_sid_active'] = FALSE;
128       }
129       if(isset($_POST['samba_rid_active'])){
130         $this->samba_settings['samba_rid_active'] = TRUE;
131         if(isset($_POST['samba_rid'])){
132           $this->samba_settings['samba_rid'] = $_POST['samba_rid'];
133         }
134       }else{
135         $this->samba_settings['samba_rid_active'] = FALSE;
136       }
138     }
140     $tmp = $this->check();
141     if(count($tmp) == 0){
142       $this->is_completed = TRUE;
143     }else{
144       $this->is_completed = FALSE;
145     }
146   }
149   function check()
150   {
151     $message = array();
152     return($message);
153   }
154   
156   /* Attributes that are interesting for configuration generation */
157   function get_attributes()
158   {
159     $tmp = setup_step::get_attributes();
160     foreach(array("samba_settings","generic_settings") as $attr){
161       $tmp[$attr]= $this->$attr;
162     }
163     return($tmp);
164   }
168 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
169 ?>