ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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, private readonly bool $has_write_access)
 
 getRows (ILIAS\UI\Component\Table\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...
 
 initRecords ()
 
 getComponent ()
 
 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...
 
 getActions (URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
 
 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

 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,
private readonly bool  $has_write_access 
)

Definition at line 45 of file LDAPRoleMappingTable.php.

54 {
55 }

Member Function Documentation

◆ getActions()

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

Definition at line 159 of file LDAPRoleMappingTable.php.

159 : array
160 {
161 $actions = [];
162
163 if ($this->has_write_access) {
164 $actions['delete'] = $this->ui_factory->table()->action()->multi(
165 $this->lng->txt('delete'),
166 $url_builder->withParameter($action_parameter_token, 'confirmDeleteRoleMapping'),
167 $row_id_token
168 );
169
170 $actions['copy'] = $this->ui_factory->table()->action()->single(
171 $this->lng->txt('copy'),
172 $url_builder->withParameter($action_parameter_token, 'addRoleMapping'),
173 $row_id_token
174 );
175 }
176
177 $actions['edit'] = $this->ui_factory->table()->action()->single(
178 $this->has_write_access ? $this->lng->txt('edit') : $this->lng->txt('view'),
179 $url_builder->withParameter($action_parameter_token, 'editRoleMapping'),
180 $row_id_token
181 );
182
183 return $actions;
184 }
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 252 of file LDAPRoleMappingTable.php.

252 : array
253 {
254 return [
255 'title' => $this->ui_factory->table()->column()->text($this->lng->txt('title')),
256 'role' => $this->ui_factory->table()->column()->text($this->lng->txt('obj_role')),
257 'dn' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_group_dn')),
258 'url' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_server')),
259 'member_attribute' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_group_member')),
260 'info' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_info_text')),
261 ];
262 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getComponent()

LDAPRoleMappingTable::getComponent ( )

Definition at line 93 of file LDAPRoleMappingTable.php.

93 : DataTable
94 {
95 $query_params_namespace = ['ldap', 'role', 'mapping'];
96 $url_builder = new URLBuilder($this->action_url);
97 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
98 $query_params_namespace,
99 'table_action',
100 'mapping_ids'
101 );
102
103 return $this->ui_factory->table()
104 ->data(
105 $this,
106 $this->lng->txt('mail_templates'),
107 $this->getColumns()
108 )
109 ->withTitle($this->lng->txt('ldap_role_group_assignments'))
110 ->withActions($this->getActions($url_builder, $action_parameter_token, $row_id_token))
111 ->withId(
112 'ldap_role_mapping_table'
113 )
114 ->withOrder(new Order('title', Order::DESC))
115 ->withRange(new Range(0, 100))
116 ->withRequest($this->http_request);
117 }
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.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 140 of file LDAPRoleMappingTable.php.

140 : array
141 {
142 $this->initRecords();
144
145 if ($order) {
146 $records = $this->orderRecords($records, $order);
147 }
148
149 if ($range) {
150 $records = $this->limitRecords($records, $range);
151 }
152
153 return $records;
154 }
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,
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 57 of file LDAPRoleMappingTable.php.

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

◆ getTotalRowCount()

LDAPRoleMappingTable::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 119 of file LDAPRoleMappingTable.php.

123 : ?int {
124 $this->initRecords();
125
126 return count((array) $this->records);
127 }

◆ initRecords()

LDAPRoleMappingTable::initRecords ( )

Definition at line 72 of file LDAPRoleMappingTable.php.

72 : void
73 {
74 if ($this->records === null) {
75 $this->records = [];
76 $mapping_instance = ilLDAPRoleGroupMappingSettings::_getInstanceByServerId($this->server_id);
77 $mappings = $mapping_instance->getMappings();
78 foreach ($mappings as $item) {
79 $title = $this->object_data_cache->lookupTitle($this->rbac_review->getObjectOfRole((int) $item['role']));
80 $this->records[] = [
81 'id' => $item['mapping_id'],
82 'title' => ilStr::shortenTextExtended($title, 30, true),
83 'role' => $item['role_name'],
84 'dn' => $item['dn'],
85 'url' => $item['url'],
86 'member_attribute' => $item['member_attribute'],
87 'info' => ilLegacyFormElementsUtil::prepareFormOutput($item['info'])
88 ];
89 }
90 }
91 }
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 206 of file LDAPRoleMappingTable.php.

206 : array
207 {
208 return array_slice($records, $range->getStart(), $range->getLength());
209 }

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 231 of file LDAPRoleMappingTable.php.

231 : array
232 {
233 [$order_field, $order_direction] = $order->join(
234 [],
235 fn($ret, $key, $value) => [$key, $value]
236 );
237 usort($records, static fn(array $left, array $right): int => ilStr::strCmp(
238 $left[$order_field] ?? '',
239 $right[$order_field] ?? ''
240 ));
241
242 if ($order_direction === Order::DESC) {
243 $records = array_reverse($records);
244 }
245
246 return $records;
247 }
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: