From ed55af4aa989a6facbb2110c3d2281b628f177ee Mon Sep 17 00:00:00 2001 From: Bostjan Skufca Date: Thu, 14 Apr 2016 02:28:19 +0200 Subject: [PATCH] Autocomplete: trigger "contacts_autocomplete_after" hook processing Provide existing list of contact suggestions as an argument - it might be unclear now what logic plugin developers decide to implement, but data for that logic should be provided upfront, and that includes list of suggestions that RC itself comes up with. Plugin logic might then replace the list entirely, or just rearrange its entries, or use part of the list when it runs out of own ideas, or do something entirely different. --- program/steps/mail/autocomplete.inc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/program/steps/mail/autocomplete.inc b/program/steps/mail/autocomplete.inc index cfa579532..61b43ef57 100644 --- a/program/steps/mail/autocomplete.inc +++ b/program/steps/mail/autocomplete.inc @@ -175,5 +175,14 @@ if (!empty($book_types) && strlen($search)) { } } + +// Allow autocomplete result optimization via plugin +$pluginResult = $RCMAIL->plugins->exec_hook('contacts_autocomplete_after', array( + 'search' => $search, + 'contacts' => $contacts, // Provide already-found contacts to plugin if they are required +)); +$contacts = $pluginResult['contacts']; + + $OUTPUT->command('ksearch_query_results', $contacts, $search, $reqid); $OUTPUT->send();