19declare(strict_types=1);
32use Psr\Http\Message\RequestInterface;
56 private readonly UIFactory $ui_factory,
57 private readonly DataFactory $data_factory,
59 private readonly \
ilCtrl $ctrl,
62 private readonly RequestInterface $request,
64 private readonly \
ilObjUser $current_user,
79 $this->operations[$op[
'ops_id']] = $op[
'operation'];
93 $cf = $this->ui_factory->table()->column();
95 return $this->ui_factory->table()->data(
97 $this->
lng->txt(
'rbac_log'),
99 self::COLUMN_DATE => $cf->date(
100 $this->lng->txt(
'date'),
101 $this->buildUserDateTimeFormat()
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)
109 )->withRequest($this->request);
114 $ff = $this->ui_factory->input()->field();
117 self::FILTER_FIELD_ACTION => $ff->multiSelect(
118 $this->
lng->txt(
'action'),
121 self::FILTER_FIELD_PERIOD => $ff->duration($this->
lng->txt(
'date'))
124 $active = array_fill(0, count(
$inputs),
true);
126 $filter = $this->ui_service->filter()->standard(
128 $this->
ctrl->getFormActionByClass([get_class($this->gui_object), \ilPermissionGUI::class],
'log'),
140 array $visible_column_ids,
143 mixed $additional_viewcontrol_data,
145 mixed $additional_parameters
147 $log_data = $this->rbac_log->getLogItems(
154 foreach ($log_data as $entry) {
157 (
string) $entry[
'log_id'],
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'] ?? [])
171 mixed $additional_viewcontrol_data,
173 mixed $additional_parameters
175 return $this->rbac_log->getLogItemsCount($this->getRefId(), $filter_data ?? []);
184 return $this->gui_object->getRefId();
189 $user_format = $this->current_user->getDateFormat();
191 return $this->data_factory->dateFormat()->withTime24($user_format);
193 return $this->data_factory->dateFormat()->withTime12($user_format);
198 $transformed_values = [
199 'action' => $filter_values[
'action']
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())
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())
213 return $transformed_values;
220 $user_name = isset(
$data[0]) && is_numeric(
$data[0])
223 return "{$this->lng->txt('rbac_log_changed_owner')}: {$user_name}";
227 return $this->parseChangesTemplate(
$data);
230 return $this->parseChangesFaPa(
$data);
237 if (isset($raw[
'src']) && is_int($raw[
'src'])) {
240 $result[] =
"{$this->lng->txt('rbac_log_source_object')}: "
241 .
'<a href="' . \ilLink::_getLink($raw[
'src']) .
'">'
246 foreach ($raw[
'ops'] as $role_id => $ops) {
247 foreach ($ops as $op) {
249 $this->
lng->txt(
'rbac_log_operation_add'),
251 ) .
': ' . $this->getOPCaption($this->gui_object->getObject()->getType(), $op);
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) {
259 $this->
lng->txt(
'rbac_log_operation_' . $action),
261 ) .
': ' . $this->getOPCaption($this->gui_object->getObject()->getType(), $op);
267 if (isset($raw[
'inht'])) {
268 foreach ($raw[
'inht'] as $action => $role_ids) {
269 foreach ((array) $role_ids as $role_id) {
271 $this->
lng->txt(
'rbac_log_inheritance_' . $action),
278 return implode(
'<br>', $result);
284 foreach ($raw as $type => $actions) {
285 foreach ($actions as $action => $ops) {
286 foreach ($ops as $op) {
288 $this->
lng->txt(
'rbac_log_operation_' . $action),
289 $this->lng->txt(
'obj_' . $type)
290 ) .
': ' . $this->getOPCaption($type, $op);
294 return implode(
'<br>', $result);
297 private function getOPCaption(
string $type, array|
int|
string $op): string
302 fn(
string $c, array|
int|
string $v) =>
$c ===
''
303 ? $this->getOPCaption($type, $v)
304 :
$c .
',' . $this->getOPCaption($type, $v),
309 if (!isset($this->operations[$op])) {
313 $op_id = $this->operations[$op];
314 if (substr($op_id, 0, 7) !==
'create_') {
315 return $this->getNonCreateTranslation($type, $op_id);
318 return $this->getCreateTranslation($type, $op_id);
323 $perm = $this->getTranslationFromPlugin($type, $op_id);
324 if ($this->isTranslated($perm, $op_id)) {
328 if ($this->
lng->exists($type .
'_' . $op_id .
'_short')) {
329 return $this->
lng->txt($type .
'_' . $op_id .
'_short');
332 return $this->
lng->txt($op_id);
337 $obj_type = substr($op_id, 7, strlen($op_id));
338 $perm = $this->getTranslationFromPlugin($obj_type, $op_id);
340 if ($this->isTranslated($perm, $op_id)) {
344 return $this->
lng->txt(
'rbac_' . $op_id);
349 if ($this->object_definition->isPlugin($type)) {
350 return \ilObjectPlugin::lookupTxtById($type, $op_id);
357 return $perm !==
null && strpos($perm, $op_id) ===
false;
getNonCreateTranslation(string $type, string $op_id)
buildChangeColumn(int $action, array $data)
getCreateTranslation(string $type, string $op_id)
parseChangesFaPa(array $raw)
applyFilterValuesTrafos(array $filter_values)
parseChangesTemplate(array $raw)
const FILTER_FIELD_ACTION
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 recor...
getOPCaption(string $type, array|int|string $op)
isTranslated(?string $perm, string $op_id)
buildUserDateTimeFormat()
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....
__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)
getTranslationFromPlugin(string $type, string $op_id)
const FILTER_FIELD_PERIOD
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a naive range of whole positive numbers.
Class ilCtrl provides processing control methods.
static _getTranslation(string $a_role_title)
static _lookupFullname(int $a_user_id)
static _lookupName(int $a_user_id)
parses the objects.xml it handles the xml-description of all ilias objects
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjectId(int $ref_id)
static _lookupTitle(int $obj_id)
class ilRbacLog Log changes in Rbac-related settings
const EDIT_TEMPLATE_EXISTING
class ilRbacReview Contains Review functions of core Rbac.
getOperations()
get all possible operations
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildDataRow(string $id, array $record)
This describes a Data Table.