Code

Added krbsasl and fixed strict behavior
[gosa.git] / setup / class_setupStep_Config1.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_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;
33   var $header_image = "images/ldapserver.png";
34   var $account_expiration  =FALSE;
35   var $base_hook         = "/usr/bin/sudo myscript"; 
36   var $base_hook_active  = FALSE; 
38   var $encryption = "crypt";
39   var $theme      = "default"; 
40   var $errorlvl   = FALSE;
42   var $include_personal_title = FALSE;
43   var $rfc2307bis             = FALSE;
45   var $pwd_rules  = array("pwminlen" => 6, 
46                           "pwminlen_active" => FALSE,
47                           "pwdiffer" => 5,
48                           "pwdiffer_active" => FALSE,
49                           "externalpwdhook" => "/path/to/your/script username oldpassword newpassword",
50                           "externalpwdhook_active" => FALSE);
52   var $id_settings = array(       "idgen"         => "{%sn}-{%givenName[2-4]}",
53                                   "idgen_active"  => FALSE,
54                                   "minid"         => "100",
55                                   "minid_active"  => FALSE);
57   var $crypt_methods  = array();
59   var $attributes = array("peopleou","groupou","peopledn","uidbase","encryption","theme","errorlvl","rfc2307bis","krbsasl",
60                           "base_hook","base_hook_active","account_expiration","strict","include_personal_title");
62   function Step_Config1()
63   {
64     $this->update_strings();
66     $tmp = @passwordMethod::get_available_methods_if_not_loaded();
67     foreach($tmp['name'] as $name){
68       $this->crypt_methods[$name] = $name;
69     }
70   }
73   function update_strings()
74   {
75     $this->s_title      = _("GOsa settings 1/3");
76     $this->s_title_long = _("GOsa settings 1/3");
77     $this->s_info       = _("GOsa generic settings");
78   }
80   
81   function execute()
82   {
83     $smarty = get_smarty();
84     $smarty->assign("peopledns",array("uid","cn"));
85     $smarty->assign("id_settings",$this->id_settings);
86     $smarty->assign("crypt_methods",$this->crypt_methods);
87     $smarty->assign("themes",$this->get_themes());
88     $smarty->assign("pwd_rules",$this->pwd_rules);
89     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
90     foreach($this->attributes as $attr){
91       $smarty->assign($attr,$this->$attr);
92     }
94     /* !!! Attention strict is inverse. If you change this, 
95      *  don't forget to change save_object too 
96      */
97     $smarty->assign("strict",!$this->strict);
98     return($smarty -> fetch (get_template_path("../setup/setup_config1.tpl")));
99   }
102   function get_themes()
103   {
104     $dir = opendir( "../ihtml/themes/");
105     $themes = array();
106     while (($file = readdir($dir)) !== false){
107       if(is_dir("../ihtml/themes/".$file) && !preg_match("/^\./",$file)){
108         $themes[$file] = $file;
109       }      
110     }
111     return($themes);
112   }
114   function check()
115   {
116     $message = array();
118     if(isset($this->id_settings['minid_active']) && !is_numeric($this->id_settings['minid'])){
119       $message[] = sprintf(_("The specified value for '%s' must be a numeric value"),_("GID / UID min id"));
120     }
122     if(preg_match("/,$/",$this->peopleou)){
123       $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("People storage ou"));
124     }
126     if(preg_match("/,$/",$this->groupou)){
127       $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("Group storage ou"));
128     }
130     if(!is_numeric($this->uidbase)){
131       $message[] = _("Uid base must be numeric");
132     }
134     if(($this->pwd_rules['pwminlen_active']) && !is_numeric($this->pwd_rules['pwminlen'])){
135       $message[] = _("The given password minimum length is not numeric.");
136     }
137     if(($this->pwd_rules['pwdiffer_active']) && !is_numeric($this->pwd_rules['pwdiffer'])){
138       $message[] = _("The given password differ value is not numeric.");
139     }
140     return($message);
141   }
143   function save_object()
144   {
145     if(isset($_POST['step5_posted'])){
147       /* Get attributes */
148       foreach($this->attributes as $attr){
149         if(isset($_POST[$attr])){
150           $this->$attr = validate($_POST[$attr]);
151         }
152       }
154       /* !!! Attention strict is inverse. If you change this, 
155        *  don't forget to change the smarty assignment too 
156        */
157       if(isset($_POST['strict'])){
158         if($_POST['strict']){
159           $this->strict = FALSE;
160         }else{
161           $this->strict = TRUE;
162         }
163       }
165       if(isset($_POST['minid_active'])){
166         $this->id_settings['minid_active'] = TRUE;
167         if(isset($_POST['minid'])){
168           $this->id_settings['minid'] = $_POST['minid'];
169         }
170       }else{
171         $this->id_settings['minid_active'] = FALSE;
172       }
174       /* Generic settings */
175       if(isset($_POST['idgen_active'])){
176         $this->id_settings['idgen_active'] = TRUE;
177         if(isset($_POST['idgen'])){
178           $this->id_settings['idgen'] = $_POST['idgen'];
179         }
180       }else{
181         $this->id_settings['idgen_active'] = FALSE;
182       }
184       /* Get password settings */ 
185       if(isset($_POST['pwdiffer_active'])){
186         $this->pwd_rules['pwdiffer_active'] = TRUE;
187         if(isset($_POST['pwdiffer'])){
188           $this->pwd_rules['pwdiffer'] = $_POST['pwdiffer'];
189         }
190       }else{
191         $this->pwd_rules['pwdiffer_active'] = FALSE;
192       }
194       /* Get password minimum length posts */
195       if(isset($_POST['pwminlen_active'])){
196         $this->pwd_rules['pwminlen_active'] = TRUE;
197         if(isset($_POST['pwminlen'])){
198           $this->pwd_rules['pwminlen'] = $_POST['pwminlen'];
199         }
200       }else{
201         $this->pwd_rules['pwminlen_active'] = FALSE;
202       }
204       /* External pwd settings */
205       if(isset($_POST['externalpwdhook_active'])){
206         $this->pwd_rules['externalpwdhook_active'] = TRUE;
207         if(isset($_POST['externalpwdhook'])){
208           $this->pwd_rules['externalpwdhook'] = $_POST['externalpwdhook'];
209         }
210       }else{
211         $this->pwd_rules['externalpwdhook_active'] = FALSE;
212       }
214       /* base hook settings */
215       if(isset($_POST['base_hook_active'])){
216         $this->pwd_rules['base_hook_active'] = TRUE;
217         if(isset($_POST['base_hook'])){
218           $this->pwd_rules['base_hook'] = $_POST['base_hook'];
219         }
220       }else{
221         $this->pwd_rules['base_hook_active'] = FALSE;
222       }
223     }
225     $tmp = $this->check(); 
226     if(count($tmp) == 0){
227       $this->is_completed = TRUE;
228     }else{
229       $this->is_completed = FALSE;
230     }
231   }// if tempalte posted 
234   /* Attributes that are interesting for configuration generation */
235   function get_attributes()
236   {
237     $tmp = setup_step::get_attributes();
238     foreach(array("pwd_rules","id_settings") as $attr){
239       $tmp[$attr]= $this->$attr;
240     }
241     return($tmp);
242   }
243 }// CLass
245 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
246 ?>