ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
ILIAS\Mail\Folder\MailFolderTableUI Class Reference
+ Inheritance diagram for ILIAS\Mail\Folder\MailFolderTableUI:
+ Collaboration diagram for ILIAS\Mail\Folder\MailFolderTableUI:

Public Member Functions

 __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)
 
 getComponent ()
 
 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.g. More...
 
 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 records available. More...
 
 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.g. More...
 
 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 records available. More...
 

Data Fields

const string ACTION_SHOW = 'show'
 
const string ACTION_EDIT = 'edit'
 
const string ACTION_REPLY = 'reply'
 
const string ACTION_FORWARD = 'forward'
 
const string ACTION_DOWNLOAD_ATTACHMENT = 'download'
 
const string ACTION_PRINT = 'print'
 
const string ACTION_PROFILE = 'profile'
 
const string ACTION_MOVE_TO = 'moveTo'
 
const string ACTION_DELETE = 'delete'
 
const string ACTION_MARK_READ = 'markRead'
 
const string ACTION_MARK_UNREAD = 'marUnread'
 

Private Member Functions

 getColumnDefinition ()
 
 getActions ()
 
 getTableTitle ()
 
 getAvatar (MailRecordData $record)
 
 getStatus (MailRecordData $record)
 
 getSender (MailRecordData $record)
 
 getRecipients (MailRecordData $record)
 
 getSubject (MailRecordData $record)
 
 getDate (MailRecordData $record)
 
 getAttachments (MailRecordData $record)
 

Private Attributes

array $avatars = []
 

Detailed Description

Definition at line 47 of file MailFolderTableUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Mail\Folder\MailFolderTableUI::__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 
)
Parameters
MailFolderData[]$user_folders

Definition at line 68 of file MailFolderTableUI.php.

86 {
87 }

Member Function Documentation

◆ getActions()

ILIAS\Mail\Folder\MailFolderTableUI::getActions ( )
private
Returns
array<string, TableAction>

Definition at line 175 of file MailFolderTableUI.php.

175 : array
176 {
177 $actions = [
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),
181 $this->row_id_token
182 ),
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),
186 $this->row_id_token
187 ),
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),
191 $this->row_id_token
192 ),
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),
196 $this->row_id_token
197 ),
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),
201 $this->row_id_token
202 ),
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),
206 $this->row_id_token
207 ),
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),
211 $this->row_id_token
212 ),
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),
216 $this->row_id_token
217 ),
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),
221 $this->row_id_token
222 )->withAsync(), // for confirmation modal
223 ];
224
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') . ')';
230 }
231
232 $actions[self::ACTION_MOVE_TO . $target_folder->getFolderId()] = $this->ui_factory
233 ->table()
234 ->action()
235 ->multi(
236 $action_title,
237 $this->url_builder
238 ->withParameter($this->action_token, self::ACTION_MOVE_TO)
239 ->withParameter($this->folder_token, (string) $target_folder->getFolderId()),
240 $this->row_id_token
241 );
242 }
243 }
244
245 if ($this->current_folder->isDrafts() || $this->current_folder->isOutbox()) {
246 unset($actions[self::ACTION_SHOW], $actions[self::ACTION_REPLY], $actions[self::ACTION_FORWARD]);
247 } else {
248 unset($actions[self::ACTION_EDIT]);
249 }
250
251 if ($this->current_folder->hasOutgoingMails()) {
252 unset($actions[self::ACTION_MARK_READ], $actions[self::ACTION_MARK_UNREAD]);
253 }
254
255 if (!$this->current_folder->isTrash()) {
256 unset($actions[self::ACTION_DELETE]);
257 }
258
259 return $actions;
260 }

References ILIAS\Repository\lng().

Referenced by ILIAS\Mail\Folder\MailFolderTableUI\getComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAttachments()

ILIAS\Mail\Folder\MailFolderTableUI::getAttachments ( MailRecordData  $record)
private

Definition at line 441 of file MailFolderTableUI.php.

441 : string
442 {
443 return $record->hasAttachments()
444 ? $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->attachment())
445 : '';
446 }

References ILIAS\Mail\Message\MailRecordData\hasAttachments().

+ Here is the call graph for this function:

◆ getAvatar()

ILIAS\Mail\Folder\MailFolderTableUI::getAvatar ( MailRecordData  $record)
private

Definition at line 361 of file MailFolderTableUI.php.

361 : string
362 {
363 if (!\array_key_exists($record->getSenderId(), $this->avatars)) {
364 if ($record->getSenderId() === ANONYMOUS_USER_ID) {
365 $avatar = $this->ui_factory->symbol()->avatar()->picture(
366 \ilUtil::getImagePath('logo/ilias_logo_centered.png'),
367 $this->getSender($record)
368 );
369 } else {
371 $avatar = $user?->getAvatar();
372 }
373
374 $this->avatars[$record->getSenderId()] = $avatar
375 ? $this->ui_renderer->render($avatar)
376 : '';
377 }
378
379 return $this->avatars[$record->getSenderId()];
380 }
static getUserObjectById(int $usr_id)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const ANONYMOUS_USER_ID
Definition: constants.php:27

References ANONYMOUS_USER_ID, ilUtil\getImagePath(), ILIAS\Mail\Message\MailRecordData\getSenderId(), and ilMailUserCache\getUserObjectById().

+ Here is the call graph for this function:

◆ getColumnDefinition()

ILIAS\Mail\Folder\MailFolderTableUI::getColumnDefinition ( )
private
Returns
array<string, TableColumn>

Definition at line 108 of file MailFolderTableUI.php.

108 : array
109 {
110 if ((int) $this->time_format === \ilCalendarSettings::TIME_FORMAT_12) {
111 $date_format = $this->data_factory->dateFormat()->withTime12($this->date_format);
112 } else {
113 $date_format = $this->data_factory->dateFormat()->withTime24($this->date_format);
114 }
115
116 $columns = [
117 'status' => $this->ui_factory
118 ->table()
119 ->column()
120 ->statusIcon($this->lng->txt('status'))
121 ->withIsSortable(true),
122
123 'avatar' => $this->ui_factory
124 ->table()
125 ->column()
126 ->status($this->lng->txt('personal_picture'))
127 ->withIsSortable(true),
128
129 'sender' => $this->ui_factory
130 ->table()
131 ->column()
132 ->text($this->lng->txt('sender'))
133 ->withIsSortable(true),
134
135 'recipients' => $this->ui_factory
136 ->table()
137 ->column()
138 ->text($this->lng->txt('recipient'))
139 ->withIsSortable(true),
140
141 'subject' => $this->ui_factory
142 ->table()
143 ->column()
144 ->link($this->lng->txt('subject'))
145 ->withIsSortable(true),
146
147 'attachments' => $this->ui_factory
148 ->table()
149 ->column()
150 ->status($this->lng->txt('attachments'))
151 ->withIsSortable(true),
152
153 'date' => $this->ui_factory
154 ->table()
155 ->column()
156 ->date(
157 $this->lng->txt('date'),
158 $date_format
159 )
160 ->withIsSortable(true),
161 ];
162
163 if ($this->current_folder->hasOutgoingMails()) {
164 unset($columns['status'], $columns['avatar'], $columns['sender']);
165 } else {
166 unset($columns['recipients']);
167 }
168
169 return $columns;
170 }

References ILIAS\Repository\lng(), and ilCalendarSettings\TIME_FORMAT_12.

Referenced by ILIAS\Mail\Folder\MailFolderTableUI\getComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponent()

ILIAS\Mail\Folder\MailFolderTableUI::getComponent ( )

Definition at line 89 of file MailFolderTableUI.php.

89 : DataTable
90 {
91 return $this->ui_factory
92 ->table()
93 ->data(
94 $this,
95 $this->getTableTitle(),
96 $this->getColumnDefinition(),
97 )
98 ->withId(str_replace('\\', '', self::class))
99 ->withOrder(new Order('date', Order::DESC))
100 ->withRange(new Range(0, 50))
101 ->withActions($this->getActions())
102 ->withRequest($this->http_request);
103 }
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
const DESC
Definition: Order.php:31
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29

References ILIAS\Data\Order\DESC, ILIAS\Mail\Folder\MailFolderTableUI\getActions(), ILIAS\Mail\Folder\MailFolderTableUI\getColumnDefinition(), and ILIAS\Mail\Folder\MailFolderTableUI\getTableTitle().

+ Here is the call graph for this function:

◆ getDate()

ILIAS\Mail\Folder\MailFolderTableUI::getDate ( MailRecordData  $record)
private

Definition at line 436 of file MailFolderTableUI.php.

436 : ?DateTimeImmutable
437 {
438 return empty($record->getSendTime()) ? null : $record->getSendTime()->setTimezone($this->user_time_zone);
439 }

References ILIAS\Mail\Message\MailRecordData\getSendTime().

+ Here is the call graph for this function:

◆ getRecipients()

ILIAS\Mail\Folder\MailFolderTableUI::getRecipients ( MailRecordData  $record)
private

Definition at line 415 of file MailFolderTableUI.php.

415 : string
416 {
417 return $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform(
418 $this->mail->formatNamesForOutput((string) $record->getRcpTo())
419 );
420 }

References ILIAS\Mail\Message\MailRecordData\getRcpTo(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getRows()

ILIAS\Mail\Folder\MailFolderTableUI::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.g.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 262 of file MailFolderTableUI.php.

270 : \Generator {
271 // mapping of table columns to allowed order columns of the mailbox query
272 $order_columns = [
273 'status' => MailBoxOrderColumn::STATUS,
274 'subject' => MailBoxOrderColumn::SUBJECT,
275 'sender' => MailBoxOrderColumn::FROM,
276 'recipients' => MailBoxOrderColumn::RCP_TO,
277 'date' => MailBoxOrderColumn::SEND_TIME,
278 'attachments' => MailBoxOrderColumn::ATTACHMENTS
279 ];
280
281 [$order_column, $order_direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
282
283 $records = $this->search->getPagedRecords(
284 $range->getLength(),
285 $range->getStart(),
286 $order_columns[$order_column] ?? null,
287 $order_direction
288 );
289
290 // preload user objects for display of avatar and sender
291 if ($this->current_folder->hasIncomingMails()) {
292 $user_ids = [];
293 foreach ($records as $record) {
294 if ($record->hasPersonalSender()) {
295 $user_ids[$record->getSenderId()] = $record->getSenderId();
296 }
297 }
299 }
300
301 foreach ($records as $record) {
302 if ($this->current_folder->hasIncomingMails()) {
303 $data = [
304 'status' => $this->getStatus($record),
305 'avatar' => $this->getAvatar($record),
306 'sender' => $this->getSender($record),
307 'subject' => $this->getSubject($record),
308 'attachments' => $this->getAttachments($record),
309 'date' => $this->getDate($record)
310 ];
311 } else {
312 $data = [
313 'recipients' => $this->getRecipients($record),
314 'subject' => $this->getSubject($record),
315 'attachments' => $this->getAttachments($record),
316 'date' => $this->getDate($record)
317 ];
318 }
319
320 yield $row_builder->buildDataRow(
321 (string) $record->getMailId(),
322 $data
323 )->withDisabledAction(self::ACTION_REPLY, !$record->hasPersonalSender())->withDisabledAction(
324 self::ACTION_DOWNLOAD_ATTACHMENT,
325 !$record->hasAttachments()
326 );
327 }
328 }
join($init, callable $fn)
Definition: Order.php:75
getAttachments(MailRecordData $record)
static preloadUserObjects(array $usr_ids)
buildDataRow(string $id, array $record)

References ilMailUserCache\preloadUserObjects().

+ Here is the call graph for this function:

◆ getSender()

ILIAS\Mail\Folder\MailFolderTableUI::getSender ( MailRecordData  $record)
private

Definition at line 389 of file MailFolderTableUI.php.

389 : string
390 {
391 if ($record->getSenderId() === ANONYMOUS_USER_ID) {
393 }
394
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())
404 ->buildURI()
405 )
406 );
407 }
408
409 return $user->getPublicName();
410 }
411
412 return trim(($record->getImportName() ?? '') . ' (' . $this->lng->txt('user_deleted') . ')');
413 }
static _getIliasMailerName()

References ilMail\_getIliasMailerName(), ANONYMOUS_USER_ID, ILIAS\Mail\Message\MailRecordData\getImportName(), ILIAS\Mail\Message\MailRecordData\getMailId(), ILIAS\Mail\Message\MailRecordData\getSenderId(), and ilMailUserCache\getUserObjectById().

+ Here is the call graph for this function:

◆ getStatus()

ILIAS\Mail\Folder\MailFolderTableUI::getStatus ( MailRecordData  $record)
private

Definition at line 382 of file MailFolderTableUI.php.

382 : Icon
383 {
384 return $record->isRead()
385 ? $this->ui_factory->symbol()->icon()->standard('mailr', $this->lng->txt('mailr'))
386 : $this->ui_factory->symbol()->icon()->standard('mailu', $this->lng->txt('mailu'));
387 }

References ILIAS\Mail\Message\MailRecordData\isRead(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getSubject()

ILIAS\Mail\Folder\MailFolderTableUI::getSubject ( MailRecordData  $record)
private

Definition at line 422 of file MailFolderTableUI.php.

422 : Link
423 {
424 return $this->ui_factory->link()->standard(
425 $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($record->getSubject()),
426 (string) $this->url_builder
427 ->withParameter(
428 $this->action_token,
429 $this->current_folder->isDrafts() || $this->current_folder->isOutbox() ? self::ACTION_EDIT : self::ACTION_SHOW
430 )
431 ->withParameter($this->row_id_token, (string) $record->getMailId())
432 ->buildURI()
433 );
434 }

References ILIAS\Mail\Message\MailRecordData\getMailId(), ILIAS\Mail\Message\MailRecordData\getSubject(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getTableTitle()

ILIAS\Mail\Folder\MailFolderTableUI::getTableTitle ( )
private

Definition at line 338 of file MailFolderTableUI.php.

338 : string
339 {
340 if ($this->current_folder->hasIncomingMails() && $this->search->getUnread() > 0) {
341 return \sprintf(
342 '%s: %s (%s %s)',
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')
349 );
350 }
351
352 return \sprintf(
353 '%s: %s',
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()),
358 );
359 }

References ILIAS\Repository\lng().

Referenced by ILIAS\Mail\Folder\MailFolderTableUI\getComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTotalRowCount()

ILIAS\Mail\Folder\MailFolderTableUI::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 records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 330 of file MailFolderTableUI.php.

334 : ?int {
335 return $this->search->getCount();
336 }

Field Documentation

◆ $avatars

array ILIAS\Mail\Folder\MailFolderTableUI::$avatars = []
private

Definition at line 63 of file MailFolderTableUI.php.

◆ ACTION_DELETE

const string ILIAS\Mail\Folder\MailFolderTableUI::ACTION_DELETE = 'delete'

Definition at line 58 of file MailFolderTableUI.php.

◆ ACTION_DOWNLOAD_ATTACHMENT

const string ILIAS\Mail\Folder\MailFolderTableUI::ACTION_DOWNLOAD_ATTACHMENT = 'download'

Definition at line 54 of file MailFolderTableUI.php.

◆ ACTION_EDIT

const string ILIAS\Mail\Folder\MailFolderTableUI::ACTION_EDIT = 'edit'

Definition at line 51 of file MailFolderTableUI.php.

◆ ACTION_FORWARD

const string ILIAS\Mail\Folder\MailFolderTableUI::ACTION_FORWARD = 'forward'

Definition at line 53 of file MailFolderTableUI.php.

◆ ACTION_MARK_READ

const string ILIAS\Mail\Folder\MailFolderTableUI::ACTION_MARK_READ = 'markRead'

Definition at line 59 of file MailFolderTableUI.php.

◆ ACTION_MARK_UNREAD

const string ILIAS\Mail\Folder\MailFolderTableUI::ACTION_MARK_UNREAD = 'marUnread'

Definition at line 60 of file MailFolderTableUI.php.

◆ ACTION_MOVE_TO

const string ILIAS\Mail\Folder\MailFolderTableUI::ACTION_MOVE_TO = 'moveTo'

Definition at line 57 of file MailFolderTableUI.php.

◆ ACTION_PRINT

const string ILIAS\Mail\Folder\MailFolderTableUI::ACTION_PRINT = 'print'

Definition at line 55 of file MailFolderTableUI.php.

◆ ACTION_PROFILE

const string ILIAS\Mail\Folder\MailFolderTableUI::ACTION_PROFILE = 'profile'

Definition at line 56 of file MailFolderTableUI.php.

◆ ACTION_REPLY

const string ILIAS\Mail\Folder\MailFolderTableUI::ACTION_REPLY = 'reply'

Definition at line 52 of file MailFolderTableUI.php.

◆ ACTION_SHOW

const string ILIAS\Mail\Folder\MailFolderTableUI::ACTION_SHOW = 'show'

Definition at line 50 of file MailFolderTableUI.php.


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