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 ->withRange(
new Range(0, 50))
147 ->withRequest($this->http_request);
150 return $this->table_component;
155 if (!isset($this->filter_component)) {
157 $is_input_initially_rendered = [];
158 $field_factory = $this->ui_factory->input()->field();
160 foreach ($this->getFilterFields($field_factory) as $filter_id => $filter) {
161 [$filter_inputs[$filter_id], $is_input_initially_rendered[$filter_id]] = $filter;
164 $this->filter_component = $this->ui_service->filter()->standard(
165 'forum_notification_filter',
168 $is_input_initially_rendered,
174 return $this->filter_component;
183 'member' => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_member'),
184 'tutor' => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_tutor'),
185 'admin' => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_admin'),
186 'moderators' => $this->
lng->txt(
'frm_moderators'),
201 mixed $additional_viewcontrol_data,
203 mixed $additional_parameters
205 $this->initRecords($filter_data);
207 return \count((array) $this->records);
218 $admin_ids = $this->participants->getAdmins();
219 $member_ids = $this->participants->getMembers();
220 $tutor_ids = $this->participants->getTutors();
222 $filter = (string) ($filter_data[
'role'] ??
'');
225 $user_ids = $member_ids;
229 $user_ids = $tutor_ids;
233 $user_ids = $admin_ids;
237 $user_ids = $moderator_ids;
241 $user_ids = array_merge($admin_ids, $member_ids, $tutor_ids, $moderator_ids);
245 return array_unique($user_ids);
261 $this->initRecords($filter_data);
262 $records = $this->records;
265 $records = $this->orderRecords($records, $order);
269 $records = $this->limitRecords($records,
$range);
289 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_ok.svg',
'',
'small'),
290 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_not_ok.svg',
'',
'small'),
297 $forced_events = $this->forumNotificationObj->getForcedEventsObjectByUserId(
$user_id);
298 $member_const =
'IL_' . strtoupper($this->participants->getType()) .
'_MEMBER';
299 $tutor_const =
'IL_' . strtoupper($this->participants->getType()) .
'_TUTOR';
300 $admin_const =
'IL_' . strtoupper($this->participants->getType()) .
'_ADMIN';
301 $member_id = $this->participants->getAutoGeneratedRoleId(
ilParticipants::{$member_const});
302 $tutor_id = $this->participants->getAutoGeneratedRoleId(
ilParticipants::{$tutor_const});
303 $admin_id = $this->participants->getAutoGeneratedRoleId(
ilParticipants::{$admin_const});
305 $types = implode(
', ', array_map(
function (
int $role_id) use ($admin_id, $tutor_id, $member_id) {
306 return match ($role_id) {
307 $member_id => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_member'),
308 $tutor_id => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_tutor'),
309 $admin_id => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_admin'),
312 }, $this->participants->getAssignedRoles(
$user_id)));
313 if (\in_array(
$user_id, $moderator_ids,
true)) {
314 $types .=
', ' . $this->
lng->txt(
'frm_moderators');
320 $users[
$counter][
'firstname'] = $name[
'firstname'];
321 $users[
$counter][
'lastname'] = $name[
'lastname'];
322 $users[
$counter][
'user_toggle_noti'] = $icons[(
int) $forced_events->getUserToggle()];
340 'enableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
341 $this->
lng->txt(
'enable_hide_user_toggle'),
342 $url_builder->withParameter($action_parameter_token,
'enableHideUserToggleNoti'),
345 'disableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
346 $this->
lng->txt(
'disable_hide_user_toggle'),
347 $url_builder->withParameter($action_parameter_token,
'disableHideUserToggleNoti'),
350 'notificationSettings' => $this->ui_factory->table()->action()->single(
351 $this->
lng->txt(
'notification_settings'),
352 $url_builder->withParameter($action_parameter_token,
'notificationSettings'),
401 [$order_field, $order_direction] = $order->
join(
403 fn($ret, $key, $value) => [$key, $value]
405 usort($records,
static fn(array $left, array $right):
int =>
ilStr::strCmp(
406 $left[$order_field] ??
'',
407 $right[$order_field] ??
''
410 if ($order_direction === Order::DESC) {
411 $records = array_reverse($records);
423 'login' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'login')),
424 'firstname' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'firstname')),
425 'lastname' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'lastname')),
426 'user_toggle_noti' => $this->ui_factory->table()->column()->statusIcon(
427 $this->
lng->txt(
'allow_user_toggle_noti')
429 ->withIsSortable(
false),
430 '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.