ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Mail\Folder\MailFolderSearch Class Reference

Search in mail folders. More...

+ Collaboration diagram for ILIAS\Mail\Folder\MailFolderSearch:

Public Member Functions

 __construct (private readonly MailFolderData $folder, private readonly MailFilterData $filter, private readonly bool $lucene_enabled,)
 
 getCount ()
 Get a cached count of mails for the filter criteria. More...
 
 getUnread ()
 Get a cached count of unread mails for the filter criteria. More...
 
 getMaiIds ()
 Get the ids of all filtered mails. More...
 
 getRecords ()
 Get record objects of all filtered mails. More...
 
 getPagedRecords (int $limit, int $offset, ?MailBoxOrderColumn $order_column, ?string $order_direction)
 Get record objects of filtered and paged mails. More...
 
 forMailIds (array $ids)
 Inject already filtered mail ids, e.g. More...
 

Private Member Functions

 getFilteredIds ()
 Get the cached mail ids from a lucene search for selected filter criteria These will be used as additional filter for the mailbox query. More...
 

Private Attributes

MailBoxQuery $mailbox_query
 
ilMailLuceneSearcher $lucene_searcher = null
 
ilMailSearchResult $lucene_result = null
 
array $filtered_ids = null
 
int $count = null
 
int $unread = null
 

Detailed Description

Search in mail folders.

  • utilises database and (if active) lucene based searchers
  • caches results for counting of all or unread mails

Definition at line 35 of file MailFolderSearch.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Mail\Folder\MailFolderSearch::__construct ( private readonly MailFolderData  $folder,
private readonly MailFilterData  $filter,
private readonly bool  $lucene_enabled 
)

Definition at line 45 of file MailFolderSearch.php.

References ILIAS\Repository\filter().

49  {
50  $this->mailbox_query = (new MailBoxQuery(
51  $this->folder->getUserId()
52  ))
53  ->withFolderId($this->folder->getFolderId())
54  ->withSender($this->filter->getSender())
55  ->withRecipients($this->filter->getRecipients())
56  ->withSubject($this->filter->getSubject())
57  ->withBody($this->filter->getBody())
58  ->withPeriodStart($this->filter->getPeriodStart())
59  ->withPeriodEnd($this->filter->getPeriodEnd())
60  ->withIsUnread($this->filter->isUnread())
61  ->withIsSystem($this->filter->isSystem())
62  ->withHasAttachment($this->filter->hasAttachment());
63 
64  if ($this->lucene_enabled && (
65  ($this->filter->getSender() ?? '') !== '' ||
66  ($this->filter->getRecipients() ?? '') !== '' ||
67  ($this->filter->getSubject() ?? '') !== '' ||
68  ($this->filter->getBody() ?? '') !== '' ||
69  ($this->filter->getAttachment() ?? '') !== ''
70  )) {
71  $query_parser = new ilMailLuceneQueryParser('');
72  $query_parser->setFields([
73  'title' => $this->filter->getSubject(),
74  'content' => $this->filter->getBody(),
75  'mattachment' => $this->filter->getAttachment(), // only possible with lucene
76  'msender' => $this->filter->getSender(),
77  ]);
78  $query_parser->parse();
79 
80  // lucene search wil be done and cached by getFilteredIds
81  $this->lucene_result = new ilMailSearchResult();
82  $this->lucene_searcher = new ilMailLuceneSearcher($query_parser, $this->lucene_result);
83  }
84  }
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
+ Here is the call graph for this function:

Member Function Documentation

◆ forMailIds()

ILIAS\Mail\Folder\MailFolderSearch::forMailIds ( array  $ids)

Inject already filtered mail ids, e.g.

from a selection

Parameters
int[]$ids

Definition at line 172 of file MailFolderSearch.php.

172  : self
173  {
174  $clone = clone $this;
175  $clone->filtered_ids = $ids;
176  return $clone;
177  }

◆ getCount()

ILIAS\Mail\Folder\MailFolderSearch::getCount ( )

Get a cached count of mails for the filter criteria.

Definition at line 89 of file MailFolderSearch.php.

References ILIAS\Mail\Folder\MailFolderSearch\$count, ILIAS\Mail\Folder\MailFolderSearch\getFilteredIds(), and null.

89  : int
90  {
91  if ($this->count === null) {
92  $this->count = $this->mailbox_query->withFilteredIds($this->getFilteredIds())->count();
93  }
94 
95  return $this->count;
96  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getFilteredIds()
Get the cached mail ids from a lucene search for selected filter criteria These will be used as addit...
+ Here is the call graph for this function:

◆ getFilteredIds()

ILIAS\Mail\Folder\MailFolderSearch::getFilteredIds ( )
private

Get the cached mail ids from a lucene search for selected filter criteria These will be used as additional filter for the mailbox query.

Returns
null|list<int>

Definition at line 156 of file MailFolderSearch.php.

References ILIAS\Mail\Folder\MailFolderSearch\$filtered_ids, and null.

Referenced by ILIAS\Mail\Folder\MailFolderSearch\getCount(), ILIAS\Mail\Folder\MailFolderSearch\getMaiIds(), ILIAS\Mail\Folder\MailFolderSearch\getPagedRecords(), ILIAS\Mail\Folder\MailFolderSearch\getRecords(), and ILIAS\Mail\Folder\MailFolderSearch\getUnread().

156  : ?array
157  {
158  if ($this->filtered_ids === null &&
159  $this->lucene_result !== null &&
160  $this->lucene_searcher !== null) {
161  $this->lucene_searcher->search($this->folder->getUserId(), $this->folder->getFolderId());
162  $this->filtered_ids = $this->lucene_result->getIds();
163  }
164 
165  return $this->filtered_ids;
166  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getMaiIds()

ILIAS\Mail\Folder\MailFolderSearch::getMaiIds ( )

Get the ids of all filtered mails.

Returns
int[]

Definition at line 114 of file MailFolderSearch.php.

References ILIAS\Mail\Folder\MailFolderSearch\getFilteredIds().

114  : array
115  {
116  return $this->mailbox_query
117  ->withFilteredIds($this->getFilteredIds())
118  ->queryMailIds();
119  }
getFilteredIds()
Get the cached mail ids from a lucene search for selected filter criteria These will be used as addit...
+ Here is the call graph for this function:

◆ getPagedRecords()

ILIAS\Mail\Folder\MailFolderSearch::getPagedRecords ( int  $limit,
int  $offset,
?MailBoxOrderColumn  $order_column,
?string  $order_direction 
)

Get record objects of filtered and paged mails.

Returns
MailRecordData[]

Definition at line 136 of file MailFolderSearch.php.

References ILIAS\Mail\Folder\MailFolderSearch\getFilteredIds().

141  : array {
142  return $this->mailbox_query
143  ->withFilteredIds($this->getFilteredIds())
144  ->withLimit($limit)
145  ->withOffset($offset)
146  ->withOrderColumn($order_column)
147  ->withOrderDirection($order_direction)
148  ->query(true);
149  }
getFilteredIds()
Get the cached mail ids from a lucene search for selected filter criteria These will be used as addit...
+ Here is the call graph for this function:

◆ getRecords()

ILIAS\Mail\Folder\MailFolderSearch::getRecords ( )

Get record objects of all filtered mails.

Returns
MailRecordData[]

Definition at line 125 of file MailFolderSearch.php.

References ILIAS\Mail\Folder\MailFolderSearch\getFilteredIds().

125  : array
126  {
127  return $this->mailbox_query
128  ->withFilteredIds($this->getFilteredIds())
129  ->query(true);
130  }
getFilteredIds()
Get the cached mail ids from a lucene search for selected filter criteria These will be used as addit...
+ Here is the call graph for this function:

◆ getUnread()

ILIAS\Mail\Folder\MailFolderSearch::getUnread ( )

Get a cached count of unread mails for the filter criteria.

Definition at line 101 of file MailFolderSearch.php.

References ILIAS\Mail\Folder\MailFolderSearch\$unread, ILIAS\Mail\Folder\MailFolderSearch\getFilteredIds(), and null.

101  : int
102  {
103  if ($this->unread === null) {
104  $this->unread = $this->mailbox_query->withFilteredIds($this->getFilteredIds())->countUnread();
105  }
106 
107  return $this->unread;
108  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getFilteredIds()
Get the cached mail ids from a lucene search for selected filter criteria These will be used as addit...
+ Here is the call graph for this function:

Field Documentation

◆ $count

int ILIAS\Mail\Folder\MailFolderSearch::$count = null
private

Definition at line 42 of file MailFolderSearch.php.

Referenced by ILIAS\Mail\Folder\MailFolderSearch\getCount().

◆ $filtered_ids

array ILIAS\Mail\Folder\MailFolderSearch::$filtered_ids = null
private

◆ $lucene_result

ilMailSearchResult ILIAS\Mail\Folder\MailFolderSearch::$lucene_result = null
private

Definition at line 39 of file MailFolderSearch.php.

◆ $lucene_searcher

ilMailLuceneSearcher ILIAS\Mail\Folder\MailFolderSearch::$lucene_searcher = null
private

Definition at line 38 of file MailFolderSearch.php.

◆ $mailbox_query

MailBoxQuery ILIAS\Mail\Folder\MailFolderSearch::$mailbox_query
private

Definition at line 37 of file MailFolderSearch.php.

◆ $unread

int ILIAS\Mail\Folder\MailFolderSearch::$unread = null
private

Definition at line 43 of file MailFolderSearch.php.

Referenced by ILIAS\Mail\Folder\MailFolderSearch\getUnread().


The documentation for this class was generated from the following file: