19declare(strict_types=1);
43use Psr\Http\Message\ServerRequestInterface;
73 private readonly array $user_folders,
76 private readonly
ilMail $mail,
77 private readonly
Factory $ui_factory,
78 private readonly
Renderer $ui_renderer,
80 private readonly ServerRequestInterface $http_request,
81 private readonly DataFactory $data_factory,
84 private readonly
string $time_format,
85 private readonly DateTimeZone $user_time_zone
91 return $this->ui_factory
98 ->withId(str_replace(
'\\',
'', self::class))
100 ->withRange(
new Range(0, 50))
102 ->withRequest($this->http_request);
111 $date_format = $this->data_factory->dateFormat()->withTime12($this->date_format);
113 $date_format = $this->data_factory->dateFormat()->withTime24($this->date_format);
117 'status' => $this->ui_factory
120 ->statusIcon($this->
lng->txt(
'status'))
121 ->withIsSortable(
true),
123 'avatar' => $this->ui_factory
126 ->status($this->
lng->txt(
'personal_picture'))
127 ->withIsSortable(
true),
129 'sender' => $this->ui_factory
132 ->text($this->
lng->txt(
'sender'))
133 ->withIsSortable(
true),
135 'recipients' => $this->ui_factory
138 ->text($this->
lng->txt(
'recipient'))
139 ->withIsSortable(
true),
141 'subject' => $this->ui_factory
144 ->link($this->
lng->txt(
'subject'))
145 ->withIsSortable(
true),
147 'attachments' => $this->ui_factory
150 ->status($this->
lng->txt(
'attachments'))
151 ->withIsSortable(
true),
153 'date' => $this->ui_factory
157 $this->
lng->txt(
'date'),
160 ->withIsSortable(
true),
163 if ($this->current_folder->hasOutgoingMails()) {
164 unset($columns[
'status'], $columns[
'avatar'], $columns[
'sender']);
166 unset($columns[
'recipients']);
178 self::ACTION_SHOW => $this->ui_factory->table()->action()->single(
179 $this->
lng->txt(
'view'),
180 $this->url_builder->withParameter($this->action_token, self::ACTION_SHOW),
183 self::ACTION_EDIT => $this->ui_factory->table()->action()->single(
184 $this->
lng->txt(
'edit'),
185 $this->url_builder->withParameter($this->action_token, self::ACTION_EDIT),
188 self::ACTION_REPLY => $this->ui_factory->table()->action()->single(
189 $this->
lng->txt(
'reply'),
190 $this->url_builder->withParameter($this->action_token, self::ACTION_REPLY),
193 self::ACTION_FORWARD => $this->ui_factory->table()->action()->single(
194 $this->
lng->txt(
'forward'),
195 $this->url_builder->withParameter($this->action_token, self::ACTION_FORWARD),
198 self::ACTION_DOWNLOAD_ATTACHMENT => $this->ui_factory->table()->action()->single(
199 $this->
lng->txt(
'mail_download_attachment'),
200 $this->url_builder->withParameter($this->action_token, self::ACTION_DOWNLOAD_ATTACHMENT),
203 self::ACTION_PRINT => $this->ui_factory->table()->action()->single(
204 $this->
lng->txt(
'print'),
205 $this->url_builder->withParameter($this->action_token, self::ACTION_PRINT),
208 self::ACTION_MARK_READ => $this->ui_factory->table()->action()->multi(
209 $this->
lng->txt(
'mail_mark_read'),
210 $this->url_builder->withParameter($this->action_token, self::ACTION_MARK_READ),
213 self::ACTION_MARK_UNREAD => $this->ui_factory->table()->action()->multi(
214 $this->
lng->txt(
'mail_mark_unread'),
215 $this->url_builder->withParameter($this->action_token, self::ACTION_MARK_UNREAD),
218 self::ACTION_DELETE => $this->ui_factory->table()->action()->standard(
219 $this->
lng->txt(
'delete'),
220 $this->url_builder->withParameter($this->action_token, self::ACTION_DELETE),
225 foreach ($this->user_folders as $target_folder) {
226 if ($target_folder->getFolderId() !== $this->current_folder->getFolderId()) {
227 $action_title = $this->
lng->txt(
'mail_move_to') .
' ' . $target_folder->getTitle();
228 if ($target_folder->isTrash()) {
229 $action_title .=
' (' . $this->
lng->txt(
'delete') .
')';
232 $actions[self::ACTION_MOVE_TO . $target_folder->getFolderId()] = $this->ui_factory
238 ->withParameter($this->action_token, self::ACTION_MOVE_TO)
239 ->withParameter($this->folder_token, (
string) $target_folder->getFolderId()),
245 if ($this->current_folder->isDrafts() || $this->current_folder->isOutbox()) {
246 unset($actions[self::ACTION_SHOW], $actions[self::ACTION_REPLY], $actions[self::ACTION_FORWARD]);
248 unset($actions[self::ACTION_EDIT]);
251 if ($this->current_folder->hasOutgoingMails()) {
252 unset($actions[self::ACTION_MARK_READ], $actions[self::ACTION_MARK_UNREAD]);
255 if (!$this->current_folder->isTrash()) {
256 unset($actions[self::ACTION_DELETE]);
264 array $visible_column_ids,
267 mixed $additional_viewcontrol_data,
269 mixed $additional_parameters
281 [$order_column, $order_direction] = $order->
join([], fn($ret, $key, $value) => [$key, $value]);
283 $records = $this->
search->getPagedRecords(
286 $order_columns[$order_column] ??
null,
291 if ($this->current_folder->hasIncomingMails()) {
293 foreach ($records as $record) {
294 if ($record->hasPersonalSender()) {
295 $user_ids[$record->getSenderId()] = $record->getSenderId();
301 foreach ($records as $record) {
302 if ($this->current_folder->hasIncomingMails()) {
309 'date' => $this->
getDate($record)
316 'date' => $this->
getDate($record)
321 (
string) $record->getMailId(),
323 )->withDisabledAction(self::ACTION_REPLY, !$record->hasPersonalSender())->withDisabledAction(
324 self::ACTION_DOWNLOAD_ATTACHMENT,
325 !$record->hasAttachments()
331 mixed $additional_viewcontrol_data,
333 mixed $additional_parameters
340 if ($this->current_folder->hasIncomingMails() && $this->search->getUnread() > 0) {
343 $this->current_folder->getTitle(),
344 $this->search->getCount() === 1
345 ? $this->lng->txt(
'mail_1')
346 : \sprintf($this->
lng->txt(
'mail_s'), $this->search->getCount()),
347 $this->search->getUnread(),
348 $this->lng->txt(
'unread')
354 $this->current_folder->getTitle(),
355 $this->search->getCount() === 1
356 ? $this->lng->txt(
'mail_1')
357 : \sprintf($this->
lng->txt(
'mail_s'), $this->search->getCount()),
363 if (!\array_key_exists($record->
getSenderId(), $this->avatars)) {
365 $avatar = $this->ui_factory->symbol()->avatar()->picture(
367 $this->getSender($record)
371 $avatar = $user?->getAvatar();
375 ? $this->ui_renderer->render($avatar)
385 ? $this->ui_factory->symbol()->icon()->standard(
'mailr', $this->
lng->txt(
'mailr'))
386 : $this->ui_factory->symbol()->icon()->standard(
'mailu', $this->
lng->txt(
'mailu'));
396 if ($user !==
null) {
397 if ($user->hasPublicProfile()) {
398 return $this->ui_renderer->render(
399 $this->ui_factory->link()->standard(
400 $user->getPublicName(),
401 (
string) $this->url_builder
402 ->withParameter($this->action_token, self::ACTION_PROFILE)
403 ->withParameter($this->row_id_token, (
string) $record->
getMailId())
409 return $user->getPublicName();
412 return trim(($record->
getImportName() ??
'') .
' (' . $this->lng->txt(
'user_deleted') .
')');
417 return $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
418 $this->mail->formatNamesForOutput((
string) $record->
getRcpTo())
424 return $this->ui_factory->link()->standard(
425 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform($record->
getSubject()),
426 (
string) $this->url_builder
429 $this->current_folder->isDrafts() || $this->current_folder->isOutbox() ? self::ACTION_EDIT : self::ACTION_SHOW
431 ->withParameter($this->row_id_token, (
string) $record->
getMailId())
444 ? $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->attachment())
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
join($init, callable $fn)
A simple class to express a naive range of whole positive numbers.
getSubject(MailRecordData $record)
getAvatar(MailRecordData $record)
const string ACTION_DOWNLOAD_ATTACHMENT
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
const string ACTION_PROFILE
const string ACTION_FORWARD
getRecipients(MailRecordData $record)
const string ACTION_MARK_UNREAD
const string ACTION_MOVE_TO
getAttachments(MailRecordData $record)
const string ACTION_MARK_READ
getStatus(MailRecordData $record)
const string ACTION_PRINT
getDate(MailRecordData $record)
const string ACTION_DELETE
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
getSender(MailRecordData $record)
__construct(private readonly URLBuilder $url_builder, private readonly URLBuilderToken $action_token, private readonly URLBuilderToken $row_id_token, private readonly URLBuilderToken $folder_token, private readonly array $user_folders, private readonly MailFolderData $current_folder, private readonly MailFolderSearch $search, private readonly ilMail $mail, private readonly Factory $ui_factory, private readonly Renderer $ui_renderer, private readonly ilLanguage $lng, private readonly ServerRequestInterface $http_request, private readonly DataFactory $data_factory, private readonly Refinery $refinery, private readonly DateFormat $date_format, private readonly string $time_format, private readonly DateTimeZone $user_time_zone)
const string ACTION_REPLY
static getUserObjectById(int $usr_id)
static preloadUserObjects(array $usr_ids)
static _getIliasMailerName()
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes how an icon could be modified during construction of UI.
A Column describes the form of presentation for a certain aspect of data, i.e.
buildDataRow(string $id, array $record)
This describes a Data Table.
This is how the factory for UI elements looks.
An entity that renders components to a string output.