| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * options_display.php |
| 5 | * |
| 6 | * Displays all optinos about display preferences |
| 7 | * |
| 8 | * @copyright 1999-2020 The SquirrelMail Project Team |
| 9 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 10 | * @version $Id$ |
| 11 | * @package squirrelmail |
| 12 | */ |
| 13 | |
| 14 | /** Define the group constants for the display options page. */ |
| 15 | define('SMOPT_GRP_GENERAL', 0); |
| 16 | define('SMOPT_GRP_MAILBOX', 1); |
| 17 | define('SMOPT_GRP_MESSAGE', 2); |
| 18 | define('SMOPT_GRP_ABOOK', 3); |
| 19 | |
| 20 | global $use_iframe; |
| 21 | if (! isset($use_iframe)) $use_iframe=false; |
| 22 | |
| 23 | /** |
| 24 | * This function builds an array with all the information about |
| 25 | * the options available to the user, and returns it. The options |
| 26 | * are grouped by the groups in which they are displayed. |
| 27 | * For each option, the following information is stored: |
| 28 | * - name: the internal (variable) name |
| 29 | * - caption: the description of the option in the UI |
| 30 | * - type: one of SMOPT_TYPE_* |
| 31 | * - refresh: one of SMOPT_REFRESH_* |
| 32 | * - size: one of SMOPT_SIZE_* |
| 33 | * - save: the name of a function to call when saving this option |
| 34 | * @return array all option information |
| 35 | */ |
| 36 | function load_optpage_data_display() { |
| 37 | global $theme, $fontsets, $language, $languages,$aTemplateSet, |
| 38 | $default_use_mdn, $squirrelmail_language, $allow_thread_sort, |
| 39 | $show_alternative_names, $use_iframe, $use_icons, |
| 40 | $sTemplateID, $oTemplate, |
| 41 | $user_themes, $chosen_theme; |
| 42 | |
| 43 | /* Build a simple array into which we will build options. */ |
| 44 | $optgrps = array(); |
| 45 | $optvals = array(); |
| 46 | |
| 47 | /******************************************************/ |
| 48 | /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */ |
| 49 | /******************************************************/ |
| 50 | |
| 51 | /*** Load the General Options into the array ***/ |
| 52 | $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options"); |
| 53 | $optvals[SMOPT_GRP_GENERAL] = array(); |
| 54 | |
| 55 | /* load the template set option */ |
| 56 | $templateset_values = array(); |
| 57 | |
| 58 | foreach ($aTemplateSet as $sKey => $aTemplateSetAttributes) { |
| 59 | $templateset_values[$aTemplateSetAttributes['NAME']] = $aTemplateSetAttributes['ID']; |
| 60 | } |
| 61 | ksort($templateset_values); |
| 62 | $templateset_values = array_flip($templateset_values); |
| 63 | // display template options only when there is more than one template |
| 64 | if (count($templateset_values)>1) { |
| 65 | $optvals[SMOPT_GRP_GENERAL][] = array( |
| 66 | 'name' => 'sTemplateID', |
| 67 | 'caption' => _("Skin"), |
| 68 | 'type' => SMOPT_TYPE_STRLIST, |
| 69 | 'refresh' => SMOPT_REFRESH_ALL, |
| 70 | 'posvals' => $templateset_values, |
| 71 | 'save' => 'save_option_template' |
| 72 | ); |
| 73 | } |
| 74 | |
| 75 | /* Load the theme option. */ |
| 76 | $theme_values = array(); |
| 77 | |
| 78 | // Always provide the template default first. |
| 79 | $theme_values['none'] = 'Template Default Theme'; |
| 80 | |
| 81 | // List alternate themes provided by templates first |
| 82 | $template_themes = $oTemplate->get_alternative_stylesheets(true); |
| 83 | asort($template_themes); |
| 84 | foreach ($template_themes as $sheet=>$name) { |
| 85 | $theme_values[$sheet] = 'Template Theme - '.sm_encode_html_special_chars($name); |
| 86 | } |
| 87 | // Next, list user-provided styles |
| 88 | asort($user_themes); |
| 89 | foreach ($user_themes as $style) { |
| 90 | if ($style['PATH'] == 'none') |
| 91 | continue; |
| 92 | $theme_values[$style['PATH']] = 'User Theme - '.sm_encode_html_special_chars($style['NAME']); |
| 93 | } |
| 94 | |
| 95 | if (count($user_themes) + count($template_themes) > 1) { |
| 96 | $optvals[SMOPT_GRP_GENERAL][] = array( |
| 97 | 'name' => 'chosen_theme', |
| 98 | 'caption' => _("Theme"), |
| 99 | 'type' => SMOPT_TYPE_STRLIST, |
| 100 | 'refresh' => SMOPT_REFRESH_ALL, |
| 101 | 'posvals' => $theme_values, |
| 102 | 'save' => 'css_theme_save' |
| 103 | ); |
| 104 | } |
| 105 | |
| 106 | /* Icon theme selection */ |
| 107 | if ($use_icons) { |
| 108 | global $icon_themes, $icon_theme; |
| 109 | |
| 110 | $temp = array(); |
| 111 | $value = 0; |
| 112 | for ($count = 0; $count < sizeof($icon_themes); $count++) { |
| 113 | $temp[$icon_themes[$count]['PATH']] = $icon_themes[$count]['NAME']; |
| 114 | } |
| 115 | if (sizeof($icon_themes) > 0) { |
| 116 | $optvals[SMOPT_GRP_GENERAL][] = array( |
| 117 | 'name' => 'icon_theme', |
| 118 | 'caption' => _("Icon Theme"), |
| 119 | 'type' => SMOPT_TYPE_STRLIST, |
| 120 | 'refresh' => SMOPT_REFRESH_NONE, |
| 121 | 'posvals' => $temp, |
| 122 | 'save' => 'icon_theme_save' |
| 123 | ); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | $fontset_values = array(); |
| 128 | $fontset_list = array(); |
| 129 | |
| 130 | if (!empty($fontsets) && is_array($fontsets)) { |
| 131 | |
| 132 | foreach (array_keys($fontsets) as $fontset_key) { |
| 133 | $fontset_list[$fontset_key]=$fontset_key; |
| 134 | } |
| 135 | ksort($fontset_list); |
| 136 | } |
| 137 | |
| 138 | if (count($fontset_list) > 1) { |
| 139 | $fontset_list = array_merge(array('' => _("Default font style")), $fontset_list); |
| 140 | $optvals[SMOPT_GRP_GENERAL][] = array( |
| 141 | 'name' => 'chosen_fontset', |
| 142 | 'caption' => _("Font style"), |
| 143 | 'type' => SMOPT_TYPE_STRLIST, |
| 144 | 'refresh' => SMOPT_REFRESH_ALL, |
| 145 | 'posvals' => $fontset_list |
| 146 | ); |
| 147 | } |
| 148 | |
| 149 | $optvals[SMOPT_GRP_GENERAL][] = array( |
| 150 | 'name' => 'chosen_fontsize', |
| 151 | 'caption' => _("Font size"), |
| 152 | 'type' => SMOPT_TYPE_STRLIST, |
| 153 | 'refresh' => SMOPT_REFRESH_ALL, |
| 154 | 'posvals' => array('' => _("Default font size"), |
| 155 | '8' => '8 px', |
| 156 | '10' => '10 px', |
| 157 | '12' => '12 px', |
| 158 | '14' => '14 px') |
| 159 | ); |
| 160 | |
| 161 | $language_values = array(); |
| 162 | foreach ($languages as $lang_key => $lang_attributes) { |
| 163 | if (isset($lang_attributes['NAME'])) { |
| 164 | $language_values[$lang_key] = $lang_attributes['NAME']; |
| 165 | if ( isset($show_alternative_names) && |
| 166 | $show_alternative_names && |
| 167 | isset($lang_attributes['ALTNAME']) ) { |
| 168 | $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME']; |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | asort($language_values); |
| 174 | $language_values = |
| 175 | array_merge(array('' => _("Default")), $language_values); |
| 176 | $language = $squirrelmail_language; |
| 177 | |
| 178 | // add language selection only when more than 2 languages are available |
| 179 | // (default, English and some other) |
| 180 | if (count($language_values)>2) { |
| 181 | $optvals[SMOPT_GRP_GENERAL][] = array( |
| 182 | 'name' => 'language', |
| 183 | 'caption' => _("Language"), |
| 184 | 'type' => SMOPT_TYPE_STRLIST, |
| 185 | 'refresh' => SMOPT_REFRESH_ALL, |
| 186 | 'posvals' => $language_values, |
| 187 | 'htmlencoded' => true |
| 188 | ); |
| 189 | } |
| 190 | |
| 191 | /* Set values for the "use javascript" option. */ |
| 192 | $optvals[SMOPT_GRP_GENERAL][] = array( |
| 193 | 'name' => 'javascript_setting', |
| 194 | 'caption' => _("Use Javascript"), |
| 195 | 'type' => SMOPT_TYPE_STRLIST, |
| 196 | 'refresh' => SMOPT_REFRESH_ALL, |
| 197 | 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"), |
| 198 | SMPREF_JS_ON => _("Always"), |
| 199 | SMPREF_JS_OFF => _("Never")), |
| 200 | 'save' => 'save_option_javascript_autodetect', |
| 201 | 'extra_attributes' => array('onclick' => 'document.option_form.new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\';'), |
| 202 | ); |
| 203 | |
| 204 | $optvals[SMOPT_GRP_GENERAL][] = array( |
| 205 | 'name' => 'js_autodetect_results', |
| 206 | 'caption' => '', |
| 207 | 'type' => SMOPT_TYPE_HIDDEN, |
| 208 | 'refresh' => SMOPT_REFRESH_NONE |
| 209 | //'post_script' => $js_autodetect_script, |
| 210 | ); |
| 211 | |
| 212 | $optvals[SMOPT_GRP_GENERAL][] = array( |
| 213 | 'name' => 'hour_format', |
| 214 | 'caption' => _("Hour Format"), |
| 215 | 'type' => SMOPT_TYPE_STRLIST, |
| 216 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
| 217 | 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"), |
| 218 | SMPREF_TIME_24HR => _("24-hour clock")) |
| 219 | ); |
| 220 | |
| 221 | /*** Load the General Options into the array ***/ |
| 222 | $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options"); |
| 223 | $optvals[SMOPT_GRP_MAILBOX] = array(); |
| 224 | |
| 225 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 226 | 'name' => 'show_num', |
| 227 | 'caption' => _("Number of Messages per Page"), |
| 228 | 'type' => SMOPT_TYPE_INTEGER, |
| 229 | 'refresh' => SMOPT_REFRESH_NONE, |
| 230 | 'size' => SMOPT_SIZE_TINY |
| 231 | ); |
| 232 | |
| 233 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 234 | 'name' => 'alt_index_colors', |
| 235 | 'caption' => _("Enable Alternating Row Colors"), |
| 236 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 237 | 'refresh' => SMOPT_REFRESH_NONE |
| 238 | ); |
| 239 | |
| 240 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 241 | 'name' => 'fancy_index_highlite', |
| 242 | 'caption' => _("Enable Fancy Row Mouseover Highlighting"), |
| 243 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 244 | 'refresh' => SMOPT_REFRESH_NONE |
| 245 | ); |
| 246 | |
| 247 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 248 | 'name' => 'show_flag_buttons', |
| 249 | 'caption' => _("Show Flag / Unflag Buttons"), |
| 250 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 251 | 'refresh' => SMOPT_REFRESH_NONE |
| 252 | ); |
| 253 | |
| 254 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 255 | 'name' => 'show_copy_buttons', |
| 256 | 'caption' => _("Enable Message Copy Buttons"), |
| 257 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 258 | 'refresh' => SMOPT_REFRESH_NONE |
| 259 | ); |
| 260 | |
| 261 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 262 | 'name' => 'page_selector', |
| 263 | 'caption' => _("Enable Page Selector"), |
| 264 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 265 | 'refresh' => SMOPT_REFRESH_NONE |
| 266 | ); |
| 267 | |
| 268 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 269 | 'name' => 'compact_paginator', |
| 270 | 'caption' => _("Use Compact Page Selector"), |
| 271 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 272 | 'refresh' => SMOPT_REFRESH_NONE |
| 273 | ); |
| 274 | |
| 275 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 276 | 'name' => 'page_selector_max', |
| 277 | 'caption' => _("Maximum Number of Pages to Show"), |
| 278 | 'type' => SMOPT_TYPE_INTEGER, |
| 279 | 'refresh' => SMOPT_REFRESH_NONE, |
| 280 | 'size' => SMOPT_SIZE_TINY |
| 281 | ); |
| 282 | |
| 283 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 284 | 'name' => 'show_personal_names', |
| 285 | 'caption' => _("Show Names Instead of Email Addresses"), |
| 286 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 287 | 'refresh' => SMOPT_REFRESH_NONE, |
| 288 | ); |
| 289 | |
| 290 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 291 | 'name' => 'show_full_date', |
| 292 | 'caption' => _("Always Show Full Date"), |
| 293 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 294 | 'refresh' => SMOPT_REFRESH_NONE |
| 295 | ); |
| 296 | |
| 297 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 298 | 'name' => 'custom_date_format', |
| 299 | 'caption' => _("Custom Date Format"), |
| 300 | //FIXME: need better wording here. users should be made aware that this is for advanced use. It might be nice to provide a list of the more common date format characters. It may be helpful to know that it overrides settings such as the one above show_full_date, and only if kept empty will the other date formats apply. For non-English users, it also may be helpful to know that the format is still passed through our own date_intl() function which translates things like the day of the week, month names and abbreviations, etc. |
| 301 | 'trailing_text' => ' ' . _("(Uses format of PHP date() function)"), |
| 302 | 'type' => SMOPT_TYPE_STRING, |
| 303 | 'refresh' => SMOPT_REFRESH_NONE, |
| 304 | 'size' => SMOPT_SIZE_TINY, |
| 305 | ); |
| 306 | |
| 307 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 308 | 'name' => 'truncate_sender', |
| 309 | 'caption' => _("Length of From/To Field (0 for full)"), |
| 310 | 'type' => SMOPT_TYPE_INTEGER, |
| 311 | 'refresh' => SMOPT_REFRESH_NONE, |
| 312 | 'size' => SMOPT_SIZE_TINY |
| 313 | ); |
| 314 | |
| 315 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 316 | 'name' => 'truncate_subject', |
| 317 | 'caption' => _("Length of Subject Field (0 for full)"), |
| 318 | 'type' => SMOPT_TYPE_INTEGER, |
| 319 | 'refresh' => SMOPT_REFRESH_NONE, |
| 320 | 'size' => SMOPT_SIZE_TINY |
| 321 | ); |
| 322 | /* |
| 323 | FIXME! |
| 324 | disabled because the template doesn't support it (yet?) |
| 325 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 326 | 'name' => 'show_recipient_instead', |
| 327 | 'caption' => _("Show recipient name if the message is from your default identity"), |
| 328 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 329 | 'refresh' => SMOPT_REFRESH_NONE, |
| 330 | 'size' => SMOPT_SIZE_TINY |
| 331 | ); |
| 332 | */ |
| 333 | |
| 334 | if ($allow_thread_sort == TRUE) { |
| 335 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
| 336 | 'name' => 'sort_by_ref', |
| 337 | 'caption' => _("Enable Thread Sort by References Header"), |
| 338 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 339 | 'refresh' => SMOPT_REFRESH_ALL |
| 340 | ); |
| 341 | } |
| 342 | |
| 343 | |
| 344 | |
| 345 | /*** Load the General Options into the array ***/ |
| 346 | $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display Options"); |
| 347 | $optvals[SMOPT_GRP_MESSAGE] = array(); |
| 348 | |
| 349 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
| 350 | 'name' => 'wrap_at', |
| 351 | 'caption' => _("Wrap Incoming Text At"), |
| 352 | 'type' => SMOPT_TYPE_INTEGER, |
| 353 | 'refresh' => SMOPT_REFRESH_NONE, |
| 354 | 'size' => SMOPT_SIZE_TINY |
| 355 | ); |
| 356 | |
| 357 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
| 358 | 'name' => 'show_html_default', |
| 359 | 'caption' => _("Show HTML Version by Default"), |
| 360 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 361 | 'refresh' => SMOPT_REFRESH_NONE |
| 362 | ); |
| 363 | |
| 364 | if ($use_iframe) { |
| 365 | // Type is set to string in order to be able to use 100%. |
| 366 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
| 367 | 'name' => 'iframe_height', |
| 368 | 'caption' => _("Height of inline frame"), |
| 369 | 'type' => SMOPT_TYPE_STRING, |
| 370 | 'size' => SMOPT_SIZE_TINY, |
| 371 | 'refresh' => SMOPT_REFRESH_NONE |
| 372 | ); |
| 373 | } |
| 374 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
| 375 | 'name' => 'enable_forward_as_attachment', |
| 376 | 'caption' => _("Enable Forward as Attachment"), |
| 377 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 378 | 'refresh' => SMOPT_REFRESH_NONE |
| 379 | ); |
| 380 | |
| 381 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
| 382 | 'name' => 'show_xmailer_default', |
| 383 | 'caption' => _("Enable Mailer Display"), |
| 384 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 385 | 'refresh' => SMOPT_REFRESH_NONE |
| 386 | ); |
| 387 | |
| 388 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
| 389 | 'name' => 'attachment_common_show_images', |
| 390 | 'caption' => _("Display Attached Images with Message"), |
| 391 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 392 | 'refresh' => SMOPT_REFRESH_NONE |
| 393 | ); |
| 394 | |
| 395 | if ($default_use_mdn) { |
| 396 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
| 397 | 'name' => 'mdn_user_support', |
| 398 | 'caption' => _("Enable Mail Delivery Notification"), |
| 399 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 400 | 'refresh' => SMOPT_REFRESH_NONE |
| 401 | ); |
| 402 | } |
| 403 | |
| 404 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
| 405 | 'name' => 'delete_prev_next_display', |
| 406 | 'caption' => _("Show 'Delete & Prev/Next' Links"), |
| 407 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 408 | 'refresh' => SMOPT_REFRESH_ALL |
| 409 | ); |
| 410 | |
| 411 | |
| 412 | |
| 413 | /*** Load the Address Book Options into the array ***/ |
| 414 | $optgrps[SMOPT_GRP_ABOOK] = _("Address Book Display Options"); |
| 415 | $optvals[SMOPT_GRP_ABOOK] = array(); |
| 416 | |
| 417 | $optvals[SMOPT_GRP_ABOOK][] = array( |
| 418 | 'name' => 'abook_show_num', |
| 419 | 'caption' => _("Number of Addresses per Page"), |
| 420 | 'type' => SMOPT_TYPE_INTEGER, |
| 421 | 'refresh' => SMOPT_REFRESH_NONE, |
| 422 | 'size' => SMOPT_SIZE_TINY |
| 423 | ); |
| 424 | |
| 425 | $optvals[SMOPT_GRP_ABOOK][] = array( |
| 426 | 'name' => 'abook_page_selector', |
| 427 | 'caption' => _("Enable Page Selector"), |
| 428 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 429 | 'refresh' => SMOPT_REFRESH_NONE |
| 430 | ); |
| 431 | |
| 432 | $optvals[SMOPT_GRP_ABOOK][] = array( |
| 433 | 'name' => 'abook_compact_paginator', |
| 434 | 'caption' => _("Use Compact Page Selector"), |
| 435 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 436 | 'refresh' => SMOPT_REFRESH_NONE |
| 437 | ); |
| 438 | |
| 439 | $optvals[SMOPT_GRP_ABOOK][] = array( |
| 440 | 'name' => 'abook_page_selector_max', |
| 441 | 'caption' => _("Maximum Number of Pages to Show"), |
| 442 | 'type' => SMOPT_TYPE_INTEGER, |
| 443 | 'refresh' => SMOPT_REFRESH_NONE, |
| 444 | 'size' => SMOPT_SIZE_TINY |
| 445 | ); |
| 446 | |
| 447 | |
| 448 | |
| 449 | /* Assemble all this together and return it as our result. */ |
| 450 | $result = array( |
| 451 | 'grps' => $optgrps, |
| 452 | 'vals' => $optvals |
| 453 | ); |
| 454 | return ($result); |
| 455 | } |
| 456 | |
| 457 | /******************************************************************/ |
| 458 | /** Define any specialized save functions for this option page. ***/ |
| 459 | /******************************************************************/ |
| 460 | |
| 461 | /** |
| 462 | * This function saves a new template setting. |
| 463 | * It updates the template array. |
| 464 | */ |
| 465 | function save_option_template($option) { |
| 466 | global $aTemplateSet; |
| 467 | |
| 468 | /* Do checking to make sure new template is in the available templates array. */ |
| 469 | $templateset_in_array = false; |
| 470 | for ($i = 0; $i < count($aTemplateSet); ++$i) { |
| 471 | if ($aTemplateSet[$i]['ID'] == $option->new_value) { |
| 472 | $templateset_in_array = true; |
| 473 | break; |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | if (!$templateset_in_array) { |
| 478 | $option->new_value = ''; |
| 479 | } else { |
| 480 | |
| 481 | // clear template cache when changing template sets |
| 482 | // (in order to do so, we have to change the global |
| 483 | // template set ID now... should not be a problem -- |
| 484 | // in fact, if we don't do it now, very anomalous |
| 485 | // problems occur) |
| 486 | // |
| 487 | global $sTemplateID; |
| 488 | $sTemplateID = $option->new_value; |
| 489 | Template::cache_template_file_hierarchy($sTemplateID, TRUE); |
| 490 | |
| 491 | } |
| 492 | |
| 493 | /** |
| 494 | * TODO: If the template changes and we are using a template provided theme |
| 495 | * ($user_theme), do we want to reset $user_theme? |
| 496 | */ |
| 497 | /* Save the option like normal. */ |
| 498 | save_option($option); |
| 499 | } |
| 500 | |
| 501 | /** |
| 502 | * This function saves the javascript detection option. |
| 503 | */ |
| 504 | function save_option_javascript_autodetect($option) { |
| 505 | save_option($option); |
| 506 | checkForJavascript(TRUE); |
| 507 | } |
| 508 | |
| 509 | /** |
| 510 | * This function saves the user's icon theme setting |
| 511 | */ |
| 512 | function icon_theme_save($option) { |
| 513 | global $icon_themes; |
| 514 | |
| 515 | |
| 516 | // Don't assume the new value is there, double check |
| 517 | // and only save if found |
| 518 | $found = false; |
| 519 | while (!$found && (list($index, $data) = each($icon_themes))) { |
| 520 | if ($data['PATH'] == $option->new_value) |
| 521 | $found = true; |
| 522 | } |
| 523 | |
| 524 | if (!$found) |
| 525 | $option->new_value = 'none'; |
| 526 | |
| 527 | save_option($option); |
| 528 | } |
| 529 | |
| 530 | function css_theme_save ($option) { |
| 531 | global $user_themes, $oTemplate; |
| 532 | |
| 533 | // Don't assume the new value is there, double check |
| 534 | // and only save if found |
| 535 | $found = false; |
| 536 | reset($user_themes); |
| 537 | while (!$found && (list($index, $data) = each($user_themes))) { |
| 538 | if ($data['PATH'] == $option->new_value) |
| 539 | $found = true; |
| 540 | } |
| 541 | |
| 542 | if (!$found) { |
| 543 | $template_themes = $oTemplate->get_alternative_stylesheets(true); |
| 544 | while (!$found && (list($path, $name) = each($template_themes))) { |
| 545 | if ($path == $option->new_value) |
| 546 | $found = true; |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | if (!$found) |
| 551 | $option->new_value = 'none'; |
| 552 | |
| 553 | save_option($option); |
| 554 | } |
| 555 | |
| 556 | |