Code

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