1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * phpGroupWare - Preferences * |
---|
4 | * http://www.phpgroupware.org * |
---|
5 | * -------------------------------------------- * |
---|
6 | * This program is free software; you can redistribute it and/or modify it * |
---|
7 | * under the terms of the GNU General Public License as published by the * |
---|
8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
9 | * option) any later version. * |
---|
10 | \**************************************************************************/ |
---|
11 | |
---|
12 | |
---|
13 | $GLOBALS['phpgw_info']['flags'] = array( |
---|
14 | 'noheader' => True, |
---|
15 | 'noappheader' => True, |
---|
16 | 'nonavbar' => True, |
---|
17 | 'currentapp' => @$_GET['appname'] ? $_GET['appname'] : 'preferences', |
---|
18 | 'enable_nextmatchs_class' => True |
---|
19 | ); |
---|
20 | include('../header.inc.php'); |
---|
21 | |
---|
22 | if ($_POST['cancel']) |
---|
23 | { |
---|
24 | $GLOBALS['phpgw']->redirect_link('/preferences/index.php'); |
---|
25 | } |
---|
26 | |
---|
27 | $user = get_var('user',Array('POST')); |
---|
28 | $forced = get_var('forced',Array('POST')); |
---|
29 | $default = get_var('default',Array('POST')); |
---|
30 | |
---|
31 | $t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('preferences')); |
---|
32 | $t->set_file(array( |
---|
33 | 'preferences' => 'preferences.tpl' |
---|
34 | )); |
---|
35 | $t->set_block('preferences','list','lists'); |
---|
36 | $t->set_block('preferences','row','rowhandle'); |
---|
37 | $t->set_block('preferences','help_row','help_rowhandle'); |
---|
38 | $t->set_var(array('rowhandle' => '','help_rowhandle' => '','messages' => '')); |
---|
39 | |
---|
40 | if ($_GET['appname'] != 'preferences') |
---|
41 | { |
---|
42 | $GLOBALS['phpgw']->translation->add_app('preferences'); // we need the prefs translations too |
---|
43 | } |
---|
44 | |
---|
45 | /* Make things a little easier to follow */ |
---|
46 | /* Some places we will need to change this if there in common */ |
---|
47 | function check_app() |
---|
48 | { |
---|
49 | if ($_GET['appname'] == 'preferences') |
---|
50 | { |
---|
51 | return 'common'; |
---|
52 | } |
---|
53 | else |
---|
54 | { |
---|
55 | return ($_GET['appname'] == 'expressoMail1_2'?'expressoMail':$_GET['appname']); |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | function is_forced_value($_appname,$preference_name) |
---|
60 | { |
---|
61 | if (isset($GLOBALS['phpgw']->preferences->forced[$_appname][$preference_name]) && $GLOBALS['type'] != 'forced') |
---|
62 | { |
---|
63 | return True; |
---|
64 | } |
---|
65 | else |
---|
66 | { |
---|
67 | return False; |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | function create_password_box($label_name,$preference_name,$help='',$size = '',$max_size = '',$run_lang=True) |
---|
72 | { |
---|
73 | global $user,$forced,$default; |
---|
74 | |
---|
75 | $_appname = check_app(); |
---|
76 | if (is_forced_value($_appname,$preference_name)) |
---|
77 | { |
---|
78 | return True; |
---|
79 | } |
---|
80 | create_input_box($label_name,$preference_name.'][pw',$help,'',$size,$max_size,'password',$run_lang); |
---|
81 | } |
---|
82 | |
---|
83 | function create_input_box($label,$name,$help='',$default='',$size = '',$max_size = '',$type='', |
---|
84 | $run_lang=True) |
---|
85 | { |
---|
86 | global $t,$prefs; |
---|
87 | |
---|
88 | $charSet = $GLOBALS['phpgw']->translation->charset(); |
---|
89 | |
---|
90 | $_appname = check_app(); |
---|
91 | if (is_forced_value($_appname,$name)) |
---|
92 | { |
---|
93 | return True; |
---|
94 | } |
---|
95 | |
---|
96 | if ($type) // used to specify password |
---|
97 | { |
---|
98 | $options = " TYPE='$type'"; |
---|
99 | } |
---|
100 | if ($size) |
---|
101 | { |
---|
102 | $options .= " SIZE='$size'"; |
---|
103 | } |
---|
104 | if ($maxsize) |
---|
105 | { |
---|
106 | $options .= " MAXSIZE='$maxsize'"; |
---|
107 | } |
---|
108 | |
---|
109 | if (isset($prefs[$name]) || $GLOBALS['type'] != 'user') |
---|
110 | { |
---|
111 | $default = $prefs[$name]; |
---|
112 | } |
---|
113 | |
---|
114 | if ($GLOBALS['type'] == 'user') |
---|
115 | { |
---|
116 | $def_text = !$GLOBALS['phpgw']->preferences->user[$_appname][$name] ? $GLOBALS['phpgw']->preferences->data[$_appname][$name] : $GLOBALS['phpgw']->preferences->default[$_appname][$name]; |
---|
117 | |
---|
118 | if (isset($notifys[$name])) // translate the substitution names |
---|
119 | { |
---|
120 | $def_text = $GLOBALS['phpgw']->preferences->lang_notify($def_text,$notifys[$name]); |
---|
121 | } |
---|
122 | $def_text = $def_text != '' ? ' <i><font size="-1">'.lang('default').': '.$def_text.'</font></i>' : ''; |
---|
123 | } |
---|
124 | $t->set_var('row_id', "${GLOBALS[type]}[$name]"); |
---|
125 | $t->set_var('row_value',"<input name=\"${GLOBALS[type]}[$name]\"value=\"". |
---|
126 | @htmlentities($default,ENT_COMPAT,$charSet)."\"$options>$def_text"); |
---|
127 | $t->set_var('row_name',lang($label)); |
---|
128 | $GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t); |
---|
129 | |
---|
130 | $t->fp('rows',process_help($help,$run_lang) ? 'help_row' : 'row',True); |
---|
131 | } |
---|
132 | |
---|
133 | function process_help($help,$run_lang=True) |
---|
134 | { |
---|
135 | global $t,$show_help,$has_help; |
---|
136 | |
---|
137 | if (!empty($help)) |
---|
138 | { |
---|
139 | $has_help = True; |
---|
140 | |
---|
141 | if ($show_help) |
---|
142 | { |
---|
143 | $t->set_var('help_value',$run_lang ? lang($help) : $help); |
---|
144 | |
---|
145 | return True; |
---|
146 | } |
---|
147 | } |
---|
148 | return False; |
---|
149 | } |
---|
150 | |
---|
151 | function create_check_box($label,$name,$help='',$default='',$run_lang=True,$checkbox_prop='',$visible=True) |
---|
152 | { |
---|
153 | // checkboxes itself can't be use as they return nothing if uncheckt !!! |
---|
154 | global $prefs; |
---|
155 | |
---|
156 | if ($GLOBALS['type'] != 'user') |
---|
157 | { |
---|
158 | $default = ''; // no defaults for default or forced prefs |
---|
159 | } |
---|
160 | if (isset($prefs[$name])) |
---|
161 | { |
---|
162 | $prefs[$name] = (int)(!!$prefs[$name]); // to care for '' and 'True' |
---|
163 | } |
---|
164 | |
---|
165 | return create_select_box($label,$name,array( |
---|
166 | '0' => lang('No'), |
---|
167 | '1' => lang('Yes') |
---|
168 | ),$help,$default,$run_lang,$checkbox_prop,$visible); |
---|
169 | } |
---|
170 | |
---|
171 | function create_option_string($selected,$values) |
---|
172 | { |
---|
173 | while (is_array($values) && list($var,$value) = each($values)) |
---|
174 | { |
---|
175 | $s .= '<option value="' . $var . '"'; |
---|
176 | if ("$var" == "$selected") // the "'s are necessary to force a string-compare |
---|
177 | { |
---|
178 | $s .= ' selected'; |
---|
179 | } |
---|
180 | $s .= '>' . $value . '</option>'; |
---|
181 | } |
---|
182 | return $s; |
---|
183 | } |
---|
184 | |
---|
185 | /* for creating different sections with a title */ |
---|
186 | function create_section($title='',$value = '') |
---|
187 | { |
---|
188 | global $t; |
---|
189 | |
---|
190 | $t->set_var('row_value',''); |
---|
191 | $t->set_var('row_name','<span class="prefSection">'.lang($title,$value).'</span>'); |
---|
192 | $GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t); |
---|
193 | |
---|
194 | $t->fp('rows',process_help($help) ? 'help_row' : 'row',True); |
---|
195 | } |
---|
196 | function create_html_code($name,$code,$appendcode) |
---|
197 | { |
---|
198 | global $t,$prefs; |
---|
199 | $t->set_var('row_id', "${GLOBALS[type]}[$name]"); |
---|
200 | $t->set_var('row_value',$code.$prefs[$name].$appendcode); |
---|
201 | $t->set_var('row_name',lang("signature")); |
---|
202 | $GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t); |
---|
203 | $t->fp('rows','row',True); |
---|
204 | } |
---|
205 | |
---|
206 | function create_select_box($label,$name,$values,$help='',$default='',$run_lang=True,$select_prop = '',$visible=True) |
---|
207 | { |
---|
208 | global $t,$prefs; |
---|
209 | |
---|
210 | $_appname = check_app(); |
---|
211 | if (is_forced_value($_appname,$name)) |
---|
212 | { |
---|
213 | return True; |
---|
214 | } |
---|
215 | |
---|
216 | if (isset($prefs[$name]) || $GLOBALS['type'] != 'user') |
---|
217 | { |
---|
218 | $default = $prefs[$name]; |
---|
219 | } |
---|
220 | |
---|
221 | switch ($GLOBALS['type']) |
---|
222 | { |
---|
223 | case 'user': |
---|
224 | $s = '<option value="">' . lang('Use default') . '</option>'; |
---|
225 | break; |
---|
226 | case 'default': |
---|
227 | $s = '<option value="">' . lang('No default') . '</option>'; |
---|
228 | break; |
---|
229 | case 'forced': |
---|
230 | $s = '<option value="**NULL**">' . lang('Users choice') . '</option>'; |
---|
231 | break; |
---|
232 | } |
---|
233 | $s .= create_option_string($default,$values); |
---|
234 | if ($GLOBALS['type'] == 'user') |
---|
235 | { |
---|
236 | $def_text = $GLOBALS['phpgw']->preferences->default[$_appname][$name]; |
---|
237 | $def_text = $def_text != '' ? ' <i><font size="-1">'.lang('default').': '.$values[$def_text].'</font></i>' : ''; |
---|
238 | } |
---|
239 | $t->set_var('row_id', "${GLOBALS[type]}[$name]"); |
---|
240 | $t->set_var('row_value',"<select name=\"${GLOBALS[type]}[$name]\" $select_prop>$s</select>$def_text"); |
---|
241 | $t->set_var('row_name',lang($label)); |
---|
242 | if ($visible) |
---|
243 | { |
---|
244 | $t->set_var('row_visibility', ''); |
---|
245 | } |
---|
246 | else |
---|
247 | { |
---|
248 | $t->set_var('row_visibility', 'style="display: none;"'); |
---|
249 | } |
---|
250 | |
---|
251 | $GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t); |
---|
252 | |
---|
253 | $t->fp('rows',process_help($help,$run_lang) ? 'help_row' : 'row',True); |
---|
254 | } |
---|
255 | |
---|
256 | /*! |
---|
257 | @function create_notify |
---|
258 | @abstract creates text-area or inputfield with subtitution-variables |
---|
259 | @syntax create_notify($label,$name,$rows,$cols,$help='',$default='',$vars2='') |
---|
260 | @param $label untranslated label |
---|
261 | @param $name name of the pref |
---|
262 | @param $rows, $cols of the textarea or input-box ($rows==1) |
---|
263 | @param $help untranslated help-text |
---|
264 | @param $default default-value |
---|
265 | @param $vars2 array with extra substitution-variables of the form key => help-text |
---|
266 | */ |
---|
267 | function create_notify($label,$name,$rows,$cols,$help='',$default='',$vars2='',$subst_help=True,$run_lang=True) |
---|
268 | { |
---|
269 | global $t,$prefs,$notifys; |
---|
270 | |
---|
271 | $vars = $GLOBALS['phpgw']->preferences->vars; |
---|
272 | if (is_array($vars2)) |
---|
273 | { |
---|
274 | $vars += $vars2; |
---|
275 | } |
---|
276 | $prefs[$name] = $GLOBALS['phpgw']->preferences->lang_notify($prefs[$name],$vars); |
---|
277 | |
---|
278 | $notifys[$name] = $vars; // this gets saved in the app_session for re-translation |
---|
279 | |
---|
280 | $help = $help && $run_lang ? lang($help) : $help; |
---|
281 | if ($subst_help) |
---|
282 | { |
---|
283 | $help .= '<p><b>'.lang('Substitutions and their meanings:').'</b>'; |
---|
284 | foreach($vars as $var => $var_help) |
---|
285 | { |
---|
286 | $lname = ($lname = lang($var)) == $var.'*' ? $var : $lname; |
---|
287 | $help .= "<br>\n".'<b>$$'.$lname.'$$</b>: '.$var_help; |
---|
288 | } |
---|
289 | $help .= "</p>\n"; |
---|
290 | } |
---|
291 | if ($row == 1) |
---|
292 | { |
---|
293 | create_input_box($label,$name,$help,$default,$cols,'','',False); |
---|
294 | } |
---|
295 | else |
---|
296 | { |
---|
297 | create_text_area($label,$name,$rows,$cols,$help,$default,False); |
---|
298 | } |
---|
299 | } |
---|
300 | |
---|
301 | function create_text_area($label,$name,$rows,$cols,$help='',$default='',$run_lang=True) |
---|
302 | { |
---|
303 | global $t,$prefs,$notifys; |
---|
304 | |
---|
305 | $charSet = $GLOBALS['phpgw']->translation->charset(); |
---|
306 | |
---|
307 | $_appname = check_app(); |
---|
308 | if (is_forced_value($_appname,$name)) |
---|
309 | { |
---|
310 | return True; |
---|
311 | } |
---|
312 | |
---|
313 | if (isset($prefs[$name]) || $GLOBALS['type'] != 'user') |
---|
314 | { |
---|
315 | $default = $prefs[$name]; |
---|
316 | } |
---|
317 | |
---|
318 | if ($GLOBALS['type'] == 'user') |
---|
319 | { |
---|
320 | $def_text = !$GLOBALS['phpgw']->preferences->user[$_appname][$name] ? $GLOBALS['phpgw']->preferences->data[$_appname][$name] : $GLOBALS['phpgw']->preferences->default[$_appname][$name]; |
---|
321 | |
---|
322 | if (isset($notifys[$name])) // translate the substitution names |
---|
323 | { |
---|
324 | $def_text = $GLOBALS['phpgw']->preferences->lang_notify($def_text,$notifys[$name]); |
---|
325 | } |
---|
326 | $def_text = $def_text != '' ? '<br><i><font size="-1"><b>'.lang('default').'</b>:<br>'.nl2br($def_text).'</font></i>' : ''; |
---|
327 | } |
---|
328 | $t->set_var('row_id', "${GLOBALS[type]}[$name]"); |
---|
329 | $t->set_var('row_value',"<textarea rows=\"$rows\" cols=\"$cols\" name=\"${GLOBALS[type]}[$name]\">". |
---|
330 | htmlentities($default,ENT_COMPAT,$charSet)."</textarea>$def_text"); |
---|
331 | $t->set_var('row_name',lang($label)); |
---|
332 | $GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t); |
---|
333 | |
---|
334 | $t->fp('rows',process_help($help,$run_lang) ? 'help_row' : 'row',True); |
---|
335 | } |
---|
336 | |
---|
337 | function process_array(&$repository,$array,$notifys,$prefix='') |
---|
338 | { |
---|
339 | $_appname = check_app(); |
---|
340 | |
---|
341 | $prefs = &$repository[$_appname]; |
---|
342 | |
---|
343 | if ($prefix != '') |
---|
344 | { |
---|
345 | $prefix_arr = explode('/',$prefix); |
---|
346 | foreach ($prefix_arr as $pre) |
---|
347 | { |
---|
348 | $prefs = &$prefs[$pre]; |
---|
349 | } |
---|
350 | } |
---|
351 | unset($prefs['']); |
---|
352 | //echo "array:<pre>"; print_r($array); echo "</pre>\n"; |
---|
353 | while (is_array($array) && list($var,$value) = each($array)) |
---|
354 | { |
---|
355 | if (isset($value) && $value != '' && $value != '**NULL**') |
---|
356 | { |
---|
357 | if (is_array($value)) |
---|
358 | { |
---|
359 | $value = $value['pw']; |
---|
360 | if (empty($value)) |
---|
361 | { |
---|
362 | continue; // dont write empty password-fields |
---|
363 | } |
---|
364 | } |
---|
365 | $prefs[$var] = stripslashes($value); |
---|
366 | |
---|
367 | if ($notifys[$var]) // need to translate the key-words back |
---|
368 | { |
---|
369 | $prefs[$var] = $GLOBALS['phpgw']->preferences->lang_notify($prefs[$var],$notifys[$var],True); |
---|
370 | } |
---|
371 | } |
---|
372 | else |
---|
373 | { |
---|
374 | unset($prefs[$var]); |
---|
375 | } |
---|
376 | } |
---|
377 | //echo "prefix='$prefix', prefs=<pre>"; print_r($repository[$_appname]); echo "</pre>\n"; |
---|
378 | |
---|
379 | // the following hook can be used to verify the prefs |
---|
380 | // if you return something else than False, it is treated as an error-msg and |
---|
381 | // displayed to the user (the prefs get not saved !!!) |
---|
382 | // |
---|
383 | if ($error = $GLOBALS['phpgw']->hooks->single(array( |
---|
384 | 'location' => 'verify_settings', |
---|
385 | 'prefs' => $repository[$_appname], |
---|
386 | 'prefix' => $prefix, |
---|
387 | 'type' => $GLOBALS['type'] |
---|
388 | ),$_GET['appname'])) |
---|
389 | { |
---|
390 | return $error; |
---|
391 | } |
---|
392 | |
---|
393 | $GLOBALS['phpgw']->preferences->save_repository(True,$GLOBALS['type']); |
---|
394 | |
---|
395 | return False; |
---|
396 | } |
---|
397 | |
---|
398 | /* Only check this once */ |
---|
399 | if ($GLOBALS['phpgw']->acl->check('run',1,'admin')) |
---|
400 | { |
---|
401 | /* Don't use a global variable for this ... */ |
---|
402 | define('HAS_ADMIN_RIGHTS',1); |
---|
403 | } |
---|
404 | |
---|
405 | /* Makes the ifs a little nicer, plus ... this will change once the ACL manager is in place */ |
---|
406 | /* and is able to create less powerfull admins. This will handle the ACL checks for that (jengo) */ |
---|
407 | function is_admin() |
---|
408 | { |
---|
409 | global $prefix; |
---|
410 | |
---|
411 | if (HAS_ADMIN_RIGHTS == 1 && empty($prefix)) // tabs only without prefix |
---|
412 | { |
---|
413 | return True; |
---|
414 | } |
---|
415 | else |
---|
416 | { |
---|
417 | return False; |
---|
418 | } |
---|
419 | } |
---|
420 | |
---|
421 | function show_list($header = ' ') |
---|
422 | { |
---|
423 | global $t,$list_shown; |
---|
424 | |
---|
425 | $t->set_var('list_header',$header); |
---|
426 | $t->parse('lists','list',$list_shown); |
---|
427 | |
---|
428 | $t->set_var('rows',''); |
---|
429 | $list_shown = True; |
---|
430 | } |
---|
431 | |
---|
432 | $session_data = $GLOBALS['phpgw']->session->appsession('session_data','preferences'); |
---|
433 | |
---|
434 | $prefix = get_var('prefix',array('GET'),$session_data['appname'] == $_GET['appname'] ? $session_data['prefix'] : ''); |
---|
435 | |
---|
436 | if (is_admin()) |
---|
437 | { |
---|
438 | /* This is where we will keep track of our postion. */ |
---|
439 | /* Developers won't have to pass around a variable then */ |
---|
440 | |
---|
441 | $GLOBALS['type'] = get_var('type',Array('GET','POST'),$session_data['type']); |
---|
442 | |
---|
443 | if (empty($GLOBALS['type'])) |
---|
444 | { |
---|
445 | $GLOBALS['type'] = 'user'; |
---|
446 | } |
---|
447 | } |
---|
448 | else |
---|
449 | { |
---|
450 | $GLOBALS['type'] = 'user'; |
---|
451 | } |
---|
452 | $show_help = "$session_data[show_help]" != '' && $session_data['appname'] == $_GET['appname'] ? |
---|
453 | $session_data['show_help'] : (int)$GLOBALS['phpgw_info']['user']['preferences']['common']['show_help']; |
---|
454 | |
---|
455 | if ($toggle_help = get_var('toggle_help','POST')) |
---|
456 | { |
---|
457 | $show_help = (int)(!$show_help); |
---|
458 | } |
---|
459 | $has_help = 0; |
---|
460 | |
---|
461 | if ($_POST['submit']) |
---|
462 | { |
---|
463 | /* Don't use a switch here, we need to check some permissions durring the ifs */ |
---|
464 | if ($GLOBALS['type'] == 'user' || !($GLOBALS['type'])) |
---|
465 | { |
---|
466 | $error = process_array($GLOBALS['phpgw']->preferences->user,$user,$session_data['notifys'],$prefix); |
---|
467 | } |
---|
468 | |
---|
469 | if ($GLOBALS['type'] == 'default' && is_admin()) |
---|
470 | { |
---|
471 | $error = process_array($GLOBALS['phpgw']->preferences->default, $default,$session_data['notifys']); |
---|
472 | } |
---|
473 | |
---|
474 | if ($GLOBALS['type'] == 'forced' && is_admin()) |
---|
475 | { |
---|
476 | $error = process_array($GLOBALS['phpgw']->preferences->forced, $forced,$session_data['notifys']); |
---|
477 | } |
---|
478 | |
---|
479 | if (!is_admin() || $error) |
---|
480 | { |
---|
481 | $GLOBALS['phpgw']->redirect_link('/preferences/index.php'); |
---|
482 | } |
---|
483 | |
---|
484 | if ($GLOBALS['type'] == 'user' && $_GET['appname'] == 'preferences' && $user['show_help'] != '') |
---|
485 | { |
---|
486 | $show_help = $user['show_help']; // use it, if admin changes his help-prefs |
---|
487 | } |
---|
488 | } |
---|
489 | $GLOBALS['phpgw']->session->appsession('session_data','preferences',array( |
---|
490 | 'type' => $GLOBALS['type'], // save our state in the app-session |
---|
491 | 'show_help' => $show_help, |
---|
492 | 'prefix' => $prefix, |
---|
493 | 'appname' => $_GET['appname'] // we use this to reset prefix on appname-change |
---|
494 | )); |
---|
495 | // changes for the admin itself, should have immediate feedback ==> redirect |
---|
496 | if (!$error && $_POST['submit'] && $GLOBALS['type'] == 'user' && $_GET['appname'] == 'preferences') { |
---|
497 | $GLOBALS['phpgw']->redirect_link('/preferences/preferences.php','appname='.$_GET['appname']); |
---|
498 | } |
---|
499 | |
---|
500 | $GLOBALS['phpgw_info']['flags']['app_header'] = $_GET['appname'] == 'preferences' ? |
---|
501 | lang('Preferences') : lang('%1 - Preferences',$GLOBALS['phpgw_info']['apps'][$_GET['appname']]['title']); |
---|
502 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
503 | echo parse_navbar(); |
---|
504 | |
---|
505 | $t->set_var('messages',$error); |
---|
506 | $t->set_var('action_url',$GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $_GET['appname'])); |
---|
507 | $t->set_var('th_bg', $GLOBALS['phpgw_info']['theme']['th_bg']); |
---|
508 | $t->set_var('th_text',$GLOBALS['phpgw_info']['theme']['th_text']); |
---|
509 | $t->set_var('row_on', $GLOBALS['phpgw_info']['theme']['row_on']); |
---|
510 | $t->set_var('row_off',$GLOBALS['phpgw_info']['theme']['row_off']); |
---|
511 | |
---|
512 | switch ($GLOBALS['type']) // set up some globals to be used by the hooks |
---|
513 | { |
---|
514 | case 'forced': |
---|
515 | $prefs = &$GLOBALS['phpgw']->preferences->forced[check_app()]; |
---|
516 | break; |
---|
517 | case 'default': |
---|
518 | $prefs = &$GLOBALS['phpgw']->preferences->default[check_app()]; |
---|
519 | break; |
---|
520 | default: |
---|
521 | $prefs = &$GLOBALS['phpgw']->preferences->user[check_app()]; |
---|
522 | // use prefix if given in the url, used for email extra-accounts |
---|
523 | if ($prefix != '') |
---|
524 | { |
---|
525 | $prefix_arr = explode('/',$prefix); |
---|
526 | foreach ($prefix_arr as $pre) |
---|
527 | { |
---|
528 | $prefs = &$prefs[$pre]; |
---|
529 | } |
---|
530 | } |
---|
531 | } |
---|
532 | //echo "prefs=<pre>"; print_r($prefs); echo "</pre>\n"; |
---|
533 | |
---|
534 | $notifys = array(); |
---|
535 | if (!$GLOBALS['phpgw']->hooks->single('settings',$_GET['appname'])) |
---|
536 | { |
---|
537 | $t->set_block('preferences','form','formhandle'); // skip the form |
---|
538 | $t->set_var('formhandle',''); |
---|
539 | |
---|
540 | $t->set_var('messages',lang('Error: There was a problem finding the preference file for %1 in %2', |
---|
541 | $GLOBALS['phpgw_info']['navbar'][$_GET['appname']]['title'],PHPGW_SERVER_ROOT . SEP |
---|
542 | . $_GET['appname'] . SEP . 'inc' . SEP . 'hook_settings.inc.php')); |
---|
543 | } |
---|
544 | $tmpl_settings = PHPGW_TEMPLATE_DIR.'/hook_settings.inc.php'; |
---|
545 | if ($_GET['appname'] == 'preferences' && file_exists($tmpl_settings)) |
---|
546 | { |
---|
547 | include($tmpl_settings); |
---|
548 | } |
---|
549 | |
---|
550 | if (count($notifys)) // there have been notifys in the hook, we need to save in the session |
---|
551 | { |
---|
552 | $GLOBALS['phpgw']->session->appsession('session_data','preferences',array( |
---|
553 | 'type' => $GLOBALS['type'], // save our state in the app-session |
---|
554 | 'show_help' => $show_help, |
---|
555 | 'prefix' => $prefix, |
---|
556 | 'appname' => $_GET['appname'], // we use this to reset prefix on appname-change |
---|
557 | 'notifys' => $notifys |
---|
558 | )); |
---|
559 | //echo "notifys:<pre>"; print_r($notifys); echo "</pre>\n"; |
---|
560 | } |
---|
561 | if (is_admin()) |
---|
562 | { |
---|
563 | $tabs[] = array( |
---|
564 | 'label' => lang('Your preferences'), |
---|
565 | 'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $_GET['appname'] . "&type=user") |
---|
566 | ); |
---|
567 | $tabs[] = array( |
---|
568 | 'label' => lang('Default preferences'), |
---|
569 | 'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $_GET['appname'] . "&type=default") |
---|
570 | ); |
---|
571 | $tabs[] = array( |
---|
572 | 'label' => lang('Forced preferences'), |
---|
573 | 'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $_GET['appname'] . "&type=forced") |
---|
574 | ); |
---|
575 | |
---|
576 | switch($GLOBALS['type']) |
---|
577 | { |
---|
578 | case 'user': $selected = 0; break; |
---|
579 | case 'default': $selected = 1; break; |
---|
580 | case 'forced': $selected = 2; break; |
---|
581 | } |
---|
582 | $t->set_var('tabs',$GLOBALS['phpgw']->common->create_tabs($tabs,$selected)); |
---|
583 | } |
---|
584 | $t->set_var('lang_submit', lang('save')); |
---|
585 | $t->set_var('lang_cancel', lang('cancel')); |
---|
586 | $t->set_var('show_help',(int)$show_help); |
---|
587 | $t->set_var('help_button',$has_help ? '<input type="submit" name="toggle_help" value="'. |
---|
588 | ($show_help ? lang('help off') : lang('help')).'">' : ''); |
---|
589 | |
---|
590 | if (!$list_shown) |
---|
591 | { |
---|
592 | show_list(); |
---|
593 | } |
---|
594 | $t->pfp('phpgw_body','preferences'); |
---|
595 | |
---|
596 | //echo '<pre style="text-align: left;">'; print_r($GLOBALS['phpgw']->preferences->data); echo "</pre>\n"; |
---|
597 | |
---|
598 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
599 | ?> |
---|