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_Config2 extends setup_step
24 {
25 var $governmentmode = FALSE;
26 var $sambaidmapping = FALSE;
27 var $strict = TRUE;
28 var $header_image = "images/ldapserver.png";
30 var $cyrusunixstyle = FALSE;
31 var $mail = "none";
32 var $mail_methods = array();
33 var $mail_settings = array("vacationdir" => "/etc/gosa/vacation",
34 "vacationdir_active" => FALSE);
36 var $generic_settings = array( "enableCopyPaste" => false,
37 "wws_ou" => "ou=winstations",
38 "wws_ou_active" => FALSE,
39 "snapshot_active" => FALSE,
40 "snapshot_base" => "ou=snapshots,%base%",
41 "snapshot_ldap_base" => "%base%",
42 "snapshot_user" => "cn=ldapadmin,%base%",
43 "snapshot_password" => "",
44 "snapshot_server" => "%connection%");
46 var $samba_settings = array( "samba_sid" => "0-815-4711",
47 "samba_sid_active" => FALSE,
48 "samba_rid" => 1000,
49 "samba_rid_active" => FALSE);
51 var $attributes = array("strict","governmentmode","sambaidmapping","cyrusunixstyle","mail");
53 function Step_Config2()
54 {
55 $this->update_strings();
56 $tmp = $this->get_available_mail_classes();
57 foreach($tmp['name'] as $name){
58 $this->mail_methods[$name] = $name;
59 }
60 }
63 function update_strings()
64 {
65 $this->s_title = _("GOsa settings 2/3");
66 $this->s_title_long = _("GOsa settings 2/3");
67 $this->s_info = _("Customize special parameters");
68 }
71 function execute()
72 {
73 /* Update snapshot values, with already collected values */
74 foreach($this->generic_settings as $key => $value){
75 foreach(array("snapshot_ldap_base","snapshot_base","snapshot_user","snapshot_server") as $attr){
76 foreach($this->parent->captured_values as $replace_name => $replace_value){
77 if(is_string($replace_value)) {
78 $this->generic_settings[$attr] = preg_replace("/%".$replace_name."%/",$replace_value,$this->generic_settings[$attr]);
79 }
80 }
81 }
82 }
84 $smarty = get_smarty();
85 $smarty->assign("generic_settings",$this->generic_settings);
86 $smarty->assign("mail_settings",$this->mail_settings);
87 $smarty->assign("mail_methods",$this->mail_methods);
88 $smarty->assign("samba_settings",$this->samba_settings);
89 $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
90 foreach($this->attributes as $attr){
91 $smarty->assign($attr,$this->$attr);
92 }
93 return($smarty -> fetch (get_template_path("../setup/setup_config2.tpl")));
94 }
96 function save_object()
97 {
98 if(isset($_POST['step6_posted'])){
100 /* Get attributes */
101 foreach($this->attributes as $attr){
102 if(isset($_POST[$attr])){
103 $this->$attr = validate($_POST[$attr]);
104 }
105 }
107 /* Mail settings */
108 if(isset($_POST['vacationdir_active'])){
109 $this->mail_settings['vacationdir_active'] = TRUE;
110 if(isset($_POST['vacationdir'])){
111 $this->mail_settings['vacationdir'] = $_POST['vacationdir'];
112 }
113 }else{
114 $this->mail_settings['vacationdir_active'] = FALSE;
115 }
117 if(isset($_POST['enableCopyPaste'])){
118 $this->generic_settings['enableCopyPaste'] = $_POST['enableCopyPaste'];
119 }
121 if(isset($_POST['wws_ou_active'])){
122 $this->generic_settings['wws_ou_active'] = TRUE;
123 if(isset($_POST['wws_ou'])){
124 $this->generic_settings['wws_ou'] = $_POST['wws_ou'];
125 }
126 }else{
127 $this->generic_settings['wws_ou_active'] = FALSE;
128 }
130 if(isset($_POST['snapshot_active'])){
131 $this->generic_settings['snapshot_active'] = TRUE;
132 if(isset($_POST['snapshot_base'])){
133 $this->generic_settings['snapshot_base'] = $_POST['snapshot_base'];
134 }
135 if(isset($_POST['snapshot_user'])){
136 $this->generic_settings['snapshot_user'] = $_POST['snapshot_user'];
137 }
138 if(isset($_POST['snapshot_password'])){
139 $this->generic_settings['snapshot_password'] = $_POST['snapshot_password'];
140 }
141 if(isset($_POST['snapshot_server'])){
142 $this->generic_settings['snapshot_server'] = $_POST['snapshot_server'];
143 }
144 if(isset($_POST['snapshot_ldap_base'])){
145 $this->generic_settings['snapshot_ldap_base'] = $_POST['snapshot_ldap_base'];
146 }
147 }else{
148 $this->generic_settings['snapshot_active'] = FALSE;
149 }
151 /* Samba settings */
152 if(isset($_POST['samba_sid_active'])){
153 $this->samba_settings['samba_sid_active'] = TRUE;
154 if(isset($_POST['samba_sid'])){
155 $this->samba_settings['samba_sid'] = $_POST['samba_sid'];
156 }
157 }else{
158 $this->samba_settings['samba_sid_active'] = FALSE;
159 }
160 if(isset($_POST['samba_rid_active'])){
161 $this->samba_settings['samba_rid_active'] = TRUE;
162 if(isset($_POST['samba_rid'])){
163 $this->samba_settings['samba_rid'] = $_POST['samba_rid'];
164 }
165 }else{
166 $this->samba_settings['samba_rid_active'] = FALSE;
167 }
169 }
171 $tmp = $this->check();
172 if(count($tmp) == 0){
173 $this->is_completed = TRUE;
174 }else{
175 $this->is_completed = FALSE;
176 }
177 }
180 function check()
181 {
182 $message = array();
183 return($message);
184 }
187 /* Attributes that are interesting for configuration generation */
188 function get_attributes()
189 {
190 $tmp = setup_step::get_attributes();
191 foreach(array("samba_settings","generic_settings","mail_settings") as $attr){
192 $tmp[$attr]= $this->$attr;
193 }
194 return($tmp);
195 }
197 /* Returns the classnames auf the mail classes */
198 function get_available_mail_classes()
199 {
200 $dir = opendir( "../include");
201 $methods = array();
202 $suffix = "class_mail-methods-";
203 $lensuf = strlen($suffix);
204 $prefix = ".inc";
205 $lenpre = strlen($prefix);
206 $i = 0;
207 while (($file = readdir($dir)) !== false){
209 if(stristr($file,$suffix)) {
210 $lenfile = strlen($file);
211 $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
212 $methods['file'][$i] = $file;
213 $methods[$i]['file'] = $file;
214 $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
215 $i++;
216 }
217 }
218 return($methods);
219 }
221 }
223 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
224 ?>