Code

c2646799ff0976bdd7177ba40c3f38b78bdc4226
[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               "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,
39               "smbhash" => 'SMBHASH');
42   function setup_step_6a()
43   {
44     $this->update_strings();
46     /* Look for samba password generation method */
47     if(file_exists("/usr/bin/mkntpasswd")){
48       $pwdhash  = "/usr/bin/mkntpasswd";
49     } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){
50       $pwdhash= "mkntpwd";
51     } else {
52       $pwdhash= 'perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen \$ARGV[0]), $/;"';
53     }
55     $this->optional['smbhash'] = $pwdhash;
56   }
59   function update_strings()
60   {
61     $this->s_title      = _("GOsa settings 3/3");
62     $this->s_title_long = _("GOsa generic settings, page 3/3");
63     $this->s_info       = _("This dialog allows you to setup GOsa behaviour");
64   }
65   
67   function execute()
68   {
69     $smarty = get_smarty();
70     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
72     $smarty->assign("optional", $this->optional);
74     foreach($this->attributes as $attr){
75       $smarty->assign($attr,$this->$attr);
76     }
78     $smarty->assign("warnings" ,$this->check());
79     $smarty->assign("warnings_cnt" ,count($this->check()));
81     return($smarty -> fetch (get_template_path("../setup/setup_step6a.tpl")));
82   }
85   function save_object()
86   {
87     if(isset($_POST['step6a_posted'])){
89       /* Get attributes */
90       foreach($this->attributes as $attr){
91         if(isset($_POST[$attr])){
92           $this->$attr = validate($_POST[$attr]);
93         }
94       }
95       
96       foreach(array("enableCopyPaste","forceglobals","forcessl","warnssl","compile","debuglevel","session_lifetime","smbhash") as $name){
97         if(isset($_POST[$name])){
98           $this->optional[$name] = stripslashes($_POST[$name]);
99         }
100       } 
102       if(isset($_POST['ppd_path_active'])){
103         $this->optional['ppd_path_active'] = TRUE;
104         if(isset($_POST['ppd_path'])){
105           $this->optional['ppd_path'] = $_POST['ppd_path'];
106         }
107       }else{
108         $this->optional['ppd_path_active'] = FALSE;
109       }
111       if(isset($_POST['kde_applications_menu_active'])){
112         $this->optional['kde_applications_menu_active'] = TRUE;
113         if(isset($_POST['kde_applications_menu'])){
114           $this->optional['kde_applications_menu'] = $_POST['kde_applications_menu'];
115         }
116       }else{
117         $this->optional['kde_applications_menu_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     }
131     $tmp = $this->check();
132     if(count($tmp) == 0){
133       $this->is_completed = TRUE;
134     }else{
135       $this->is_completed = FALSE;
136     }
137   }
140   function check()
141   {
142     $message = array();
144     if(!is_numeric( $this->optional['session_lifetime'])){
145       $message[] = _("Session lifetime must be a numeric value.");
146     }
148     if(!is_numeric( $this->optional['max_ldap_query_time'])){
149       $message[] = _("Maximal ldap query time must be a numeric value. ");
150     }
151   
152     return($message);
153   }
154   
156   /* Attributes that are interesting for configuration generation */
157   function get_attributes()
158   {
159     $tmp = setup_step::get_attributes();
160     foreach(array("optional") as $attr){
161       $tmp[$attr]= $this->$attr;
162     }
163     return($tmp);
164   }
168 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
169 ?>