ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\Forum\Notification\ForumNotificationTable Class Reference
+ Inheritance diagram for ILIAS\Forum\Notification\ForumNotificationTable:
+ Collaboration diagram for ILIAS\Forum\Notification\ForumNotificationTable:

Public Member Functions

 __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)
 
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 
 initRecords (?array $filter_data)
 
 getComponents ()
 
 getTableComponent ()
 
 getFilterComponent ()
 
 getFilterFields (Factory $field_factory)
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 
 getFilteredUserIds (?array $filter_data)
 
 getActions (URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
 
 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...
 

Private Member Functions

 getRecords (Range $range, Order $order, ?array $filter_data)
 
 getUserNotificationTableData (array $user_ids)
 
 limitRecords (array $records, Range $range)
 
 orderRecords (array $records, Order $order)
 
 getColumns ()
 

Private Attributes

array $records = null
 
FilterComponent $filter_component
 
DataTable $table_component
 

Detailed Description

Definition at line 49 of file ForumNotificationTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Forum\Notification\ForumNotificationTable::__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 
)

Definition at line 63 of file ForumNotificationTable.php.

73 {
74 }

Member Function Documentation

◆ getActions()

ILIAS\Forum\Notification\ForumNotificationTable::getActions ( URLBuilder  $url_builder,
URLBuilderToken  $action_parameter_token,
URLBuilderToken  $row_id_token 
)
Returns
array<string, Action>

Definition at line 333 of file ForumNotificationTable.php.

337 : array {
338 return [
339 'enableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
340 $this->lng->txt('enable_hide_user_toggle'),
341 $url_builder->withParameter($action_parameter_token, 'enableHideUserToggleNoti'),
342 $row_id_token
343 ),
344 'disableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
345 $this->lng->txt('disable_hide_user_toggle'),
346 $url_builder->withParameter($action_parameter_token, 'disableHideUserToggleNoti'),
347 $row_id_token
348 ),
349 'notificationSettings' => $this->ui_factory->table()->action()->single(
350 $this->lng->txt('notification_settings'),
351 $url_builder->withParameter($action_parameter_token, 'notificationSettings'),
352 $row_id_token
353 )->withAsync(true),
354 ];
355 }
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Definition: URLBuilder.php:166

◆ getColumns()

ILIAS\Forum\Notification\ForumNotificationTable::getColumns ( )
private
Returns
array<string, Column>

Definition at line 419 of file ForumNotificationTable.php.

419 : array
420 {
421 return [
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')
427 )
428 ->withIsSortable(false),
429 'role' => $this->ui_factory->table()->column()->text($this->lng->txt('role')),
430 ];
431 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getComponents()

ILIAS\Forum\Notification\ForumNotificationTable::getComponents ( )
Returns
array{ 0: FilterComponent, 1: DataTable }

Definition at line 110 of file ForumNotificationTable.php.

◆ getFilterComponent()

ILIAS\Forum\Notification\ForumNotificationTable::getFilterComponent ( )

Definition at line 152 of file ForumNotificationTable.php.

152 : FilterComponent
153 {
154 if (!isset($this->filter_component)) {
155 $filter_inputs = [];
156 $is_input_initially_rendered = [];
157 $field_factory = $this->ui_factory->input()->field();
158
159 foreach ($this->getFilterFields($field_factory) as $filter_id => $filter) {
160 [$filter_inputs[$filter_id], $is_input_initially_rendered[$filter_id]] = $filter;
161 }
162
163 $this->filter_component = $this->ui_service->filter()->standard(
164 'forum_notification_filter',
165 $this->action,
166 $filter_inputs,
167 $is_input_initially_rendered,
168 true,
169 true
170 );
171 }
172
174 }

◆ getFilteredUserIds()

ILIAS\Forum\Notification\ForumNotificationTable::getFilteredUserIds ( ?array  $filter_data)
Parameters
array{rolestring}|null $filter_data
Returns
list<int>

Definition at line 213 of file ForumNotificationTable.php.

213 : array
214 {
215 $moderator_ids = ilForum::_getModerators($this->ref_id);
216
217 $admin_ids = $this->participants->getAdmins();
218 $member_ids = $this->participants->getMembers();
219 $tutor_ids = $this->participants->getTutors();
220
221 $filter = (string) ($filter_data['role'] ?? '');
222 switch ($filter) {
223 case 'member':
224 $user_ids = $member_ids;
225 break;
226
227 case 'tutor':
228 $user_ids = $tutor_ids;
229 break;
230
231 case 'admin':
232 $user_ids = $admin_ids;
233 break;
234
235 case 'moderators':
236 $user_ids = $moderator_ids;
237 break;
238
239 default:
240 $user_ids = array_merge($admin_ids, $member_ids, $tutor_ids, $moderator_ids);
241 break;
242 }
243
244 return array_unique($user_ids);
245 }
static _getModerators(int $a_ref_id)

References ilForum\_getModerators().

+ Here is the call graph for this function:

◆ getFilterFields()

ILIAS\Forum\Notification\ForumNotificationTable::getFilterFields ( Factory  $field_factory)
Returns
array<string, array{0: FilterInput, 1: bool}>

Definition at line 179 of file ForumNotificationTable.php.

179 : array
180 {
181 $options = [
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'),
186 ];
187
188 return [
189 'role' => [
190 $field_factory->select($this->lng->txt('roles'), $options),
191 true
192 ]
193 ];
194 }
return true
select(string $label, array $options, ?string $byline=null)

References ILIAS\UI\Implementation\Component\Input\Field\$options, ILIAS\Repository\lng(), ILIAS\UI\Component\Input\Field\Factory\select(), and true.

+ Here is the call graph for this function:

◆ getRecords()

ILIAS\Forum\Notification\ForumNotificationTable::getRecords ( Range  $range,
Order  $order,
?array  $filter_data 
)
private
Parameters
array{rolestring}|null $filter_data
Returns
list<array{ 'user_id': int, 'login': string, 'firstname': string, 'lastname': string, 'user_toggle_noti': Icon, 'role': string, }>

Definition at line 258 of file ForumNotificationTable.php.

258 : array
259 {
260 $this->initRecords($filter_data);
262
263 if ($order) {
264 $records = $this->orderRecords($records, $order);
265 }
266
267 if ($range) {
268 $records = $this->limitRecords($records, $range);
269 }
270
271 return $records;
272 }

References ILIAS\UI\Implementation\Component\Table\$range.

◆ getRows()

ILIAS\Forum\Notification\ForumNotificationTable::getRows ( DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)
Parameters
array{rolestring}|null $filter_data

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 79 of file ForumNotificationTable.php.

87 : Generator {
88 $records = $this->getRecords($range, $order, $filter_data);
89 foreach ($records as $record) {
90 yield $row_builder->buildDataRow((string) $record['user_id'], $record);
91 }
92 }
getRecords(Range $range, Order $order, ?array $filter_data)
buildDataRow(string $id, array $record)

References ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow().

+ Here is the call graph for this function:

◆ getTableComponent()

ILIAS\Forum\Notification\ForumNotificationTable::getTableComponent ( )

Definition at line 115 of file ForumNotificationTable.php.

115 : DataTable
116 {
117 if (!isset($this->table_component)) {
118 $query_params_namespace = ['frm', 'notifications', 'table'];
119 $table_uri = $this->data_factory->uri(ilUtil::_getHttpPath() . '/' . $this->action);
120 $url_builder = new URLBuilder($table_uri);
121 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
122 $query_params_namespace,
123 'action',
124 'usr_ids'
125 );
126
127 $this->table_component = $this->ui_factory->table()
128 ->data(
129 $this,
130 $this->lng->txt(''),
131 $this->getColumns()
132 )
133 ->withFilter(
134 $this->ui_service->filter()->getData(
135 $this->getFilterComponent()
136 )
137 )
138 ->withActions(
139 $this->getActions(
140 $url_builder,
141 $action_parameter_token,
142 $row_id_token
143 )
144 )
145 ->withId('forum_notification_table')
146 ->withRequest($this->http_request);
147 }
148
150 }
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
static _getHttpPath()

References ilUtil\_getHttpPath(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\Forum\Notification\ForumNotificationTable::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)
Parameters
array{rolestring}|null $filter_data

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 199 of file ForumNotificationTable.php.

203 : ?int {
204 $this->initRecords($filter_data);
205
206 return \count((array) $this->records);
207 }

◆ getUserNotificationTableData()

ILIAS\Forum\Notification\ForumNotificationTable::getUserNotificationTableData ( array  $user_ids)
private
Parameters
int[]$user_ids
Returns
list<array{ 'user_id': int, 'login': string, 'firstname': string, 'lastname': string, 'user_toggle_noti': Icon, 'role': string, }>

Definition at line 285 of file ForumNotificationTable.php.

285 : array
286 {
287 $icons = [
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'),
290 ];
291
292 $counter = 0;
293 $users = [];
294 $moderator_ids = ilForum::_getModerators($this->ref_id);
295 foreach ($user_ids as $user_id) {
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});
303
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'),
309 default => ''
310 };
311 }, $this->participants->getAssignedRoles($user_id)));
312 if (\in_array($user_id, $moderator_ids, true)) {
313 $types .= ', ' . $this->lng->txt('frm_moderators');
314 }
315
316 $users[$counter]['user_id'] = $user_id;
317 $users[$counter]['login'] = ilObjUser::_lookupLogin($user_id);
319 $users[$counter]['firstname'] = $name['firstname'];
320 $users[$counter]['lastname'] = $name['lastname'];
321 $users[$counter]['user_toggle_noti'] = $icons[(int) $forced_events->getUserToggle()];
322 $users[$counter]['role'] = $types;
323
324 $counter++;
325 }
326
327 return $users;
328 }
static _lookupName(int $a_user_id)
static _lookupLogin(int $a_user_id)
Base class for course and group participants.
$counter

References $counter, $user_id, ilForum\_getModerators(), ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ILIAS\Repository\int(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ initRecords()

ILIAS\Forum\Notification\ForumNotificationTable::initRecords ( ?array  $filter_data)
Parameters
array{rolestring}|null $filter_data

Definition at line 97 of file ForumNotificationTable.php.

97 : void
98 {
99 if ($this->records === null) {
100 $this->records = $this->getUserNotificationTableData($this->getFilteredUserIds($filter_data));
101 }
102 }

◆ limitRecords()

ILIAS\Forum\Notification\ForumNotificationTable::limitRecords ( array  $records,
Range  $range 
)
private
Parameters
list<array{'user_id': int, 'login': string, 'firstname': string, 'lastname': string, 'user_toggle_noti': Icon, 'role': string, }> $records
Returns
list<array{ 'user_id': int, 'login': string, 'firstname': string, 'lastname': string, 'user_toggle_noti': Icon, 'role': string, }>>

Definition at line 375 of file ForumNotificationTable.php.

375 : array
376 {
377 return \array_slice($records, $range->getStart(), $range->getLength());
378 }

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

+ Here is the call graph for this function:

◆ orderRecords()

ILIAS\Forum\Notification\ForumNotificationTable::orderRecords ( array  $records,
Order  $order 
)
private
Parameters
list<array{'user_id': int, 'login': string, 'firstname': string, 'lastname': string, 'user_toggle_noti': Icon, 'role': string, }> $records
Returns
list<array{ 'user_id': int, 'login': string, 'firstname': string, 'lastname': string, 'user_toggle_noti': Icon, 'role': string, }>

Definition at line 398 of file ForumNotificationTable.php.

398 : array
399 {
400 [$order_field, $order_direction] = $order->join(
401 [],
402 fn($ret, $key, $value) => [$key, $value]
403 );
404 usort($records, static fn(array $left, array $right): int => ilStr::strCmp(
405 $left[$order_field] ?? '',
406 $right[$order_field] ?? ''
407 ));
408
409 if ($order_direction === Order::DESC) {
410 $records = array_reverse($records);
411 }
412
413 return $records;
414 }
join($init, callable $fn)
Definition: Order.php:75
const DESC
Definition: Order.php:31
static strCmp(string $a, string $b)
Definition: class.ilStr.php:87

References ILIAS\Data\Order\join(), and ilStr\strCmp().

+ Here is the call graph for this function:

Field Documentation

◆ $filter_component

FilterComponent ILIAS\Forum\Notification\ForumNotificationTable::$filter_component
private

Definition at line 60 of file ForumNotificationTable.php.

◆ $records

array ILIAS\Forum\Notification\ForumNotificationTable::$records = null
private

Definition at line 59 of file ForumNotificationTable.php.

◆ $table_component

DataTable ILIAS\Forum\Notification\ForumNotificationTable::$table_component
private

Definition at line 61 of file ForumNotificationTable.php.


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