9f3076b131415ffaa79ab53cc821f60e84b8501a
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;
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_ldap_base" => "%base%",
40 "snapshot_user" => "cn=ldapadmin,%base%",
41 "snapshot_password" => "",
42 "snapshot_server" => "%connection%");
44 var $samba_settings = array( "samba_sid" => "0-815-4711",
45 "samba_sid_active" => FALSE,
46 "samba_rid" => 1000,
47 "samba_rid_active" => FALSE);
48 var $attributes = array("strict","governmentmode","sambaidmapping","account_expiration");
50 function Step_Config2()
51 {
52 $this->update_strings();
53 }
56 function update_strings()
57 {
58 $this->s_title = _("GOsa settings 2/3");
59 $this->s_title_long = _("GOsa generic settings, page 2/3");
60 $this->s_info = _("This dialog allows you to setup GOsa behaviour");
61 }
64 function execute()
65 {
66 /* Update snapshot values, with already collected values */
67 foreach($this->generic_settings as $key => $value){
68 foreach(array("snapshot_ldap_base","snapshot_base","snapshot_user","snapshot_server") as $attr){
69 foreach($this->parent->captured_values as $replace_name => $replace_value){
70 if(is_string($replace_value)) {
71 $this->generic_settings[$attr] = preg_replace("/%".$replace_name."%/",$replace_value,$this->generic_settings[$attr]);
72 }
73 }
74 }
75 }
77 $smarty = get_smarty();
78 $smarty->assign("generic_settings",$this->generic_settings);
79 $smarty->assign("samba_settings",$this->samba_settings);
80 $smarty->assign("warnings" ,$this->check());
81 $smarty->assign("warnings_cnt" ,count($this->check()));
82 $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
83 foreach($this->attributes as $attr){
84 $smarty->assign($attr,$this->$attr);
85 }
86 return($smarty -> fetch (get_template_path("../setup/setup_config2.tpl")));
87 }
89 function save_object()
90 {
91 if(isset($_POST['step6_posted'])){
93 /* Get attributes */
94 foreach($this->attributes as $attr){
95 if(isset($_POST[$attr])){
96 $this->$attr = validate($_POST[$attr]);
97 }
98 }
100 if(isset($_POST['minid_active'])){
101 $this->generic_settings['minid_active'] = TRUE;
102 if(isset($_POST['minid'])){
103 $this->generic_settings['minid'] = $_POST['minid'];
104 }
105 }else{
106 $this->generic_settings['minid_active'] = FALSE;
107 }
109 if(isset($_POST['wws_ou_active'])){
110 $this->generic_settings['wws_ou_active'] = TRUE;
111 if(isset($_POST['wws_ou'])){
112 $this->generic_settings['wws_ou'] = $_POST['wws_ou'];
113 }
114 }else{
115 $this->generic_settings['wws_ou_active'] = FALSE;
116 }
118 /* Generic settings */
119 if(isset($_POST['idgen_active'])){
120 $this->generic_settings['idgen_active'] = TRUE;
121 if(isset($_POST['idgen'])){
122 $this->generic_settings['idgen'] = $_POST['idgen'];
123 }
124 }else{
125 $this->generic_settings['idgen_active'] = FALSE;
126 }
127 if(isset($_POST['snapshot_active'])){
128 $this->generic_settings['snapshot_active'] = TRUE;
129 if(isset($_POST['snapshot_base'])){
130 $this->generic_settings['snapshot_base'] = $_POST['snapshot_base'];
131 }
132 if(isset($_POST['snapshot_user'])){
133 $this->generic_settings['snapshot_user'] = $_POST['snapshot_user'];
134 }
135 if(isset($_POST['snapshot_password'])){
136 $this->generic_settings['snapshot_password'] = $_POST['snapshot_password'];
137 }
138 if(isset($_POST['snapshot_server'])){
139 $this->generic_settings['snapshot_server'] = $_POST['snapshot_server'];
140 }
141 if(isset($_POST['snapshot_ldap_base'])){
142 $this->generic_settings['snapshot_ldap_base'] = $_POST['snapshot_ldap_base'];
143 }
144 }else{
145 $this->generic_settings['snapshot_active'] = FALSE;
146 }
148 /* Samba settings */
149 if(isset($_POST['samba_sid_active'])){
150 $this->samba_settings['samba_sid_active'] = TRUE;
151 if(isset($_POST['samba_sid'])){
152 $this->samba_settings['samba_sid'] = $_POST['samba_sid'];
153 }
154 }else{
155 $this->samba_settings['samba_sid_active'] = FALSE;
156 }
157 if(isset($_POST['samba_rid_active'])){
158 $this->samba_settings['samba_rid_active'] = TRUE;
159 if(isset($_POST['samba_rid'])){
160 $this->samba_settings['samba_rid'] = $_POST['samba_rid'];
161 }
162 }else{
163 $this->samba_settings['samba_rid_active'] = FALSE;
164 }
166 }
168 $tmp = $this->check();
169 if(count($tmp) == 0){
170 $this->is_completed = TRUE;
171 }else{
172 $this->is_completed = FALSE;
173 }
174 }
177 function check()
178 {
179 $message = array();
181 if(isset($this->generic_settings['minid_active']) && !is_numeric($this->generic_settings['minid'])){
182 $message[] = sprintf(_("The specified value for '%s' must be a numeric value"),_("GID / UID min id"));
183 }
185 return($message);
186 }
189 /* Attributes that are interesting for configuration generation */
190 function get_attributes()
191 {
192 $tmp = setup_step::get_attributes();
193 foreach(array("samba_settings","generic_settings") as $attr){
194 $tmp[$attr]= $this->$attr;
195 }
196 return($tmp);
197 }
199 }
201 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
202 ?>