annotate program/steps/mail/autocomplete.inc @ 0:4681f974d28b

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:52:31 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1 <?php
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
2
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
3 /**
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
4 +-----------------------------------------------------------------------+
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
5 | program/steps/mail/autocomplete.inc |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
6 | |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
7 | This file is part of the Roundcube Webmail client |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
8 | Copyright (C) 2008-2013, Roundcube Dev Team |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
9 | Copyright (C) 2011-2013, Kolab Systems AG |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
10 | |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
11 | Licensed under the GNU General Public License version 3 or |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
12 | any later version with exceptions for skins & plugins. |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
13 | See the README file for a full license statement. |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
14 | |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
15 | PURPOSE: |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
16 | Perform a search on configured address books for the address |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
17 | autocompletion of the message compose screen |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
18 +-----------------------------------------------------------------------+
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
19 | Author: Thomas Bruederli <roundcube@gmail.com> |
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
20 +-----------------------------------------------------------------------+
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
21 */
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
22
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
23 if ($RCMAIL->action == 'group-expand') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
24 $abook = $RCMAIL->get_address_book(rcube_utils::get_input_value('_source', rcube_utils::INPUT_GPC));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
25 if ($gid = rcube_utils::get_input_value('_gid', rcube_utils::INPUT_GET)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
26 $abook->set_group($gid);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
27 $abook->set_pagesize(9999); // TODO: limit number of group members by config?
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
28
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
29 $separator = trim($RCMAIL->config->get('recipients_separator', ',')) . ' ';
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
30 $result = $abook->list_records($RCMAIL->config->get('contactlist_fields'));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
31 $members = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
32
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
33 while ($result && ($record = $result->iterate())) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
34 $emails = (array) $abook->get_col_values('email', $record, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
35 if (!empty($emails) && ($email = array_shift($emails))) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
36 $members[] = format_email_recipient($email, rcube_addressbook::compose_list_name($record));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
37 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
38 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
39
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
40 $OUTPUT->command('replace_group_recipients', $gid, join($separator, array_unique($members)));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
41 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
42
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
43 $OUTPUT->send();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
44 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
45
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
46
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
47 $MAXNUM = (int) $RCMAIL->config->get('autocomplete_max', 15);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
48 $mode = (int) $RCMAIL->config->get('addressbook_search_mode');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
49 $single = (bool) $RCMAIL->config->get('autocomplete_single');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
50 $search = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
51 $source = rcube_utils::get_input_value('_source', rcube_utils::INPUT_GPC);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
52 $reqid = rcube_utils::get_input_value('_reqid', rcube_utils::INPUT_GPC);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
53
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
54 if (strlen($source)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
55 $book_types = array($source);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
56 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
57 else {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
58 $book_types = (array) $RCMAIL->config->get('autocomplete_addressbooks', 'sql');
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
59 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
60
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
61 $contacts = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
62 if (!empty($book_types) && strlen($search)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
63 $sort_keys = array();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
64 $books_num = count($book_types);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
65 $search_lc = mb_strtolower($search);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
66 $mode |= rcube_addressbook::SEARCH_GROUPS;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
67
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
68 foreach ($book_types as $abook_id) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
69 $abook = $RCMAIL->get_address_book($abook_id);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
70 $abook->set_pagesize($MAXNUM);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
71
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
72 if ($result = $abook->search($RCMAIL->config->get('contactlist_fields'), $search, $mode, true, true, 'email')) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
73 while ($record = $result->iterate()) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
74 // Contact can have more than one e-mail address
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
75 $email_arr = (array)$abook->get_col_values('email', $record, true);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
76 $email_cnt = count($email_arr);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
77 $idx = 0;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
78
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
79 foreach ($email_arr as $email) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
80 if (empty($email)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
81 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
82 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
83
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
84 $name = rcube_addressbook::compose_list_name($record);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
85 $contact = format_email_recipient($email, $name);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
86
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
87 // skip entries that don't match
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
88 if ($email_cnt > 1 && strpos(mb_strtolower($contact), $search_lc) === false) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
89 continue;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
90 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
91
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
92 $index = $contact;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
93
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
94 // skip duplicates
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
95 if (empty($contacts[$index])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
96 $contact = array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
97 'name' => $contact,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
98 'type' => $record['_type'],
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
99 'id' => $record['ID'],
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
100 'source' => $abook_id,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
101 );
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
102
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
103 if (($display = rcube_addressbook::compose_search_name($record, $email, $name)) && $display != $contact['name']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
104 $contact['display'] = $display;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
105 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
106
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
107 // groups with defined email address will not be expanded to its members' addresses
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
108 if ($record['_type'] == 'group') {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
109 $contact['email'] = $email;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
110 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
111
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
112 $contacts[$index] = $contact;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
113 $sort_keys[$index] = sprintf('%s %03d', $contact['display'] ?: $name, $idx++);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
114
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
115 if (count($contacts) >= $MAXNUM) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
116 break 2;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
117 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
118 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
119
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
120 // skip redundant entries (show only first email address)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
121 if ($single) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
122 break;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
123 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
124 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
125 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
126 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
127
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
128 // also list matching contact groups
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
129 if ($abook->groups && count($contacts) < $MAXNUM) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
130 foreach ($abook->list_groups($search, $mode) as $group) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
131 $abook->reset();
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
132 $abook->set_group($group['ID']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
133
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
134 $group_prop = $abook->get_group($group['ID']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
135
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
136 // group (distribution list) with email address(es)
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
137 if ($group_prop['email']) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
138 $idx = 0;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
139 foreach ((array)$group_prop['email'] as $email) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
140 $index = format_email_recipient($email, $group['name']);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
141
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
142 if (empty($contacts[$index])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
143 $sort_keys[$index] = sprintf('%s %03d', $group['name'] , $idx++);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
144 $contacts[$index] = array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
145 'name' => $index,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
146 'email' => $email,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
147 'type' => 'group',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
148 'id' => $group['ID'],
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
149 'source' => $abook_id,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
150 );
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
151
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
152 if (count($contacts) >= $MAXNUM) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
153 break 2;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
154 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
155 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
156 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
157 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
158 // show group with count
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
159 else if (($result = $abook->count()) && $result->count) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
160 if (empty($contacts[$group['name']])) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
161 $sort_keys[$group['name']] = $group['name'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
162 $contacts[$group['name']] = array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
163 'name' => $group['name'] . ' (' . intval($result->count) . ')',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
164 'type' => 'group',
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
165 'id' => $group['ID'],
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
166 'source' => $abook_id,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
167 );
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
168
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
169 if (count($contacts) >= $MAXNUM) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
170 break;
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
171 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
172 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
173 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
174 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
175 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
176 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
177
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
178 if (count($contacts)) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
179 // sort contacts index
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
180 asort($sort_keys, SORT_LOCALE_STRING);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
181 // re-sort contacts according to index
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
182 foreach ($sort_keys as $idx => $val) {
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
183 $sort_keys[$idx] = $contacts[$idx];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
184 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
185 $contacts = array_values($sort_keys);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
186 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
187 }
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
188
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
189
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
190 // Allow autocomplete result optimization via plugin
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
191 $pluginResult = $RCMAIL->plugins->exec_hook('contacts_autocomplete_after', array(
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
192 'search' => $search,
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
193 'contacts' => $contacts, // Provide already-found contacts to plugin if they are required
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
194 ));
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
195 $contacts = $pluginResult['contacts'];
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
196
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
197
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
198 $OUTPUT->command('ksearch_query_results', $contacts, $search, $reqid);
4681f974d28b vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
199 $OUTPUT->send();