259e10430917b74aa82d4f6a25d36fddf14938a1
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 $account_expiration =FALSE;
29 var $header_image = "images/ldapserver.png";
31 var $cyrusunixstyle = FALSE;
32 var $mail = "none";
33 var $mail_methods = array();
34 var $mail_settings = array("vacationdir" => "/etc/gosa/vacation",
35 "vacationdir_active" => FALSE);
37 var $generic_settings = array( "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","account_expiration","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['wws_ou_active'])){
118 $this->generic_settings['wws_ou_active'] = TRUE;
119 if(isset($_POST['wws_ou'])){
120 $this->generic_settings['wws_ou'] = $_POST['wws_ou'];
121 }
122 }else{
123 $this->generic_settings['wws_ou_active'] = FALSE;
124 }
126 if(isset($_POST['snapshot_active'])){
127 $this->generic_settings['snapshot_active'] = TRUE;
128 if(isset($_POST['snapshot_base'])){
129 $this->generic_settings['snapshot_base'] = $_POST['snapshot_base'];
130 }
131 if(isset($_POST['snapshot_user'])){
132 $this->generic_settings['snapshot_user'] = $_POST['snapshot_user'];
133 }
134 if(isset($_POST['snapshot_password'])){
135 $this->generic_settings['snapshot_password'] = $_POST['snapshot_password'];
136 }
137 if(isset($_POST['snapshot_server'])){
138 $this->generic_settings['snapshot_server'] = $_POST['snapshot_server'];
139 }
140 if(isset($_POST['snapshot_ldap_base'])){
141 $this->generic_settings['snapshot_ldap_base'] = $_POST['snapshot_ldap_base'];
142 }
143 }else{
144 $this->generic_settings['snapshot_active'] = FALSE;
145 }
147 /* Samba settings */
148 if(isset($_POST['samba_sid_active'])){
149 $this->samba_settings['samba_sid_active'] = TRUE;
150 if(isset($_POST['samba_sid'])){
151 $this->samba_settings['samba_sid'] = $_POST['samba_sid'];
152 }
153 }else{
154 $this->samba_settings['samba_sid_active'] = FALSE;
155 }
156 if(isset($_POST['samba_rid_active'])){
157 $this->samba_settings['samba_rid_active'] = TRUE;
158 if(isset($_POST['samba_rid'])){
159 $this->samba_settings['samba_rid'] = $_POST['samba_rid'];
160 }
161 }else{
162 $this->samba_settings['samba_rid_active'] = FALSE;
163 }
165 }
167 $tmp = $this->check();
168 if(count($tmp) == 0){
169 $this->is_completed = TRUE;
170 }else{
171 $this->is_completed = FALSE;
172 }
173 }
176 function check()
177 {
178 $message = array();
179 return($message);
180 }
183 /* Attributes that are interesting for configuration generation */
184 function get_attributes()
185 {
186 $tmp = setup_step::get_attributes();
187 foreach(array("samba_settings","generic_settings","mail_settings") as $attr){
188 $tmp[$attr]= $this->$attr;
189 }
190 return($tmp);
191 }
193 /* Returns the classnames auf the mail classes */
194 function get_available_mail_classes()
195 {
196 $dir = opendir( "../include");
197 $methods = array();
198 $suffix = "class_mail-methods-";
199 $lensuf = strlen($suffix);
200 $prefix = ".inc";
201 $lenpre = strlen($prefix);
202 $i = 0;
203 while (($file = readdir($dir)) !== false){
205 if(stristr($file,$suffix)) {
206 $lenfile = strlen($file);
207 $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
208 $methods['file'][$i] = $file;
209 $methods[$i]['file'] = $file;
210 $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
211 $i++;
212 }
213 }
214 return($methods);
215 }
217 }
219 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
220 ?>