1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-11-29 11:24:11 +01:00
OwncloudContactsOfficial/lib/search.php

22 lines
759 B
PHP
Raw Normal View History

<?php
class OC_Search_Provider_Contacts extends OC_Search_Provider{
function search($query){
2012-05-01 18:50:31 +02:00
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1);
2012-06-14 22:44:54 +02:00
if(count($addressbooks)==0 || !OCP\App::isEnabled('contacts')){
return array();
}
2012-06-14 22:44:54 +02:00
$results=array();
$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){
2012-06-21 22:03:57 +02:00
$link = OCP\Util::linkTo('contacts', 'index.php').'&id='.urlencode($vcard['id']);
2012-06-22 01:43:59 +02:00
$results[]=new OC_Search_Result($vcard['fullname'],'', $link,(string)$l->t('Contact'));//$name,$text,$link,$type
}
}
}
return $results;
}
}