From e3773d46cb4f06aaab2747db98765edd6d871524 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Thu, 06 Mar 2014 07:16:01 -0500
Subject: [PATCH] Support structured data for autocompletion results; map 'type' attribute to CSS class for autocomplete list items

---
 program/steps/mail/autocomplete.inc |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/program/steps/mail/autocomplete.inc b/program/steps/mail/autocomplete.inc
index c15de92..20cf940 100644
--- a/program/steps/mail/autocomplete.inc
+++ b/program/steps/mail/autocomplete.inc
@@ -90,7 +90,7 @@
 
                     // skip duplicates
                     if (!in_array($contact, $contacts)) {
-                        $contacts[]  = $contact;
+                        $contacts[]  = array('name' => $contact, 'type' => $sql_arr['_type']);
                         $sort_keys[] = sprintf('%s %03d', $sql_arr['name'] , $idx++);
 
                         if (count($contacts) >= $MAXNUM) {
@@ -118,7 +118,7 @@
                 if ($group_prop['email']) {
                     $idx = 0;
                     foreach ((array)$group_prop['email'] as $email) {
-                        $contacts[]  = format_email_recipient($email, $group['name']);
+                        $contacts[]  = array('name' => format_email_recipient($email, $group['name']), 'type' => 'group');
                         $sort_keys[] = sprintf('%s %03d', $group['name'] , $idx++);
 
                         if (count($contacts) >= $MAXNUM) {
@@ -131,6 +131,7 @@
                     $sort_keys[] = $group['name'];
                     $contacts[]  = array(
                         'name'   => $group['name'] . ' (' . intval($result->count) . ')',
+                        'type'   => 'group',
                         'id'     => $group['ID'],
                         'source' => $id
                     );

--
Gitblit v1.9.1