Complete Request #7322
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 19 Dec 2008 08:02:20 +0000 (01:02 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 19 Dec 2008 08:02:20 +0000 (01:02 -0700)
Make autocompletion threshold parameters configurable

imp/config/conf.xml
imp/docs/CHANGES
imp/lib/Imple/ContactAutoCompleter.php

index 9158a4e..09c486c 100644 (file)
    <configinteger name="reply_limit" desc="What is the maximum total size of
    text (in bytes) to use when replying or forwarding a message. Set this value
    to 0 for no limit.">200000</configinteger>
+   <configinteger name="ac_browser" desc="For autocompletion of addresses,
+   if the addressbook is below this many entries, the user's address book will
+   be transmitted to the browser if it is below this many entries. This will
+   result in faster lookups and less server load, but requires additional
+   processing on compose creation. Set to 0 to disable.">100</configinteger>
+   <configinteger name="ac_threshold" desc="When autocompleting addresses in
+   the compose screen, this is the minimum number of characters required
+   before the search is performed on the server.">3</configinteger>
   </configsection>
  </configtab>
 
index 9f03425..20766c7 100644 (file)
@@ -2,6 +2,7 @@
 v5.0-cvs
 --------
 
+[mms] Make autocompletion threshold parameters configurable (Request #7322).
 [mms] Add compose attachment preview to DIMP.
 [mms] Add 'unit' parameter for quota display (Carlos Pires <acmpires@sapo.pt>,
       Request #7044).
index c04f762..44465dd 100644 (file)
@@ -58,8 +58,9 @@ class IMP_Imple_ContactAutoCompleter extends IMP_Imple
             'indicator: "' . $this->_params['triggerId'] . '_loading_img"',
             'afterUpdateElement: function(f, t) { if (!f.value.endsWith(";")) { f.value += ","; } f.value += " "; }'
         );
+        $ac_browser = empty($GLOBALS['conf']['compose']['ac_browser']) ? 0 : $GLOBALS['conf']['compose']['ac_browser'];
 
-        if (!isset($_SESSION['imp']['cache']['ac_ajax'])) {
+        if ($ac_browser && !isset($_SESSION['imp']['cache']['ac_ajax'])) {
             $success = $use_ajax = true;
             $sparams = IMP_Compose::getAddressSearchParams();
             foreach ($sparams['fields'] as $val) {
@@ -72,17 +73,19 @@ class IMP_Imple_ContactAutoCompleter extends IMP_Imple
             }
             if ($success) {
                 $addrlist = IMP_Compose::getAddressList();
-                $use_ajax = count($addrlist) > 200;
+                $use_ajax = count($addrlist) > $ac_browser;
             }
             $_SESSION['imp']['cache']['ac_ajax'] = $use_ajax;
         }
 
-        if ($_SESSION['imp']['cache']['ac_ajax']) {
+        if (!$ac_browser || $_SESSION['imp']['cache']['ac_ajax']) {
             $func = 'Ajax.Autocompleter';
             if (empty($this->_url)) {
                 $this->_url = Horde::url($GLOBALS['registry']->get('webroot', 'imp') . '/imple.php?imple=ContactAutoCompleter/input=' . rawurlencode($this->_params['triggerId']), true);
             }
             $params[] = '"' . $this->_url . '"';
+
+            $js_params[] = 'minChars: ' . intval($GLOBALS['conf']['compose']['ac_threshold'] ? $GLOBALS['conf']['compose']['ac_threshold'] : 1);
         } else {
             if (!$list_output) {
                 if (!isset($addrlist)) {