2012-01-12 19:06:27 +04:00
|
|
|
<?php
|
2012-04-14 13:29:44 +04:00
|
|
|
class OC_Search_Provider_Contacts extends OC_Search_Provider{
|
|
|
|
function search($query){
|
2012-05-01 20:50:31 +04:00
|
|
|
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1);
|
2012-07-20 02:17:59 +04:00
|
|
|
if(count($addressbooks)==0 || !OCP\App::isEnabled('contacts')) {
|
2012-06-15 00:44:54 +04:00
|
|
|
return array();
|
2012-01-12 19:06:27 +04:00
|
|
|
}
|
2012-06-15 00:44:54 +04:00
|
|
|
$results=array();
|
2012-01-12 19:06:27 +04:00
|
|
|
$l = new OC_l10n('contacts');
|
|
|
|
foreach($addressbooks as $addressbook){
|
|
|
|
$vcards = OC_Contacts_VCard::all($addressbook['id']);
|
|
|
|
foreach($vcards as $vcard){
|
2012-07-20 02:17:59 +04:00
|
|
|
if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0) {
|
2012-06-22 00:03:57 +04:00
|
|
|
$link = OCP\Util::linkTo('contacts', 'index.php').'&id='.urlencode($vcard['id']);
|
2012-07-20 02:17:59 +04:00
|
|
|
$results[]=new OC_Search_Result($vcard['fullname'], '', $link, (string)$l->t('Contact'));//$name,$text,$link,$type
|
2012-01-12 19:06:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
}
|