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 "notifydir" => "",
54 "notifydir_active" => FALSE,
56 "uniq_identifier" => "entryCSN",
57 "uniq_identifier_active" => TRUE,
59 "kioskpath" => "/var/spool/kiosk",
60 "kioskpath_active" => FALSE,
62 "sudoou" => "ou=sudoers,%BASE%",
63 "sudoou_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 }
83 function execute()
84 {
86 $cv = $this->parent->captured_values;
87 $this->optional['sudoou'] = preg_replace("/%BASE%/",$cv['base'],$this->optional['sudoou']);
88 $smarty = get_smarty();
89 $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
90 $smarty->assign("uniq_identifiers",array( "entryCNS" => "entryCSN",
91 "contextCSN"=>"contextCSN" ));
94 $smarty->assign("optional", $this->optional);
95 foreach($this->attributes as $attr){
96 $smarty->assign($attr,$this->$attr);
97 }
98 $smarty->assign("login_attributes",$this->login_attributes);
99 return($smarty -> fetch (get_template_path("../setup/setup_config3.tpl")));
100 }
103 function save_object()
104 {
105 if(isset($_POST['step6a_posted'])){
107 /* Get attributes */
108 foreach($this->attributes as $attr){
109 if(isset($_POST[$attr])){
110 $this->$attr = validate(get_post($attr));
111 }
112 }
114 foreach(array("login_attribute","list_summary","strict_units","snmpcommunity","noprimarygroup","forceglobals","forcessl","ldapstats","user_filter_cookie","warnssl","compile","debuglevel","session_lifetime") as $name){
115 if(isset($_POST[$name])){
116 $this->optional[$name] = get_post($name);
117 }
118 }
120 if(isset($_POST['ppd_path_active'])){
121 $this->optional['ppd_path_active'] = TRUE;
122 if(isset($_POST['ppd_path'])){
123 $this->optional['ppd_path'] = get_post('ppd_path');
124 }
125 }else{
126 $this->optional['ppd_path_active'] = FALSE;
127 }
129 if(isset($_POST['max_ldap_query_time_active'])){
130 $this->optional['max_ldap_query_time_active'] = TRUE;
131 if(isset($_POST['max_ldap_query_time'])){
132 $this->optional['max_ldap_query_time'] = get_post('max_ldap_query_time');
133 }
134 }else{
135 $this->optional['max_ldap_query_time_active'] = FALSE;
136 }
138 if(isset($_POST['mailQueueScriptPath_active'])){
139 $this->optional['mailQueueScriptPath_active'] = TRUE;
140 if(isset($_POST['mailQueueScriptPath'])){
141 $this->optional['mailQueueScriptPath'] = get_post('mailQueueScriptPath');
142 }
143 }else{
144 $this->optional['mailQueueScriptPath_active'] = FALSE;
145 }
147 if(isset($_POST['kioskpath_active'])){
148 $this->optional['kioskpath_active'] = TRUE;
149 if(isset($_POST['kioskpath'])){
150 $this->optional['kioskpath'] = get_post('kioskpath');
151 }
152 }else{
153 $this->optional['kioskpath_active'] = FALSE;
154 }
156 if(isset($_POST['sudoou_active'])){
157 $this->optional['sudoou_active'] = TRUE;
158 if(isset($_POST['sudoou'])){
159 $this->optional['sudoou'] = get_post('sudoou');
160 }
161 }else{
162 $this->optional['sudoou_active'] = FALSE;
163 }
165 if(isset($_POST['notifydir_active'])){
166 $this->optional['notifydir_active'] = TRUE;
167 if(isset($_POST['notifydir'])){
168 $this->optional['notifydir'] = get_post('notifydir');
169 }
170 }else{
171 $this->optional['notifydir_active'] = FALSE;
172 }
174 if(isset($_POST['uniq_identifier_active'])){
175 $this->optional['uniq_identifier_active'] = TRUE;
176 if(isset($_POST['uniq_identifier'])){
177 $this->optional['uniq_identifier'] = get_post('uniq_identifier');
178 }
179 }else{
180 $this->optional['uniq_identifier_active'] = FALSE;
181 }
182 }
184 $tmp = $this->check();
185 if(count($tmp) == 0){
186 $this->is_completed = TRUE;
187 }else{
188 $this->is_completed = FALSE;
189 }
190 }
193 function check()
194 {
195 $message = array();
197 if(!is_numeric( $this->optional['session_lifetime'])){
198 $message[] = _("Session lifetime must be a numeric value!");
199 }
201 if(!is_numeric( $this->optional['max_ldap_query_time'])){
202 $message[] = _("Maximum LDAP query time must be a numeric value!");
203 }
205 return($message);
206 }
209 /* Attributes that are interesting for configuration generation */
210 function get_attributes()
211 {
212 $tmp = setup_step::get_attributes();
213 foreach(array("optional") as $attr){
214 $tmp[$attr]= $this->$attr;
215 }
216 return($tmp);
217 }
219 }
221 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
222 ?>