Code

Fixed post capture for noprimarygroup.
[gosa.git] / setup / class_setupStep6a.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 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               "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 setup_step_6a()
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")));
81     $smarty->assign("optional", $this->optional);
83     foreach($this->attributes as $attr){
84       $smarty->assign($attr,$this->$attr);
85     }
87     $smarty->assign("warnings" ,$this->check());
88     $smarty->assign("warnings_cnt" ,count($this->check()));
90     return($smarty -> fetch (get_template_path("../setup/setup_step6a.tpl")));
91   }
94   function save_object()
95   {
96     if(isset($_POST['step6a_posted'])){
98       /* Get attributes */
99       foreach($this->attributes as $attr){
100         if(isset($_POST[$attr])){
101           $this->$attr = validate($_POST[$attr]);
102         }
103       }
104       
105       foreach(array("noprimarygroup","enableCopyPaste","forceglobals","forcessl","warnssl","compile","debuglevel","session_lifetime","smbhash") as $name){
106         if(isset($_POST[$name])){
107           $this->optional[$name] = stripslashes($_POST[$name]);
108         }
109       } 
111       if(isset($_POST['ppd_path_active'])){
112         $this->optional['ppd_path_active'] = TRUE;
113         if(isset($_POST['ppd_path'])){
114           $this->optional['ppd_path'] = $_POST['ppd_path'];
115         }
116       }else{
117         $this->optional['ppd_path_active'] = FALSE;
118       }
120       if(isset($_POST['max_ldap_query_time_active'])){
121         $this->optional['max_ldap_query_time_active'] = TRUE;
122         if(isset($_POST['max_ldap_query_time'])){
123           $this->optional['max_ldap_query_time'] = $_POST['max_ldap_query_time'];
124         }
125       }else{
126         $this->optional['max_ldap_query_time_active'] = FALSE;
127       }
129       if(isset($_POST['mailQueueScriptPath_active'])){
130         $this->optional['mailQueueScriptPath_active'] = TRUE;
131         if(isset($_POST['mailQueueScriptPath'])){
132           $this->optional['mailQueueScriptPath'] = $_POST['mailQueueScriptPath'];
133         }
134       }else{
135         $this->optional['mailQueueScriptPath_active'] = FALSE;
136       }
138       if(isset($_POST['auto_network_hook_active'])){
139         $this->optional['auto_network_hook_active'] = TRUE;
140         if(isset($_POST['auto_network_hook'])){
141           $this->optional['auto_network_hook'] = $_POST['auto_network_hook'];
142         }
143       }else{
144         $this->optional['auto_network_hook_active'] = FALSE;
145       }
147       if(isset($_POST['notifydir_active'])){
148         $this->optional['notifydir_active'] = TRUE;
149         if(isset($_POST['notifydir'])){
150           $this->optional['notifydir'] = $_POST['notifydir'];
151         }
152       }else{
153         $this->optional['notifydir_active'] = FALSE;
154       }
155     }
157     $tmp = $this->check();
158     if(count($tmp) == 0){
159       $this->is_completed = TRUE;
160     }else{
161       $this->is_completed = FALSE;
162     }
163   }
166   function check()
167   {
168     $message = array();
170     if(!is_numeric( $this->optional['session_lifetime'])){
171       $message[] = _("Session lifetime must be a numeric value.");
172     }
174     if(!is_numeric( $this->optional['max_ldap_query_time'])){
175       $message[] = _("Maximal ldap query time must be a numeric value. ");
176     }
177   
178     return($message);
179   }
180   
182   /* Attributes that are interesting for configuration generation */
183   function get_attributes()
184   {
185     $tmp = setup_step::get_attributes();
186     foreach(array("optional") as $attr){
187       $tmp[$attr]= $this->$attr;
188     }
189     return($tmp);
190   }
194 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
195 ?>