Request #6875: Add advanced search interface to DIMP
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 16 Sep 2009 06:02:49 +0000 (00:02 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 16 Sep 2009 06:03:59 +0000 (00:03 -0600)
It works, but various UI elements remain to be tweaked to reflect the fact
this is a search mailbox rather than a real mailbox.

imp/docs/CHANGES
imp/js/DimpBase.js
imp/search.php
imp/templates/javascript_defs_dimp.php

index 2c6b254..327f3ed 100644 (file)
@@ -2,6 +2,7 @@
 v5.0-git
 --------
 
+[mms] Add advanced search query interface to DIMP (Request #6875).
 [mms] Add ability to search by a custom defined header (Request #6875).
 [mms] Improved advanced search query interface (Request #6875).
 [mms] More intelligent ordering of autocomplete search results.
index d5b034c..9d3832c 100644 (file)
@@ -254,6 +254,12 @@ var DimpBase = {
         }
 
         switch (loc) {
+        case 'search':
+            this.highlightSidebar();
+            DimpCore.setTitle(DIMP.text.search);
+            this.iframeContent(loc, DimpCore.addURLParam(DIMP.conf.URI_SEARCH, { search_mailbox: this.folder }));
+            break;
+
         case 'portal':
             this.highlightSidebar('appportal');
             this._addHistory(loc);
@@ -288,11 +294,11 @@ var DimpBase = {
         var curr = $('sidebarPanel').down('.on'),
             elt = $(id);
 
-        if (!elt || curr == elt) {
+        if (curr == elt) {
             return;
         }
 
-        if (!elt.match('LI')) {
+        if (elt && !elt.match('LI')) {
             elt = elt.up();
             if (!elt) {
                 return;
@@ -302,9 +308,11 @@ var DimpBase = {
         if (curr) {
             curr.removeClassName('on');
         }
-        elt.addClassName('on');
 
-        this._toggleSubFolder(elt, 'exp');
+        if (elt) {
+            elt.addClassName('on');
+            this._toggleSubFolder(elt, 'exp');
+        }
     },
 
     iframeContent: function(name, loc)
@@ -768,7 +776,7 @@ var DimpBase = {
             break;
 
         case 'ctx_qsearchopts_advanced':
-            alert('Placeholder for advanced search');
+            this.go('search');
             break;
 
         case 'ctx_qsearchopts_all':
@@ -863,7 +871,7 @@ var DimpBase = {
         var elt, unseen,
             label = this.viewport.getMetaData('label');
 
-        if (this.isSearch()) {
+        if (this.isSearch() && this.sfolder) {
             label += ' (' + this.sfolder + ')';
         } else {
             elt = $(this.getFolderId(this.folder));
index a9b8a0a..eb1f784 100644 (file)
@@ -40,6 +40,7 @@ if (!$browser->hasFeature('javascript') ||
 
 $charset = Horde_Nls::getCharset();
 $criteria = Horde_Util::getFormData('criteria_form');
+$dimp_view = ($_SESSION['imp']['view'] == 'dimp');
 $search_fields = $imp_search->searchFields();
 
 /* Generate the search query if 'criteria_form' is present in the form
@@ -64,7 +65,16 @@ if (!empty($criteria)) {
     }
 
     /* Redirect to the mailbox page. */
-    header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('mailbox.php', true), array('mailbox' => $GLOBALS['imp_search']->createSearchID($id)), null, false));
+    $id = $GLOBALS['imp_search']->createSearchID($id);
+    if ($dimp_view) {
+        /* Output javascript code to close the IFRAME and load the search
+         * mailbox in DIMP. */
+        print '<html><head>' .
+            Horde::wrapInlineScript(array('window.parent.DimpBase.go(' . Horde_Serialize::serialize('folder:' . $id, Horde_Serialize::JSON, $charset) . ')')) .
+            '</head></html>';
+    } else {
+        header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('mailbox.php', true), array('mailbox' => $$id), null, false));
+    }
     exit;
 }
 
@@ -174,9 +184,13 @@ Horde::addInlineScript($on_domload, 'dom');
 $title = _("Search");
 Horde::addScriptFile('horde.js', 'horde', true);
 Horde::addScriptFile('search.js', 'imp', true);
-IMP::prepareMenu();
+if (!$dimp_view) {
+    IMP::prepareMenu();
+}
 require IMP_TEMPLATES . '/common-header.inc';
-IMP::menu();
+if (!$dimp_view) {
+    IMP::menu();
+}
 IMP::status();
 
 echo $t->fetch(IMP_TEMPLATES . '/search/search.html');
index e1ae82a..8039004 100644 (file)
@@ -50,6 +50,7 @@ $code['conf'] = array_filter(array(
     'URI_PREFS' => Horde::getServiceLink('prefsapi', 'imp'),
     'URI_PREFS_IMP' => str_replace('&amp;', '&', Horde::getServiceLink('options', 'imp')),
     'URI_SEARCH_BASIC' => Horde::applicationUrl('search-basic.php'),
+    'URI_SEARCH' => Horde::applicationUrl('search.php'),
     'URI_VIEW' => Horde::applicationUrl('view.php'),
 
     'SESSION_ID' => defined('SID') ? SID : '',