ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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, 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...
 
 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

 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 196 of file Table.php.

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

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 216 of file Table.php.

216 : string
217 {
218 if ($action === \ilRbacLog::CHANGE_OWNER) {
219
220 $user_name = isset($data[0]) && is_numeric($data[0])
222 : '';
223 return "{$this->lng->txt('rbac_log_changed_owner')}: {$user_name}";
224 }
225
226 if ($action === \ilRbacLog::EDIT_TEMPLATE) {
227 return $this->parseChangesTemplate($data);
228 }
229
230 return $this->parseChangesFaPa($data);
231 }
parseChangesFaPa(array $raw)
Definition: Table.php:233
parseChangesTemplate(array $raw)
Definition: Table.php:281
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 187 of file Table.php.

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

References ilCalendarSettings\TIME_FORMAT_24.

◆ getCreateTranslation()

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

Definition at line 335 of file Table.php.

335 : string
336 {
337 $obj_type = substr($op_id, 7, strlen($op_id));
338 $perm = $this->getTranslationFromPlugin($obj_type, $op_id);
339
340 if ($this->isTranslated($perm, $op_id)) {
341 return $perm;
342 }
343
344 return $this->lng->txt('rbac_' . $op_id);
345 }
isTranslated(?string $perm, string $op_id)
Definition: Table.php:355
getTranslationFromPlugin(string $type, string $op_id)
Definition: Table.php:347

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:196

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 321 of file Table.php.

321 : string
322 {
323 $perm = $this->getTranslationFromPlugin($type, $op_id);
324 if ($this->isTranslated($perm, $op_id)) {
325 return $perm;
326 }
327
328 if ($this->lng->exists($type . '_' . $op_id . '_short')) {
329 return $this->lng->txt($type . '_' . $op_id . '_short');
330 }
331
332 return $this->lng->txt($op_id);
333 }

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 297 of file Table.php.

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

References $c.

◆ getRefId()

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

Definition at line 178 of file Table.php.

178 : int
179 {
180 // special case: role folder should display root folder entries
181 if ($this->gui_object->getRefId() === ROLE_FOLDER_ID) {
182 return ROOT_FOLDER_ID;
183 }
184 return $this->gui_object->getRefId();
185 }
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\StaticURL\Shortlinks\UI\Table::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.

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.

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

174 : ?int {
175 return $this->rbac_log->getLogItemsCount($this->getRefId(), $filter_data ?? []);
176 }

◆ getTranslationFromPlugin()

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

Definition at line 347 of file Table.php.

347 : ?string
348 {
349 if ($this->object_definition->isPlugin($type)) {
350 return \ilObjectPlugin::lookupTxtById($type, $op_id);
351 }
352 return null;
353 }

◆ isTranslated()

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

Definition at line 355 of file Table.php.

355 : bool
356 {
357 return $perm !== null && strpos($perm, $op_id) === false;
358 }

◆ parseChangesFaPa()

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

Definition at line 233 of file Table.php.

233 : string
234 {
235 $result = [];
236
237 if (isset($raw['src']) && is_int($raw['src'])) {
238 $obj_id = \ilObject::_lookupObjectId($raw['src']);
239 if ($obj_id) {
240 $result[] = "{$this->lng->txt('rbac_log_source_object')}: "
241 . '<a href="' . \ilLink::_getLink($raw['src']) . '">'
242 . \ilObject::_lookupTitle($obj_id) . '</a>';
243 }
244
245 // added only
246 foreach ($raw['ops'] as $role_id => $ops) {
247 foreach ($ops as $op) {
248 $result[] = sprintf(
249 $this->lng->txt('rbac_log_operation_add'),
251 ) . ': ' . $this->getOPCaption($this->gui_object->getObject()->getType(), $op);
252 }
253 }
254 } elseif (isset($raw['ops'])) {
255 foreach ($raw['ops'] as $role_id => $actions) {
256 foreach ($actions as $action => $ops) {
257 foreach ((array) $ops as $op) {
258 $result[] = sprintf(
259 $this->lng->txt('rbac_log_operation_' . $action),
261 ) . ': ' . $this->getOPCaption($this->gui_object->getObject()->getType(), $op);
262 }
263 }
264 }
265 }
266
267 if (isset($raw['inht'])) {
268 foreach ($raw['inht'] as $action => $role_ids) {
269 foreach ((array) $role_ids as $role_id) {
270 $result[] = sprintf(
271 $this->lng->txt('rbac_log_inheritance_' . $action),
273 );
274 }
275 }
276 }
277
278 return implode('<br>', $result);
279 }
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 281 of file Table.php.

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

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 files: