+
+/**
+ * options.php
+ *
+ * Functions needed to display the options pages.
+ *
+ * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage prefs
+ */
+
+/**********************************************/
+/* Define constants used in the options code. */
+/**********************************************/
+
+/* Define constants for the various option types. */
+define('SMOPT_TYPE_STRING', 0);
+define('SMOPT_TYPE_STRLIST', 1);
+define('SMOPT_TYPE_TEXTAREA', 2);
+define('SMOPT_TYPE_INTEGER', 3);
+define('SMOPT_TYPE_FLOAT', 4);
+define('SMOPT_TYPE_BOOLEAN', 5);
+define('SMOPT_TYPE_HIDDEN', 6);
+define('SMOPT_TYPE_COMMENT', 7);
+define('SMOPT_TYPE_FLDRLIST', 8);
+
+/* Define constants for the options refresh levels. */
+define('SMOPT_REFRESH_NONE', 0);
+define('SMOPT_REFRESH_FOLDERLIST', 1);
+define('SMOPT_REFRESH_ALL', 2);
+
+/* Define constants for the options size. */
+define('SMOPT_SIZE_TINY', 0);
+define('SMOPT_SIZE_SMALL', 1);
+define('SMOPT_SIZE_MEDIUM', 2);
+define('SMOPT_SIZE_LARGE', 3);
+define('SMOPT_SIZE_HUGE', 4);
+define('SMOPT_SIZE_NORMAL', 5);
+
+define('SMOPT_SAVE_DEFAULT', 'save_option');
+define('SMOPT_SAVE_NOOP', 'save_option_noop');
+
+/**
+ * SquirrelOption: An option for SquirrelMail.
+ *
+ * @package squirrelmail
+ * @subpackage prefs
+ */
+class SquirrelOption {
+ /**
+ * The name of this setting
+ * @var string
+ */
+ var $name;
+ /**
+ * The text that prefaces setting on the preferences page
+ * @var string
+ */
+ var $caption;
+ /**
+ * The type of INPUT element
+ *
+ * See SMOPT_TYPE_* defines
+ * @var integer
+ */
+ var $type;
+ /**
+ * Indicates if a link should be shown to refresh part
+ * or all of the window
+ *
+ * See SMOPT_REFRESH_* defines
+ * @var integer
+ */
+ var $refresh_level;
+ /**
+ * Specifies the size of certain input items
+ *
+ * See SMOPT_SIZE_* defines
+ * @var integer
+ */
+ var $size;
+ /**
+ * Text that follows a text input or
+ * select list input on the preferences page
+ *
+ * useful for indicating units, meanings of special values, etc.
+ * @var string
+ */
+ var $trailing_text;
+ /**
+ * text displayed to the user
+ *
+ * Used with SMOPT_TYPE_COMMENT options
+ * @var string
+ */
+ var $comment;
+ /**
+ * additional javascript or other code added to the user input
+ * @var string
+ */
+ var $script;
+ /**
+ * script (usually Javascript) that will be placed after (outside of)
+ * the INPUT tag
+ * @var string
+ */
+ var $post_script;
+
+ /**
+ * The name of the Save Function for this option.
+ * @var string
+ */
+ var $save_function;
+
+ /* The various 'values' for this options. */
+ /**
+ * default/preselected value for this option
+ * @var mixed
+ */
+ var $value;
+ /**
+ * new option value
+ * @var mixed
+ */
+ var $new_value;
+ /**
+ * associative array, where each key is an actual input value
+ * and the corresponding value is what is displayed to the user
+ * for that list item in the drop-down list
+ * @var array
+ */
+ var $possible_values;
+ /**
+ * disables html sanitizing.
+ *
+ * WARNING - don't use it, if user input is possible in option
+ * or use own sanitizing functions. Currently works only with
+ * SMOPT_TYPE_STRLIST.
+ * @var bool
+ */
+ var $htmlencoded=false;
+ /**
+ * Controls folder list limits in SMOPT_TYPE_FLDRLIST widget.
+ * See $flag argument in sqimap_mailbox_option_list() function.
+ * @var string
+ * @since 1.5.1
+ */
+ var $folder_filter='noselect';
+
+ /**
+ * Constructor function
+ * @param string $name
+ * @param string $caption
+ * @param integer $type
+ * @param integer $refresh_level
+ * @param mixed $initial_value
+ * @param array $possible_values
+ * @param bool $htmlencoded
+ */
+ function SquirrelOption
+ ($name, $caption, $type, $refresh_level, $initial_value = '', $possible_values = '', $htmlencoded = false) {
+ /* Set the basic stuff. */
+ $this->name = $name;
+ $this->caption = $caption;
+ $this->type = $type;
+ $this->refresh_level = $refresh_level;
+ $this->possible_values = $possible_values;
+ $this->htmlencoded = $htmlencoded;
+ $this->size = SMOPT_SIZE_MEDIUM;
+ $this->trailing_text = '';
+ $this->comment = '';
+ $this->script = '';
+ $this->post_script = '';
+
+ /* Check for a current value. */
+ if (isset($GLOBALS[$name])) {
+ $this->value = $GLOBALS[$name];
+ } else if (!empty($initial_value)) {
+ $this->value = $initial_value;
+ } else {
+ $this->value = '';