19declare(strict_types=1);
41use Psr\Http\Message\ServerRequestInterface;
63 private readonly ServerRequestInterface $http_request,
65 private readonly UIFactory $ui_factory,
66 private readonly DataFactory $data_factory,
71 private readonly
string $action
80 array $visible_column_ids,
84 ?array $additional_parameters,
88 yield $row_builder->buildDataRow((
string) $record[
'user_id'], $record);
97 if ($this->records ===
null) {
98 $this->records = $this->getUserNotificationTableData($this->getFilteredUserIds($filter_data));
110 return [$this->getFilterComponent(), $this->getTableComponent()];
115 if (!isset($this->table_component)) {
116 $query_params_namespace = [
'frm',
'notifications',
'table'];
119 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
120 $query_params_namespace,
125 $this->table_component = $this->ui_factory->table()
132 $this->ui_service->filter()->getData(
133 $this->getFilterComponent()
139 $action_parameter_token,
143 ->withId(
'forum_notification_table')
144 ->withRequest($this->http_request);
147 return $this->table_component;
152 if (!isset($this->filter_component)) {
154 $is_input_initially_rendered = [];
155 $field_factory = $this->ui_factory->input()->field();
157 foreach ($this->getFilterFields($field_factory) as $filter_id => $filter) {
158 [$filter_inputs[$filter_id], $is_input_initially_rendered[$filter_id]] = $filter;
161 $this->filter_component = $this->ui_service->filter()->standard(
162 'forum_notification_filter',
165 $is_input_initially_rendered,
171 return $this->filter_component;
180 'member' => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_member'),
181 'tutor' => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_tutor'),
182 'admin' => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_admin'),
183 'moderators' => $this->
lng->txt(
'frm_moderators'),
188 $field_factory->
select($this->
lng->txt(
'roles'), $options),
199 $this->initRecords($filter_data);
201 return \count((array) $this->records);
212 $admin_ids = $this->participants->getAdmins();
213 $member_ids = $this->participants->getMembers();
214 $tutor_ids = $this->participants->getTutors();
216 $filter = (string) ($filter_data[
'role'] ??
'');
219 $user_ids = $member_ids;
223 $user_ids = $tutor_ids;
227 $user_ids = $admin_ids;
231 $user_ids = $moderator_ids;
235 $user_ids = array_merge($admin_ids, $member_ids, $tutor_ids, $moderator_ids);
239 return array_unique($user_ids);
255 $this->initRecords($filter_data);
256 $records = $this->records;
259 $records = $this->orderRecords($records, $order);
263 $records = $this->limitRecords($records,
$range);
283 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_ok.svg',
'',
'small'),
284 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_not_ok.svg',
'',
'small'),
291 $forced_events = $this->forumNotificationObj->getForcedEventsObjectByUserId(
$user_id);
292 $member_const =
'IL_' . strtoupper($this->participants->getType()) .
'_MEMBER';
293 $tutor_const =
'IL_' . strtoupper($this->participants->getType()) .
'_TUTOR';
294 $admin_const =
'IL_' . strtoupper($this->participants->getType()) .
'_ADMIN';
295 $member_id = $this->participants->getAutoGeneratedRoleId(
ilParticipants::{$member_const});
296 $tutor_id = $this->participants->getAutoGeneratedRoleId(
ilParticipants::{$tutor_const});
297 $admin_id = $this->participants->getAutoGeneratedRoleId(
ilParticipants::{$admin_const});
299 $types = implode(
', ', array_map(
function (
int $role_id) use ($admin_id, $tutor_id, $member_id) {
300 return match ($role_id) {
301 $member_id => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_member'),
302 $tutor_id => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_tutor'),
303 $admin_id => $this->
lng->txt(
'il_' . $this->participants->getType() .
'_admin'),
306 }, $this->participants->getAssignedRoles(
$user_id)));
307 if (\in_array(
$user_id, $moderator_ids,
true)) {
308 $types .=
', ' . $this->
lng->txt(
'frm_moderators');
314 $users[
$counter][
'firstname'] = $name[
'firstname'];
315 $users[
$counter][
'lastname'] = $name[
'lastname'];
316 $users[
$counter][
'user_toggle_noti'] = $icons[(
int) $forced_events->getUserToggle()];
334 'enableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
335 $this->
lng->txt(
'enable_hide_user_toggle'),
336 $url_builder->withParameter($action_parameter_token,
'enableHideUserToggleNoti'),
339 'disableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
340 $this->
lng->txt(
'disable_hide_user_toggle'),
341 $url_builder->withParameter($action_parameter_token,
'disableHideUserToggleNoti'),
344 'notificationSettings' => $this->ui_factory->table()->action()->single(
345 $this->
lng->txt(
'notification_settings'),
346 $url_builder->withParameter($action_parameter_token,
'notificationSettings'),
395 [$order_field, $order_direction] = $order->
join(
397 fn($ret, $key, $value) => [$key, $value]
399 usort($records,
static fn(array $left, array $right):
int =>
ilStr::strCmp(
400 $left[$order_field] ??
'',
401 $right[$order_field] ??
''
404 if ($order_direction === Order::DESC) {
405 $records = array_reverse($records);
417 'login' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'login')),
418 'firstname' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'firstname')),
419 'lastname' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'lastname')),
420 'user_toggle_noti' => $this->ui_factory->table()->column()->statusIcon(
421 $this->
lng->txt(
'allow_user_toggle_noti')
423 ->withIsSortable(
false),
424 '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)
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
DataTable $table_component
getRows(\ILIAS\UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters,)
getFilterFields(Factory $field_factory)
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.
This describes a Data Table.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.