4 +-----------------------------------------------------------------------+
5 | program/steps/mail/autocomplete.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2008-2009, RoundCube Dev Team |
9 | Licensed under the GNU GPL |
12 | Perform a search on configured address books for the address |
13 | autocompletion of the message compose screen |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
22 $MAXNUM = 15; // same limit as in app.js
24 $book_types = (array) $RCMAIL->config->get('autocomplete_addressbooks', 'sql');
26 if ($book_types && $search = get_input_value('_search', RCUBE_INPUT_POST)) {
28 foreach ($book_types as $id) {
29 $abook = $RCMAIL->get_address_book($id);
30 $abook->set_pagesize($MAXNUM);
32 if ($result = $abook->search(array('email','name'), $search)) {
33 while ($sql_arr = $result->iterate()) {
34 if (stripos((string)$sql_arr['email'], $search) !== false || stripos((string)$sql_arr['name'], $search) !== false) {
35 $contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
40 if (count($contacts) >= $MAXNUM)
47 $OUTPUT->command('ksearch_query_results', $contacts, $search);