Code

Moved strict to step1
[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               "noprimarygroup"  => FALSE,
48               "smbhash" => 'SMBHASH');
51   function Step_Config3()
52   {
53     $this->update_strings();
55     /* Look for samba password generation method */
56     if(file_exists("/usr/bin/mkntpasswd")){
57       $pwdhash  = "/usr/bin/mkntpasswd";
58     } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){
59       $pwdhash= "mkntpwd";
60     } else {
61       $pwdhash= 'perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen \$ARGV[0]), $/;"';
62     }
64     $this->optional['smbhash'] = $pwdhash;
65   }
68   function update_strings()
69   {
70     $this->s_title      = _("GOsa settings 3/3");
71     $this->s_title_long = _("GOsa generic settings, page 3/3");
72     $this->s_info       = _("This dialog allows you to setup GOsa behaviour");
73   }
74   
76   function execute()
77   {
78     $smarty = get_smarty();
79     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
80     $smarty->assign("optional", $this->optional);
81     foreach($this->attributes as $attr){
82       $smarty->assign($attr,$this->$attr);
83     }
84     return($smarty -> fetch (get_template_path("../setup/setup_config3.tpl")));
85   }
88   function save_object()
89   {
90     if(isset($_POST['step6a_posted'])){
92       /* Get attributes */
93       foreach($this->attributes as $attr){
94         if(isset($_POST[$attr])){
95           $this->$attr = validate($_POST[$attr]);
96         }
97       }
98       
99       foreach(array("strict_units","noprimarygroup","forceglobals","forcessl","warnssl","compile","debuglevel","session_lifetime","smbhash") as $name){
100         if(isset($_POST[$name])){
101           $this->optional[$name] = stripslashes($_POST[$name]);
102         }
103       } 
105       if(isset($_POST['ppd_path_active'])){
106         $this->optional['ppd_path_active'] = TRUE;
107         if(isset($_POST['ppd_path'])){
108           $this->optional['ppd_path'] = $_POST['ppd_path'];
109         }
110       }else{
111         $this->optional['ppd_path_active'] = FALSE;
112       }
114       if(isset($_POST['max_ldap_query_time_active'])){
115         $this->optional['max_ldap_query_time_active'] = TRUE;
116         if(isset($_POST['max_ldap_query_time'])){
117           $this->optional['max_ldap_query_time'] = $_POST['max_ldap_query_time'];
118         }
119       }else{
120         $this->optional['max_ldap_query_time_active'] = FALSE;
121       }
123       if(isset($_POST['mailQueueScriptPath_active'])){
124         $this->optional['mailQueueScriptPath_active'] = TRUE;
125         if(isset($_POST['mailQueueScriptPath'])){
126           $this->optional['mailQueueScriptPath'] = $_POST['mailQueueScriptPath'];
127         }
128       }else{
129         $this->optional['mailQueueScriptPath_active'] = FALSE;
130       }
132       if(isset($_POST['auto_network_hook_active'])){
133         $this->optional['auto_network_hook_active'] = TRUE;
134         if(isset($_POST['auto_network_hook'])){
135           $this->optional['auto_network_hook'] = $_POST['auto_network_hook'];
136         }
137       }else{
138         $this->optional['auto_network_hook_active'] = FALSE;
139       }
141       if(isset($_POST['notifydir_active'])){
142         $this->optional['notifydir_active'] = TRUE;
143         if(isset($_POST['notifydir'])){
144           $this->optional['notifydir'] = $_POST['notifydir'];
145         }
146       }else{
147         $this->optional['notifydir_active'] = FALSE;
148       }
149     }
151     $tmp = $this->check();
152     if(count($tmp) == 0){
153       $this->is_completed = TRUE;
154     }else{
155       $this->is_completed = FALSE;
156     }
157   }
160   function check()
161   {
162     $message = array();
164     if(!is_numeric( $this->optional['session_lifetime'])){
165       $message[] = _("Session lifetime must be a numeric value.");
166     }
168     if(!is_numeric( $this->optional['max_ldap_query_time'])){
169       $message[] = _("Maximal ldap query time must be a numeric value. ");
170     }
171   
172     return($message);
173   }
174   
176   /* Attributes that are interesting for configuration generation */
177   function get_attributes()
178   {
179     $tmp = setup_step::get_attributes();
180     foreach(array("optional") as $attr){
181       $tmp[$attr]= $this->$attr;
182     }
183     return($tmp);
184   }
188 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
189 ?>