From 99ecf044060cdb4f2b3b7512dbfcee4406018300 Mon Sep 17 00:00:00 2001 From: tokul Date: Mon, 31 Oct 2005 18:00:46 +0000 Subject: [PATCH] adding IMAP folder type controls to folder option widget. Widget uses default noselect filtering and sent_subfolders needs to filter noinferiors fixed sent_subfolder E_NOTICE issues with yearly subfolders and added delimiter between subfolder base and year folder. Sent Subfolder Base selection box now lists only folders without noinferiors flag. Tested on UW. Some complex folder check is pending. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@10210 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 1 + doc/Development/plugin.txt | 3 ++ functions/options.php | 43 ++++++++++++++++++---- plugins/sent_subfolders/setup.php | 60 ++++++++++++++++--------------- 4 files changed, 73 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 590e3fdd..07f2c5a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -460,6 +460,7 @@ Version 1.5.1 -- CVS is restarted. - If you don't have any filters defined, and spam filters are disabled, no point issuing a STATUS call on INBOX for the filters plugin. + - Added folder filtering controls to SMOPT_TYPE_FLDRLIST option widget. Version 1.5.0 - 2 February 2004 ------------------------------- diff --git a/doc/Development/plugin.txt b/doc/Development/plugin.txt index b5c1bac6..fedaec7c 100644 --- a/doc/Development/plugin.txt +++ b/doc/Development/plugin.txt @@ -728,6 +728,9 @@ for you. This is the preferred method of building options lists going forward. htmlencoded 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. + folder_filter Controls folder list limits in SMOPT_TYPE_FLDRLIST widget. + See $flag argument in sqimap_mailbox_option_list() + function. Available since 1.5.1. Note that you do not have to create a whole new section on the options page if you merely want to add a simple input item or two to an options diff --git a/functions/options.php b/functions/options.php index 66b4ff16..71851102 100644 --- a/functions/options.php +++ b/functions/options.php @@ -142,6 +142,13 @@ class SquirrelOption { * @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 @@ -254,6 +261,15 @@ class SquirrelOption { $this->save_function = $save_function; } + /** + * Set the trailing_text for this option. + * @param string $folder_filter + * @since 1.5.1 + */ + function setFolderFilter($folder_filter) { + $this->folder_filter = $folder_filter; + } + /** * Creates fields on option pages according to option type * @@ -383,14 +399,14 @@ class SquirrelOption { function createWidget_FolderList() { $selected = array(strtolower($this->value)); - /* Begin the select tag. */ - $result = "\n"; + return ($ret); + } } /** @@ -649,6 +675,11 @@ function create_option_groups($optgrps, $optvals) { $next_option->setPostScript($optset['post_script']); } + /* If provided, set the folder_filter for this option. */ + if (isset($optset['folder_filter'])) { + $next_option->setFolderFilter($optset['folder_filter']); + } + /* Add this option to the option array. */ $result[$grpkey]['options'][] = $next_option; } diff --git a/plugins/sent_subfolders/setup.php b/plugins/sent_subfolders/setup.php index 359c2463..c6582b34 100644 --- a/plugins/sent_subfolders/setup.php +++ b/plugins/sent_subfolders/setup.php @@ -136,7 +136,8 @@ function sent_subfolders_optpage_loadhook_folders() { 'caption' => _("Base Sent Folder"), 'type' => SMOPT_TYPE_FLDRLIST, 'refresh' => SMOPT_REFRESH_FOLDERLIST, - 'posvals' => $sent_subfolders_base_values + 'posvals' => $sent_subfolders_base_values, + 'folder_filter' => 'noinferiors' ); /* Add our option data to the global array. */ @@ -195,19 +196,12 @@ function sent_subfolders_update_sentfolder() { $month = date('m'); $quarter = sent_subfolder_getQuarter($month); - /* - Regarding the structure we've got three main possibilities. - One sent holder. level 0. - Multiple year holders with messages in it. level 1. - Multiple year folders with holders in it. level 2. - */ -/* - if( $imap_server_type == 'uw' ) { - $cnd_delimiter = ''; - } else { - $cnd_delimiter = $delimiter; - } -*/ + /** + * Regarding the structure we've got three main possibilities. + * One sent holder. level 0. + * Multiple year holders with messages in it. level 1. + * Multiple year folders with holders in it. level 2. + */ $cnd_delimiter = $delimiter; switch ($sent_subfolders_setting) { @@ -221,7 +215,7 @@ function sent_subfolders_update_sentfolder() { $sent_subfolder = $sent_subfolders_base . $cnd_delimiter . $year . $delimiter . $quarter; - $year_folder = $sent_subfolders_base + $year_folder = $sent_subfolders_base . $cnd_delimiter . $year; break; case SMPREF_SENT_SUBFOLDERS_MONTHLY: @@ -229,7 +223,7 @@ function sent_subfolders_update_sentfolder() { $sent_subfolder = $sent_subfolders_base . $cnd_delimiter . $year . $delimiter . $month; - $year_folder = $sent_subfolders_base . $year; + $year_folder = $sent_subfolders_base. $cnd_delimiter . $year; break; case SMPREF_SENT_SUBFOLDERS_DISABLED: default: @@ -240,8 +234,16 @@ function sent_subfolders_update_sentfolder() { /* If this folder is NOT the current sent folder, update stuff. */ if ($sent_subfolder != $sent_folder) { - /* First, update the sent folder. */ - + /** + * $sent_subfolder should not have \noselect flag or folder should + * not exist. + * if $level=2, $year_folder should not have \noinferiors or folder + * should not exist. + * + * If some condition fails - sent_subfolders is misconfigured + */ + + /* Update sent_folder setting. */ setPref($data_dir, $username, 'sent_folder', $sent_subfolder); setPref($data_dir, $username, 'move_to_sent', SMPREF_ON); $sent_folder = $sent_subfolder; @@ -250,19 +252,20 @@ function sent_subfolders_update_sentfolder() { /* Auto-create folders, if they do not yet exist. */ if ($sent_folder != 'none') { /* Create the imap connection. */ - $ic = sqimap_login - ($username, $key, $imapServerAddress, $imapPort, 10); - - /* Auto-create the year folder, if it does not yet exist. */ - if (!sqimap_mailbox_exists($ic, $year_folder)) { - sqimap_mailbox_create($ic, $year_folder, ($level==1)?'':'noselect'); - } else if (!sqimap_mailbox_is_subscribed($ic, $year_folder)) { - sqimap_subscribe($ic, $year_folder); + $ic = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); + + if ($level==2) { + /* Auto-create the year folder, if it does not yet exist. */ + if (!sqimap_mailbox_exists($ic, $year_folder)) { + sqimap_mailbox_create($ic, $year_folder, 'noselect'); + } else if (!sqimap_mailbox_is_subscribed($ic, $year_folder)) { + sqimap_subscribe($ic, $year_folder); + } } /* Auto-create the subfolder, if it does not yet exist. */ - if (!sqimap_mailbox_exists($ic, $sent_folder)) { - sqimap_mailbox_create($ic, $sent_folder, ''); + if (!sqimap_mailbox_exists($ic, $sent_subfolder)) { + sqimap_mailbox_create($ic, $sent_subfolder, ''); } else if (!sqimap_mailbox_is_subscribed($ic, $sent_subfolder)) { sqimap_subscribe($ic, $sent_subfolder); } @@ -270,6 +273,7 @@ function sent_subfolders_update_sentfolder() { /* Close the imap connection. */ sqimap_logout($ic); } + } } } -- 2.25.1