X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Foptions.php;h=6255f7533289a4fb89ae6286d7b439d626f84b06;hb=049dd3d14ad72a9d624f6b67826e82ad1015c9dc;hp=50f45037d0cd42a7e10c7ded28c50ae87b35a963;hpb=625c8b787b79d07a1e53ba05213f66451d73651e;p=squirrelmail.git
diff --git a/src/options.php b/src/options.php
index 50f45037..6255f753 100644
--- a/src/options.php
+++ b/src/options.php
@@ -3,32 +3,34 @@
/**
* options.php
*
- * Copyright (c) 1999-2002 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
* and config.php. Displays preferences as selected and other options.
*
- * $Id$
+ * @copyright 1999-2017 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage prefs
*/
-/* Path for SquirrelMail required files. */
-define('SM_PATH','../');
+/** This is the options page */
+define('PAGE_NAME', 'options');
+
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../include/init.php');
/* 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');
+
+//include(SM_PATH . 'functions/imap_general.php');
require_once(SM_PATH . 'functions/options.php');
-require_once(SM_PATH . 'functions/strings.php');
-require_once(SM_PATH . 'functions/html.php');
+require_once(SM_PATH . 'functions/forms.php');
/*********************************/
/*** Build the resultant page. ***/
/*********************************/
-displayPageHeader($color, 'None');
-
define('SMOPT_MODE_DISPLAY', 'display');
define('SMOPT_MODE_SUBMIT', 'submit');
define('SMOPT_MODE_LINK', 'link');
@@ -36,22 +38,49 @@ define('SMOPT_MODE_LINK', 'link');
define('SMOPT_PAGE_MAIN', 'main');
define('SMOPT_PAGE_PERSONAL', 'personal');
define('SMOPT_PAGE_DISPLAY', 'display');
+define('SMOPT_PAGE_COMPOSE', 'compose');
+define('SMOPT_PAGE_ACCESSIBILITY', 'accessibility');
define('SMOPT_PAGE_HIGHLIGHT', 'highlight');
define('SMOPT_PAGE_FOLDER', 'folder');
define('SMOPT_PAGE_ORDER', 'order');
+/**
+ * Save submitted options and calculate the most
+ * we need to refresh the page
+ *
+ * @param string $optpage The name of the page being submitted
+ * @param array $optpage_data An array of all the submitted options
+ *
+ * @return int The highest level of screen refresh needed per
+ * the options that were changed. This value will
+ * correspond to the SMOPT_REFRESH_* constants found
+ * in functions/options.php.
+ *
+ */
function process_optionmode_submit($optpage, $optpage_data) {
/* Initialize the maximum option refresh level. */
$max_refresh = SMOPT_REFRESH_NONE;
+
+
/* Save each option in each option group. */
foreach ($optpage_data['options'] as $option_grp) {
foreach ($option_grp['options'] as $option) {
+
+ /* Special case: need to make sure emailaddress
+ * is saved if we use it as a test for ask_user_info */
+ global $ask_user_info;
+ if ( $optpage = SMOPT_PAGE_PERSONAL && $ask_user_info &&
+ $option->name == 'email_address' ) {
+ $option->setValue('');
+ }
+
/* Remove Debug Mode Until Needed
echo "name = '$option->name', "
. "value = '$option->value', "
. "new_value = '$option->new_value'\n";
- echo "
";
+//FIXME: NO HTML IN THE CORE!
+ echo "
";
*/
if ($option->changed()) {
$option->save();
@@ -69,69 +98,14 @@ function process_optionmode_link($optpage) {
}
-/**
- * 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'];
-
+sqgetGlobalVar('optpage', $optpage);
+sqgetGlobalVar('optmode', $optmode, SQ_FORM);
+sqgetGlobalVar('optpage_data',$optpage_data, SQ_POST);
+sqgetGlobalVar('smtoken', $submitted_token, SQ_FORM, '');
/* end of getting globals */
/* Make sure we have an Option Page set. Default to main. */
@@ -147,7 +121,7 @@ if (!isset($optmode)) {
}
/*
- * First, set the load information for each option page.
+ * First, set the load information for each option page.
*/
/* Initialize load information variables. */
@@ -157,7 +131,7 @@ $optpage_loader = '';
/* Set the load information for each page. */
switch ($optpage) {
- case SMOPT_PAGE_MAIN:
+ case SMOPT_PAGE_MAIN:
break;
case SMOPT_PAGE_PERSONAL:
$optpage_name = _("Personal Information");
@@ -171,6 +145,18 @@ switch ($optpage) {
$optpage_loader = 'load_optpage_data_display';
$optpage_loadhook = 'optpage_loadhook_display';
break;
+ case SMOPT_PAGE_COMPOSE:
+ $optpage_name = _("Compose Preferences");
+ $optpage_file = SM_PATH . 'include/options/compose.php';
+ $optpage_loader = 'load_optpage_data_compose';
+ $optpage_loadhook = 'optpage_loadhook_compose';
+ break;
+ case SMOPT_PAGE_ACCESSIBILITY:
+ $optpage_name = _("Accessibility Preferences");
+ $optpage_file = SM_PATH . 'include/options/accessibility.php';
+ $optpage_loader = 'load_optpage_data_accessibility';
+ $optpage_loadhook = 'optpage_loadhook_accessibility';
+ break;
case SMOPT_PAGE_HIGHLIGHT:
$optpage_name = _("Message Highlighting");
$optpage_file = SM_PATH . 'include/options/highlight.php';
@@ -189,7 +175,7 @@ switch ($optpage) {
$optpage_loader = 'load_optpage_data_order';
$optpage_loadhook = 'optpage_loadhook_order';
break;
- default: do_hook('optpage_set_loadinfo');
+ default: do_hook('optpage_set_loadinfo', $null);
}
/**********************************************************/
@@ -198,23 +184,30 @@ switch ($optpage) {
if ( !@is_file( $optpage_file ) ) {
$optpage = SMOPT_PAGE_MAIN;
-} else if ($optpage != SMOPT_PAGE_MAIN ) {
+} elseif ($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']);
+ do_hook($optpage_loadhook, $null);
+ $optpage_data['options'] = create_option_groups($optpage_data['grps'], $optpage_data['vals']);
}
/***********************************************************/
/*** Next, process anything that needs to be processed. ***/
/***********************************************************/
+// security check before saving anything...
+//FIXME: what about SMOPT_MODE_LINK??
+if ($optmode == SMOPT_MODE_SUBMIT) {
+ sm_validate_security_token($submitted_token, -1, TRUE);
+}
+
+$optpage_save_error=array();
+
if ( isset( $optpage_data ) ) {
switch ($optmode) {
case SMOPT_MODE_SUBMIT:
@@ -225,25 +218,17 @@ if ( isset( $optpage_data ) ) {
break;
}
}
-/*** MOVE THIS DISPLAY CODE DOWN EVENTUALLY!!! ***/
$optpage_title = _("Options");
if (isset($optpage_name) && ($optpage_name != '')) {
$optpage_title .= " - $optpage_name";
}
-echo html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) . "\n" .
- html_tag( 'tr' ) . "\n" .
- html_tag( 'td', '', 'center' ) .
- "$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. */
/*******************************************************************/
+//FIXME: let's remove these finally in 1.5.2..... but first, are there any plugins using them?
/* If in submit mode, select a save hook name and run it. */
if ($optmode == SMOPT_MODE_SUBMIT) {
/* Select a save hook name. */
@@ -254,16 +239,22 @@ if ($optmode == SMOPT_MODE_SUBMIT) {
case SMOPT_PAGE_DISPLAY:
$save_hook_name = 'options_display_save';
break;
+ case SMOPT_PAGE_COMPOSE:
+ $save_hook_name = 'options_compose_save';
+ break;
+ case SMOPT_PAGE_ACCESSIBILITY:
+ $save_hook_name = 'options_accessibility_save';
+ break;
case SMOPT_PAGE_FOLDER:
$save_hook_name = 'options_folder_save';
break;
- default:
+ default:
$save_hook_name = 'options_save';
break;
}
/* Run the options save hook. */
- do_hook($save_hook_name);
+ do_hook($save_hook_name, $null);
}
/***************************************************************/
@@ -275,12 +266,15 @@ if ($optmode == SMOPT_MODE_SUBMIT) {
if ($optmode == SMOPT_MODE_SUBMIT) {
$optpage = SMOPT_PAGE_MAIN;
+ $optpage_title = _("Options");
}
/***************************************************************/
/* Finally, display whatever page we are supposed to show now. */
/***************************************************************/
+displayPageHeader($color, null, (isset($optpage_data['xtra']) ? $optpage_data['xtra'] : ''));
+
/*
* The main option page has a different layout then the rest of the option
* pages. Therefore, we create it here first, then the others below.
@@ -289,68 +283,125 @@ if ($optpage == SMOPT_PAGE_MAIN) {
/**********************************************************/
/* First, display the results of a submission, if needed. */
/**********************************************************/
+ $notice = '';
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";
+
+ if (isset($optpage_save_error) && $optpage_save_error!=array()) {
+//FIXME: REMOVE HTML FROM CORE
+ $notice = _("Error(s) occurred while saving your options") . "
\n