19declare(strict_types=1);
35 private readonly
string $target_url,
36 private readonly
bool $lucene_enabled,
38 private readonly
Factory $ui_factory,
41 private readonly DateTimeZone $user_time_zone
44 if ($this->folder->hasIncomingMails()) {
45 $inputs[
'sender'] = $this->ui_factory->input()->field()->text($this->
lng->txt(
'mail_filter_sender'));
47 $inputs[
'recipients'] = $this->ui_factory->input()->field()->text(
48 $this->
lng->txt(
'mail_filter_recipients')
52 $inputs[
'subject'] = $this->ui_factory->input()->field()->text($this->
lng->txt(
'mail_filter_subject'));
53 $inputs[
'body'] = $this->ui_factory->input()->field()->text($this->
lng->txt(
'mail_filter_body'));
55 if ($this->lucene_enabled) {
56 $inputs[
'attachment'] = $this->ui_factory->input()->field()->text($this->
lng->txt(
'mail_filter_attach'));
59 $inputs[
'display'] = $this->ui_factory->input()->field()->multiSelect($this->
lng->txt(
'mail_filter_display'), [
60 'read' => $this->lng->txt(
'mail_filter_show_read'),
61 'unread' => $this->lng->txt(
'mail_filter_show_unread'),
62 'user' => $this->lng->txt(
'mail_filter_show_user_mails'),
63 'system' => $this->lng->txt(
'mail_filter_show_system_mails'),
64 'with_attachment' => $this->lng->txt(
'mail_filter_show_with_attachments'),
65 'without_attachment' => $this->lng->txt(
'mail_filter_show_without_attachment')
67 $inputs[
'period'] = $this->ui_factory
68 ->input()->field()->duration($this->
lng->txt(
'mail_filter_period'))
69 ->withTimezone($this->user_time_zone->getName());
71 $this->
filter = $this->filter_service->standard(
77 array_map(
static fn($value):
bool =>
true,
$inputs),
96 $data = $this->filter_service->getData($this->
filter);
100 $has_attachment =
null;
103 if (\is_array($display =
$data[
'display'] ??
null)) {
104 if (\in_array(
'read', $display,
true) xor \in_array(
'unread', $display,
true)) {
105 $is_unread = \in_array(
'unread', $display,
true);
107 if (\in_array(
'system', $display,
true) xor \in_array(
'user', $display,
true)) {
108 $is_system = \in_array(
'system', $display,
true);
110 if (\in_array(
'with_attachment', $display,
true) xor \in_array(
'without_attachment', $display,
true)) {
111 $has_attachment = \in_array(
'with_attachment', $display,
true);
116 if ((
$data[
'period'][0] ??
'') !==
'') {
117 $start =
new DateTimeImmutable(
$data[
'period'][0] .
' 00:00:00', $this->user_time_zone);
120 if ((
$data[
'period'][1] ??
'') !==
'') {
121 $end =
new DateTimeImmutable(
$data[
'period'][1] .
' 23:59:59', $this->user_time_zone);
125 (
$data[
'sender'] ??
'') ===
'' ?
null : (
string)
$data[
'sender'],
126 (
$data[
'recipients'] ??
'') ===
'' ?
null : (
string)
$data[
'recipients'],
127 (
$data[
'subject'] ??
'') ===
'' ?
null : (
string)
$data[
'subject'],
128 (
$data[
'body'] ??
'') ===
'' ?
null :
$data[
'body'],
129 (
$data[
'attachment'] ??
'') ===
'' ?
null : (
string)
$data[
'attachment'],
Builds a Color from either hex- or rgb values.
Filter data for display of mail records Properties with null value will not be applied as a filter.
getComponent()
Get the filter UI component.
getData()
Get the user entered filter data.
readonly FilterComponent $filter
__construct(private readonly string $target_url, private readonly bool $lucene_enabled, private readonly MailFolderData $folder, private readonly Factory $ui_factory, private readonly ilUIFilterService $filter_service, private readonly ilLanguage $lng, private readonly DateTimeZone $user_time_zone)
This is how the factory for UI elements looks.
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)