19declare(strict_types=1);
41use Psr\Http\Message\ServerRequestInterface;
64 private readonly ServerRequestInterface $http_request,
66 private readonly UIFactory $ui_factory,
67 private readonly DataFactory $data_factory,
72 private readonly
string $action
81 array $visible_column_ids,
84 mixed $additional_viewcontrol_data,
86 mixed $additional_parameters
90 yield $row_builder->
buildDataRow((
string) $record[
'user_id'], $record);
99 if ($this->records ===
null) {
100 $this->records = $this->getUserNotificationTableData($this->getFilteredUserIds($filter_data));
112 return [$this->getFilterComponent(), $this->getTableComponent()];
117 if (!isset($this->table_component)) {
118 $query_params_namespace = [
'frm',
'notifications',
'table'];
121 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
122 $query_params_namespace,
127 $this->table_component = $this->ui_factory->table()
134 $this->ui_service->filter()->getData(
135 $this->getFilterComponent()
141 $action_parameter_token,
145 ->withId(
'forum_notification_table')
146 ->withRequest($this->http_request);
149 return $this->table_component;
154 if (!isset($this->filter_component)) {
156 $is_input_initially_rendered = [];
157 $field_factory = $this->ui_factory->input()->field();
159 foreach ($this->getFilterFields($field_factory) as $filter_id => $filter) {
160 [$filter_inputs[$filter_id], $is_input_initially_rendered[$filter_id]] = $filter;
163 $this->filter_component = $this->ui_service->filter()->standard(
164 'forum_notification_filter',
167 $is_input_initially_rendered,
173 return $this->filter_component;
182 'member' => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_member'),
183 'tutor' => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_tutor'),
184 'admin' => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_admin'),
185 'moderators' => $this->
lng->txt(
'frm_moderators'),
200 mixed $additional_viewcontrol_data,
202 mixed $additional_parameters
204 $this->initRecords($filter_data);
206 return \count((array) $this->records);
217 $admin_ids = $this->participants->getAdmins();
218 $member_ids = $this->participants->getMembers();
219 $tutor_ids = $this->participants->getTutors();
221 $filter = (string) ($filter_data[
'role'] ??
'');
224 $user_ids = $member_ids;
228 $user_ids = $tutor_ids;
232 $user_ids = $admin_ids;
236 $user_ids = $moderator_ids;
240 $user_ids = array_merge($admin_ids, $member_ids, $tutor_ids, $moderator_ids);
244 return array_unique($user_ids);
260 $this->initRecords($filter_data);
261 $records = $this->records;
264 $records = $this->orderRecords($records, $order);
268 $records = $this->limitRecords($records,
$range);
288 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_ok.svg',
'',
'small'),
289 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_not_ok.svg',
'',
'small'),
296 $forced_events = $this->forumNotificationObj->getForcedEventsObjectByUserId(
$user_id);
297 $member_const =
'IL_' . strtoupper($this->participants->getType()) .
'_MEMBER';
298 $tutor_const =
'IL_' . strtoupper($this->participants->getType()) .
'_TUTOR';
299 $admin_const =
'IL_' . strtoupper($this->participants->getType()) .
'_ADMIN';
300 $member_id = $this->participants->getAutoGeneratedRoleId(
ilParticipants::{$member_const});
301 $tutor_id = $this->participants->getAutoGeneratedRoleId(
ilParticipants::{$tutor_const});
302 $admin_id = $this->participants->getAutoGeneratedRoleId(
ilParticipants::{$admin_const});
304 $types = implode(
', ', array_map(
function (
int $role_id) use ($admin_id, $tutor_id, $member_id) {
305 return match ($role_id) {
306 $member_id => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_member'),
307 $tutor_id => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_tutor'),
308 $admin_id => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_admin'),
311 }, $this->participants->getAssignedRoles(
$user_id)));
312 if (\in_array(
$user_id, $moderator_ids,
true)) {
313 $types .=
', ' . $this->
lng->txt(
'frm_moderators');
319 $users[
$counter][
'firstname'] = $name[
'firstname'];
320 $users[
$counter][
'lastname'] = $name[
'lastname'];
321 $users[
$counter][
'user_toggle_noti'] = $icons[(
int) $forced_events->getUserToggle()];
339 'enableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
340 $this->
lng->txt(
'enable_hide_user_toggle'),
341 $url_builder->withParameter($action_parameter_token,
'enableHideUserToggleNoti'),
344 'disableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
345 $this->
lng->txt(
'disable_hide_user_toggle'),
346 $url_builder->withParameter($action_parameter_token,
'disableHideUserToggleNoti'),
349 'notificationSettings' => $this->ui_factory->table()->action()->single(
350 $this->
lng->txt(
'notification_settings'),
351 $url_builder->withParameter($action_parameter_token,
'notificationSettings'),
400 [$order_field, $order_direction] = $order->
join(
402 fn($ret, $key, $value) => [$key, $value]
404 usort($records,
static fn(array $left, array $right):
int =>
ilStr::strCmp(
405 $left[$order_field] ??
'',
406 $right[$order_field] ??
''
409 if ($order_direction === Order::DESC) {
410 $records = array_reverse($records);
422 'login' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'login')),
423 'firstname' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'firstname')),
424 'lastname' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'lastname')),
425 'user_toggle_noti' => $this->ui_factory->table()->column()->statusIcon(
426 $this->
lng->txt(
'allow_user_toggle_noti')
428 ->withIsSortable(
false),
429 'role' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'role')),
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.
orderRecords(array $records, Order $order)
getRecords(Range $range, Order $order, ?array $filter_data)
DataTable $table_component
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
getFilterFields(Factory $field_factory)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
getFilteredUserIds(?array $filter_data)
initRecords(?array $filter_data)
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
__construct(private readonly ServerRequestInterface $http_request, private readonly ilLanguage $lng, private readonly UIFactory $ui_factory, private readonly DataFactory $data_factory, private readonly int $ref_id, private readonly ilParticipants $participants, private readonly ilForumNotification $forumNotificationObj, private readonly ilUIService $ui_service, private readonly string $action)
getUserNotificationTableData(array $user_ids)
FilterComponent $filter_component
limitRecords(array $records, Range $range)
Class ilForumNotification.
Class Forum core functions for forum.
static _getModerators(int $a_ref_id)
static _lookupName(int $a_user_id)
static _lookupLogin(int $a_user_id)
Base class for course and group participants.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static strCmp(string $a, string $b)
Util class various functions, usage as namespace.
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.