ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 DataFactory $data_factory, private readonly int $server_id, private readonly ilObjectDataCache $object_data_cache, private readonly ilRbacReview $rbac_review,)
 
 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)
 

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 33 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 DataFactory  $data_factory,
private readonly int  $server_id,
private readonly ilObjectDataCache  $object_data_cache,
private readonly ilRbacReview  $rbac_review 
)

Definition at line 46 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 155 of file LDAPRoleMappingTable.php.

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

Referenced by getComponent().

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

◆ getColumns()

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

Definition at line 245 of file LDAPRoleMappingTable.php.

References ILIAS\Repository\lng().

Referenced by getComponent().

245  : array
246  {
247  return [
248  'title' => $this->ui_factory->table()->column()->text($this->lng->txt('title')),
249  'role' => $this->ui_factory->table()->column()->text($this->lng->txt('obj_role')),
250  'dn' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_group_dn')),
251  'url' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_server')),
252  'member_attribute' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_group_member')),
253  'info' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_info_text')),
254  ];
255  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponent()

LDAPRoleMappingTable::getComponent ( )

Definition at line 92 of file LDAPRoleMappingTable.php.

References getActions(), getColumns(), ILIAS\Repository\lng(), and ILIAS\GlobalScreen\Scope\Footer\Factory\withTitle().

92  : DataTable
93  {
94  $query_params_namespace = ['ldap', 'role', 'mapping'];
95  $table_uri = $this->data_factory->uri($this->http_request->getUri()->__toString());
96  $url_builder = new URLBuilder($table_uri);
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  ->withRequest($this->http_request);
116  }
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:28
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
URLBuilder.
Definition: URLBuilder.php:40
+ 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 136 of file LDAPRoleMappingTable.php.

References $records, initRecords(), limitRecords(), and orderRecords().

Referenced by getRows().

136  : array
137  {
138  $this->initRecords();
140 
141  if ($order) {
142  $records = $this->orderRecords($records, $order);
143  }
144 
145  if ($range) {
146  $records = $this->limitRecords($records, $range);
147  }
148 
149  return $records;
150  }
orderRecords(array $records, Order $order)
limitRecords(array $records, Range $range)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

References getRecords().

64  : Generator {
65  $records = $this->getRecords($range, $order);
66  foreach ($records as $record) {
67  yield $row_builder->buildDataRow((string) $record['id'], $record);
68  }
69  }
getRecords(Range $range, Order $order)
+ Here is the call graph for this function:

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

References initRecords().

118  : ?int
119  {
120  $this->initRecords();
121 
122  return count((array) $this->records);
123  }
+ Here is the call graph for this function:

◆ initRecords()

LDAPRoleMappingTable::initRecords ( )

Definition at line 71 of file LDAPRoleMappingTable.php.

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

Referenced by getRecords(), and getTotalRowCount().

71  : void
72  {
73  if ($this->records === null) {
74  $this->records = [];
75  $mapping_instance = ilLDAPRoleGroupMappingSettings::_getInstanceByServerId($this->server_id);
76  $mappings = $mapping_instance->getMappings();
77  foreach ($mappings as $item) {
78  $title = $this->object_data_cache->lookupTitle($this->rbac_review->getObjectOfRole((int) $item['role']));
79  $this->records[] = [
80  'id' => $item['mapping_id'],
81  'title' => ilStr::shortenTextExtended($title, 30, true),
82  'role' => $item['role_name'],
83  'dn' => $item['dn'],
84  'url' => $item['url'],
85  'member_attribute' => $item['member_attribute'],
86  'info' => ilLegacyFormElementsUtil::prepareFormOutput($item['info'])
87  ];
88  }
89  }
90  }
static prepareFormOutput($a_str, bool $a_strip=false)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getInstanceByServerId(int $a_server_id)
Get instance of class.
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
+ Here is the call graph for this function:
+ Here is the caller 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 199 of file LDAPRoleMappingTable.php.

References ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

Referenced by getRecords().

199  : array
200  {
201  return array_slice($records, $range->getStart(), $range->getLength());
202  }
+ Here is the call graph for this function:
+ Here is the caller 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 224 of file LDAPRoleMappingTable.php.

References $records, ILIAS\Data\Order\join(), and ilStr\strCmp().

Referenced by getRecords().

224  : array
225  {
226  [$order_field, $order_direction] = $order->join(
227  [],
228  fn($ret, $key, $value) => [$key, $value]
229  );
230  usort($records, static fn(array $left, array $right): int => ilStr::strCmp(
231  $left[$order_field] ?? '',
232  $right[$order_field] ?? ''
233  ));
234 
235  if ($order_direction === Order::DESC) {
236  $records = array_reverse($records);
237  }
238 
239  return $records;
240  }
join($init, callable $fn)
Definition: Order.php:75
static strCmp(string $a, string $b)
Definition: class.ilStr.php:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $records

array LDAPRoleMappingTable::$records = null
private

Definition at line 44 of file LDAPRoleMappingTable.php.

Referenced by getRecords(), and orderRecords().


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