search.php 941 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. class OC_Search_Provider_Contacts extends OC_Search_Provider{
  3. function search($query){
  4. $addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1);
  5. // if(count($calendars)==0 || !OCP\App::isEnabled('contacts')){
  6. // //return false;
  7. // }
  8. // NOTE: Does the following do anything
  9. $results=array();
  10. $searchquery=array();
  11. if(substr_count($query, ' ') > 0){
  12. $searchquery = explode(' ', $query);
  13. }else{
  14. $searchquery[] = $query;
  15. }
  16. $l = new OC_l10n('contacts');
  17. foreach($addressbooks as $addressbook){
  18. $vcards = OC_Contacts_VCard::all($addressbook['id']);
  19. foreach($vcards as $vcard){
  20. if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0){
  21. $link = OCP\Util::linkTo('contacts', 'index.php').'?id='.urlencode($vcard['id']);
  22. $results[]=new OC_Search_Result($vcard['fullname'],'', $link,$l->t('Contact'));//$name,$text,$link,$type
  23. }
  24. }
  25. }
  26. return $results;
  27. }
  28. }