ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
LDAPRoleMappingTable Class Reference
+ Inheritance diagram for LDAPRoleMappingTable:
+ Collaboration diagram for LDAPRoleMappingTable:

Public Member Functions

 __construct (private readonly ServerRequestInterface $http_request, private readonly ilLanguage $lng, private readonly UIFactory $ui_factory, private readonly int $server_id, private readonly ilObjectDataCache $object_data_cache, private readonly ilRbacReview $rbac_review, private readonly \ILIAS\Data\URI $action_url)
 
 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.g. More...
 
 initRecords ()
 
 getComponent ()
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
 getActions (URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
 
 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...
 
 getTotalRowCount (?array $filter_data, ?array $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)
 
 limitRecords (array $records, Range $range)
 
 orderRecords (array $records, Order $order)
 
 getColumns ()
 

Private Attributes

array $records = null
 

Detailed Description

Definition at line 32 of file LDAPRoleMappingTable.php.

Constructor & Destructor Documentation

◆ __construct()

LDAPRoleMappingTable::__construct ( private readonly ServerRequestInterface  $http_request,
private readonly ilLanguage  $lng,
private readonly UIFactory  $ui_factory,
private readonly int  $server_id,
private readonly ilObjectDataCache  $object_data_cache,
private readonly ilRbacReview  $rbac_review,
private readonly \ILIAS\Data\URI  $action_url 
)

Definition at line 45 of file LDAPRoleMappingTable.php.

53 {
54 }

Member Function Documentation

◆ getActions()

LDAPRoleMappingTable::getActions ( URLBuilder  $url_builder,
URLBuilderToken  $action_parameter_token,
URLBuilderToken  $row_id_token 
)
Returns
array<string, Action>

Definition at line 153 of file LDAPRoleMappingTable.php.

153 : array
154 {
155 $actions = [];
156 $actions['delete'] = $this->ui_factory->table()->action()->multi(
157 $this->lng->txt('delete'),
158 $url_builder->withParameter($action_parameter_token, 'confirmDeleteRoleMapping'),
159 $row_id_token
160 );
161
162 $actions['copy'] = $this->ui_factory->table()->action()->single(
163 $this->lng->txt('copy'),
164 $url_builder->withParameter($action_parameter_token, 'addRoleMapping'),
165 $row_id_token
166 );
167
168 $actions['edit'] = $this->ui_factory->table()->action()->single(
169 $this->lng->txt('edit'),
170 $url_builder->withParameter($action_parameter_token, 'editRoleMapping'),
171 $row_id_token
172 );
173
174 return $actions;
175 }
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Definition: URLBuilder.php:166

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

+ Here is the call graph for this function:

◆ getColumns()

LDAPRoleMappingTable::getColumns ( )
private
Returns
array<string, Column>

Definition at line 243 of file LDAPRoleMappingTable.php.

243 : array
244 {
245 return [
246 'title' => $this->ui_factory->table()->column()->text($this->lng->txt('title')),
247 'role' => $this->ui_factory->table()->column()->text($this->lng->txt('obj_role')),
248 'dn' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_group_dn')),
249 'url' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_server')),
250 'member_attribute' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_group_member')),
251 'info' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_info_text')),
252 ];
253 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getComponent()

LDAPRoleMappingTable::getComponent ( )

Definition at line 91 of file LDAPRoleMappingTable.php.

91 : DataTable
92 {
93 $query_params_namespace = ['ldap', 'role', 'mapping'];
94 $url_builder = new URLBuilder($this->action_url);
95 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
96 $query_params_namespace,
97 'table_action',
98 'mapping_ids'
99 );
100
101 return $this->ui_factory->table()
102 ->data(
103 $this,
104 $this->lng->txt('mail_templates'),
105 $this->getColumns()
106 )
107 ->withTitle($this->lng->txt('ldap_role_group_assignments'))
108 ->withActions($this->getActions($url_builder, $action_parameter_token, $row_id_token))
109 ->withId(
110 'ldap_role_mapping_table'
111 )
112 ->withOrder(new Order('title', Order::DESC))
113 ->withRequest($this->http_request);
114 }
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRecords()

LDAPRoleMappingTable::getRecords ( Range  $range,
Order  $order 
)
private
Returns
list<array{ 'id': int, 'title': string, 'role': string, 'dn': string, 'url': string, 'member_attribute': string, 'info': string }>

Definition at line 134 of file LDAPRoleMappingTable.php.

134 : array
135 {
136 $this->initRecords();
138
139 if ($order) {
140 $records = $this->orderRecords($records, $order);
141 }
142
143 if ($range) {
144 $records = $this->limitRecords($records, $range);
145 }
146
147 return $records;
148 }
orderRecords(array $records, Order $order)
limitRecords(array $records, Range $range)

References ILIAS\UI\Implementation\Component\Table\$range.

◆ getRows()

LDAPRoleMappingTable::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.g.

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

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 56 of file LDAPRoleMappingTable.php.

63 : Generator {
64 $records = $this->getRecords($range, $order);
65 foreach ($records as $record) {
66 yield $row_builder->buildDataRow((string) $record['id'], $record);
67 }
68 }
getRecords(Range $range, Order $order)

◆ getTotalRowCount()

LDAPRoleMappingTable::getTotalRowCount ( ?array  $filter_data,
?array  $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 116 of file LDAPRoleMappingTable.php.

116 : ?int
117 {
118 $this->initRecords();
119
120 return count((array) $this->records);
121 }

◆ initRecords()

LDAPRoleMappingTable::initRecords ( )

Definition at line 70 of file LDAPRoleMappingTable.php.

70 : void
71 {
72 if ($this->records === null) {
73 $this->records = [];
74 $mapping_instance = ilLDAPRoleGroupMappingSettings::_getInstanceByServerId($this->server_id);
75 $mappings = $mapping_instance->getMappings();
76 foreach ($mappings as $item) {
77 $title = $this->object_data_cache->lookupTitle($this->rbac_review->getObjectOfRole((int) $item['role']));
78 $this->records[] = [
79 'id' => $item['mapping_id'],
80 'title' => ilStr::shortenTextExtended($title, 30, true),
81 'role' => $item['role_name'],
82 'dn' => $item['dn'],
83 'url' => $item['url'],
84 'member_attribute' => $item['member_attribute'],
85 'info' => ilLegacyFormElementsUtil::prepareFormOutput($item['info'])
86 ];
87 }
88 }
89 }
static _getInstanceByServerId(int $a_server_id)
Get instance of class.
static prepareFormOutput($a_str, bool $a_strip=false)
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)

References ilLDAPRoleGroupMappingSettings\_getInstanceByServerId(), ilLegacyFormElementsUtil\prepareFormOutput(), and ilStr\shortenTextExtended().

+ Here is the call graph for this function:

◆ limitRecords()

LDAPRoleMappingTable::limitRecords ( array  $records,
Range  $range 
)
private
Parameters
list<array{'id': int, 'title': string, 'role': string, 'dn': string, 'url': string, 'member_attribute': string, 'info': string }> $records
Returns
list<array{ 'id': int, 'title': string, 'role': string, 'dn': string, 'url': string, 'member_attribute': string, 'info': string }>>

Definition at line 197 of file LDAPRoleMappingTable.php.

197 : array
198 {
199 return array_slice($records, $range->getStart(), $range->getLength());
200 }

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()

LDAPRoleMappingTable::orderRecords ( array  $records,
Order  $order 
)
private
Parameters
list<array{'id': int, 'title': string, 'role': string, 'dn': string, 'url': string, 'member_attribute': string, 'info': string }> $records
Returns
list<array{ 'id': int, 'title': string, 'role': string, 'dn': string, 'url': string, 'member_attribute': string, 'info': string }>

Definition at line 222 of file LDAPRoleMappingTable.php.

222 : array
223 {
224 [$order_field, $order_direction] = $order->join(
225 [],
226 fn($ret, $key, $value) => [$key, $value]
227 );
228 usort($records, static fn(array $left, array $right): int => ilStr::strCmp(
229 $left[$order_field] ?? '',
230 $right[$order_field] ?? ''
231 ));
232
233 if ($order_direction === Order::DESC) {
234 $records = array_reverse($records);
235 }
236
237 return $records;
238 }
join($init, callable $fn)
Definition: Order.php:75
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

◆ $records

array LDAPRoleMappingTable::$records = null
private

Definition at line 43 of file LDAPRoleMappingTable.php.


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