2012-01-12 16:06:27 +01:00
|
|
|
<?php
|
2012-04-14 11:29:44 +02:00
|
|
|
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-05-02 00:50:26 +02:00
|
|
|
// if(count($calendars)==0 || !OCP\App::isEnabled('contacts')){
|
2012-01-12 16:06:27 +01:00
|
|
|
// //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){
|
2012-05-01 23:19:39 +02:00
|
|
|
$link = OCP\Util::linkTo('contacts', 'index.php').'?id='.urlencode($vcard['id']);
|
2012-01-12 16:06:27 +01:00
|
|
|
$results[]=new OC_Search_Result($vcard['fullname'],'', $link,$l->t('Contact'));//$name,$text,$link,$type
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
}
|