ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 (\ILIAS\UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters,)
 
 initRecords (?array $filter_data)
 
 getComponents ()
 
 getTableComponent ()
 
 getFilterComponent ()
 
 getFilterFields (Factory $field_factory)
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 
 getFilteredUserIds (?array $filter_data)
 
 getActions (URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
 
- Public Member Functions inherited from ILIAS\UI\Component\Table\DataRetrieval
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. 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 48 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 62 of file ForumNotificationTable.php.

72  {
73  }

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

References ILIAS\Repository\lng(), and ILIAS\UI\URLBuilder\withParameter().

Referenced by ILIAS\Forum\Notification\ForumNotificationTable\getTableComponent().

332  : array {
333  return [
334  'enableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
335  $this->lng->txt('enable_hide_user_toggle'),
336  $url_builder->withParameter($action_parameter_token, 'enableHideUserToggleNoti'),
337  $row_id_token
338  ),
339  'disableHideUserToggleNoti' => $this->ui_factory->table()->action()->multi(
340  $this->lng->txt('disable_hide_user_toggle'),
341  $url_builder->withParameter($action_parameter_token, 'disableHideUserToggleNoti'),
342  $row_id_token
343  ),
344  'notificationSettings' => $this->ui_factory->table()->action()->single(
345  $this->lng->txt('notification_settings'),
346  $url_builder->withParameter($action_parameter_token, 'notificationSettings'),
347  $row_id_token
348  )->withAsync(true),
349  ];
350  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumns()

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

Definition at line 414 of file ForumNotificationTable.php.

References ILIAS\Repository\lng().

Referenced by ILIAS\Forum\Notification\ForumNotificationTable\getTableComponent().

414  : array
415  {
416  return [
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')
422  )
423  ->withIsSortable(false),
424  'role' => $this->ui_factory->table()->column()->text($this->lng->txt('role')),
425  ];
426  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponents()

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

Definition at line 108 of file ForumNotificationTable.php.

References ILIAS\Forum\Notification\ForumNotificationTable\getFilterComponent(), and ILIAS\Forum\Notification\ForumNotificationTable\getTableComponent().

+ Here is the call graph for this function:

◆ getFilterComponent()

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

Definition at line 150 of file ForumNotificationTable.php.

References ILIAS\Forum\Notification\ForumNotificationTable\$filter_component, and ILIAS\Forum\Notification\ForumNotificationTable\getFilterFields().

Referenced by ILIAS\Forum\Notification\ForumNotificationTable\getComponents(), and ILIAS\Forum\Notification\ForumNotificationTable\getTableComponent().

151  {
152  if (!isset($this->filter_component)) {
153  $filter_inputs = [];
154  $is_input_initially_rendered = [];
155  $field_factory = $this->ui_factory->input()->field();
156 
157  foreach ($this->getFilterFields($field_factory) as $filter_id => $filter) {
158  [$filter_inputs[$filter_id], $is_input_initially_rendered[$filter_id]] = $filter;
159  }
160 
161  $this->filter_component = $this->ui_service->filter()->standard(
162  'forum_notification_filter',
163  $this->action,
164  $filter_inputs,
165  $is_input_initially_rendered,
166  true,
167  true
168  );
169  }
170 
172  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilteredUserIds()

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

Definition at line 208 of file ForumNotificationTable.php.

References ilForum\_getModerators().

Referenced by ILIAS\Forum\Notification\ForumNotificationTable\initRecords().

208  : array
209  {
210  $moderator_ids = ilForum::_getModerators($this->ref_id);
211 
212  $admin_ids = $this->participants->getAdmins();
213  $member_ids = $this->participants->getMembers();
214  $tutor_ids = $this->participants->getTutors();
215 
216  $filter = (string) ($filter_data['role'] ?? '');
217  switch ($filter) {
218  case 'member':
219  $user_ids = $member_ids;
220  break;
221 
222  case 'tutor':
223  $user_ids = $tutor_ids;
224  break;
225 
226  case 'admin':
227  $user_ids = $admin_ids;
228  break;
229 
230  case 'moderators':
231  $user_ids = $moderator_ids;
232  break;
233 
234  default:
235  $user_ids = array_merge($admin_ids, $member_ids, $tutor_ids, $moderator_ids);
236  break;
237  }
238 
239  return array_unique($user_ids);
240  }
static _getModerators(int $a_ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilterFields()

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

Definition at line 177 of file ForumNotificationTable.php.

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

Referenced by ILIAS\Forum\Notification\ForumNotificationTable\getFilterComponent().

177  : array
178  {
179  $options = [
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'),
184  ];
185 
186  return [
187  'role' => [
188  $field_factory->select($this->lng->txt('roles'), $options),
189  true
190  ]
191  ];
192  }
+ Here is the call graph for this function:
+ Here is the caller 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 253 of file ForumNotificationTable.php.

References ILIAS\Forum\Notification\ForumNotificationTable\$records, ILIAS\Forum\Notification\ForumNotificationTable\initRecords(), ILIAS\Forum\Notification\ForumNotificationTable\limitRecords(), and ILIAS\Forum\Notification\ForumNotificationTable\orderRecords().

Referenced by ILIAS\Forum\Notification\ForumNotificationTable\getRows().

253  : array
254  {
255  $this->initRecords($filter_data);
257 
258  if ($order) {
259  $records = $this->orderRecords($records, $order);
260  }
261 
262  if ($range) {
264  }
265 
266  return $records;
267  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRows()

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

Definition at line 78 of file ForumNotificationTable.php.

References ILIAS\Forum\Notification\ForumNotificationTable\getRecords().

85  : Generator {
86  $records = $this->getRecords($range, $order, $filter_data);
87  foreach ($records as $record) {
88  yield $row_builder->buildDataRow((string) $record['user_id'], $record);
89  }
90  }
getRecords(Range $range, Order $order, ?array $filter_data)
+ Here is the call graph for this function:

◆ getTableComponent()

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

Definition at line 113 of file ForumNotificationTable.php.

References ILIAS\Forum\Notification\ForumNotificationTable\$table_component, ilUtil\_getHttpPath(), ILIAS\Forum\Notification\ForumNotificationTable\getActions(), ILIAS\Forum\Notification\ForumNotificationTable\getColumns(), ILIAS\Forum\Notification\ForumNotificationTable\getFilterComponent(), and ILIAS\Repository\lng().

Referenced by ILIAS\Forum\Notification\ForumNotificationTable\getComponents().

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

◆ getTotalRowCount()

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

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 197 of file ForumNotificationTable.php.

References ILIAS\Forum\Notification\ForumNotificationTable\initRecords().

197  : ?int
198  {
199  $this->initRecords($filter_data);
200 
201  return \count((array) $this->records);
202  }
+ Here is the call graph for this function:

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

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

Referenced by ILIAS\Forum\Notification\ForumNotificationTable\initRecords().

280  : array
281  {
282  $icons = [
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'),
285  ];
286 
287  $counter = 0;
288  $users = [];
289  $moderator_ids = ilForum::_getModerators($this->ref_id);
290  foreach ($user_ids as $user_id) {
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});
298 
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'),
304  default => ''
305  };
306  }, $this->participants->getAssignedRoles($user_id)));
307  if (\in_array($user_id, $moderator_ids, true)) {
308  $types .= ', ' . $this->lng->txt('frm_moderators');
309  }
310 
311  $users[$counter]['user_id'] = $user_id;
312  $users[$counter]['login'] = ilObjUser::_lookupLogin($user_id);
313  $name = ilObjUser::_lookupName($user_id);
314  $users[$counter]['firstname'] = $name['firstname'];
315  $users[$counter]['lastname'] = $name['lastname'];
316  $users[$counter]['user_toggle_noti'] = $icons[(int) $forced_events->getUserToggle()];
317  $users[$counter]['role'] = $types;
318 
319  $counter++;
320  }
321 
322  return $users;
323  }
static _lookupName(int $a_user_id)
lookup user name
static _getModerators(int $a_ref_id)
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initRecords()

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

Definition at line 95 of file ForumNotificationTable.php.

References ILIAS\Forum\Notification\ForumNotificationTable\getFilteredUserIds(), ILIAS\Forum\Notification\ForumNotificationTable\getUserNotificationTableData(), and null.

Referenced by ILIAS\Forum\Notification\ForumNotificationTable\getRecords(), and ILIAS\Forum\Notification\ForumNotificationTable\getTotalRowCount().

95  : void
96  {
97  if ($this->records === null) {
98  $this->records = $this->getUserNotificationTableData($this->getFilteredUserIds($filter_data));
99  }
100  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

References ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

Referenced by ILIAS\Forum\Notification\ForumNotificationTable\getRecords().

+ Here is the call graph for this function:
+ Here is the caller 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 393 of file ForumNotificationTable.php.

References ILIAS\Forum\Notification\ForumNotificationTable\$records, ILIAS\Data\Order\DESC, ILIAS\Data\Order\join(), and ilStr\strCmp().

Referenced by ILIAS\Forum\Notification\ForumNotificationTable\getRecords().

393  : array
394  {
395  [$order_field, $order_direction] = $order->join(
396  [],
397  fn($ret, $key, $value) => [$key, $value]
398  );
399  usort($records, static fn(array $left, array $right): int => ilStr::strCmp(
400  $left[$order_field] ?? '',
401  $right[$order_field] ?? ''
402  ));
403 
404  if ($order_direction === Order::DESC) {
405  $records = array_reverse($records);
406  }
407 
408  return $records;
409  }
static strCmp(string $a, string $b)
Definition: class.ilStr.php:87
const DESC
Definition: Order.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $filter_component

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

◆ $records

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

◆ $table_component

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

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