1087b6a2b18af2da7ebc52cb32659aba184de84c
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_Config1 extends setup_step
24 {
26 var $peopleou = "ou=people";
27 var $groupou = "ou=groups";
28 var $peopledn = "cn";
29 var $uidbase = 1000;
30 var $krbsasl = FALSE;
31 var $strict = TRUE;
32 var $compressed = TRUE;
34 var $header_image = "images/ldapserver.png";
35 var $account_expiration =FALSE;
36 var $base_hook = "";
37 var $base_hook_active = FALSE;
39 var $encryption = "crypt";
40 var $theme = "default";
42 var $include_personal_title = FALSE;
44 var $pwd_rules = array("pwminlen" => 6,
45 "pwminlen_active" => FALSE,
46 "pwdiffer" => 5,
47 "pwdiffer_active" => FALSE,
48 "externalpwdhook" => "",
49 "externalpwdhook_active" => FALSE);
51 var $id_settings = array( "idgen" => "{%sn}-{%givenName[2-4]}",
52 "idgen_active" => FALSE,
53 "minid" => "100",
54 "minid_active" => FALSE);
56 var $crypt_methods = array();
58 var $attributes = array("compressed","peopleou","groupou","peopledn","uidbase","encryption","theme","krbsasl",
59 "base_hook","base_hook_active","account_expiration","strict","include_personal_title");
61 function Step_Config1()
62 {
63 $this->update_strings();
65 $tmp = @passwordMethod::get_available_methods();
66 foreach($tmp['name'] as $name){
67 $this->crypt_methods[$name] = $name;
68 }
69 }
72 function update_strings()
73 {
74 $this->s_title = _("GOsa settings 1/3");
75 $this->s_title_long = _("GOsa settings 1/3");
76 $this->s_info = _("GOsa generic settings");
77 }
80 function execute()
81 {
82 $smarty = get_smarty();
83 $smarty->assign("peopledns",array("uid","cn"));
84 $smarty->assign("id_settings",$this->id_settings);
85 $smarty->assign("crypt_methods",$this->crypt_methods);
86 $smarty->assign("themes",$this->get_themes());
87 $smarty->assign("pwd_rules",$this->pwd_rules);
88 $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
89 foreach($this->attributes as $attr){
90 $smarty->assign($attr,$this->$attr);
91 }
93 /* !!! Attention strict is inverse. If you change this,
94 * don't forget to change save_object too
95 */
96 $smarty->assign("strict",!$this->strict);
97 return($smarty -> fetch (get_template_path("../setup/setup_config1.tpl")));
98 }
101 function get_themes()
102 {
103 $dir = opendir( "../ihtml/themes/");
104 $themes = array();
105 while (($file = readdir($dir)) !== false){
106 if(is_dir("../ihtml/themes/".$file) && !preg_match("/^\./",$file)){
107 $themes[$file] = $file;
108 }
109 }
110 return($themes);
111 }
113 function check()
114 {
115 $message = array();
117 if(isset($this->id_settings['minid_active']) && !is_numeric($this->id_settings['minid'])){
118 $message[] = sprintf(_("The specified value for '%s' must be a numeric value"),_("GID / UID min id"));
119 }
121 if(preg_match("/,$/",$this->peopleou)){
122 $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("People storage ou"));
123 }
125 if(preg_match("/,$/",$this->groupou)){
126 $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("Group storage ou"));
127 }
129 if(!is_numeric($this->uidbase)){
130 $message[] = _("Uid base must be numeric");
131 }
133 if(($this->pwd_rules['pwminlen_active']) && !is_numeric($this->pwd_rules['pwminlen'])){
134 $message[] = _("The given password minimum length is not numeric.");
135 }
136 if(($this->pwd_rules['pwdiffer_active']) && !is_numeric($this->pwd_rules['pwdiffer'])){
137 $message[] = _("The given password differ value is not numeric.");
138 }
139 return($message);
140 }
142 function save_object()
143 {
144 if(isset($_POST['step5_posted'])){
146 /* Get attributes */
147 foreach($this->attributes as $attr){
148 if(isset($_POST[$attr])){
149 $this->$attr = validate(get_post($attr));
150 }
151 }
153 /* !!! Attention strict is inverse. If you change this,
154 * don't forget to change the smarty assignment too
155 */
156 if(isset($_POST['strict'])){
157 if($_POST['strict']){
158 $this->strict = FALSE;
159 }else{
160 $this->strict = TRUE;
161 }
162 }
164 if(isset($_POST['minid_active'])){
165 $this->id_settings['minid_active'] = TRUE;
166 if(isset($_POST['minid'])){
167 $this->id_settings['minid'] = get_post('minid');
168 }
169 }else{
170 $this->id_settings['minid_active'] = FALSE;
171 }
173 /* Generic settings */
174 if(isset($_POST['idgen_active'])){
175 $this->id_settings['idgen_active'] = TRUE;
176 if(isset($_POST['idgen'])){
177 $this->id_settings['idgen'] = get_post('idgen');
178 }
179 }else{
180 $this->id_settings['idgen_active'] = FALSE;
181 }
183 /* Get password settings */
184 if(isset($_POST['pwdiffer_active'])){
185 $this->pwd_rules['pwdiffer_active'] = TRUE;
186 if(isset($_POST['pwdiffer'])){
187 $this->pwd_rules['pwdiffer'] = get_post('pwdiffer');
188 }
189 }else{
190 $this->pwd_rules['pwdiffer_active'] = FALSE;
191 }
193 /* Get password minimum length posts */
194 if(isset($_POST['pwminlen_active'])){
195 $this->pwd_rules['pwminlen_active'] = TRUE;
196 if(isset($_POST['pwminlen'])){
197 $this->pwd_rules['pwminlen'] = get_post('pwminlen');
198 }
199 }else{
200 $this->pwd_rules['pwminlen_active'] = FALSE;
201 }
203 /* External pwd settings */
204 if(isset($_POST['externalpwdhook_active'])){
205 $this->pwd_rules['externalpwdhook_active'] = TRUE;
206 if(isset($_POST['externalpwdhook'])){
207 $this->pwd_rules['externalpwdhook'] = get_post('externalpwdhook');
208 }
209 }else{
210 $this->pwd_rules['externalpwdhook_active'] = FALSE;
211 }
213 /* base hook settings */
214 if(isset($_POST['base_hook_active'])){
215 $this->pwd_rules['base_hook_active'] = TRUE;
216 if(isset($_POST['base_hook'])){
217 $this->pwd_rules['base_hook'] = get_post('base_hook');
218 }
219 }else{
220 $this->pwd_rules['base_hook_active'] = FALSE;
221 }
222 }
224 $tmp = $this->check();
225 if(count($tmp) == 0){
226 $this->is_completed = TRUE;
227 }else{
228 $this->is_completed = FALSE;
229 }
230 }// if tempalte posted
233 /* Attributes that are interesting for configuration generation */
234 function get_attributes()
235 {
236 $tmp = setup_step::get_attributes();
237 foreach(array("pwd_rules","id_settings") as $attr){
238 $tmp[$attr]= $this->$attr;
239 }
240 return($tmp);
241 }
242 }// CLass
244 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
245 ?>