Code

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