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