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 setup_step_6a extends setup_step
24 {
25 var $optional = array(
26 "enableCopyPaste" => false,
27 "forceglobals" => false,
28 "forcessl" => false,
29 "warnssl" => false,
30 "ppd_path" => "/var/spool/ppd/",
31 "ppd_path_active" => FALSE,
32 "kde_applications_menu" => "",
33 "kde_applications_menu_active" => FALSE,
34 "compile" => "/var/spool/gosa",
35 "debuglevel" => 0,
36 "session_lifetime" => 7200,
37 "max_ldap_query_time" => "5.0",
38 "max_ldap_query_time_active" => FALSE,
40 "mailQueueScriptPath" => "/usr/bin/sudo /usr/local/sbin/mailqueue %action %id %server",
41 "mailQueueScriptPath_active" => FALSE,
43 "auto_network_hook" => "/etc/gosa/net-resolv.sh",
44 "auto_network_hook_active" => FALSE,
46 "notifydir" => "",
47 "notifydir_active" => FALSE,
49 "noprimarygroup" => FALSE,
50 "smbhash" => 'SMBHASH');
53 function setup_step_6a()
54 {
55 $this->update_strings();
57 /* Look for samba password generation method */
58 if(file_exists("/usr/bin/mkntpasswd")){
59 $pwdhash = "/usr/bin/mkntpasswd";
60 } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){
61 $pwdhash= "mkntpwd";
62 } else {
63 $pwdhash= 'perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen \$ARGV[0]), $/;"';
64 }
66 $this->optional['smbhash'] = $pwdhash;
67 }
70 function update_strings()
71 {
72 $this->s_title = _("GOsa settings 3/3");
73 $this->s_title_long = _("GOsa generic settings, page 3/3");
74 $this->s_info = _("This dialog allows you to setup GOsa behaviour");
75 }
78 function execute()
79 {
80 $smarty = get_smarty();
81 $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
83 $smarty->assign("optional", $this->optional);
85 foreach($this->attributes as $attr){
86 $smarty->assign($attr,$this->$attr);
87 }
89 $smarty->assign("warnings" ,$this->check());
90 $smarty->assign("warnings_cnt" ,count($this->check()));
92 return($smarty -> fetch (get_template_path("../setup/setup_step6a.tpl")));
93 }
96 function save_object()
97 {
98 if(isset($_POST['step6a_posted'])){
100 /* Get attributes */
101 foreach($this->attributes as $attr){
102 if(isset($_POST[$attr])){
103 $this->$attr = validate($_POST[$attr]);
104 }
105 }
107 foreach(array("enableCopyPaste","forceglobals","forcessl","warnssl","compile","debuglevel","session_lifetime","smbhash") as $name){
108 if(isset($_POST[$name])){
109 $this->optional[$name] = stripslashes($_POST[$name]);
110 }
111 }
113 if(isset($_POST['ppd_path_active'])){
114 $this->optional['ppd_path_active'] = TRUE;
115 if(isset($_POST['ppd_path'])){
116 $this->optional['ppd_path'] = $_POST['ppd_path'];
117 }
118 }else{
119 $this->optional['ppd_path_active'] = FALSE;
120 }
122 if(isset($_POST['kde_applications_menu_active'])){
123 $this->optional['kde_applications_menu_active'] = TRUE;
124 if(isset($_POST['kde_applications_menu'])){
125 $this->optional['kde_applications_menu'] = $_POST['kde_applications_menu'];
126 }
127 }else{
128 $this->optional['kde_applications_menu_active'] = FALSE;
129 }
131 if(isset($_POST['max_ldap_query_time_active'])){
132 $this->optional['max_ldap_query_time_active'] = TRUE;
133 if(isset($_POST['max_ldap_query_time'])){
134 $this->optional['max_ldap_query_time'] = $_POST['max_ldap_query_time'];
135 }
136 }else{
137 $this->optional['max_ldap_query_time_active'] = FALSE;
138 }
140 if(isset($_POST['mailQueueScriptPath_active'])){
141 $this->optional['mailQueueScriptPath_active'] = TRUE;
142 if(isset($_POST['mailQueueScriptPath'])){
143 $this->optional['mailQueueScriptPath'] = $_POST['mailQueueScriptPath'];
144 }
145 }else{
146 $this->optional['mailQueueScriptPath_active'] = FALSE;
147 }
149 if(isset($_POST['auto_network_hook_active'])){
150 $this->optional['auto_network_hook_active'] = TRUE;
151 if(isset($_POST['auto_network_hook'])){
152 $this->optional['auto_network_hook'] = $_POST['auto_network_hook'];
153 }
154 }else{
155 $this->optional['auto_network_hook_active'] = FALSE;
156 }
158 if(isset($_POST['notifydir_active'])){
159 $this->optional['notifydir_active'] = TRUE;
160 if(isset($_POST['notifydir'])){
161 $this->optional['notifydir'] = $_POST['notifydir'];
162 }
163 }else{
164 $this->optional['notifydir_active'] = FALSE;
165 }
166 }
168 $tmp = $this->check();
169 if(count($tmp) == 0){
170 $this->is_completed = TRUE;
171 }else{
172 $this->is_completed = FALSE;
173 }
174 }
177 function check()
178 {
179 $message = array();
181 if(!is_numeric( $this->optional['session_lifetime'])){
182 $message[] = _("Session lifetime must be a numeric value.");
183 }
185 if(!is_numeric( $this->optional['max_ldap_query_time'])){
186 $message[] = _("Maximal ldap query time must be a numeric value. ");
187 }
189 return($message);
190 }
193 /* Attributes that are interesting for configuration generation */
194 function get_attributes()
195 {
196 $tmp = setup_step::get_attributes();
197 foreach(array("optional") as $attr){
198 $tmp[$attr]= $this->$attr;
199 }
200 return($tmp);
201 }
203 }
205 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
206 ?>