Changeset 2c8e84c in github
- Timestamp:
- Nov 23, 2008 7:38:44 AM (5 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 69ad1e8
- Parents:
- b4b31d62
- Files:
-
- 5 edited
-
CHANGELOG (modified) (1 diff)
-
config/main.inc.php.dist (modified) (1 diff)
-
program/js/app.js (modified) (13 diffs)
-
program/steps/mail/compose.inc (modified) (2 diffs)
-
skins/default/common.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
rd59aaa1 r2c8e84c 1 1 CHANGELOG RoundCube Webmail 2 2 --------------------------- 3 4 2008/11/23 (thomasb) 5 ---------- 6 - Do serverside addressbook queries for autocompletion (#1485531) 3 7 4 8 2008/11/23 (alec) -
config/main.inc.php.dist
rd59aaa1 r2c8e84c 280 280 * 'scope' => 'sub', // search mode: sub|base|list 281 281 * 'filter' => '', // used for basic listing (if not empty) and will be &'d with search queries. example: status=act 282 * 'global_search' => true, // perform a global search for address auto-completion on compose283 282 * 'fuzzy_search' => true); // server allows wildcard search 284 283 */ 284 285 // An ordered array of the ids of the addressbooks that should be searched 286 // when populating address autocomplete fields server-side. ex: array('sql','Verisign'); 287 $rcmail_config['autocomplete_addressbooks'] = array('sql'); 285 288 286 289 // don't allow these settings to be overriden by the user -
program/js/app.js
rd59aaa1 r2c8e84c 459 459 { 460 460 var handler = function(e){ return ref.ksearch_keypress(e,this); }; 461 var handler2 = function(e){ return ref.ksearch_blur(e,this); };462 461 463 462 if (obj.addEventListener) 464 {465 463 obj.addEventListener(bw.safari ? 'keydown' : 'keypress', handler, false); 466 obj.addEventListener('blur', handler2, false);467 }468 464 else 469 {470 465 obj.onkeydown = handler; 471 obj.onblur = handler2; 472 } 473 474 obj.setAttribute('autocomplete', 'off'); 466 467 obj.setAttribute('autocomplete', 'off'); 475 468 }; 476 469 … … 1174 1167 model = this.env.address_sources; 1175 1168 } 1169 else if (this.ksearch_value) { 1170 this.ksearch_blur(); 1171 } 1176 1172 1177 1173 // handle mouse release when dragging … … 2314 2310 2315 2311 if (this.gui_objects.search_filter) 2316 addurl = '&_filter=' + this.gui_objects.search_filter.value;2312 addurl = '&_filter=' + this.gui_objects.search_filter.value; 2317 2313 2318 2314 // reset vars … … 2320 2316 this.set_busy(true, 'searching'); 2321 2317 this.http_request('search', '_q='+urlencode(value) 2322 +(this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : '')2323 +(this.env.source ? '&_source='+urlencode(this.env.source) : '')2324 +(addurl ? addurl : ''), true);2318 + (this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : '') 2319 + (this.env.source ? '&_source='+urlencode(this.env.source) : '') 2320 + (addurl ? addurl : ''), true); 2325 2321 } 2326 2322 return true; … … 2350 2346 // handler for keyboard events on address-fields 2351 2347 this.ksearch_keypress = function(e, obj) 2352 { 2353 if (typeof(this.env.contacts)!='object' || !this.env.contacts.length) 2354 return true; 2355 2348 { 2356 2349 if (this.ksearch_timer) 2357 2350 clearTimeout(this.ksearch_timer); … … 2369 2362 2370 2363 var dir = key==38 ? 1 : 0; 2371 var next;2372 2364 2373 2365 highlight = document.getElementById('rcmksearchSelected'); … … 2375 2367 highlight = this.ksearch_pane.ul.firstChild; 2376 2368 2377 if (highlight && (next = dir ? highlight.previousSibling : highlight.nextSibling)) 2378 { 2379 highlight.removeAttribute('id'); 2380 this.set_classname(highlight, 'selected', false); 2381 } 2382 2383 if (next) 2384 { 2385 next.setAttribute('id', 'rcmksearchSelected'); 2386 this.set_classname(next, 'selected', true); 2387 this.ksearch_selected = next._rcm_id; 2388 } 2369 if (highlight) 2370 this.ksearch_select(dir ? highlight.previousSibling : highlight.nextSibling); 2389 2371 2390 2372 return rcube_event.cancel(e); … … 2394 2376 break; 2395 2377 2396 case 13: // enter 2378 case 13: // enter 2397 2379 if (this.ksearch_selected===null || !this.ksearch_input || !this.ksearch_value) 2398 2380 break; … … 2415 2397 2416 2398 return true; 2417 }; 2399 }; 2400 2401 this.ksearch_select = function(node) 2402 { 2403 var current = document.getElementById('rcmksearchSelected'); 2404 if (current && node) { 2405 current.removeAttribute('id'); 2406 this.set_classname(current, 'selected', false); 2407 } 2408 2409 if (node) { 2410 node.setAttribute('id', 'rcmksearchSelected'); 2411 this.set_classname(node, 'selected', true); 2412 this.ksearch_selected = node._rcm_id; 2413 } 2414 }; 2418 2415 2419 2416 this.insert_recipient = function(id) … … 2441 2438 // address search processor 2442 2439 this.ksearch_get_results = function() 2443 {2440 { 2444 2441 var inp_value = this.ksearch_input ? this.ksearch_input.value : null; 2445 if (inp_value ===null)2442 if (inp_value === null) 2446 2443 return; 2444 2445 if (this.ksearch_pane && this.ksearch_pane.visible) 2446 this.ksearch_pane.show(0); 2447 2447 2448 2448 // get string from current cursor pos to last comma … … 2454 2454 q = q.replace(/(^\s+|\s+$)/g, '').toLowerCase(); 2455 2455 2456 if (!q.length || q==this.ksearch_value) 2457 { 2458 if (!q.length && this.ksearch_pane && this.ksearch_pane.visible) 2459 this.ksearch_pane.show(0); 2460 2461 return; 2462 } 2456 // Don't (re-)search if string is empty or if the last results are still active 2457 if (!q.length || q == this.ksearch_value) 2458 return; 2463 2459 2464 2460 this.ksearch_value = q; 2465 2461 2466 // start searching the contact list 2467 var a_results = new Array(); 2468 var a_result_ids = new Array(); 2462 this.display_message('searching', 'loading', true); 2463 this.http_post('autocomplete', '_search='+q); 2464 }; 2465 2466 this.ksearch_query_results = function(results) 2467 { 2468 this.hide_message(); 2469 this.env.contacts = results ? results : []; 2470 2471 var result_ids = new Array(); 2469 2472 var c=0; 2470 for (var i=0; i<this.env.contacts.length; i++) 2471 { 2472 if (this.env.contacts[i].toLowerCase().indexOf(q)>=0) 2473 { 2474 a_results[c] = this.env.contacts[i]; 2475 a_result_ids[c++] = i; 2476 2477 if (c==15) // limit search results 2478 break; 2479 } 2480 } 2481 2473 for (var i=0; i < this.env.contacts.length; i++) { 2474 result_ids[c++] = i; 2475 if (c == 15) // limit search results 2476 break; 2477 } 2478 2479 this.ksearch_display_results(this.env.contacts, result_ids, c); 2480 }; 2481 2482 this.ksearch_display_results = function (a_results, a_result_ids, c) 2483 { 2482 2484 // display search results 2483 if (c && a_results.length) 2484 { 2485 if (c && a_results.length) { 2485 2486 var p, ul, li; 2486 2487 2487 2488 // create results pane if not present 2488 if (!this.ksearch_pane) 2489 { 2489 if (!this.ksearch_pane) { 2490 2490 ul = document.createElement('UL'); 2491 2491 this.ksearch_pane = new rcube_layer('rcmKSearchpane', {vis:0, zindex:30000}); 2492 2492 this.ksearch_pane.elm.appendChild(ul); 2493 2493 this.ksearch_pane.ul = ul; 2494 }2494 } 2495 2495 else 2496 2496 ul = this.ksearch_pane.ul; … … 2500 2500 2501 2501 // add each result line to list 2502 for (i=0; i<a_results.length; i++) 2503 { 2502 for (i=0; i<a_results.length; i++) { 2504 2503 li = document.createElement('LI'); 2505 li.innerHTML = a_results[i].replace(/</, '<').replace(/>/, '>'); 2504 li.innerHTML = a_results[i].replace(/</, '<').replace(/>/, '>').replace(new RegExp('('+this.ksearch_value+')', 'ig'), '<b>$1</b>'); 2505 li.onmouseover = function(){ ref.ksearch_select(this); }; 2506 li.onclick = function(){ ref.ksearch_click(this) }; 2506 2507 li._rcm_id = a_result_ids[i]; 2507 2508 ul.appendChild(li); 2508 }2509 } 2509 2510 2510 2511 // check if last selected item is still in result list 2511 if (this.ksearch_selected!==null) 2512 { 2512 if (this.ksearch_selected !== null) { 2513 2513 p = find_in_array(this.ksearch_selected, a_result_ids); 2514 if (p>=0 && ul.childNodes) 2515 { 2514 if (p >= 0 && ul.childNodes) { 2516 2515 ul.childNodes[p].setAttribute('id', 'rcmksearchSelected'); 2517 2516 this.set_classname(ul.childNodes[p], 'selected', true); 2518 }2517 } 2519 2518 else 2520 2519 this.ksearch_selected = null; 2521 }2520 } 2522 2521 2523 2522 // if no item selected, select the first one 2524 if (this.ksearch_selected===null) 2525 { 2523 if (this.ksearch_selected === null) { 2526 2524 ul.firstChild.setAttribute('id', 'rcmksearchSelected'); 2527 2525 this.set_classname(ul.firstChild, 'selected', true); 2528 2526 this.ksearch_selected = a_result_ids[0]; 2529 }2527 } 2530 2528 2531 2529 // move the results pane right under the input box and make it visible 2532 2530 var pos = rcube_get_object_pos(this.ksearch_input); 2533 2531 this.ksearch_pane.move(pos.x, pos.y+this.ksearch_input.offsetHeight); 2534 this.ksearch_pane.show(1); 2535 }2532 this.ksearch_pane.show(1); 2533 } 2536 2534 // hide results pane 2537 2535 else 2538 2536 this.ksearch_hide(); 2539 }; 2540 2541 this.ksearch_blur = function(e, obj) 2537 }; 2538 2539 this.ksearch_click = function(node) 2540 { 2541 this.insert_recipient(node._rcm_id); 2542 this.ksearch_hide(); 2543 2544 if (ref.ksearch_input) 2545 this.ksearch_input.focus(); 2546 }; 2547 2548 this.ksearch_blur = function() 2542 2549 { 2543 2550 if (this.ksearch_timer) 2544 2551 clearTimeout(this.ksearch_timer); 2545 2552 2546 this.ksearch_value = ''; 2553 this.ksearch_value = ''; 2547 2554 this.ksearch_input = null; 2548 2555 … … 2556 2563 2557 2564 if (this.ksearch_pane) 2558 this.ksearch_pane.show(0); 2565 this.ksearch_pane.show(0); 2559 2566 }; 2560 2567 -
program/steps/mail/compose.inc
r300fc65 r2c8e84c 84 84 $OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubjectwarning', 85 85 'nobodywarning', 'notsentwarning', 'savingmessage', 'sendingmessage', 'messagesaved', 86 'converting', 'editorwarning' );86 'converting', 'editorwarning', 'searching'); 87 87 88 88 // add config parameters to client script … … 914 914 )); 915 915 916 /****** get contacts for this user and add them to client scripts ********/917 918 $CONTACTS = new rcube_contacts($DB, $USER->ID);919 $CONTACTS->set_pagesize(1000);920 921 $a_contacts = array();922 923 if ($result = $CONTACTS->list_records())924 {925 while ($sql_arr = $result->iterate())926 if ($sql_arr['email'])927 $a_contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);928 }929 if (!empty($CONFIG['ldap_public']) && is_array($CONFIG['ldap_public']))930 {931 /* LDAP autocompletion */932 foreach ($CONFIG['ldap_public'] as $ldapserv_config)933 {934 if ($ldapserv_config['fuzzy_search'] != 1 ||935 $ldapserv_config['global_search'] != 1)936 {937 continue;938 }939 940 $LDAP = new rcube_ldap($ldapserv_config);941 $LDAP->connect();942 $LDAP->set_pagesize(1000);943 944 $results = $LDAP->search($ldapserv_config['mail_field'], "");945 946 for ($i = 0; $i < $results->count; $i++)947 {948 if ($results->records[$i]['email'] != '')949 {950 $email = $results->records[$i]['email'];951 $name = $results->records[$i]['name'];952 953 $a_contacts[] = format_email_recipient($email, $name);954 }955 }956 $LDAP->close();957 }958 }959 if ($a_contacts)960 {961 $OUTPUT->set_env('contacts', $a_contacts);962 }963 964 916 $OUTPUT->send('compose'); 965 917 -
skins/default/common.css
re538b3d r2c8e84c 432 432 #rcmKSearchpane ul li 433 433 { 434 display: block; 434 435 height: 16px; 435 436 font-size: 11px; 436 padding-left: 8px;437 padding-left: 6px; 437 438 padding-top: 2px; 438 padding-right: 8px; 439 white-space: nowrap; 439 padding-right: 6px; 440 white-space: nowrap; 441 cursor: pointer; 440 442 } 441 443
Note: See TracChangeset
for help on using the changeset viewer.
