ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\Badge\ilBadgeUserTableGUI Class Reference
+ Inheritance diagram for ILIAS\Badge\ilBadgeUserTableGUI:
+ Collaboration diagram for ILIAS\Badge\ilBadgeUserTableGUI:

Public Member Functions

 __construct (private readonly ?int $parent_ref_id=null, private readonly ?ilBadge $award_badge=null, private readonly ?int $parent_obj_id=null, private readonly ?int $restrict_badge_id=null)
 
 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...
 
 getColumns ()
 
 renderTable (string $url)
 
 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

 getActions (URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token,)
 

Private Attributes

readonly Factory $factory
 
readonly Renderer $renderer
 
readonly ServerRequestInterface RequestInterface $request
 
readonly ilLanguage $lng
 
readonly ilGlobalTemplateInterface $tpl
 
readonly ilTree $tree
 
readonly ilObjUser $user
 
DateFormat $date_format
 
bool $is_container_context = false
 
array $cached_records = null
 

Detailed Description

Definition at line 50 of file class.ilBadgeUserTableGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Badge\ilBadgeUserTableGUI::__construct ( private readonly ?int  $parent_ref_id = null,
private readonly ?ilBadge  $award_badge = null,
private readonly ?int  $parent_obj_id = null,
private readonly ?int  $restrict_badge_id = null 
)

Definition at line 76 of file class.ilBadgeUserTableGUI.php.

81 {
82 global $DIC;
83
84 $this->lng = $DIC->language();
85 $this->tpl = $DIC->ui()->mainTemplate();
86 $this->factory = $DIC->ui()->factory();
87 $this->renderer = $DIC->ui()->renderer();
88 $this->request = $DIC->http()->request();
89 $this->tree = $DIC->repositoryTree();
90 $this->user = $DIC->user();
91
92 if ($this->parent_ref_id) {
93 $parent_type = ilObject::_lookupType($this->parent_ref_id, true);
94 if (\in_array($parent_type, ['grp', 'crs'], true)) {
95 $this->is_container_context = $this->parent_obj_id === null && $this->award_badge === null;
96 }
97 }
98 }
renderer()
factory()
static _lookupType(int $id, bool $reference=false)
global $DIC
Definition: shib_login.php:26

References $DIC, ilObject\_lookupType(), factory(), ILIAS\Repository\lng(), renderer(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ getActions()

ILIAS\Badge\ilBadgeUserTableGUI::getActions ( URLBuilder  $url_builder,
URLBuilderToken  $action_parameter_token,
URLBuilderToken  $row_id_token 
)
private
Returns
array<string, Action>

Definition at line 324 of file class.ilBadgeUserTableGUI.php.

328 : array {
329 return ($this->award_badge instanceof ilBadge) ? [
330 'badge_award_badge' =>
331 $this->factory->table()->action()->multi(
332 $this->lng->txt('badge_award_badge'),
333 $url_builder->withParameter($action_parameter_token, 'assignBadge'),
334 $row_id_token
335 ),
336 'badge_revoke_badge' =>
337 $this->factory->table()->action()->multi(
338 $this->lng->txt('badge_remove_badge'),
339 $url_builder->withParameter($action_parameter_token, 'revokeBadge'),
340 $row_id_token
341 )
342 ] : [];
343 }
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Definition: URLBuilder.php:166

◆ getColumns()

ILIAS\Badge\ilBadgeUserTableGUI::getColumns ( )
Returns
array<string, Column>

Definition at line 303 of file class.ilBadgeUserTableGUI.php.

303 : array
304 {
305 $columns = [
306 'name' => $this->factory->table()->column()->text($this->lng->txt('name')),
307 'login' => $this->factory->table()->column()->text($this->lng->txt('login')),
308 'type' => $this->factory->table()->column()->text($this->lng->txt('type')),
309 'title' => $this->factory->table()->column()->text($this->lng->txt('title')),
310 // Cannot be a date column, because when awarding/revoking badges for uses, the list items may contain NULL values for `issued`
311 'issued' => $this->factory->table()->column()->text($this->lng->txt('badge_issued_on'))
312 ];
313
314 if ($this->is_container_context) {
315 $columns['parent'] = $this->factory->table()->column()->text($this->lng->txt('object'));
316 }
317
318 return $columns;
319 }

References factory(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRows()

ILIAS\Badge\ilBadgeUserTableGUI::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.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 236 of file class.ilBadgeUserTableGUI.php.

244 : Generator {
245 $records = $this->getRecords();
246
247 if ($order) {
248 [$order_field, $order_direction] = $order->join(
249 [],
250 fn($ret, $key, $value) => [$key, $value]
251 );
252 usort($records, static function (array $left, array $right) use ($order_field): int {
253 if (\in_array($order_field, ['name', 'login', 'type', 'title', 'parent'], true)) {
254 if ($order_field === 'parent') {
255 $order_field .= '_sortable';
256 }
257
258 return \ilStr::strCmp(
259 $left[$order_field] ?? '',
260 $right[$order_field] ?? ''
261 );
262 }
263
264 if ($order_field === 'issued') {
265 $order_field .= '_sortable';
266 return $left[$order_field] <=> $right[$order_field];
267 }
268
269 return $left[$order_field] <=> $right[$order_field];
270 });
271
272 if ($order_direction === ORDER::DESC) {
273 $records = array_reverse($records);
274 }
275 }
276
277 if ($range) {
278 $records = \array_slice($records, $range->getStart(), $range->getLength());
279 }
280
281 foreach ($records as $record) {
282 yield $row_builder->buildDataRow($record['id'], $record)->withDisabledAction(
283 'badge_award_badge',
284 $record['issued'] === null
285 )->withDisabledAction(
286 'badge_revoke_badge',
287 $record['issued'] !== null
288 );
289 }
290 }
join($init, callable $fn)
Definition: Order.php:75
buildDataRow(string $id, array $record)

References ILIAS\Data\Order\join().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\Badge\ilBadgeUserTableGUI::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.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 292 of file class.ilBadgeUserTableGUI.php.

296 : ?int {
297 return \count($this->getRecords());
298 }

◆ renderTable()

ILIAS\Badge\ilBadgeUserTableGUI::renderTable ( string  $url)

Definition at line 345 of file class.ilBadgeUserTableGUI.php.

345 : void
346 {
347 $df = new \ILIAS\Data\Factory();
348 $this->date_format = $this->user->getDateTimeFormat();
349
350 $table_uri = $df->uri($url);
351 $url_builder = new URLBuilder($table_uri);
352 $query_params_namespace = ['tid'];
353
354 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
355 $query_params_namespace,
356 'table_action',
357 'id',
358 );
359
360 if ($this->award_badge instanceof ilBadge) {
361 $title = $this->lng->txt('badge_award_badge') . ': ' . $this->award_badge->getTitle();
362 } else {
363 $parent = '';
364 if ($this->parent_obj_id) {
365 $title = ilObject::_lookupTitle($this->parent_obj_id);
366 if (!$title) {
367 $title = ilObjectDataDeletionLog::get($this->parent_obj_id);
368 if ($title) {
369 $title = $title['title'];
370 }
371 }
372
373 if ($this->restrict_badge_id) {
374 $badge = new ilBadge($this->restrict_badge_id);
375 $title .= ' - ' . $badge->getTitle();
376 }
377
378 $parent = $title . ': ';
379 }
380 $title = $parent . $this->lng->txt('users');
381 }
382
383 $table = $this->factory
384 ->table()
385 ->data($this, $title, $this->getColumns())
386 ->withId(self::class . '_' . $this->parent_ref_id)
387 ->withOrder(new Order('name', Order::ASC))
388 ->withActions($this->getActions($url_builder, $action_parameter_token, $row_id_token))
389 ->withRequest($this->request);
390
391 $out = [$table];
392
393 $this->tpl->setContent($this->renderer->render($out));
394 }
$out
Definition: buildRTE.php:24
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token,)
static _lookupTitle(int $obj_id)
$url
Definition: shib_logout.php:68

References $out, $url, ilObject\_lookupTitle(), factory(), ilObjectDataDeletionLog\get(), ILIAS\Repository\lng(), renderer(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Field Documentation

◆ $cached_records

array ILIAS\Badge\ilBadgeUserTableGUI::$cached_records = null
private

Definition at line 74 of file class.ilBadgeUserTableGUI.php.

◆ $date_format

DateFormat ILIAS\Badge\ilBadgeUserTableGUI::$date_format
private

Definition at line 59 of file class.ilBadgeUserTableGUI.php.

◆ $factory

readonly Factory ILIAS\Badge\ilBadgeUserTableGUI::$factory
private

Definition at line 52 of file class.ilBadgeUserTableGUI.php.

◆ $is_container_context

bool ILIAS\Badge\ilBadgeUserTableGUI::$is_container_context = false
private

Definition at line 60 of file class.ilBadgeUserTableGUI.php.

◆ $lng

readonly ilLanguage ILIAS\Badge\ilBadgeUserTableGUI::$lng
private

Definition at line 55 of file class.ilBadgeUserTableGUI.php.

◆ $renderer

readonly Renderer ILIAS\Badge\ilBadgeUserTableGUI::$renderer
private

Definition at line 53 of file class.ilBadgeUserTableGUI.php.

◆ $request

readonly ServerRequestInterface RequestInterface ILIAS\Badge\ilBadgeUserTableGUI::$request
private

Definition at line 54 of file class.ilBadgeUserTableGUI.php.

◆ $tpl

readonly ilGlobalTemplateInterface ILIAS\Badge\ilBadgeUserTableGUI::$tpl
private

Definition at line 56 of file class.ilBadgeUserTableGUI.php.

◆ $tree

readonly ilTree ILIAS\Badge\ilBadgeUserTableGUI::$tree
private

Definition at line 57 of file class.ilBadgeUserTableGUI.php.

◆ $user

readonly ilObjUser ILIAS\Badge\ilBadgeUserTableGUI::$user
private

Definition at line 58 of file class.ilBadgeUserTableGUI.php.


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