diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-01-12 16:06:27 +0100 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-01-12 22:50:12 +0100 |
commit | 22356533a0529197d8a4c383307b566f94ed6fc4 (patch) | |
tree | b4738cdde1a844b249b0801691e4f028003e57dd /apps/contacts/lib | |
parent | 0d120efda591a8405373309b0ac887415c5e94a6 (diff) | |
download | nextcloud-server-22356533a0529197d8a4c383307b566f94ed6fc4.tar.gz nextcloud-server-22356533a0529197d8a4c383307b566f94ed6fc4.zip |
Added search. Thanks to icewind it was mostly copy/paste :-)
Diffstat (limited to 'apps/contacts/lib')
-rw-r--r-- | apps/contacts/lib/search.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/apps/contacts/lib/search.php b/apps/contacts/lib/search.php new file mode 100644 index 00000000000..97638821007 --- /dev/null +++ b/apps/contacts/lib/search.php @@ -0,0 +1,29 @@ +<?php +class OC_Search_Provider_Contacts extends OC_Search_Provider{ + function search($query){ + $addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser(), 1); +// if(count($calendars)==0 || !OC_App::isEnabled('contacts')){ +// //return false; +// } + // NOTE: Does the following do anything + $results=array(); + $searchquery=array(); + if(substr_count($query, ' ') > 0){ + $searchquery = explode(' ', $query); + }else{ + $searchquery[] = $query; + } + $l = new OC_l10n('contacts'); + foreach($addressbooks as $addressbook){ + $vcards = OC_Contacts_VCard::all($addressbook['id']); + foreach($vcards as $vcard){ + if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0){ + $link = OC_Helper::linkTo('apps/contacts', 'index.php?id='.urlencode($vcard['id'])); + $results[]=new OC_Search_Result($vcard['fullname'],'', $link,$l->t('Contact'));//$name,$text,$link,$type + } + } + } + return $results; + } +} +new OC_Search_Provider_Contacts(); |