Code

Added rfc2307bis
[gosa.git] / setup / class_setupStep_Config3.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_Config3 extends setup_step
24 {
25   var $header_image= "images/ldap.png";
26   var $optional = array(
27               "strict_units" => false,
28               "forceglobals" => true,
29               "forcessl" => false,
30               "warnssl" => true,
31               "ppd_path" => "/var/spool/ppd/",
32               "ppd_path_active" => FALSE,
33               "compile" =>  "/var/spool/gosa",
34               "debuglevel" => 0,
35               "session_lifetime" => 7200,
36               "max_ldap_query_time" => "5.0",
37               "max_ldap_query_time_active" => FALSE,
39               "mailQueueScriptPath" => "/usr/bin/sudo /usr/local/sbin/mailqueue %action %id %server",
40               "mailQueueScriptPath_active" => FALSE,
42               "auto_network_hook" => "/etc/gosa/net-resolv.sh",
43               "auto_network_hook_active" => FALSE,
45               "notifydir" => "",
46               "notifydir_active" => FALSE,
48               "kioskpath" => "/var/spool/kiosk",
49               "kioskpath_active" => FALSE,
51               "noprimarygroup"  => FALSE,
52               "smbhash" => 'SMBHASH');
55   function Step_Config3()
56   {
57     $this->update_strings();
59     /* Look for samba password generation method */
60     if(file_exists("/usr/bin/mkntpasswd")){
61       $pwdhash  = "/usr/bin/mkntpasswd";
62     } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){
63       $pwdhash= "mkntpwd";
64     } else {
65       $pwdhash= 'perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen \$ARGV[0]), $/;"';
66     }
68     $this->optional['smbhash'] = $pwdhash;
69   }
72   function update_strings()
73   {
74     $this->s_title      = _("GOsa settings 3/3");
75     $this->s_title_long = _("GOsa settings 3/3");
76     $this->s_info       = _("Tweak some GOsa core behaviour");
77   }
78   
80   function execute()
81   {
82     $smarty = get_smarty();
83     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
84     $smarty->assign("optional", $this->optional);
85     foreach($this->attributes as $attr){
86       $smarty->assign($attr,$this->$attr);
87     }
88     return($smarty -> fetch (get_template_path("../setup/setup_config3.tpl")));
89   }
92   function save_object()
93   {
94     if(isset($_POST['step6a_posted'])){
96       /* Get attributes */
97       foreach($this->attributes as $attr){
98         if(isset($_POST[$attr])){
99           $this->$attr = validate($_POST[$attr]);
100         }
101       }
102       
103       foreach(array("strict_units","noprimarygroup","forceglobals","forcessl","warnssl","compile","debuglevel","session_lifetime","smbhash") as $name){
104         if(isset($_POST[$name])){
105           $this->optional[$name] = stripslashes($_POST[$name]);
106         }
107       } 
109       if(isset($_POST['ppd_path_active'])){
110         $this->optional['ppd_path_active'] = TRUE;
111         if(isset($_POST['ppd_path'])){
112           $this->optional['ppd_path'] = $_POST['ppd_path'];
113         }
114       }else{
115         $this->optional['ppd_path_active'] = FALSE;
116       }
118       if(isset($_POST['max_ldap_query_time_active'])){
119         $this->optional['max_ldap_query_time_active'] = TRUE;
120         if(isset($_POST['max_ldap_query_time'])){
121           $this->optional['max_ldap_query_time'] = $_POST['max_ldap_query_time'];
122         }
123       }else{
124         $this->optional['max_ldap_query_time_active'] = FALSE;
125       }
127       if(isset($_POST['mailQueueScriptPath_active'])){
128         $this->optional['mailQueueScriptPath_active'] = TRUE;
129         if(isset($_POST['mailQueueScriptPath'])){
130           $this->optional['mailQueueScriptPath'] = $_POST['mailQueueScriptPath'];
131         }
132       }else{
133         $this->optional['mailQueueScriptPath_active'] = FALSE;
134       }
136       if(isset($_POST['kioskpath_active'])){
137         $this->optional['kioskpath_active'] = TRUE;
138         if(isset($_POST['kioskpath'])){
139           $this->optional['kioskpath'] = $_POST['kioskpath'];
140         }
141       }else{
142         $this->optional['kioskpath_active'] = FALSE;
143       }
145       if(isset($_POST['auto_network_hook_active'])){
146         $this->optional['auto_network_hook_active'] = TRUE;
147         if(isset($_POST['auto_network_hook'])){
148           $this->optional['auto_network_hook'] = $_POST['auto_network_hook'];
149         }
150       }else{
151         $this->optional['auto_network_hook_active'] = FALSE;
152       }
154       if(isset($_POST['notifydir_active'])){
155         $this->optional['notifydir_active'] = TRUE;
156         if(isset($_POST['notifydir'])){
157           $this->optional['notifydir'] = $_POST['notifydir'];
158         }
159       }else{
160         $this->optional['notifydir_active'] = FALSE;
161       }
162     }
164     $tmp = $this->check();
165     if(count($tmp) == 0){
166       $this->is_completed = TRUE;
167     }else{
168       $this->is_completed = FALSE;
169     }
170   }
173   function check()
174   {
175     $message = array();
177     if(!is_numeric( $this->optional['session_lifetime'])){
178       $message[] = _("Session lifetime must be a numeric value.");
179     }
181     if(!is_numeric( $this->optional['max_ldap_query_time'])){
182       $message[] = _("Maximal ldap query time must be a numeric value. ");
183     }
184   
185     return($message);
186   }
187   
189   /* Attributes that are interesting for configuration generation */
190   function get_attributes()
191   {
192     $tmp = setup_step::get_attributes();
193     foreach(array("optional") as $attr){
194       $tmp[$attr]= $this->$attr;
195     }
196     return($tmp);
197   }
201 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
202 ?>