Code

Closes #274 - Tries to close this with last commit failed. I've forgotten to add...
[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 $header_image= "images/ldapserver.png";
27   var $errorlvl   = TRUE;
29   var $login_attributes = array("uid"       => "uid", 
30                                 "mail"      => "mail",
31                                 "uid,mail"  => "both");
32   var $optional = array(
33               "login_attribute" => "uid",
34               "strict_units" => false,
35               "list_summary" => false,
36               "forceglobals" => true,
37               "forcessl" => false,
38               "ldapstats" => false,
39               "warnssl" => true,
40               "user_filter_cookie" => true,
41               "ppd_path" => "/var/spool/ppd/",
42               "ppd_path_active" => FALSE,
43               "compile" =>  "/var/spool/gosa",
44               "snmpcommunity" =>  "goto",
45               "debuglevel" => 0,
46               "session_lifetime" => 7200,
47               "max_ldap_query_time" => "5.0",
48               "max_ldap_query_time_active" => FALSE,
50               "mailQueueScriptPath" => "/usr/bin/sudo /usr/local/sbin/mailqueue %action %id %server",
51               "mailQueueScriptPath_active" => FALSE,
53               "auto_network_hook" => "/usr/bin/net-resolver.sh",
54               "auto_network_hook_active" => FALSE,
56               "notifydir" => "",
57               "notifydir_active" => FALSE,
59               "kioskpath" => "/var/spool/kiosk",
60               "kioskpath_active" => FALSE,
62               "gotomasses_file"   => "/etc/gosa/gotomasses",
63               "gotomasses_active" => FALSE,
65               "noprimarygroup"  => FALSE);
67   var $attributes = array("errorlvl");
69   function Step_Config3()
70   {
71     $this->update_strings();
72   }
75   function update_strings()
76   {
77     $this->s_title      = _("GOsa settings 3/3");
78     $this->s_title_long = _("GOsa settings 3/3");
79     $this->s_info       = _("Tweak some GOsa core behaviour");
80   }
81   
83   function execute()
84   {
85     $smarty = get_smarty();
86     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
87     $smarty->assign("optional", $this->optional);
88     foreach($this->attributes as $attr){
89       $smarty->assign($attr,$this->$attr);
90     }
91     $smarty->assign("login_attributes",$this->login_attributes);
92     return($smarty -> fetch (get_template_path("../setup/setup_config3.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(get_post($attr));
104         }
105       }
106       
107       foreach(array("login_attribute","list_summary","strict_units","snmpcommunity","noprimarygroup","forceglobals","forcessl","ldapstats","user_filter_cookie","warnssl","compile","debuglevel","session_lifetime") as $name){
108         if(isset($_POST[$name])){
109           $this->optional[$name] = get_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'] = get_post('ppd_path');
117         }
118       }else{
119         $this->optional['ppd_path_active'] = FALSE;
120       }
122       if(isset($_POST['max_ldap_query_time_active'])){
123         $this->optional['max_ldap_query_time_active'] = TRUE;
124         if(isset($_POST['max_ldap_query_time'])){
125           $this->optional['max_ldap_query_time'] = get_post('max_ldap_query_time');
126         }
127       }else{
128         $this->optional['max_ldap_query_time_active'] = FALSE;
129       }
131       if(isset($_POST['mailQueueScriptPath_active'])){
132         $this->optional['mailQueueScriptPath_active'] = TRUE;
133         if(isset($_POST['mailQueueScriptPath'])){
134           $this->optional['mailQueueScriptPath'] = get_post('mailQueueScriptPath');
135         }
136       }else{
137         $this->optional['mailQueueScriptPath_active'] = FALSE;
138       }
140       if(isset($_POST['kioskpath_active'])){
141         $this->optional['kioskpath_active'] = TRUE;
142         if(isset($_POST['kioskpath'])){
143           $this->optional['kioskpath'] = get_post('kioskpath');
144         }
145       }else{
146         $this->optional['kioskpath_active'] = FALSE;
147       }
149       if(isset($_POST['gotomasses_active'])){
150         $this->optional['gotomasses_active'] = TRUE;
151         if(isset($_POST['gotomasses_file'])){
152           $this->optional['gotomasses_file'] = get_post('gotomasses_file');
153         }
154       }else{
155         $this->optional['gotomasses_active'] = FALSE;
156       }
158       if(isset($_POST['auto_network_hook_active'])){
159         $this->optional['auto_network_hook_active'] = TRUE;
160         if(isset($_POST['auto_network_hook'])){
161           $this->optional['auto_network_hook'] = get_post('auto_network_hook');
162         }
163       }else{
164         $this->optional['auto_network_hook_active'] = FALSE;
165       }
167       if(isset($_POST['notifydir_active'])){
168         $this->optional['notifydir_active'] = TRUE;
169         if(isset($_POST['notifydir'])){
170           $this->optional['notifydir'] = get_post('notifydir');
171         }
172       }else{
173         $this->optional['notifydir_active'] = FALSE;
174       }
175     }
177     $tmp = $this->check();
178     if(count($tmp) == 0){
179       $this->is_completed = TRUE;
180     }else{
181       $this->is_completed = FALSE;
182     }
183   }
186   function check()
187   {
188     $message = array();
190     if(!is_numeric( $this->optional['session_lifetime'])){
191       $message[] = _("Session lifetime must be a numeric value.");
192     }
194     if(!is_numeric( $this->optional['max_ldap_query_time'])){
195       $message[] = _("Maximal ldap query time must be a numeric value. ");
196     }
197   
198     return($message);
199   }
200   
202   /* Attributes that are interesting for configuration generation */
203   function get_attributes()
204   {
205     $tmp = setup_step::get_attributes();
206     foreach(array("optional") as $attr){
207       $tmp[$attr]= $this->$attr;
208     }
209     return($tmp);
210   }
214 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
215 ?>