From 06c893b73d0c5d6acc89fb2800d692958471b356 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 19 Nov 2010 12:54:51 -0700 Subject: [PATCH] Allow search mailboxes to be selected via the IMP Folder Navigation screen --- imp/folders.php | 9 ++++++ imp/js/folders.js | 18 +++--------- imp/search.php | 53 +++++++++++++++++++++------------- imp/templates/imp/folders/actions.html | 2 ++ 4 files changed, 48 insertions(+), 34 deletions(-) diff --git a/imp/folders.php b/imp/folders.php index b214dafce..03cf720ed 100644 --- a/imp/folders.php +++ b/imp/folders.php @@ -323,6 +323,15 @@ case 'mbox_size': exit; } break; + +case 'search': + if (!empty($folder_list)) { + $url = new Horde_Url(Horde::url('search.php')); + $url->add('subfolder', 1) + ->add('search_mailbox', $folder_list) + ->redirect(); + } + break; } /* Token to use in requests */ diff --git a/imp/js/folders.js b/imp/js/folders.js index 038ed1d04..1a741a446 100644 --- a/imp/js/folders.js +++ b/imp/js/folders.js @@ -65,19 +65,6 @@ var ImpFolders = { this.renameMailbox(); break; - case 'subscribe_folder': - case 'unsubscribe_folder': - case 'poll_folder': - case 'expunge_folder': - case 'nopoll_folder': - case 'mark_folder_seen': - case 'mark_folder_unseen': - case 'delete_folder_confirm': - case 'folders_empty_mailbox_confirm': - case 'mbox_size': - this.submitAction(action); - break; - case 'download_folder': case 'download_folder_zip': this.downloadMailbox(action); @@ -90,8 +77,11 @@ var ImpFolders = { this.submitAction(action); } break; - } + default: + this.submitAction(action); + break; + } break; } }, diff --git a/imp/search.php b/imp/search.php index 02126b771..5d6c50136 100644 --- a/imp/search.php +++ b/imp/search.php @@ -5,19 +5,22 @@ * script only. * * URL Parameters: + *
  * ---------------
- * 'criteria_form' - (string) JSON representation of the search query.
- * 'edit_query' - (string) The search query to edit.
- * 'edit_query_filter' - (string) The name of the filter being edited.
- * 'edit_query_vfolder' - (string) The name of the virtual folder being
- *                        edited.
- * 'folders_form' - (string) JSON representation of the list of mailboxes for
- *                  the query. Hash containing 2 keys: mbox & subfolder.
- * 'search_label' - (string) The label to use when saving the search.
- * 'search_mailbox' - (string) Use this mailbox as the default value.
- *                    DEFAULT: INBOX
- * 'search_type' - (string) The type of saved search ('filter', 'vfolder').
- *                 If empty, the search should not be saved.
+ * criteria_form - (string) JSON representation of the search query.
+ * edit_query - (string) The search query to edit.
+ * edit_query_filter - (string) The name of the filter being edited.
+ * edit_query_vfolder - (string) The name of the virtual folder being edited.
+ * folders_form - (string) JSON representation of the list of mailboxes for
+ *                the query. Hash containing 2 keys: mbox & subfolder.
+ * search_label - (string) The label to use when saving the search.
+ * search_mailbox - (mixed) Use this mailbox(es) as the default value.
+ *                  DEFAULT: INBOX
+ * search_type - (string) The type of saved search ('filter', 'vfolder').
+ *               If empty, the search should not be saved.
+ * subfolder - (boolean) If set, search_mailbox will default to subfolder
+ *             search.
+ * 
* * Copyright 1999-2010 The Horde Project (http://www.horde.org/) * @@ -151,11 +154,21 @@ $vars = Horde_Variables::getDefaultVariables(); $dimp_view = ($session->get('imp', 'view') == 'dimp'); $js_vars = array(); -$search_mailbox = isset($vars->search_mailbox) - ? $vars->search_mailbox - : 'INBOX'; -$flist = $imp_flags->getFlagList($search_mailbox); +if (isset($vars->search_mailbox)) { + if (is_array($vars->search_mailbox)) { + $default_mailbox = 'INBOX'; + $search_mailbox = $vars->search_mailbox; + } else { + $default_mailbox = $vars->search_mailbox; + $search_mailbox = array($vars->search_mailbox); + } +} else { + $default_mailbox = 'INBOX'; + $search_mailbox = array('INBOX'); +} + +$flist = $imp_flags->getFlagList($default_mailbox); /* Generate the search query if 'criteria_form' is present in the form * data. */ @@ -391,8 +404,8 @@ if ($vars->edit_query && $imp_search->isSearchMbox($vars->edit_query)) { } $js_vars['ImpSearch.i_folders'] = array( - 'm' => array($search_mailbox), - 's' => array() + 'm' => $vars->subfolder ? array() : $search_mailbox, + 's' => $vars->subfolder ? $search_mailbox : array() ); } @@ -460,7 +473,7 @@ Horde::addInlineJsVars(array_merge($js_vars, array( 'dimp' => $dimp_view, 'folder_list' => $folder_list, 'months' => Horde_Core_Ui_JsCalendar::months(), - 'searchmbox' => $search_mailbox, + 'searchmbox' => $default_mailbox, 'types' => $types ), /* Gettext strings for this page. */ @@ -482,7 +495,7 @@ Horde::addInlineJsVars(array_merge($js_vars, array( if ($dimp_view) { if (!$vars->edit_query) { - $t->set('return_mailbox_val', sprintf(_("Return to %s"), htmlspecialchars(IMP::displayFolder($search_mailbox)))); + $t->set('return_mailbox_val', sprintf(_("Return to %s"), htmlspecialchars(IMP::displayFolder($default_mailbox)))); } } else { $menu = IMP::menu(); diff --git a/imp/templates/imp/folders/actions.html b/imp/templates/imp/folders/actions.html index dc4629464..94cd9ec81 100644 --- a/imp/templates/imp/folders/actions.html +++ b/imp/templates/imp/folders/actions.html @@ -37,6 +37,8 @@ + + -- 2.11.0