Allow search mailboxes to be selected via the IMP Folder Navigation screen
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 19 Nov 2010 19:54:51 +0000 (12:54 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 19 Nov 2010 20:10:49 +0000 (13:10 -0700)
imp/folders.php
imp/js/folders.js
imp/search.php
imp/templates/imp/folders/actions.html

index b214daf..03cf720 100644 (file)
@@ -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 */
index 038ed1d..1a741a4 100644 (file)
@@ -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;
         }
     },
index 02126b7..5d6c501 100644 (file)
@@ -5,19 +5,22 @@
  * script only.
  *
  * URL Parameters:
+ * <pre>
  * ---------------
- * '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.
+ * </pre>
  *
  * 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();
index dc46294..94cd9ec 100644 (file)
@@ -37,6 +37,8 @@
      <option value="import_mbox"><gettext>Import Messages</gettext></option>
 </if:file_upload>
      <option value="mbox_size"><gettext>Show Size</gettext></option>
+     <option value="search"><gettext>Search</gettext></option>
+     <option value="" disabled="disabled">--------------------</option>
      <option value="rebuild_tree"><gettext>Rebuild Folder Tree</gettext></option>
     </select>
 <if:javascript><else:javascript>