CRM-15493 - Ensure quickSearch uses a fresh qfKey every time
authorColeman Watts <coleman@civicrm.org>
Sun, 19 Oct 2014 22:00:24 +0000 (18:00 -0400)
committerColeman Watts <coleman@civicrm.org>
Sun, 19 Oct 2014 22:00:24 +0000 (18:00 -0400)
CRM/Core/Smarty/plugins/function.crmNavigationMenu.php
templates/CRM/common/navigation.js.tpl

index 8fcbd47069effb1e1c3ce105cf40f7ae2801f686..e9120445a24ec19befbdc5ea9e63e5fda0db03a8 100644 (file)
@@ -63,7 +63,9 @@ function smarty_function_crmNavigationMenu($params, &$smarty) {
       $domain = CRM_Core_Config::domainID();
       $key = CRM_Core_BAO_Navigation::getCacheKey($contactID);
       $src = CRM_Utils_System::url("civicrm/ajax/menujs/$contactID/$lang/$domain/$key");
-      return '<script type="text/javascript" src="' . $src . '"></script>';
+      // CRM-15493 QFkey needed for quicksearch bar - must be unique on each page refresh so adding it directly to markup
+      $qfKey = CRM_Core_Key::get('CRM_Contact_Controller_Search', TRUE);
+      return '<script id="civicrm-navigation-menu" type="text/javascript" src="' . $src . '" data-qfkey=' . json_encode($qfKey) . '></script>';
     }
   }
   return '';
index 05c8c53d0c3a8e54bcfda052343156f7f0a21b1d..ff627c457d0c7517ac306888664547f1a5dd719c 100644 (file)
@@ -32,7 +32,7 @@
             <input type="text" class="form-text" id="sort_name_navigation" placeholder="{ts}Find Contacts{/ts}" name="sort_name" style="width: 12em;" />
             <input type="text" id="sort_contact_id" style="display: none" />
             <input type="hidden" name="hidden_location" value="1" />
-            <input type="hidden" name="qfKey" value="{crmKey name='CRM_Contact_Controller_Search' addSequence=1}" />
+            <input type="hidden" name="qfKey" value="" />
             <div style="height:1px; overflow:hidden;"><input type="submit" value="{ts}Go{/ts}" name="_qf_Advanced_refresh" class="crm-form-submit default" /></div>
           </div>
         </form>
@@ -80,6 +80,9 @@
     $("#crm-nav-menu-container").html(menuMarkup).css({'padding-bottom': '10px'});
   }
 {/literal}{/if}{literal}
+  // CRM-15493 get the current qfKey
+  $("input[name=qfKey]", "#quickSearch").val($('#civicrm-navigation-menu').data('qfkey'));
+
 $('#civicrm-menu').ready(function() {
   $('#root-menu-div .outerbox').css({'margin-top': '6px'});
   $('#root-menu-div .menu-ul li').css({'padding-bottom': '2px', 'margin-top': '2px'});