diff options
author | Georg Ehrke <ownclouddev@georgswebsite.de> | 2011-11-14 22:52:34 +0100 |
---|---|---|
committer | Georg Ehrke <ownclouddev@georgswebsite.de> | 2011-11-14 22:52:34 +0100 |
commit | 3d498002d040603778efbbd558a4d25c6d6734a4 (patch) | |
tree | 12fa86cdd636d5813e1de0910b837517397ac327 /apps/calendar/lib | |
parent | 89b3a395df12411328c33c1d5460f87eb1972024 (diff) | |
download | nextcloud-server-3d498002d040603778efbbd558a4d25c6d6734a4.tar.gz nextcloud-server-3d498002d040603778efbbd558a4d25c6d6734a4.zip |
first implementation of the search function
Diffstat (limited to 'apps/calendar/lib')
-rw-r--r-- | apps/calendar/lib/search.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php new file mode 100644 index 00000000000..41faf49a519 --- /dev/null +++ b/apps/calendar/lib/search.php @@ -0,0 +1,26 @@ +<?php +class OC_Search_Provider_Calendar extends OC_Search_Provider{ + function search($query){ + $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1); + if(count($calendars)==0 || !OC_App::isEnabled('calendar')){ + //return false; + } + $results=array(); + $searchquery=array(); + if(substr_count($query, ' ') > 0){ + $searchquery = explode(' ', $query); + }else{ + $searchquery[] = $query; + } + foreach($calendars as $calendar){ + $objects = OC_Calendar_Object::all($calendar['id']); + foreach($objects as $object){ + if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){//$name,$text,$link,$type + $results[]=new OC_Search_Result($object['summary'],'','#','Cal.'); + } + } + } + return $results; + } +} +new OC_Search_Provider_Calendar();
\ No newline at end of file |