X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Foptions.php;h=f2a8b1120769f587ae9e91fcde965ca4d90dc294;hb=7fb6790274b00b152d2eab22ba94c6b6a387e093;hp=44eb86df029974d503d09ecdcc88e58723ef0605;hpb=cbe5423b30fd1c50b7dd9546778cbebf48804953;p=squirrelmail.git diff --git a/src/options.php b/src/options.php index 44eb86df..f2a8b112 100644 --- a/src/options.php +++ b/src/options.php @@ -3,7 +3,7 @@ /** * options.php * - * Copyright (c) 1999-2001 The SquirrelMail Development Team + * Copyright (c) 1999-2003 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * * Displays the options page. Pulls from proper user preference files @@ -12,29 +12,22 @@ * $Id$ */ -require_once('../src/validate.php'); -require_once('../functions/display_messages.php'); -require_once('../functions/imap.php'); -require_once('../functions/array.php'); -require_once('../functions/options.php'); +/* Path for SquirrelMail required files. */ +define('SM_PATH','../'); -/* Set the base uri. */ -ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs); -$base_uri = $regs[1]; - -/* First and foremost, deal with language stuff. */ -if (isset($language)) { - setcookie('squirrelmail_language', $language, time()+2592000, $base_uri); - $squirrelmail_language = $language; -} else { - $language = getPref($data_dir, $username, 'language'); -} +/* SquirrelMail required files. */ +require_once(SM_PATH . 'include/validate.php'); +require_once(SM_PATH . 'functions/display_messages.php'); +require_once(SM_PATH . 'functions/imap.php'); +require_once(SM_PATH . 'functions/options.php'); +require_once(SM_PATH . 'functions/strings.php'); +require_once(SM_PATH . 'functions/html.php'); /*********************************/ /*** Build the resultant page. ***/ /*********************************/ -displayPageHeader($color, _("None")); +displayPageHeader($color, 'None'); define('SMOPT_MODE_DISPLAY', 'display'); define('SMOPT_MODE_SUBMIT', 'submit'); @@ -54,9 +47,12 @@ function process_optionmode_submit($optpage, $optpage_data) { /* Save each option in each option group. */ foreach ($optpage_data['options'] as $option_grp) { foreach ($option_grp['options'] as $option) { + /* Remove Debug Mode Until Needed echo "name = '$option->name', " . "value = '$option->value', " - . "new_value = '$option->new_value'
\n"; + . "new_value = '$option->new_value'\n"; + echo "
"; + */ if ($option->changed()) { $option->save(); $max_refresh = max($max_refresh, $option->refresh_level); @@ -72,9 +68,77 @@ function process_optionmode_link($optpage) { /* There will be something here, later. */ } + +/** + * This function prints out an option page row. + */ +function print_optionpages_row($leftopt, $rightopt = false) { + global $color; + + if ($rightopt) { + $rightopt_name = html_tag( 'td', '' . $rightopt['name'] . '', 'left', $color[9], 'valign="top" width="49%"' ); + $rightopt_desc = html_tag( 'td', $rightopt['desc'], 'left', $color[0], 'valign="top" width="49%"' ); + } else { + $rightopt_name = html_tag( 'td', ' ', 'left', $color[4], 'valign="top" width="49%"' ); + $rightopt_desc = html_tag( 'td', ' ', 'left', $color[4], 'valign="top" width="49%"' ); + } + + echo + html_tag( 'table', "\n" . + html_tag( 'tr', "\n" . + html_tag( 'td', "\n" . + html_tag( 'table', "\n" . + html_tag( 'tr', "\n" . + html_tag( 'td', + '' . $leftopt['name'] . '' , + 'left', $color[9], 'valign="top" width="49%"' ) . + html_tag( 'td', + ' ' , + 'left', $color[4], 'valign="top" width="2%"' ) . "\n" . + $rightopt_name + ) . "\n" . + html_tag( 'tr', "\n" . + html_tag( 'td', + $leftopt['desc'] , + 'left', $color[0], 'valign="top" width="49%"' ) . + html_tag( 'td', + ' ' , + 'left', $color[4], 'valign="top" width="2%"' ) . "\n" . + $rightopt_desc + ) , + '', '', 'width="100%" cellpadding="2" cellspacing="0" border="0"' ) , + 'left', '', 'valign="top"' ) + ) , + '', $color[4], 'width="100%" cellpadding="0" cellspacing="5" border="0"' ); +} + +/* ---------------------------- main ---------------------------- */ + +/* get the globals that we may need */ +if (isset($_GET['optpage'])) { + $optpage = $_GET['optpage']; +} +elseif (isset($_POST['optpage'])) { + $optpage = $_POST['optpage']; +} +if (isset($_POST['optmode'])) { + $optmode = $_POST['optmode']; +} +if (isset($_POST['optpage_data'])) { + $optpage_data = $_POST['optpage_data']; +} +$username = $_SESSION['username']; +$key = $_COOKIE['key']; +$onetimepad = $_SESSION['onetimepad']; +$delimiter = $_SESSION['delimiter']; + +/* end of getting globals */ + /* Make sure we have an Option Page set. Default to main. */ -if (!isset($optpage)) { - $optpage = 'main'; +if ( !isset($optpage) || $optpage == '' ) { + $optpage = SMOPT_PAGE_MAIN; +} else { + $optpage = strip_tags( $optpage ); } /* Make sure we have an Option Mode set. Default to display. */ @@ -82,9 +146,9 @@ if (!isset($optmode)) { $optmode = SMOPT_MODE_DISPLAY; } -/*************************************************************/ -/*** First, set the load information for each option page. ***/ -/*************************************************************/ +/* + * First, set the load information for each option page. + */ /* Initialize load information variables. */ $optpage_name = ''; @@ -93,46 +157,56 @@ $optpage_loader = ''; /* Set the load information for each page. */ switch ($optpage) { - case SMOPT_PAGE_MAIN: break; + case SMOPT_PAGE_MAIN: + break; case SMOPT_PAGE_PERSONAL: - $optpage_name = _("Personal Information"); - $optpage_file = 'options_personal.php'; - $optpage_loader = 'load_optpage_data_personal'; + $optpage_name = _("Personal Information"); + $optpage_file = SM_PATH . 'include/options/personal.php'; + $optpage_loader = 'load_optpage_data_personal'; + $optpage_loadhook = 'optpage_loadhook_personal'; break; case SMOPT_PAGE_DISPLAY: $optpage_name = _("Display Preferences"); - $optpage_file = 'options_display.php'; + $optpage_file = SM_PATH . 'include/options/display.php'; $optpage_loader = 'load_optpage_data_display'; + $optpage_loadhook = 'optpage_loadhook_display'; break; case SMOPT_PAGE_HIGHLIGHT: $optpage_name = _("Message Highlighting"); - $optpage_file = 'options_highlight.php'; + $optpage_file = SM_PATH . 'include/options/highlight.php'; $optpage_loader = 'load_optpage_data_highlight'; + $optpage_loadhook = 'optpage_loadhook_highlight'; break; case SMOPT_PAGE_FOLDER: $optpage_name = _("Folder Preferences"); - $optpage_file = 'options_folder.php'; + $optpage_file = SM_PATH . 'include/options/folder.php'; $optpage_loader = 'load_optpage_data_folder'; + $optpage_loadhook = 'optpage_loadhook_folder'; break; case SMOPT_PAGE_ORDER: $optpage_name = _("Index Order"); - $optpage_file = 'options_order.php'; + $optpage_file = SM_PATH . 'include/options/order.php'; $optpage_loader = 'load_optpage_data_order'; + $optpage_loadhook = 'optpage_loadhook_order'; break; - default: do_hook('set_optpage_loadinfo'); + default: do_hook('optpage_set_loadinfo'); } /**********************************************************/ /*** Second, load the option information for this page. ***/ /**********************************************************/ -if ($optpage != SMOPT_PAGE_MAIN) { +if ( !@is_file( $optpage_file ) ) { + $optpage = SMOPT_PAGE_MAIN; +} else if ($optpage != SMOPT_PAGE_MAIN ) { /* Include the file for this optionpage. */ + require_once($optpage_file); /* Assemble the data for this option page. */ $optpage_data = array(); $optpage_data = $optpage_loader(); + do_hook($optpage_loadhook); $optpage_data['options'] = create_option_groups($optpage_data['grps'], $optpage_data['vals']); } @@ -141,15 +215,16 @@ if ($optpage != SMOPT_PAGE_MAIN) { /*** Next, process anything that needs to be processed. ***/ /***********************************************************/ -switch ($optmode) { - case SMOPT_MODE_SUBMIT: - $max_refresh = process_optionmode_submit($optpage, $optpage_data); - break; - case SMOPT_MODE_LINK: - $max_refresh = process_optionmode_link($optpage, $optpage_data); - break; +if ( isset( $optpage_data ) ) { + switch ($optmode) { + case SMOPT_MODE_SUBMIT: + $max_refresh = process_optionmode_submit($optpage, $optpage_data); + break; + case SMOPT_MODE_LINK: + $max_refresh = process_optionmode_link($optpage, $optpage_data); + break; + } } - /*** MOVE THIS DISPLAY CODE DOWN EVENTUALLY!!! ***/ $optpage_title = _("Options"); @@ -157,23 +232,20 @@ if (isset($optpage_name) && ($optpage_name != '')) { $optpage_title .= " - $optpage_name"; } -?> - -
- -
-
- -
- -$optpage_title
\n". + html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n" . + html_tag( 'tr' ) . "\n" . + html_tag( 'td', '', 'center', $color[4] ) . "\n"; /*******************************************************************/ /* DO OLD SAVING OF SUBMITTED OPTIONS. THIS WILL BE REMOVED LATER. */ /*******************************************************************/ /* If in submit mode, select a save hook name and run it. */ -if ($optmode == SMOPT_MODE_SUBMIT) { +if ($optmode == SMOPT_MODE_SUBMIT) { /* Select a save hook name. */ switch ($optpage) { case SMOPT_PAGE_PERSONAL: @@ -185,7 +257,8 @@ if ($optmode == SMOPT_MODE_SUBMIT) { case SMOPT_PAGE_FOLDER: $save_hook_name = 'options_folder_save'; break; - default: $save_hook_name = 'options_save'; + default: + $save_hook_name = 'options_save'; break; } @@ -217,14 +290,18 @@ if ($optpage == SMOPT_PAGE_MAIN) { /* First, display the results of a submission, if needed. */ /**********************************************************/ if ($optmode == SMOPT_MODE_SUBMIT) { + if (!isset($frame_top)) { + $frame_top = '_top'; + } /* Display a message indicating a successful save. */ - echo '' . _("Successfully Saved Options") . ": $optpage_name
\n"; + echo '' . _("Successfully Saved Options") . ": $optpage_name
\n"; /* If $max_refresh != SMOPT_REFRESH_NONE, provide a refresh link. */ - if ($max_refresh == SMOPT_REFRESH_FOLDERLIST) { - echo '' . _("Refresh Folder List") . '
'; + if ( !isset( $max_refresh ) ) { + } else if ($max_refresh == SMOPT_REFRESH_FOLDERLIST) { + echo '' . _("Refresh Folder List") . '
'; } else if ($max_refresh) { - echo '' . _("Refresh Page") . '
'; + echo '' . _("Refresh Page") . '
'; } } /******************************************/ @@ -268,7 +345,7 @@ if ($optpage == SMOPT_PAGE_MAIN) { $optpage_blocks[] = array( 'name' => _("Index Order"), 'url' => 'options_order.php', - 'desc' => _("The order of the message index can be rearanged and changed to contain the headers in any order you want."), + 'desc' => _("The order of the message index can be rearranged and changed to contain the headers in any order you want."), 'js' => false ); @@ -293,9 +370,12 @@ if ($optpage == SMOPT_PAGE_MAIN) { /* Now, print out each option page section. */ /********************************************/ $first_optpage = false; - echo "" . - '
' . - ""; + echo html_tag( 'table', '', '', $color[4], 'width="100%" cellpadding="0" cellspacing="5" border="0"' ) . "\n" . + html_tag( 'tr' ) . "\n" . + html_tag( 'td', '', 'left', '', 'valign="top"' ) . + html_tag( 'table', '', '', $color[4], 'width="100%" cellpadding="3" cellspacing="0" border="0"' ) . "\n" . + html_tag( 'tr' ) . "\n" . + html_tag( 'td', '', 'left' ); foreach ($optpage_blocks as $next_optpage) { if ($first_optpage == false) { $first_optpage = $next_optpage; @@ -309,7 +389,7 @@ if ($optpage == SMOPT_PAGE_MAIN) { print_optionpages_row($first_optpage); } - echo "
\n"; + echo "
\n"; do_hook('options_link_and_description'); @@ -318,17 +398,16 @@ if ($optpage == SMOPT_PAGE_MAIN) { /* If we are not looking at the main option page, display the page here. */ /*************************************************************************/ } else { - echo '

' . "\n" - . '' . "\n" + echo '
' . "\n" . create_optpage_element($optpage) - . create_optmode_element(SMOPT_MODE_SUBMIT); + . create_optmode_element(SMOPT_MODE_SUBMIT) + . html_tag( 'table', '', '', '', 'width="100%" cellpadding="2" cellspacing="0" border="0"' ) . "\n" + . html_tag( 'tr' ) . "\n" + . html_tag( 'td', '', 'left' ) . "\n"; /* Output the option groups for this page. */ print_option_groups($optpage_data['options']); - /*** FIXME: CURRENTLY, THIS NEXT SWITCH STATEMENT DOES NOT TAKE - *** INTO ACCOUNT FOR PLUGINS. NEED TO FIX IT. ***/ - /* Set the inside_hook_name and submit_name. */ switch ($optpage) { case SMOPT_PAGE_PERSONAL: @@ -343,12 +422,12 @@ if ($optpage == SMOPT_PAGE_MAIN) { break; case SMOPT_PAGE_HIGHLIGHT: $inside_hook_name = 'options_highlight_inside'; - $bottom_hook_name = 'options_display_bottom'; + $bottom_hook_name = 'options_highlight_bottom'; $submit_name = 'submit_highlight'; break; case SMOPT_PAGE_FOLDER: $inside_hook_name = 'options_folder_inside'; - $bottom_hook_name = 'options_display_bottom'; + $bottom_hook_name = 'options_folder_bottom'; $submit_name = 'submit_folder'; break; case SMOPT_PAGE_ORDER: @@ -369,7 +448,7 @@ if ($optpage == SMOPT_PAGE_MAIN) { /* Spit out a submit button. */ OptionSubmit($submit_name); - echo '
'; + echo ''; /* If it is not empty, trigger the bottom hook. */ if ($bottom_hook_name != '') { @@ -377,76 +456,10 @@ if ($optpage == SMOPT_PAGE_MAIN) { } } -?> - - - - - - - - -" . - '' . - '' . - '' . - "'. - ""; - if ($rightopt) { - echo "'; - } else { - echo ""; - } - - echo '' . - '' . - "' . - ""; - if ($rightopt) { - echo "'; - } else { - echo ""; - } - - echo '' . - '
" . - '' . $leftopt['name'] . ''. - ' " . - '' . $rightopt['name'] . '' . - ' 
" . - $leftopt['desc'] . - ' " . - $rightopt['desc'] . - ' 
' . - '' . - "\n"; - } +echo '' . + ''. + ''. + '' . + ''; ?>