Also search in task comments
This commit is contained in:
parent
00317d84fb
commit
a46968c2cf
2 changed files with 25 additions and 26 deletions
|
@ -51,29 +51,25 @@ class SearchController extends \OCP\Search\Provider {
|
|||
$vtodo = Helper::parseVTODO($object['calendardata']);
|
||||
$id = $object['id'];
|
||||
$calendarId = $object['calendarid'];
|
||||
// check the task summary
|
||||
$summary = $vtodo->getAsString('SUMMARY');
|
||||
if (stripos($summary, $query) !== false) {
|
||||
$results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,'summary',$query);
|
||||
continue;
|
||||
|
||||
// check these properties
|
||||
$properties = ['SUMMARY', 'DESCRIPTION', 'LOCATION', 'CATEGORIES'];
|
||||
|
||||
foreach ($properties as $property) {
|
||||
$string = $vtodo->getAsString($property);
|
||||
if (stripos($string, $query) !== false) {
|
||||
$results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,$property,$query);
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
// check the task note
|
||||
$note = $vtodo->getAsString('DESCRIPTION');
|
||||
if (stripos($note, $query) !== false) {
|
||||
$results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,'note',$query);
|
||||
continue;
|
||||
}
|
||||
// check the task location
|
||||
$location = $vtodo->getAsString('LOCATION');
|
||||
if (stripos($location, $query) !== false) {
|
||||
$results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,'location',$query);
|
||||
continue;
|
||||
}
|
||||
// check the task categorie
|
||||
$categories = $vtodo->getAsString('CATEGORIES');
|
||||
if (stripos($categories, $query) !== false) {
|
||||
$results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,'categories',$query);
|
||||
continue;
|
||||
$comments = $vtodo->COMMENT;
|
||||
if($comments) {
|
||||
foreach($comments as $com) {
|
||||
if (stripos($com->value, $query) !== false) {
|
||||
$results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,'COMMENTS',$query);
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,18 +74,21 @@ class Task extends \OCP\Search\Result {
|
|||
$this->link = \OCP\Util::linkToRoute('tasks.page.index') . '#/lists/' . $calendarId . '/tasks/' . $taskId;
|
||||
$l = new \OC_l10n('tasks');
|
||||
switch($reason){
|
||||
case 'summary':
|
||||
case 'SUMMARY':
|
||||
$this->text = '"' . $query .'" '. $l->t('found in task title.');
|
||||
break;
|
||||
case 'note':
|
||||
case 'DESCRIPTION':
|
||||
$this->text = '"' . $query .'" '. $l->t('found in task note.');
|
||||
break;
|
||||
case 'location':
|
||||
case 'LOCATION':
|
||||
$this->text = '"' . $query .'" '. $l->t('found in task location.');
|
||||
break;
|
||||
case 'categories':
|
||||
case 'CATEGORIES':
|
||||
$this->text = '"' . $query .'" '. $l->t('found in task categories.');
|
||||
break;
|
||||
case 'COMMENTS':
|
||||
$this->text = '"' . $query .'" '. $l->t('found in task comments.');
|
||||
break;
|
||||
default:
|
||||
$this->text = '';
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue