ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ILIAS\Registration\RegistrationCodesTable Class Reference
+ Inheritance diagram for ILIAS\Registration\RegistrationCodesTable:
+ Collaboration diagram for ILIAS\Registration\RegistrationCodesTable:

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 ilRbacReview $rbac_review, private readonly string $action, private readonly ilObjUser $actor, private readonly RegistrationCodeRepository $code_repository, private readonly bool $has_permission_to_delete=false,)
 
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters,)
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 
 getActions (URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
 

Private Member Functions

 getRecords (Range $range, Order $order, ?array $filter_data)
 
 getColumns ()
 

Detailed Description

Definition at line 44 of file RegistrationCodesTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Registration\RegistrationCodesTable::__construct ( private readonly ServerRequestInterface  $http_request,
private readonly ilLanguage  $lng,
private readonly UIFactory  $ui_factory,
private readonly DataFactory  $data_factory,
private readonly ilRbacReview  $rbac_review,
private readonly string  $action,
private readonly ilObjUser  $actor,
private readonly RegistrationCodeRepository  $code_repository,
private readonly bool  $has_permission_to_delete = false 
)

Definition at line 46 of file RegistrationCodesTable.php.

56  {
57  }

Member Function Documentation

◆ getActions()

ILIAS\Registration\RegistrationCodesTable::getActions ( URLBuilder  $url_builder,
URLBuilderToken  $action_parameter_token,
URLBuilderToken  $row_id_token 
)
Returns
array<string, Action>

Definition at line 247 of file RegistrationCodesTable.php.

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

Referenced by ILIAS\Registration\RegistrationCodesTable\getRows().

251  : array {
252  $actions = [
253  $this->ui_factory->table()->action()->multi(
254  $this->lng->txt('registration_codes_export'),
255  $url_builder->withParameter($action_parameter_token, 'exportCodes'),
256  $row_id_token
257  ),
258  ];
259  if ($this->has_permission_to_delete) {
260  $actions[] = $this->ui_factory->table()->action()->multi(
261  $this->lng->txt('delete'),
262  $url_builder->withParameter($action_parameter_token, 'deleteConfirmation'),
263  $row_id_token
264  );
265  }
266 
267  return $actions;
268  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumns()

ILIAS\Registration\RegistrationCodesTable::getColumns ( )
private
Returns
array<string, Column>

Definition at line 273 of file RegistrationCodesTable.php.

References ILIAS\Repository\lng(), and ilCalendarSettings\TIME_FORMAT_12.

Referenced by ILIAS\Registration\RegistrationCodesTable\getRows().

273  : array
274  {
275  if ((int) $this->actor->getTimeFormat() === ilCalendarSettings::TIME_FORMAT_12) {
276  $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
277  } else {
278  $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
279  }
280 
281  return [
282  'code' => $this->ui_factory->table()->column()
283  ->text($this->lng->txt('registration_code')),
284  'role' => $this->ui_factory->table()->column()
285  ->text($this->lng->txt('registration_codes_roles')),
286  'role_local' => $this->ui_factory->table()->column()
287  ->text($this->lng->txt('registration_codes_roles_local'))
288  ->withIsSortable(false),
289  'alimit' => $this->ui_factory->table()->column()
290  ->text($this->lng->txt('reg_access_limitations'))
291  ->withIsSortable(false),
292  'generated' => $this->ui_factory->table()->column()
293  ->date($this->lng->txt('registration_generated'), $date_format),
294  'used' => $this->ui_factory->table()->column()
295  ->text($this->lng->txt('registration_used')),
296  ];
297  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRecords()

ILIAS\Registration\RegistrationCodesTable::getRecords ( Range  $range,
Order  $order,
?array  $filter_data 
)
private
Parameters
array{codestring, role: int, generated: string, access_limitation: string} $filter_data
Returns
list<array{ code: string, code_id: int, generated: DateTimeImmutable, used: string|null, role: string, role_local: string|null, alimit: string|null }>

Definition at line 125 of file RegistrationCodesTable.php.

References ilObject\_lookupTitle(), ANONYMOUS_ROLE_ID, ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), ILIAS\Repository\int(), ILIAS\Data\Order\join(), ILIAS\Repository\lng(), null, ILIAS\UI\examples\Symbol\Glyph\Sort\sort(), SYSTEM_ROLE_ID, and ilCalendarSettings\TIME_FORMAT_12.

Referenced by ILIAS\Registration\RegistrationCodesTable\getRows().

125  : array
126  {
127  [$order_field, $order_direction] = $order->join(
128  [],
129  fn(array $ret, string $key, string $value): array => [$key, $value]
130  );
131  $filter = (new CodeFilter())->withData($filter_data);
132 
133  $codes_data = $this->code_repository->getCodesData(
134  $order_field,
135  $order_direction,
136  $range->getStart(),
137  $range->getLength(),
138  $filter
139  );
140 
141  if (\count($codes_data) === 0 && $range->getStart() > 0) {
142  $codes_data = $this->code_repository->getCodesData(
143  $order_field,
144  $order_direction,
145  0,
146  $range->getLength(),
147  $filter
148  );
149  }
150 
151  if ((int) $this->actor->getTimeFormat() === ilCalendarSettings::TIME_FORMAT_12) {
152  $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
153  } else {
154  $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
155  }
156 
157  $role_map = [];
158  foreach ($this->rbac_review->getGlobalRoles() as $role_id) {
159  if (!\in_array($role_id, [SYSTEM_ROLE_ID, ANONYMOUS_ROLE_ID], true)) {
160  $role_map[$role_id] = ilObject::_lookupTitle($role_id);
161  }
162  }
163 
164  $result = [];
165  foreach ($codes_data as $k => $code) {
166  $result[$k]['code'] = $code['code'];
167  $result[$k]['code_id'] = (int) $code['code_id'];
168 
169  $result[$k]['generated'] = (new DateTimeImmutable('@' . $code['generated']))->setTimezone(
170  new DateTimeZone($this->actor->getTimeZone())
171  );
172  if ($code['used']) {
173  $result[$k]['used'] = $date_format->applyTo(
174  (new DateTimeImmutable('@' . $code['used']))->setTimezone(
175  new DateTimeZone($this->actor->getTimeZone())
176  )
177  );
178  } else {
179  $result[$k]['used'] = null;
180  }
181 
182  if ($code['role']) {
183  $result[$k]['role'] = $role_map[$code['role']] ?? $this->lng->txt('deleted');
184  } else {
185  $result[$k]['role'] = '';
186  }
187 
188  if (\is_string($code['role_local'])) {
189  $local = [];
190  foreach (explode(';', $code['role_local']) as $role_id) {
191  $role = ilObject::_lookupTitle((int) $role_id);
192  if ($role) {
193  $local[] = $role;
194  }
195  }
196  if (\count($local)) {
197  sort($local);
198  $result[$k]['role_local'] = implode('<br />', $local);
199  }
200  } else {
201  $result[$k]['role_local'] = '';
202  }
203 
204  if ($code['alimit']) {
205  switch ($code['alimit']) {
206  case 'unlimited':
207  $result[$k]['alimit'] = $this->lng->txt('reg_access_limitation_none');
208  break;
209 
210  case 'absolute':
211  $result[$k]['alimit'] = $this->lng->txt('reg_access_limitation_mode_absolute_target') .
212  ': ' .
213  $date_format->applyTo(
214  (new DateTimeImmutable('@' . $code['alimitdt']))->setTimezone(
215  new DateTimeZone($this->actor->getTimeZone())
216  )
217  );
218  break;
219 
220  case 'relative':
221  $limit_caption = [];
222  $limit = unserialize($code['alimitdt'], ['allowed_classes' => false]);
223  if ((int) $limit['d']) {
224  $limit_caption[] = (int) $limit['d'] . ' ' . $this->lng->txt('days');
225  }
226  if ((int) $limit['m']) {
227  $limit_caption[] = (int) $limit['m'] . ' ' . $this->lng->txt('months');
228  }
229  if ((int) $limit['y']) {
230  $limit_caption[] = (int) $limit['y'] . ' ' . $this->lng->txt('years');
231  }
232  if (\count($limit_caption)) {
233  $result[$k]['alimit'] = $this->lng->txt('reg_access_limitation_mode_relative_target') .
234  ': ' . implode(', ', $limit_caption);
235  }
236  break;
237  }
238  }
239  }
240 
241  return $result;
242  }
const SYSTEM_ROLE_ID
Definition: constants.php:29
sort()
description: > Example for rendering a Sort Glyph.
Definition: sort.php:41
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _lookupTitle(int $obj_id)
const ANONYMOUS_ROLE_ID
Definition: constants.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRows()

ILIAS\Registration\RegistrationCodesTable::getRows ( DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
?array  $filter_data,
?array  $additional_parameters 
)
Parameters
array{codestring, role: int, generated: string, access_limitation: string} $filter_data

Definition at line 62 of file RegistrationCodesTable.php.

References ILIAS\Data\Order\DESC, ILIAS\Registration\RegistrationCodesTable\getActions(), ILIAS\Registration\RegistrationCodesTable\getColumns(), ILIAS\Registration\RegistrationFilterComponent\getFilterData(), ILIAS\Registration\RegistrationCodesTable\getRecords(), and ILIAS\UI\Implementation\Component\Table\withOrder().

69  : Generator {
70  $records = $this->getRecords($range, $order, $filter_data);
71  foreach ($records as $record) {
72  yield $row_builder->buildDataRow((string) $record['code_id'], $record);
73  }
74  }
getRecords(Range $range, Order $order, ?array $filter_data)
+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\Registration\RegistrationCodesTable::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)
Parameters
array{codestring, role: int, generated: string, access_limitation: string} $filter_data

Definition at line 106 of file RegistrationCodesTable.php.

106  : ?int
107  {
108  return $this->code_repository->getTotalCodeCount(
109  (new CodeFilter())->withData($filter_data)
110  );
111  }

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