ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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 334 of file ForumNotificationTable.php.

338 : array {
339 return [
340 'enableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
341 $this->lng->txt('enable_hide_user_toggle'),
342 $url_builder->withParameter($action_parameter_token, 'enableHideUserToggleNoti'),
343 $row_id_token
344 ),
345 'disableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
346 $this->lng->txt('disable_hide_user_toggle'),
347 $url_builder->withParameter($action_parameter_token, 'disableHideUserToggleNoti'),
348 $row_id_token
349 ),
350 'notificationSettings' => $this->ui_factory->table()->action()->single(
351 $this->lng->txt('notification_settings'),
352 $url_builder->withParameter($action_parameter_token, 'notificationSettings'),
353 $row_id_token
354 )->withAsync(true),
355 ];
356 }
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 420 of file ForumNotificationTable.php.

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

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 153 of file ForumNotificationTable.php.

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

◆ getFilteredUserIds()

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

Definition at line 214 of file ForumNotificationTable.php.

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

180 : array
181 {
182 $options = [
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'),
187 ];
188
189 return [
190 'role' => [
191 $field_factory->select($this->lng->txt('roles'), $options),
192 true
193 ]
194 ];
195 }
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 259 of file ForumNotificationTable.php.

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

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 ->withRange(new Range(0, 50))
147 ->withRequest($this->http_request);
148 }
149
151 }
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
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 200 of file ForumNotificationTable.php.

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

◆ 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 286 of file ForumNotificationTable.php.

286 : array
287 {
288 $icons = [
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'),
291 ];
292
293 $counter = 0;
294 $users = [];
295 $moderator_ids = ilForum::_getModerators($this->ref_id);
296 foreach ($user_ids as $user_id) {
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});
304
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'),
310 default => ''
311 };
312 }, $this->participants->getAssignedRoles($user_id)));
313 if (\in_array($user_id, $moderator_ids, true)) {
314 $types .= ', ' . $this->lng->txt('frm_moderators');
315 }
316
317 $users[$counter]['user_id'] = $user_id;
318 $users[$counter]['login'] = ilObjUser::_lookupLogin($user_id);
320 $users[$counter]['firstname'] = $name['firstname'];
321 $users[$counter]['lastname'] = $name['lastname'];
322 $users[$counter]['user_toggle_noti'] = $icons[(int) $forced_events->getUserToggle()];
323 $users[$counter]['role'] = $types;
324
325 $counter++;
326 }
327
328 return $users;
329 }
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 376 of file ForumNotificationTable.php.

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

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 399 of file ForumNotificationTable.php.

399 : array
400 {
401 [$order_field, $order_direction] = $order->join(
402 [],
403 fn($ret, $key, $value) => [$key, $value]
404 );
405 usort($records, static fn(array $left, array $right): int => ilStr::strCmp(
406 $left[$order_field] ?? '',
407 $right[$order_field] ?? ''
408 ));
409
410 if ($order_direction === Order::DESC) {
411 $records = array_reverse($records);
412 }
413
414 return $records;
415 }
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: