X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Foptions.php;h=0d320b21030de7769925de18718df578f9761c7e;hb=24e8917ead46268f6a4264900c832b4a5c37ee84;hp=298182c6c9284652f11906113b28137a59634f41;hpb=d03f35823cb991b22439f56fd7329fdac246b96b;p=squirrelmail.git
diff --git a/src/options.php b/src/options.php
index 298182c6..0d320b21 100644
--- a/src/options.php
+++ b/src/options.php
@@ -3,40 +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-2020 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage prefs
*/
-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');
-require_once('../functions/strings.php');
-
-/* 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');
-}
+/** This is the options page */
+define('PAGE_NAME', 'options');
+
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../include/init.php');
+
+/* SquirrelMail required files. */
+
+//include(SM_PATH . 'functions/imap_general.php');
+require_once(SM_PATH . 'functions/options.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');
@@ -44,21 +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";
+ . "new_value = '$option->new_value'\n";
+//FIXME: NO HTML IN THE CORE!
+ echo "
";
*/
if ($option->changed()) {
$option->save();
@@ -75,9 +97,22 @@ function process_optionmode_link($optpage) {
/* There will be something here, later. */
}
+
+
+/* ---------------------------- main ---------------------------- */
+
+/* get the globals that we may need */
+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. */
-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. */
@@ -85,9 +120,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 = '';
@@ -96,60 +131,83 @@ $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 = '../src/options_personal.php';
+ $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 = '../src/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_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 = '../src/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 = '../src/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 = '../src/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('optpage_set_loadinfo');
+ default: do_hook('optpage_set_loadinfo', $null);
}
/**********************************************************/
/*** Second, load the option information for this page. ***/
/**********************************************************/
-if ($optpage != SMOPT_PAGE_MAIN) {
+if ( !@is_file( $optpage_file ) ) {
+ $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:
@@ -160,30 +218,19 @@ if ( isset( $optpage_data ) ) {
break;
}
}
-/*** MOVE THIS DISPLAY CODE DOWN EVENTUALLY!!! ***/
$optpage_title = _("Options");
if (isset($optpage_name) && ($optpage_name != '')) {
$optpage_title .= " - $optpage_name";
}
-?>
-
-
-
- -
|