19 declare(strict_types=1);
73 private readonly array $user_folders,
76 private readonly
ilMail $mail,
77 private readonly
Factory $ui_factory,
78 private readonly
Renderer $ui_renderer,
84 private readonly
string $time_format,
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()) {
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,
267 ?array $additional_parameters
271 'status' => MailBoxOrderColumn::STATUS,
272 'subject' => MailBoxOrderColumn::SUBJECT,
273 'sender' => MailBoxOrderColumn::FROM,
274 'recipients' => MailBoxOrderColumn::RCP_TO,
275 'date' => MailBoxOrderColumn::SEND_TIME,
279 [$order_column, $order_direction] = $order->
join([], fn($ret, $key, $value) => [$key, $value]);
281 $records = $this->
search->getPagedRecords(
284 $order_columns[$order_column] ??
null,
289 if ($this->current_folder->hasIncomingMails()) {
291 foreach ($records as $record) {
292 if ($record->hasPersonalSender()) {
293 $user_ids[$record->getSenderId()] = $record->getSenderId();
299 foreach ($records as $record) {
300 if ($this->current_folder->hasIncomingMails()) {
307 'date' => $this->
getDate($record)
314 'date' => $this->
getDate($record)
319 (
string) $record->getMailId(),
321 )->withDisabledAction(self::ACTION_REPLY, !$record->hasPersonalSender())->withDisabledAction(
322 self::ACTION_DOWNLOAD_ATTACHMENT,
323 !$record->hasAttachments()
330 return $this->
search->getCount();
335 if ($this->current_folder->hasIncomingMails() && $this->
search->getUnread() > 0) {
338 $this->current_folder->getTitle(),
339 $this->
search->getCount() === 1
340 ? $this->
lng->txt(
'mail_1')
341 : \sprintf($this->
lng->txt(
'mail_s'), $this->
search->getCount()),
342 $this->
search->getUnread(),
343 $this->
lng->txt(
'unread')
349 $this->current_folder->getTitle(),
350 $this->
search->getCount() === 1
351 ? $this->
lng->txt(
'mail_1')
352 : \sprintf($this->
lng->txt(
'mail_s'), $this->
search->getCount()),
360 $avatar = $this->ui_factory->symbol()->avatar()->picture(
366 $avatar = $user?->getAvatar();
370 ? $this->ui_renderer->render($avatar)
380 ? $this->ui_factory->symbol()->icon()->standard(
'mailr', $this->
lng->txt(
'mailr'))
381 : $this->ui_factory->symbol()->icon()->standard(
'mailu', $this->
lng->txt(
'mailu'));
391 if ($user !==
null) {
392 if ($user->hasPublicProfile()) {
393 return $this->ui_renderer->render(
394 $this->ui_factory->link()->standard(
395 $user->getPublicName(),
396 (string) $this->url_builder
397 ->withParameter($this->action_token, self::ACTION_PROFILE)
398 ->withParameter($this->row_id_token, (
string) $record->
getMailId())
404 return $user->getPublicName();
407 return trim(($record->
getImportName() ??
'') .
' (' . $this->
lng->txt(
'user_deleted') .
')');
412 return $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
413 $this->mail->formatNamesForOutput((
string) $record->
getRcpTo())
419 return $this->ui_factory->link()->standard(
420 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform($record->
getSubject()),
421 (
string) $this->url_builder
424 $this->current_folder->isDrafts() ? self::ACTION_EDIT : self::ACTION_SHOW
426 ->withParameter($this->row_id_token, (
string) $record->
getMailId())
439 ? $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->attachment())
search()
description: > Example for rendring a search glyph.
join($init, callable $fn)
static getUserObjectById(int $usr_id)
getSubject(MailRecordData $record)
getAvatar(MailRecordData $record)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e...
static _getIliasMailerName()
getSender(MailRecordData $record)
Both the subject and the direction need to be specified when expressing an order. ...
buildDataRow(string $id, array $record)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getRecipients(MailRecordData $record)
This is how the factory for UI elements looks.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static preloadUserObjects(array $usr_ids)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
getDate(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)
getAttachments(MailRecordData $record)
getStatus(MailRecordData $record)
A simple class to express a naive range of whole positive numbers.
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
const ACTION_DOWNLOAD_ATTACHMENT