- /**
- ** options.php
- **
- ** Copyright (c) 1999-2000 The SquirrelMail development team
- ** Licensed under the GNU GPL. For full terms see the file COPYING.
- **
- ** Functions needed to display the options pages.
- **
- ** $Id$
- **/
-
- function OptionSelect( $title, $name, $data, $default, $show = '', $store = '' ) {
-
- echo "<tr><td align=right valign=middle nowrap>$title: </td><td>" .
- "<select name=\"$name\">";
- foreach( $data as $key => $opt ) {
- if ( $store == '' ) {
- $vl = $key;
- } else{
- $vl = $opt[$store];
- }
- if ( $show == '' ) {
- $nm = $opt;
- } else{
- $nm = $opt[$show];
- }
- if ( $nm <> '') {
- echo "<option value=\"$vl\"";
- if( $vl == $default ) {
- echo ' selected';
- }
- echo ">$nm</option>\n";
- }
+
+/**
+ * options.php
+ *
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * Functions needed to display the options pages.
+ *
+ * $Id$
+ */
+
+/**********************************************/
+/* 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 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.
+ *
+ * This class is a work in progress. When complete, it will handle
+ * presentation and saving of Squirrelmail user options in a simple,
+ * streamline manner. Stay tuned for more stuff.
+ *
+ * Also, I'd like to ask that people leave this alone (mostly :) until
+ * I get it a little further along. That should only be a day or two or
+ * three. I will remove this message when it is ready for primetime usage.
+ */
+class SquirrelOption {
+ /* The basic stuff. */
+ var $name;
+ var $caption;
+ var $type;
+ var $refresh_level;
+ var $size;
+ var $comment;
+ var $script;
+
+ /* The name of the Save Function for this option. */
+ var $save_function;
+
+ /* The various 'values' for this options. */
+ var $value;
+ var $new_value;
+ var $possible_values;
+
+ function SquirrelOption
+ ($name, $caption, $type, $refresh_level, $possible_values = '') {
+ /* Set the basic stuff. */
+ $this->name = $name;
+ $this->caption = $caption;
+ $this->type = $type;
+ $this->refresh_level = $refresh_level;
+ $this->possible_values = $possible_values;
+ $this->size = SMOPT_SIZE_MEDIUM;
+ $this->comment = '';
+ $this->script = '';
+
+ /* Check for a current value. */
+ if (isset($GLOBALS[$name])) {
+ $this->value = $GLOBALS[$name];
+ } else {
+ $this->value = '';
+ }
+
+ /* Check for a new value. */
+ if (isset($GLOBALS["new_$name"])) {
+ $this->new_value = $GLOBALS["new_$name"];
+ } else {
+ $this->new_value = '';