19declare(strict_types=1);
29use Psr\Http\Message\ServerRequestInterface;
46 private readonly ServerRequestInterface $http_request,
48 private readonly UIFactory $ui_factory,
49 private readonly \
ILIAS\Data\URI $action_url,
50 private readonly
int $server_id
56 array $visible_column_ids,
60 ?array $additional_parameters,
64 yield $row_builder->buildDataRow((
string) $record[
'id'], $record);
68 public function initRecords(): void
70 if ($this->records ===
null) {
72 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_not_ok.svg',
'',
'small'),
73 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_ok.svg',
'',
'small')
78 foreach ($rule_objs as $rule) {
79 switch ($rule->getType()) {
81 $type = $this->
lng->txt(
'ldap_role_by_attribute');
85 $type = $this->
lng->txt(
'ldap_role_by_group');
89 $type = $this->
lng->txt(
'ldap_role_by_plugin');
93 'id' => $rule->getRuleId(),
94 'type' => $type ??
'',
95 'condition' => $rule->conditionToString(),
96 'add' => $icons[(
int) $rule->isAddOnUpdateEnabled()],
97 'remove' => $icons[(
int) $rule->isRemoveOnUpdateEnabled()],
106 $query_params_namespace = [
'ldap',
'role',
'assignment'];
107 $url_builder =
new URLBuilder($this->action_url);
108 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
109 $query_params_namespace,
114 return $this->ui_factory->table()
117 $this->
lng->txt(
'ldap_tbl_role_ass'),
120 ->withActions($this->getActions($url_builder, $action_parameter_token, $row_id_token))
121 ->withId(
'ldap_role_assignment_table')
122 ->withOrder(
new Order(
'type', Order::DESC))
123 ->withRequest($this->http_request);
128 $this->initRecords();
130 return count((array) $this->records);
145 $this->initRecords();
146 $records = $this->records;
149 $records = $this->orderRecords($records, $order);
153 $records = $this->limitRecords($records,
$range);
168 $actions[
'delete'] = $this->ui_factory->table()->action()->multi(
169 $this->
lng->txt(
'delete'),
170 $url_builder->
withParameter($action_parameter_token,
'confirmDeleteRules'),
174 $actions[
'edit'] = $this->ui_factory->table()->action()->single(
175 $this->
lng->txt(
'edit'),
176 $url_builder->
withParameter($action_parameter_token,
'editRoleAssignment'),
226 [$order_field, $order_direction] = $order->
join(
228 fn($ret, $key, $value) => [$key, $value]
230 usort($records,
static fn(array $left, array $right):
int =>
ilStr::strCmp(
231 $left[$order_field] ??
'',
232 $right[$order_field] ??
''
235 if ($order_direction === Order::DESC) {
236 $records = array_reverse($records);
248 'type' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'ldap_rule_type')),
249 'role' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'ldap_ilias_role')),
250 'condition' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'ldap_rule_condition')),
251 'add' => $this->ui_factory->table()->column()->statusIcon($this->
lng->txt(
'ldap_add_roles'))
252 ->withIsSortable(
false),
253 'remove' => $this->ui_factory->table()->column()->statusIcon($this->
lng->txt(
'ldap_remove_roles'))
254 ->withIsSortable(
false),
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
join($init, callable $fn)
A simple class to express a naive range of whole positive numbers.
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
orderRecords(array $records, Order $order)
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
limitRecords(array $records, Range $range)
getRecords(Range $range, Order $order)
__construct(private readonly ServerRequestInterface $http_request, private readonly ilLanguage $lng, private readonly UIFactory $ui_factory, private readonly \ILIAS\Data\URI $action_url, private readonly int $server_id)
getRows(ILIAS\UI\Component\Table\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....
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
static _getRules($a_server_id)
Get all rules.
static _lookupTitle(int $obj_id)
static strCmp(string $a, string $b)
This describes how an icon could be modified during construction of UI.
A Column describes the form of presentation for a certain aspect of data, i.e.
This describes a Data Table.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.