1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00
OwncloudContactsOfficial/lib/search.php
Thomas Tanghus ec86736336 Merge branch 'master' of github.com:owncloud/apps into contacts_rework
Fix conflicts:
	contacts/ajax/contact/saveproperty.php
	contacts/js/contacts.js
	contacts/lib/hooks.php
	contacts/lib/search.php
	contacts/lib/vcard.php
2012-10-30 07:19:56 +01:00

25 lines
760 B
PHP

<?php
namespace OCA\Contacts;
class SearchProvider extends \OC_Search_Provider{
function search($query) {
$addressbooks = Addressbook::all(\OCP\USER::getUser(), 1);
if(count($addressbooks)==0 || !\OCP\App::isEnabled('contacts')) {
return array();
}
$results=array();
$l = new OC_l10n('contacts');
foreach($addressbooks as $addressbook) {
$vcards = VCard::all($addressbook['id']);
foreach($vcards as $vcard) {
if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0) {
$link = \OCP\Util::linkTo('contacts', 'index.php').'?id='.urlencode($vcard['id']);
$results[]=new \OC_Search_Result($vcard['fullname'], '', $link, (string)$l->t('Contact'));//$name,$text,$link,$type
}
}
}
return $results;
}
}