ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\AccessControl\Log\Table Class Reference
+ Inheritance diagram for ILIAS\AccessControl\Log\Table:
+ Collaboration diagram for ILIAS\AccessControl\Log\Table:

Public Member Functions

 __construct (private readonly \ilRbacLog $rbac_log, private readonly UIFactory $ui_factory, private readonly DataFactory $data_factory, private readonly \ilLanguage $lng, private readonly \ilCtrl $ctrl, private readonly \ilUIService $ui_service, private readonly \ilObjectDefinition $object_definition, private readonly RequestInterface $request, \ilRbacReview $rbac_review, private readonly \ilObjUser $current_user, private readonly \ilObjectGUI $gui_object)
 
 getTableAndFilter ()
 
 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...
 
 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

 getTable ()
 
 getFilter ()
 
 getRefId ()
 
 buildUserDateTimeFormat ()
 
 applyFilterValuesTrafos (array $filter_values)
 
 buildChangeColumn (int $action, array $data)
 
 parseChangesFaPa (array $raw)
 
 parseChangesTemplate (array $raw)
 
 getOPCaption (string $type, array|int|string $op)
 
 getNonCreateTranslation (string $type, string $op_id)
 
 getCreateTranslation (string $type, string $op_id)
 
 getTranslationFromPlugin (string $type, string $op_id)
 
 isTranslated (?string $perm, string $op_id)
 

Private Attributes

const FILTER_ID = 'perm_table_filter'
 
const FILTER_FIELD_ACTION = 'action'
 
const FILTER_FIELD_PERIOD = 'period'
 
const COLUMN_DATE = 'created'
 
const COLUMN_NAME = 'name'
 
const COLUMN_LOGIN = 'login'
 
const COLUMN_ACTION = 'action'
 
const COLUMN_CHANGES = 'changes'
 
array $filter_data
 
array $action_map = []
 
array $operations = []
 

Detailed Description

Definition at line 34 of file Table.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\AccessControl\Log\Table::__construct ( private readonly \ilRbacLog  $rbac_log,
private readonly UIFactory  $ui_factory,
private readonly DataFactory  $data_factory,
private readonly \ilLanguage  $lng,
private readonly \ilCtrl  $ctrl,
private readonly \ilUIService  $ui_service,
private readonly \ilObjectDefinition  $object_definition,
private readonly RequestInterface  $request,
\ilRbacReview  $rbac_review,
private readonly \ilObjUser  $current_user,
private readonly \ilObjectGUI  $gui_object 
)

Definition at line 54 of file Table.php.

66 {
67 $this->action_map = [
68 \ilRbacLog::EDIT_PERMISSIONS => $this->lng->txt('rbac_log_edit_permissions'),
69 \ilRbacLog::MOVE_OBJECT => $this->lng->txt('rbac_log_move_object'),
70 \ilRbacLog::LINK_OBJECT => $this->lng->txt('rbac_log_link_object'),
71 \ilRbacLog::COPY_OBJECT => $this->lng->txt('rbac_log_copy_object'),
72 \ilRbacLog::CREATE_OBJECT => $this->lng->txt('rbac_log_create_object'),
73 \ilRbacLog::EDIT_TEMPLATE => $this->lng->txt('rbac_log_edit_template'),
74 \ilRbacLog::EDIT_TEMPLATE_EXISTING => $this->lng->txt('rbac_log_edit_template_existing'),
75 \ilRbacLog::CHANGE_OWNER => $this->lng->txt('rbac_log_change_owner')
76 ];
77
78 foreach ($rbac_review->getOperations() as $op) {
79 $this->operations[$op['ops_id']] = $op['operation'];
80 }
81 }
const EDIT_PERMISSIONS
const COPY_OBJECT
const MOVE_OBJECT
const EDIT_TEMPLATE_EXISTING
const CHANGE_OWNER
const LINK_OBJECT
const EDIT_TEMPLATE
const CREATE_OBJECT

References ilRbacLog\CHANGE_OWNER, ilRbacLog\COPY_OBJECT, ilRbacLog\CREATE_OBJECT, ilRbacLog\EDIT_PERMISSIONS, ilRbacLog\EDIT_TEMPLATE, ilRbacLog\EDIT_TEMPLATE_EXISTING, ilRbacReview\getOperations(), ilRbacLog\LINK_OBJECT, ILIAS\Repository\lng(), and ilRbacLog\MOVE_OBJECT.

+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilterValuesTrafos()

ILIAS\AccessControl\Log\Table::applyFilterValuesTrafos ( array  $filter_values)
private

Definition at line 194 of file Table.php.

194 : array
195 {
196 $transformed_values = [
197 'action' => $filter_values['action']
198 ];
199 if (isset($filter_values['period'][0])) {
200 $transformed_values['from'] = (new \DateTimeImmutable(
201 $filter_values['period'][0],
202 new \DateTimeZone($this->current_user->getTimeZone())
203 ))->getTimestamp();
204 }
205 if (isset($filter_values['period'][1])) {
206 $transformed_values['to'] = (new \DateTimeImmutable(
207 $filter_values['period'][1] . '23:59:59',
208 new \DateTimeZone($this->current_user->getTimeZone())
209 ))->getTimestamp();
210 }
211 return $transformed_values;
212 }

Referenced by ILIAS\AccessControl\Log\Table\getFilter().

+ Here is the caller graph for this function:

◆ buildChangeColumn()

ILIAS\AccessControl\Log\Table::buildChangeColumn ( int  $action,
array  $data 
)
private

Definition at line 214 of file Table.php.

214 : string
215 {
216 if ($action === \ilRbacLog::CHANGE_OWNER) {
217 $user_name = \ilObjUser::_lookupFullname($data[0] ?? 0);
218 return "{$this->lng->txt('rbac_log_changed_owner')}: {$user_name}";
219 }
220
221 if ($action === \ilRbacLog::EDIT_TEMPLATE) {
222 return $this->parseChangesTemplate($data);
223 }
224
225 return $this->parseChangesFaPa($data);
226 }
parseChangesFaPa(array $raw)
Definition: Table.php:228
parseChangesTemplate(array $raw)
Definition: Table.php:276
static _lookupFullname(int $a_user_id)

References $data, ilObjUser\_lookupFullname(), ilRbacLog\CHANGE_OWNER, and ilRbacLog\EDIT_TEMPLATE.

+ Here is the call graph for this function:

◆ buildUserDateTimeFormat()

ILIAS\AccessControl\Log\Table::buildUserDateTimeFormat ( )
private

Definition at line 185 of file Table.php.

185 : DateFormat
186 {
187 $user_format = $this->current_user->getDateFormat();
188 if ($this->current_user->getTimeFormat() == \ilCalendarSettings::TIME_FORMAT_24) {
189 return $this->data_factory->dateFormat()->withTime24($user_format);
190 }
191 return $this->data_factory->dateFormat()->withTime12($user_format);
192 }

References ilCalendarSettings\TIME_FORMAT_24.

◆ getCreateTranslation()

ILIAS\AccessControl\Log\Table::getCreateTranslation ( string  $type,
string  $op_id 
)
private

Definition at line 330 of file Table.php.

330 : string
331 {
332 $obj_type = substr($op_id, 7, strlen($op_id));
333 $perm = $this->getTranslationFromPlugin($obj_type, $op_id);
334
335 if ($this->isTranslated($perm, $op_id)) {
336 return $perm;
337 }
338
339 return $this->lng->txt('rbac_' . $op_id);
340 }
isTranslated(?string $perm, string $op_id)
Definition: Table.php:350
getTranslationFromPlugin(string $type, string $op_id)
Definition: Table.php:342

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getFilter()

ILIAS\AccessControl\Log\Table::getFilter ( )
private

Definition at line 112 of file Table.php.

112 : Filter
113 {
114 $ff = $this->ui_factory->input()->field();
115
116 $inputs = [
117 self::FILTER_FIELD_ACTION => $ff->multiSelect(
118 $this->lng->txt('action'),
119 $this->action_map
120 ),
121 self::FILTER_FIELD_PERIOD => $ff->duration($this->lng->txt('date'))
122 ];
123
124 $active = array_fill(0, count($inputs), true);
125
126 $filter = $this->ui_service->filter()->standard(
127 self::FILTER_ID,
128 $this->ctrl->getFormActionByClass([get_class($this->gui_object), \ilPermissionGUI::class], 'log'),
129 $inputs,
130 $active,
131 true,
132 true
133 );
134 $this->filter_data = $this->applyFilterValuesTrafos($this->ui_service->filter()->getData($filter));
135 return $filter;
136 }
applyFilterValuesTrafos(array $filter_values)
Definition: Table.php:194

References ILIAS\UI\Implementation\Component\Input\$inputs, ILIAS\AccessControl\Log\Table\applyFilterValuesTrafos(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by ILIAS\AccessControl\Log\Table\getTableAndFilter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNonCreateTranslation()

ILIAS\AccessControl\Log\Table::getNonCreateTranslation ( string  $type,
string  $op_id 
)
private

Definition at line 316 of file Table.php.

316 : string
317 {
318 $perm = $this->getTranslationFromPlugin($type, $op_id);
319 if ($this->isTranslated($perm, $op_id)) {
320 return $perm;
321 }
322
323 if ($this->lng->exists($type . '_' . $op_id . '_short')) {
324 return $this->lng->txt($type . '_' . $op_id . '_short');
325 }
326
327 return $this->lng->txt($op_id);
328 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getOPCaption()

ILIAS\AccessControl\Log\Table::getOPCaption ( string  $type,
array|int|string  $op 
)
private

Definition at line 292 of file Table.php.

292 : string
293 {
294 if (is_array($op)) {
295 return array_reduce(
296 $op,
297 fn(string $c, array|int|string $v) => $c === ''
298 ? $this->getOPCaption($type, $v)
299 : $c . ',' . $this->getOPCaption($type, $v),
300 ''
301 );
302 }
303
304 if (!isset($this->operations[$op])) {
305 return '';
306 }
307
308 $op_id = $this->operations[$op];
309 if (substr($op_id, 0, 7) !== 'create_') {
310 return $this->getNonCreateTranslation($type, $op_id);
311 }
312
313 return $this->getCreateTranslation($type, $op_id);
314 }
getNonCreateTranslation(string $type, string $op_id)
Definition: Table.php:316
getCreateTranslation(string $type, string $op_id)
Definition: Table.php:330
getOPCaption(string $type, array|int|string $op)
Definition: Table.php:292
$c
Definition: deliver.php:25

References $c.

◆ getRefId()

ILIAS\AccessControl\Log\Table::getRefId ( )
private

Definition at line 176 of file Table.php.

176 : int
177 {
178 // special case: role folder should display root folder entries
179 if ($this->gui_object->getRefId() === ROLE_FOLDER_ID) {
180 return ROOT_FOLDER_ID;
181 }
182 return $this->gui_object->getRefId();
183 }
const ROLE_FOLDER_ID
Definition: constants.php:34
const ROOT_FOLDER_ID
Definition: constants.php:32

References ROLE_FOLDER_ID, and ROOT_FOLDER_ID.

◆ getRows()

ILIAS\AccessControl\Log\Table::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.

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

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 138 of file Table.php.

145 : \Generator {
146 $log_data = $this->rbac_log->getLogItems(
147 $this->getRefId(),
148 $range,
149 $order,
150 $this->filter_data
151 );
152
153 foreach ($log_data as $entry) {
154 $user_data = \ilObjUser::_lookupName($entry['user_id']);
155 yield $row_builder->buildDataRow(
156 (string) $entry['log_id'],
157 [
158 self::COLUMN_DATE => (new \DateTimeImmutable('@' . $entry['created']))
159 ->setTimezone(new \DateTimeZone($this->current_user->getTimeZone())),
160 self::COLUMN_NAME => "{$user_data['lastname']}, {$user_data['firstname']}",
161 self::COLUMN_LOGIN => $user_data['login'],
162 self::COLUMN_ACTION => $this->action_map[$entry['action']] ?? '',
163 self::COLUMN_CHANGES => $this->buildChangeColumn($entry['action'], $entry['data'] ?? [])
164 ]
165 );
166 }
167 }
static _lookupName(int $a_user_id)
buildDataRow(string $id, array $record)

References ilObjUser\_lookupName(), and ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow().

+ Here is the call graph for this function:

◆ getTable()

ILIAS\AccessControl\Log\Table::getTable ( )
private

Definition at line 91 of file Table.php.

91 : DataTable
92 {
93 $cf = $this->ui_factory->table()->column();
94
95 return $this->ui_factory->table()->data(
96 $this,
97 $this->lng->txt('rbac_log'),
98 [
99 self::COLUMN_DATE => $cf->date(
100 $this->lng->txt('date'),
101 $this->buildUserDateTimeFormat()
102 ),
103 self::COLUMN_NAME => $cf->text($this->lng->txt('name')),
104 self::COLUMN_LOGIN => $cf->text($this->lng->txt('login')),
105 self::COLUMN_ACTION => $cf->text($this->lng->txt('action')),
106 self::COLUMN_CHANGES => $cf->text($this->lng->txt('rbac_changes'))
107 ->withIsSortable(false)
108 ],
109 )->withRequest($this->request);
110 }

References ILIAS\Repository\lng().

Referenced by ILIAS\AccessControl\Log\Table\getTableAndFilter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableAndFilter()

ILIAS\AccessControl\Log\Table::getTableAndFilter ( )

Definition at line 83 of file Table.php.

83 : array
84 {
85 return [
86 $this->getFilter(),
87 $this->getTable()
88 ];
89 }

References ILIAS\AccessControl\Log\Table\getFilter(), and ILIAS\AccessControl\Log\Table\getTable().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\AccessControl\Log\Table::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 169 of file Table.php.

172 : ?int {
173 return $this->rbac_log->getLogItemsCount($this->getRefId(), $filter_data);
174 }

◆ getTranslationFromPlugin()

ILIAS\AccessControl\Log\Table::getTranslationFromPlugin ( string  $type,
string  $op_id 
)
private

Definition at line 342 of file Table.php.

342 : ?string
343 {
344 if ($this->object_definition->isPlugin($type)) {
345 return \ilObjectPlugin::lookupTxtById($type, $op_id);
346 }
347 return null;
348 }

◆ isTranslated()

ILIAS\AccessControl\Log\Table::isTranslated ( ?string  $perm,
string  $op_id 
)
private

Definition at line 350 of file Table.php.

350 : bool
351 {
352 return $perm !== null && strpos($perm, $op_id) === false;
353 }

◆ parseChangesFaPa()

ILIAS\AccessControl\Log\Table::parseChangesFaPa ( array  $raw)
private

Definition at line 228 of file Table.php.

228 : string
229 {
230 $result = [];
231
232 if (isset($raw['src']) && is_int($raw['src'])) {
233 $obj_id = \ilObject::_lookupObjectId($raw['src']);
234 if ($obj_id) {
235 $result[] = "{$this->lng->txt('rbac_log_source_object')}: "
236 . '<a href="' . \ilLink::_getLink($raw['src']) . '">'
237 . \ilObject::_lookupTitle($obj_id) . '</a>';
238 }
239
240 // added only
241 foreach ($raw['ops'] as $role_id => $ops) {
242 foreach ($ops as $op) {
243 $result[] = sprintf(
244 $this->lng->txt('rbac_log_operation_add'),
246 ) . ': ' . $this->getOPCaption($this->gui_object->getObject()->getType(), $op);
247 }
248 }
249 } elseif (isset($raw['ops'])) {
250 foreach ($raw['ops'] as $role_id => $actions) {
251 foreach ($actions as $action => $ops) {
252 foreach ((array) $ops as $op) {
253 $result[] = sprintf(
254 $this->lng->txt('rbac_log_operation_' . $action),
256 ) . ': ' . $this->getOPCaption($this->gui_object->getObject()->getType(), $op);
257 }
258 }
259 }
260 }
261
262 if (isset($raw['inht'])) {
263 foreach ($raw['inht'] as $action => $role_ids) {
264 foreach ((array) $role_ids as $role_id) {
265 $result[] = sprintf(
266 $this->lng->txt('rbac_log_inheritance_' . $action),
268 );
269 }
270 }
271 }
272
273 return implode('<br>', $result);
274 }
static _getTranslation(string $a_role_title)
static _lookupObjectId(int $ref_id)
static _lookupTitle(int $obj_id)

References ilObjRole\_getTranslation(), ilObject\_lookupObjectId(), ilObject\_lookupTitle(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ parseChangesTemplate()

ILIAS\AccessControl\Log\Table::parseChangesTemplate ( array  $raw)
private

Definition at line 276 of file Table.php.

276 : string
277 {
278 $result = [];
279 foreach ($raw as $type => $actions) {
280 foreach ($actions as $action => $ops) {
281 foreach ($ops as $op) {
282 $result[] = sprintf(
283 $this->lng->txt('rbac_log_operation_' . $action),
284 $this->lng->txt('obj_' . $type)
285 ) . ': ' . $this->getOPCaption($type, $op);
286 }
287 }
288 }
289 return implode('<br>', $result);
290 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $action_map

array ILIAS\AccessControl\Log\Table::$action_map = []
private

Definition at line 51 of file Table.php.

◆ $filter_data

array ILIAS\AccessControl\Log\Table::$filter_data
private

Definition at line 49 of file Table.php.

◆ $operations

array ILIAS\AccessControl\Log\Table::$operations = []
private

Definition at line 52 of file Table.php.

◆ COLUMN_ACTION

const ILIAS\AccessControl\Log\Table::COLUMN_ACTION = 'action'
private

Definition at line 43 of file Table.php.

◆ COLUMN_CHANGES

const ILIAS\AccessControl\Log\Table::COLUMN_CHANGES = 'changes'
private

Definition at line 44 of file Table.php.

◆ COLUMN_DATE

const ILIAS\AccessControl\Log\Table::COLUMN_DATE = 'created'
private

Definition at line 40 of file Table.php.

◆ COLUMN_LOGIN

const ILIAS\AccessControl\Log\Table::COLUMN_LOGIN = 'login'
private

Definition at line 42 of file Table.php.

◆ COLUMN_NAME

const ILIAS\AccessControl\Log\Table::COLUMN_NAME = 'name'
private

Definition at line 41 of file Table.php.

◆ FILTER_FIELD_ACTION

const ILIAS\AccessControl\Log\Table::FILTER_FIELD_ACTION = 'action'
private

Definition at line 37 of file Table.php.

◆ FILTER_FIELD_PERIOD

const ILIAS\AccessControl\Log\Table::FILTER_FIELD_PERIOD = 'period'
private

Definition at line 38 of file Table.php.

◆ FILTER_ID

const ILIAS\AccessControl\Log\Table::FILTER_ID = 'perm_table_filter'
private

Definition at line 36 of file Table.php.


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