From: sizzlingmercury Date: Thu, 24 Oct 2002 05:45:48 +0000 (+0000) Subject: Folder Selection changes integrated from sizzle-ui stream.. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=be2d549570f1501e50b89557351aa3b0372e2e36;p=squirrelmail.git Folder Selection changes integrated from sizzle-ui stream.. Options for how folder selection list is displayed is on Folder Options page Folder lists on Search, Folders, and Folder Options Pages, as well as Folder selection lists used by the Message Index and the Delete_move_next plugin all modified to use new Option list creation method in imap_mailbox. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3990 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index a2088a6c..2c161eae 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -446,6 +446,52 @@ function user_strcasecmp($a, $b) { return $result; } +/* + * Returns list of options (to be echoed into select statement + * based on available mailboxes and separators + * Caller should surround options with and + * any formatting. + * $imap_stream - $imapConnection to query for mailboxes + * $show_selected - array containing list of mailboxes to pre-select (0 if none) + * $folder_skip - array of folders to keep out of option list (compared in lower) + * $boxes - list of already fetched boxes (for places like folder panel, where + * you know these options will be shown 3 times in a row.. (most often unset). + */ +function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_skip = 0, $boxes = 0 ) { + global $username, $data_dir; + $mbox_options = ''; + + $shorten_box_names = getPref($data_dir, $username, 'mailbox_select_style', SMPREF_OFF); + + if ( $boxes == 0 ) { + $boxes = sqimap_mailbox_list($imap_stream); + } + foreach ($boxes as $boxes_part) { + if (!in_array('noselect', $boxes_part['flags'])) { + $box = $boxes_part['unformatted']; + $lowerbox = strtolower($box); + + if ( $folder_skip != 0 && in_array($lowerbox, $folder_skip) ) { + continue; + } + if ($lowerbox == 'inbox'){ + $box2 = _("INBOX"); + } else if ( $shorten_box_names == 2 ) { /* delimited, style = 2 */ + $box2 = str_replace('  ', '. ', $boxes_part['formatted']); + } else if ( $shorten_box_names == 1 ) { /* indent, style = 1 */ + $box2 = $boxes_part['formatted']; + } else { /* default, long names, style = 0 */ + $box2 = str_replace(' ', ' ', imap_utf7_decode_local($boxes_part['unformatted-disp'])); + } + if ($show_selected != 0 && in_array($lowerbox, $show_selected) ) { + $mbox_options .= '' . "\n"; + } else { + $mbox_options .= '' . "\n"; + } + } + } + return $mbox_options; +} /* * Returns sorted mailbox lists in several different ways. diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 74cdc82c..309a6f43 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -1193,21 +1193,7 @@ function processSubject($subject) { function getMbxList($imapConnection) { global $lastTargetMailbox; echo '   '; } diff --git a/functions/options.php b/functions/options.php index 67c3c132..18282715 100644 --- a/functions/options.php +++ b/functions/options.php @@ -24,6 +24,7 @@ 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); @@ -163,6 +164,9 @@ class SquirrelOption { case SMOPT_TYPE_COMMENT: $result = $this->createWidget_Comment(); break; + case SMOPT_TYPE_FLDRLIST: + $result = $this->createWidget_FolderList(); + break; default: $result = '' . sprintf(_("Option Type '%s' Not Found"), $this->type) @@ -225,6 +229,38 @@ class SquirrelOption { return ($result); } + function createWidget_FolderList() { + $selected = array(strtolower($this->value)); + + /* Begin the select tag. */ + $result = "'; + return ($result); + } + + function createWidget_TextArea() { switch ($this->size) { case SMOPT_SIZE_TINY: $rows = 3; $cols = 10; break; diff --git a/include/load_prefs.php b/include/load_prefs.php index e9c7e647..35064bfa 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -244,6 +244,8 @@ $search_memory = getPref($data_dir, $username, 'search_memory', 0); $forward_cc = getPref($data_dir, $username, 'forward_cc', 0); +$mailbox_select_style = getPref($data_dir, $username, 'mailbox_select_style', 0); + do_hook('loading_prefs'); ?> diff --git a/include/options/folder.php b/include/options/folder.php index 2098bc34..a84952b0 100644 --- a/include/options/folder.php +++ b/include/options/folder.php @@ -13,10 +13,12 @@ /* SquirrelMail required files. */ require_once(SM_PATH . 'functions/imap.php'); +require_once(SM_PATH . 'functions/imap_general.php'); /* Define the group constants for the folder options page. */ define('SMOPT_GRP_SPCFOLDER', 0); define('SMOPT_GRP_FOLDERLIST', 1); +define('SMOPT_GRP_FOLDERSELECT', 2); /* Define the optpage load function for the folder options page. */ function load_optpage_data_folder() { @@ -52,43 +54,34 @@ function load_optpage_data_folder() { ); } - $special_folder_values = array(); - foreach ($boxes as $folder) { - if (strtolower($folder['unformatted']) != 'inbox') { - $real_value = $folder['unformatted-dm']; - $disp_value = str_replace(' ', ' ', $folder['formatted']); - $special_folder_values[$real_value] = $disp_value; - } - } - - $trash_none = array(SMPREF_NONE => _("Do not use Trash")); - $trash_folder_values = array_merge($trash_none, $special_folder_values); + $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]', + 'whatever' => $boxes); $optvals[SMOPT_GRP_SPCFOLDER][] = array( 'name' => 'trash_folder', 'caption' => _("Trash Folder"), - 'type' => SMOPT_TYPE_STRLIST, + 'type' => SMOPT_TYPE_FLDRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => $trash_folder_values, 'save' => 'save_option_trash_folder' ); - $sent_none = array(SMPREF_NONE => _("Do not use Sent")); - $sent_folder_values = array_merge($sent_none, $special_folder_values); + $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]', + 'whatever' => $boxes); $optvals[SMOPT_GRP_SPCFOLDER][] = array( 'name' => 'sent_folder', 'caption' => _("Sent Folder"), - 'type' => SMOPT_TYPE_STRLIST, + 'type' => SMOPT_TYPE_FLDRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => $sent_folder_values, 'save' => 'save_option_sent_folder' ); - $draft_none = array(SMPREF_NONE => _("Do not use Drafts")); - $draft_folder_values = array_merge($draft_none, $special_folder_values); + $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]', + 'whatever' => $boxes); $optvals[SMOPT_GRP_SPCFOLDER][] = array( 'name' => 'draft_folder', 'caption' => _("Draft Folder"), - 'type' => SMOPT_TYPE_STRLIST, + 'type' => SMOPT_TYPE_FLDRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, 'posvals' => $draft_folder_values, 'save' => 'save_option_draft_folder' @@ -211,6 +204,22 @@ function load_optpage_data_folder() { 9 => '9') ); + + /*** Load the General Options into the array ***/ + $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options"); + $optvals[SMOPT_GRP_FOLDERSELECT] = array(); + + $delim = sqimap_get_delimiter(); + $optvals[SMOPT_GRP_FOLDERSELECT][] = array( + 'name' => 'mailbox_select_style', + 'caption' => _("Selection List Style"), + 'type' => SMOPT_TYPE_STRLIST, + 'refresh' => SMOPT_REFRESH_NONE, + 'posvals' => array( 0 => _("Long: ") . '"Folder' . $delim . 'Subfolder"', + 1 => _("Indented: ") . '"    ' . 'Subfolder"', + 2 => _("Delimited: ") . '". ' . 'Subfolder"') + ); + /* Assemble all this together and return it as our result. */ $result = array( 'grps' => $optgrps, diff --git a/plugins/delete_move_next/setup.php b/plugins/delete_move_next/setup.php index 48c9d080..59ecf4e4 100644 --- a/plugins/delete_move_next/setup.php +++ b/plugins/delete_move_next/setup.php @@ -219,18 +219,7 @@ function delete_move_next_read($currloc) { function get_move_target_list() { global $imapConnection; - - $boxes = sqimap_mailbox_list($imapConnection); - for ($i = 0; $i < count($boxes); $i++) { - if (!in_array('noselect', $boxes[$i]['flags'])) { - $box = $boxes[$i]['unformatted']; - $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']); - if ( $box2 == 'INBOX' ) { - $box2 = _("INBOX"); - } - echo "\n"; - } - } + echo sqimap_mailbox_option_list($imapConnection); } function delete_move_next_moveNextForm($next) { diff --git a/src/folders.php b/src/folders.php index a6c8f639..ebbfe5ba 100644 --- a/src/folders.php +++ b/src/folders.php @@ -109,25 +109,17 @@ if ($default_sub_of_inbox == false) { echo '\n"; - } else { - $box = $boxes[$i]['unformatted']; - $box2 = str_replace(' ', ' ', - imap_utf7_decode_local($boxes[$i]['unformatted-disp'])); - if (strtolower($imap_server_type) != 'courier' || - strtolower($box) != "inbox.trash") - echo "\n"; - } - } +$show_selected = 0; +if ( $default_sub_of_inbox ) { + $show_selected = array('inbox'); } +$skip_folders = 0; +if ( strtolower($imap_server_type) == 'courier' ) { + $skip_folders = array('inbox.trash'); +} + +echo sqimap_mailbox_option_list($imapConnection, $show_selected, $skip_folders, $boxes, 'noinferiors'); + echo "\n"; if ($show_contain_subfolders_option) { echo '
 ' @@ -179,22 +171,9 @@ if ($count_special_folders < count($boxes)) { echo "
\n" . "\n". "\n" . "\n" . '' . _("Current Search") . '', 'left' ) . "\n" . html_tag( 'table', '', '', '', 'width="95%" cellpadding="0" cellspacing="0" border="0"' ) . html_tag( 'tr' ) . html_tag( 'td', '', 'left' ) - . ''. - " \n"; + . ''. + " \n"; if ( !isset( $what ) ) { $what = ''; }