Code

Replaced config->search with get_cfg_value
[gosa.git] / gosa-core / 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/setup/server.png";
27   var $errorlvl   = false;
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" => true,
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               "templateCompileDirectory" =>  "/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               "notifydir" => "",
51               "notifydir_active" => FALSE,
53               "gosaSupportURI" => "gosa-si-secret@server:20081",
54               "gosaSupportTimeout" => 15,
55               "gosaSupportURI_active" => FALSE,
57               "uniq_identifier" => "entryCSN",
58               "uniq_identifier_active" => TRUE,
60               "kioskpath" => "/var/spool/kiosk",
61               "kioskpath_active" => FALSE,
63               "sudoou"   => "ou=sudoers",
64               "sudoou_active" => FALSE,
66               "noprimarygroup"  => FALSE);
68   var $attributes = array("errorlvl");
70   function Step_Config3()
71   {
72     $this->update_strings();
73   }
76   function update_strings()
77   {
78     $this->s_title      = _("GOsa settings 3/3");
79     $this->s_title_long = _("GOsa settings 3/3");
80     $this->s_info       = _("Tweak some GOsa core behaviour");
81   }
82   
84   function execute()
85   {
87     $cv = $this->parent->captured_values;
88     $this->optional['sudoou'] = preg_replace("/%BASE%/",$cv['base'],$this->optional['sudoou']);
89     $smarty = get_smarty();
90     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
91     $smarty->assign("uniq_identifiers",array( "entryCSN" => "entryCSN",
92                                               "contextCSN"=>"contextCSN" ));
94     
95     $smarty->assign("optional", reverse_html_entities($this->optional));
96     foreach($this->attributes as $attr){
97       $smarty->assign($attr,reverse_html_entities($this->$attr));
98     }
99     $smarty->assign("login_attributes",$this->login_attributes);
100     return($smarty -> fetch (get_template_path("../setup/setup_config3.tpl")));
101   }
104   function save_object()
105   {
106     if(isset($_POST['step6a_posted'])){
108       /* Get attributes */
109       foreach($this->attributes as $attr){
110         if(isset($_POST[$attr])){
111           $this->$attr = validate(get_post($attr));
112         }
113       }
114       
115       foreach(array("login_attribute","list_summary","strict_units","snmpcommunity","noprimarygroup","forceglobals","forceSSL","ldapstats","user_filter_cookie","warnSSL","templateCompileDirectory","debugLevel","session_lifetime") as $name){
116         if(isset($_POST[$name])){
117           $this->optional[$name] = get_post($name);
118         }
119       } 
121       if(isset($_POST['ppd_path_active'])){
122         $this->optional['ppd_path_active'] = TRUE;
123         if(isset($_POST['ppd_path'])){
124           $this->optional['ppd_path'] = get_post('ppd_path');
125         }
126       }else{
127         $this->optional['ppd_path_active'] = FALSE;
128       }
130       if(isset($_POST['max_ldap_query_time_active'])){
131         $this->optional['max_ldap_query_time_active'] = TRUE;
132         if(isset($_POST['max_ldap_query_time'])){
133           $this->optional['max_ldap_query_time'] = get_post('max_ldap_query_time');
134         }
135       }else{
136         $this->optional['max_ldap_query_time_active'] = FALSE;
137       }
139       if(isset($_POST['kioskpath_active'])){
140         $this->optional['kioskpath_active'] = TRUE;
141         if(isset($_POST['kioskpath'])){
142           $this->optional['kioskpath'] = get_post('kioskpath');
143         }
144       }else{
145         $this->optional['kioskpath_active'] = FALSE;
146       }
148       if(isset($_POST['sudoou_active'])){
149         $this->optional['sudoou_active'] = TRUE;
150         if(isset($_POST['sudoou'])){
151           $this->optional['sudoou'] = get_post('sudoou');
152         }
153       }else{
154         $this->optional['sudoou_active'] = FALSE;
155       }
157       if(isset($_POST['notifydir_active'])){
158         $this->optional['notifydir_active'] = TRUE;
159         if(isset($_POST['notifydir'])){
160           $this->optional['notifydir'] = get_post('notifydir');
161         }
162       }else{
163         $this->optional['notifydir_active'] = FALSE;
164       }
166       if(isset($_POST['gosaSupportURI_active'])){
167         $this->optional['gosaSupportURI_active'] = TRUE;
168         if(isset($_POST['gosaSupportURI'])){
169           $this->optional['gosaSupportURI'] = get_post('gosaSupportURI');
170           $this->optional['gosaSupportTimeout'] = get_post('gosaSupportTimeout');
171         }
172       }else{
173         $this->optional['gosaSupportURI_active'] = FALSE;
174       }
176       if(isset($_POST['uniq_identifier_active'])){
177         $this->optional['uniq_identifier_active'] = TRUE;
178         if(isset($_POST['uniq_identifier'])){
179           $this->optional['uniq_identifier'] = get_post('uniq_identifier');
180         }
181       }else{
182         $this->optional['uniq_identifier_active'] = FALSE;
183       }
184     }
186     $tmp = $this->check();
187     if(count($tmp) == 0){
188       $this->is_completed = TRUE;
189     }else{
190       $this->is_completed = FALSE;
191     }
192   }
195   function check()
196   {
197     $message = array();
199     if(!is_numeric( $this->optional['session_lifetime'])){
200       $message[] = _("Session lifetime must be a numeric value!");
201     }
203     if(!is_numeric( $this->optional['max_ldap_query_time'])){
204       $message[] = _("Maximum LDAP query time must be a numeric value!");
205     }
206   
207     return($message);
208   }
209   
211   /* Attributes that are interesting for configuration generation */
212   function get_attributes()
213   {
214     $tmp = setup_step::get_attributes();
215     foreach(array("optional") as $attr){
216       $tmp[$attr]= $this->$attr;
217     }
218     return($tmp);
219   }
223 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
224 ?>