*
* Functions needed to display the options pages.
*
- * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @copyright © 1999-2007 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
define('SMOPT_TYPE_HIDDEN', 6);
define('SMOPT_TYPE_COMMENT', 7);
define('SMOPT_TYPE_FLDRLIST', 8);
+define('SMOPT_TYPE_FLDRLIST_MULTI', 9);
/* Define constants for the options refresh levels. */
define('SMOPT_REFRESH_NONE', 0);
*/
var $htmlencoded=false;
/**
- * Controls folder list limits in SMOPT_TYPE_FLDRLIST widget.
+ * Controls folder list limits in SMOPT_TYPE_FLDRLIST and
+ * SMOPT_TYPE_FLDRLIST_MULTI widgets.
* See $flag argument in sqimap_mailbox_option_list() function.
* @var string
* @since 1.5.1
case SMOPT_TYPE_FLDRLIST:
$result = $this->createWidget_FolderList();
break;
+ case SMOPT_TYPE_FLDRLIST_MULTI:
+ $result = $this->createWidget_FolderList(TRUE);
+ break;
default:
-//FIXME: can we throw an error here instead? either way, we don't want HTML here!
- $result = '<font color="' . $color[2] . '">'
- . sprintf(_("Option Type '%s' Not Found"), $this->type)
- . '</font>';
+ error_box (
+ sprintf(_("Option Type '%s' Not Found"), $this->type)
+ );
}
/* Add the "post script" for this option. */
* @return string html formated selection box
*/
function createWidget_StrList() {
-
- return addSelect('new_' . $this->name, $this->possible_values, $this->value, TRUE, $this->aExtraAttribs, !$this->htmlencoded) . htmlspecialchars($this->trailing_text);
+//FIXME: Currently, $this->htmlencoded is ignored here -- was removed when changing to template-based output; a fix is available as part of proposed centralized sanitizing patch
+ return addSelect('new_' . $this->name, $this->possible_values, $this->value, TRUE, $this->aExtraAttribs) . htmlspecialchars($this->trailing_text);
}
/**
* Create folder selection box
+ *
+ * @param boolean $multiple_select When TRUE, the select widget
+ * will allow multiple selections
+ * (OPTIONAL; default is FALSE
+ * (single select list))
+ *
* @return string html formated selection box
+ *
*/
- function createWidget_FolderList() {
+ function createWidget_FolderList($multiple_select=FALSE) {
// possible values might include a nested array of
// possible values (list of folders)
// list of folders (boxes array)
//
if (is_array($text)) {
- $option_list = array_merge($option_list, sqimap_mailbox_option_array(0, array(strtolower($this->value)), 0, $text, $this->folder_filter));
+ $option_list = array_merge($option_list, sqimap_mailbox_option_array(0, 0, $text, $this->folder_filter));
// just one option here
//
$option_list = array('ignore' => _("unavailable"));
- return addSelect('new_' . $this->name, $option_list, $this->value, TRUE, $this->aExtraAttribs) . htmlspecialchars($this->trailing_text);
+ // OK to use sq_htmlspecialchars() below because addSelect() already does
+ return addSelect('new_' . $this->name, $option_list, $this->value, TRUE, $this->aExtraAttribs, $multiple_select) . sq_htmlspecialchars($this->trailing_text);
}
*/
function createWidget_Boolean() {
- global $oTemplate;
- $nbsp = $oTemplate->fetch('non_breaking_space.tpl');
+ global $oTemplate, $nbsp;
/* Build the yes choice. */
$yes_option = addRadioBox('new_' . $this->name, ($this->value != SMPREF_NO), SMPREF_YES, array_merge(array('id' => 'new_' . $this->name . '_yes'), $this->aExtraAttribs)) . $nbsp . create_label(_("Yes"), 'new_' . $this->name . '_yes');
} /* End of SquirrelOption class*/
/**
- * Saves option
+ * Saves the option value (this is the default save function
+ * unless overridden by the user)
+ *
* @param object $option object that holds option name and new_value
*/
function save_option($option) {
+
+ // Can't save the pref if we don't have the username
+ //
if ( !sqgetGlobalVar('username', $username, SQ_SESSION ) ) {
- /* Can't save the pref if we don't have the username */
return;
}
+
global $data_dir;
- setPref($data_dir, $username, $option->name, $option->new_value);
+
+ // Certain option types need to be serialized because
+ // they are not scalar
+ //
+ if ($option->type == SMOPT_TYPE_FLDRLIST_MULTI)
+ setPref($data_dir, $username, $option->name, serialize($option->new_value));
+ else
+ setPref($data_dir, $username, $option->name, $option->new_value);
+
}
/**
return ($result);
}
-// vim: et ts=4