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
101 ->withRequest($this->http_request);
110 $date_format = $this->data_factory->dateFormat()->withTime12($this->date_format);
112 $date_format = $this->data_factory->dateFormat()->withTime24($this->date_format);
116 'status' => $this->ui_factory
119 ->statusIcon($this->
lng->txt(
'status'))
120 ->withIsSortable(
true),
122 'avatar' => $this->ui_factory
125 ->status($this->
lng->txt(
'personal_picture'))
126 ->withIsSortable(
true),
128 'sender' => $this->ui_factory
131 ->text($this->
lng->txt(
'sender'))
132 ->withIsSortable(
true),
134 'recipients' => $this->ui_factory
137 ->text($this->
lng->txt(
'recipient'))
138 ->withIsSortable(
true),
140 'subject' => $this->ui_factory
143 ->link($this->
lng->txt(
'subject'))
144 ->withIsSortable(
true),
146 'attachments' => $this->ui_factory
149 ->status($this->
lng->txt(
'attachments'))
150 ->withIsSortable(
true),
152 'date' => $this->ui_factory
156 $this->
lng->txt(
'date'),
159 ->withIsSortable(
true),
162 if ($this->current_folder->hasOutgoingMails()) {
163 unset($columns[
'status'], $columns[
'avatar'], $columns[
'sender']);
165 unset($columns[
'recipients']);
177 self::ACTION_SHOW => $this->ui_factory->table()->action()->single(
178 $this->
lng->txt(
'view'),
179 $this->url_builder->withParameter($this->action_token, self::ACTION_SHOW),
182 self::ACTION_EDIT => $this->ui_factory->table()->action()->single(
183 $this->
lng->txt(
'edit'),
184 $this->url_builder->withParameter($this->action_token, self::ACTION_EDIT),
187 self::ACTION_REPLY => $this->ui_factory->table()->action()->single(
188 $this->
lng->txt(
'reply'),
189 $this->url_builder->withParameter($this->action_token, self::ACTION_REPLY),
192 self::ACTION_FORWARD => $this->ui_factory->table()->action()->single(
193 $this->
lng->txt(
'forward'),
194 $this->url_builder->withParameter($this->action_token, self::ACTION_FORWARD),
197 self::ACTION_DOWNLOAD_ATTACHMENT => $this->ui_factory->table()->action()->single(
198 $this->
lng->txt(
'mail_download_attachment'),
199 $this->url_builder->withParameter($this->action_token, self::ACTION_DOWNLOAD_ATTACHMENT),
202 self::ACTION_PRINT => $this->ui_factory->table()->action()->single(
203 $this->
lng->txt(
'print'),
204 $this->url_builder->withParameter($this->action_token, self::ACTION_PRINT),
207 self::ACTION_MARK_READ => $this->ui_factory->table()->action()->multi(
208 $this->
lng->txt(
'mail_mark_read'),
209 $this->url_builder->withParameter($this->action_token, self::ACTION_MARK_READ),
212 self::ACTION_MARK_UNREAD => $this->ui_factory->table()->action()->multi(
213 $this->
lng->txt(
'mail_mark_unread'),
214 $this->url_builder->withParameter($this->action_token, self::ACTION_MARK_UNREAD),
217 self::ACTION_DELETE => $this->ui_factory->table()->action()->standard(
218 $this->
lng->txt(
'delete'),
219 $this->url_builder->withParameter($this->action_token, self::ACTION_DELETE),
224 foreach ($this->user_folders as $target_folder) {
225 if ($target_folder->getFolderId() !== $this->current_folder->getFolderId()) {
226 $action_title = $this->
lng->txt(
'mail_move_to') .
' ' . $target_folder->getTitle();
227 if ($target_folder->isTrash()) {
228 $action_title .=
' (' . $this->
lng->txt(
'delete') .
')';
231 $actions[self::ACTION_MOVE_TO . $target_folder->getFolderId()] = $this->ui_factory
237 ->withParameter($this->action_token, self::ACTION_MOVE_TO)
238 ->withParameter($this->folder_token, (
string) $target_folder->getFolderId()),
244 if ($this->current_folder->isDrafts() || $this->current_folder->isOutbox()) {
245 unset($actions[self::ACTION_SHOW], $actions[self::ACTION_REPLY], $actions[self::ACTION_FORWARD]);
247 unset($actions[self::ACTION_EDIT]);
250 if ($this->current_folder->hasOutgoingMails()) {
251 unset($actions[self::ACTION_MARK_READ], $actions[self::ACTION_MARK_UNREAD]);
254 if (!$this->current_folder->isTrash()) {
255 unset($actions[self::ACTION_DELETE]);
263 array $visible_column_ids,
266 mixed $additional_viewcontrol_data,
268 mixed $additional_parameters
280 [$order_column, $order_direction] = $order->
join([], fn($ret, $key, $value) => [$key, $value]);
282 $records = $this->
search->getPagedRecords(
285 $order_columns[$order_column] ??
null,
290 if ($this->current_folder->hasIncomingMails()) {
292 foreach ($records as $record) {
293 if ($record->hasPersonalSender()) {
294 $user_ids[$record->getSenderId()] = $record->getSenderId();
300 foreach ($records as $record) {
301 if ($this->current_folder->hasIncomingMails()) {
308 'date' => $this->
getDate($record)
315 'date' => $this->
getDate($record)
320 (
string) $record->getMailId(),
322 )->withDisabledAction(self::ACTION_REPLY, !$record->hasPersonalSender())->withDisabledAction(
323 self::ACTION_DOWNLOAD_ATTACHMENT,
324 !$record->hasAttachments()
330 mixed $additional_viewcontrol_data,
332 mixed $additional_parameters
339 if ($this->current_folder->hasIncomingMails() && $this->search->getUnread() > 0) {
342 $this->current_folder->getTitle(),
343 $this->search->getCount() === 1
344 ? $this->lng->txt(
'mail_1')
345 : \sprintf($this->
lng->txt(
'mail_s'), $this->search->getCount()),
346 $this->search->getUnread(),
347 $this->lng->txt(
'unread')
353 $this->current_folder->getTitle(),
354 $this->search->getCount() === 1
355 ? $this->lng->txt(
'mail_1')
356 : \sprintf($this->
lng->txt(
'mail_s'), $this->search->getCount()),
362 if (!\array_key_exists($record->
getSenderId(), $this->avatars)) {
364 $avatar = $this->ui_factory->symbol()->avatar()->picture(
366 $this->getSender($record)
370 $avatar = $user?->getAvatar();
374 ? $this->ui_renderer->render($avatar)
384 ? $this->ui_factory->symbol()->icon()->standard(
'mailr', $this->
lng->txt(
'mailr'))
385 : $this->ui_factory->symbol()->icon()->standard(
'mailu', $this->
lng->txt(
'mailu'));
395 if ($user !==
null) {
396 if ($user->hasPublicProfile()) {
397 return $this->ui_renderer->render(
398 $this->ui_factory->link()->standard(
399 $user->getPublicName(),
400 (
string) $this->url_builder
401 ->withParameter($this->action_token, self::ACTION_PROFILE)
402 ->withParameter($this->row_id_token, (
string) $record->
getMailId())
408 return $user->getPublicName();
411 return trim(($record->
getImportName() ??
'') .
' (' . $this->lng->txt(
'user_deleted') .
')');
416 return $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
417 $this->mail->formatNamesForOutput((
string) $record->
getRcpTo())
423 return $this->ui_factory->link()->standard(
424 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform($record->
getSubject()),
425 (
string) $this->url_builder
428 $this->current_folder->isDrafts() || $this->current_folder->isOutbox() ? self::ACTION_EDIT : self::ACTION_SHOW
430 ->withParameter($this->row_id_token, (
string) $record->
getMailId())
443 ? $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.