ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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, ?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.g. More...
 
 getTotalRowCount (?array $filter_data, ?array $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, ?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.g. More...
 
 getTotalRowCount (?array $filter_data, ?array $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 174 of file MailFolderTableUI.php.

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

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 436 of file MailFolderTableUI.php.

436 : string
437 {
438 return $record->hasAttachments()
439 ? $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->attachment())
440 : '';
441 }

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 356 of file MailFolderTableUI.php.

356 : string
357 {
358 if (!\array_key_exists($record->getSenderId(), $this->avatars)) {
359 if ($record->getSenderId() === ANONYMOUS_USER_ID) {
360 $avatar = $this->ui_factory->symbol()->avatar()->picture(
361 \ilUtil::getImagePath('logo/ilias_logo_centered.png'),
362 $this->getSender($record)
363 );
364 } else {
366 $avatar = $user?->getAvatar();
367 }
368
369 $this->avatars[$record->getSenderId()] = $avatar
370 ? $this->ui_renderer->render($avatar)
371 : '';
372 }
373
374 return $this->avatars[$record->getSenderId()];
375 }
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 107 of file MailFolderTableUI.php.

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

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(self::class)
99 ->withOrder(new Order('date', Order::DESC))
100 ->withActions($this->getActions())
101 ->withRequest($this->http_request);
102 }
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
const DESC
Definition: Order.php:31

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 431 of file MailFolderTableUI.php.

431 : ?DateTimeImmutable
432 {
433 return empty($record->getSendTime()) ? null : $record->getSendTime()->setTimezone($this->user_time_zone);
434 }

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 410 of file MailFolderTableUI.php.

410 : string
411 {
412 return $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform(
413 $this->mail->formatNamesForOutput((string) $record->getRcpTo())
414 );
415 }

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,
?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.g.

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

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 261 of file MailFolderTableUI.php.

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

384 : string
385 {
386 if ($record->getSenderId() === ANONYMOUS_USER_ID) {
388 }
389
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())
399 ->buildURI()
400 )
401 );
402 }
403
404 return $user->getPublicName();
405 }
406
407 return trim(($record->getImportName() ?? '') . ' (' . $this->lng->txt('user_deleted') . ')');
408 }
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 377 of file MailFolderTableUI.php.

377 : Icon
378 {
379 return $record->isRead()
380 ? $this->ui_factory->symbol()->icon()->standard('mailr', $this->lng->txt('mailr'))
381 : $this->ui_factory->symbol()->icon()->standard('mailu', $this->lng->txt('mailu'));
382 }

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 417 of file MailFolderTableUI.php.

417 : Link
418 {
419 return $this->ui_factory->link()->standard(
420 $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($record->getSubject()),
421 (string) $this->url_builder
422 ->withParameter(
423 $this->action_token,
424 $this->current_folder->isDrafts() ? self::ACTION_EDIT : self::ACTION_SHOW
425 )
426 ->withParameter($this->row_id_token, (string) $record->getMailId())
427 ->buildURI()
428 );
429 }

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 333 of file MailFolderTableUI.php.

333 : string
334 {
335 if ($this->current_folder->hasIncomingMails() && $this->search->getUnread() > 0) {
336 return \sprintf(
337 '%s: %s (%s %s)',
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')
344 );
345 }
346
347 return \sprintf(
348 '%s: %s',
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()),
353 );
354 }

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 ( ?array  $filter_data,
?array  $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 328 of file MailFolderTableUI.php.

328 : ?int
329 {
330 return $this->search->getCount();
331 }

References ILIAS\UI\examples\Symbol\Glyph\Search\search().

+ Here is the call graph for this function:

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: