ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilRbacLog Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilRbacLog:

Static Public Member Functions

static isActive ()
 
static gatherFaPa (int $a_ref_id, array $a_role_ids, bool $a_add_action=false)
 
static diffFaPa (array $a_old, array $a_new)
 
static gatherTemplate (int $a_role_ref_id, int $a_role_id)
 
static diffTemplate (array $a_old, array $a_new)
 
static add (int $a_action, int $a_ref_id, array $a_diff, bool $a_source_ref_id=false)
 
static getLogItems (int $a_ref_id, int $a_limit, int $a_offset, array $a_filter=null)
 
static delete (int $a_ref_id)
 
static garbageCollection ()
 

Data Fields

const EDIT_PERMISSIONS = 1
 
const MOVE_OBJECT = 2
 
const LINK_OBJECT = 3
 
const COPY_OBJECT = 4
 
const CREATE_OBJECT = 5
 
const EDIT_TEMPLATE = 6
 
const EDIT_TEMPLATE_EXISTING = 7
 
const CHANGE_OWNER = 8
 

Static Protected Member Functions

static isValidAction (int $a_action)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning class ilRbacLog Log changes in Rbac-related settings

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 26 of file class.ilRbacLog.php.

Member Function Documentation

◆ add()

static ilRbacLog::add ( int  $a_action,
int  $a_ref_id,
array  $a_diff,
bool  $a_source_ref_id = false 
)
static

Definition at line 141 of file class.ilRbacLog.php.

References $DIC, $id, $ilDB, and $ilUser.

Referenced by ilRbacAdmin\adjustMovedObjectPermissions(), ilObjRole\adjustPermissions(), ilPermission2GUI\changeOwner(), ilSoapUtils\cloneNode(), ilObjChatroom\cloneObject(), ilObjectCopyGUI\copyMultipleNonContainer(), ilObjChatroomGUI\insertObject(), ilSoapUtils\internalLinkNode(), ilSoapUtils\linkNode(), ilContainerGUI\performPasteIntoMultipleObjectsObject(), ilObjRoleGUI\permSaveObject(), ilObject2GUI\putObjectInTree(), ilObjectGUI\putObjectInTree(), and ilPermissionGUI\savePermissions().

141  : bool
142  {
143  global $DIC;
144 
145  $ilUser = $DIC->user();
146  $ilDB = $DIC->database();
147 
148  if (self::isValidAction($a_action) && count($a_diff)) {
149  if ($a_source_ref_id) {
150  $a_diff["src"] = $a_source_ref_id;
151  }
152  $id = $ilDB->nextId('rbac_log');
153 
154  $ilDB->query("INSERT INTO rbac_log (log_id, user_id, created, ref_id, action, data)" .
155  " VALUES (" . $ilDB->quote($id, "integer") . "," . $ilDB->quote($ilUser->getId(), "integer") .
156  "," . $ilDB->quote(time(), "integer") .
157  "," . $ilDB->quote($a_ref_id, "integer") . "," . $ilDB->quote($a_action, "integer") .
158  "," . $ilDB->quote(serialize($a_diff), "text") . ")");
159  return true;
160  }
161  return false;
162  }
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ delete()

static ilRbacLog::delete ( int  $a_ref_id)
static

Definition at line 230 of file class.ilRbacLog.php.

References $DIC, and $ilDB.

Referenced by ilObject\delete().

230  : void
231  {
232  global $DIC;
233 
234  $ilDB = $DIC->database();
235  $ilDB->query("DELETE FROM rbac_log WHERE ref_id = " . $ilDB->quote($a_ref_id, "integer"));
236  self::garbageCollection();
237  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ diffFaPa()

static ilRbacLog::diffFaPa ( array  $a_old,
array  $a_new 
)
static

Definition at line 75 of file class.ilRbacLog.php.

Referenced by ilRbacAdmin\adjustMovedObjectPermissions(), ilObjRole\adjustPermissions(), and ilPermissionGUI\savePermissions().

75  : array
76  {
77  $result = array();
78 
79  // roles
80  foreach ((array) $a_old["ops"] as $role_id => $ops) {
81  $diff = array_diff($ops, $a_new["ops"][$role_id]);
82  if ($diff !== []) {
83  $result["ops"][$role_id]["rmv"] = array_values($diff);
84  }
85  $diff = array_diff($a_new["ops"][$role_id], $ops);
86  if ($diff !== []) {
87  $result["ops"][$role_id]["add"] = array_values($diff);
88  }
89  }
90 
91  if (isset($a_old["inht"]) || isset($a_new["inht"])) {
92  if (isset($a_old["inht"]) && !isset($a_new["inht"])) {
93  $result["inht"]["rmv"] = $a_old["inht"];
94  } elseif (!isset($a_old["inht"]) && isset($a_new["inht"])) {
95  $result["inht"]["add"] = $a_new["inht"];
96  } else {
97  $diff = array_diff($a_old["inht"], $a_new["inht"]);
98  if ($diff !== []) {
99  $result["inht"]["rmv"] = array_values($diff);
100  }
101  $diff = array_diff($a_new["inht"], $a_old["inht"]);
102  if ($diff !== []) {
103  $result["inht"]["add"] = array_values($diff);
104  }
105  }
106  }
107  return $result;
108  }
+ Here is the caller graph for this function:

◆ diffTemplate()

static ilRbacLog::diffTemplate ( array  $a_old,
array  $a_new 
)
static

Definition at line 118 of file class.ilRbacLog.php.

References $type.

Referenced by ilObjRoleGUI\permSaveObject().

118  : array
119  {
120  $result = array();
121  $types = array_unique(array_merge(array_keys($a_old), array_keys($a_new)));
122  foreach ($types as $type) {
123  if (!isset($a_old[$type])) {
124  $result[$type]["add"] = $a_new[$type];
125  } elseif (!isset($a_new[$type])) {
126  $result[$type]["rmv"] = $a_old[$type];
127  } else {
128  $diff = array_diff($a_old[$type], $a_new[$type]);
129  if ($diff !== []) {
130  $result[$type]["rmv"] = array_values($diff);
131  }
132  $diff = array_diff($a_new[$type], $a_old[$type]);
133  if ($diff !== []) {
134  $result[$type]["add"] = array_values($diff);
135  }
136  }
137  }
138  return $result;
139  }
$type
+ Here is the caller graph for this function:

◆ garbageCollection()

static ilRbacLog::garbageCollection ( )
static

Definition at line 239 of file class.ilRbacLog.php.

References $DIC, $ilDB, ILIAS\LTI\ToolProvider\$settings, and ilPrivacySettings\getInstance().

239  : void
240  {
241  global $DIC;
242 
243  $ilDB = $DIC->database();
244 
246  $max = $settings->getRbacLogAge();
247 
248  $ilDB->query("DELETE FROM rbac_log WHERE created < " . $ilDB->quote(
249  strtotime("-" . $max . "months"),
250  "integer"
251  ));
252  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ gatherFaPa()

static ilRbacLog::gatherFaPa ( int  $a_ref_id,
array  $a_role_ids,
bool  $a_add_action = false 
)
static

Definition at line 42 of file class.ilRbacLog.php.

References $DIC, ROLE_FOLDER_ID, and SYSTEM_ROLE_ID.

Referenced by ilRbacAdmin\adjustMovedObjectPermissions(), ilObjRole\adjustPermissions(), ilSoapUtils\cloneNode(), ilObjChatroom\cloneObject(), ilObjectCopyGUI\copyMultipleNonContainer(), ilObjChatroomGUI\insertObject(), ilSoapUtils\internalLinkNode(), ilSoapUtils\linkNode(), ilContainerGUI\performPasteIntoMultipleObjectsObject(), ilObject2GUI\putObjectInTree(), ilObjectGUI\putObjectInTree(), and ilPermissionGUI\savePermissions().

42  : array
43  {
44  global $DIC;
45 
46  $rbacreview = $DIC->rbac()->review();
47  $result = array();
48 
49  // #10946 - if result is written to log directly we need to add an "action" dimension
50  // if result is used as input to diffFaPa() we need "raw" data
51 
52  // roles
53  foreach ($a_role_ids as $role_id) {
54  if ($role_id != SYSTEM_ROLE_ID) {
55  if ($a_add_action) {
56  $result["ops"][$role_id]["add"] = $rbacreview->getRoleOperationsOnObject($role_id, $a_ref_id);
57  } else {
58  $result["ops"][$role_id] = $rbacreview->getRoleOperationsOnObject($role_id, $a_ref_id);
59  }
60  }
61  }
62 
63  // inheritance
64  if ($a_ref_id && $a_ref_id != ROLE_FOLDER_ID) {
65  if ($a_add_action) {
66  $result["inht"]["add"] = $rbacreview->getRolesOfRoleFolder($a_ref_id);
67  } else {
68  $result["inht"] = $rbacreview->getRolesOfRoleFolder($a_ref_id);
69  }
70  }
71 
72  return $result;
73  }
const SYSTEM_ROLE_ID
Definition: constants.php:29
global $DIC
Definition: feed.php:28
const ROLE_FOLDER_ID
Definition: constants.php:34
+ Here is the caller graph for this function:

◆ gatherTemplate()

static ilRbacLog::gatherTemplate ( int  $a_role_ref_id,
int  $a_role_id 
)
static

Definition at line 110 of file class.ilRbacLog.php.

References $DIC.

Referenced by ilObjRoleGUI\permSaveObject().

110  : array
111  {
112  global $DIC;
113 
114  $rbacreview = $DIC->rbac()->review();
115  return $rbacreview->getAllOperationsOfRole($a_role_id, $a_role_ref_id);
116  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getLogItems()

static ilRbacLog::getLogItems ( int  $a_ref_id,
int  $a_limit,
int  $a_offset,
array  $a_filter = null 
)
static

Definition at line 184 of file class.ilRbacLog.php.

References $DIC, $ilDB, $res, and IL_CAL_UNIX.

Referenced by ilRbacLogTableGUI\getItems().

184  : array
185  {
186  global $DIC;
187 
188  $ilDB = $DIC->database();
189  $rbacreview = $DIC->rbac()->review();
190 
191  $where = [];
192  if ($a_filter) {
193  if ($a_filter["action"]) {
194  $where[] = "action = " . $ilDB->quote($a_filter["action"], "integer");
195  }
196  if ($a_filter["date"]["from"]) {
197  $from = $a_filter["date"]["from"]->get(IL_CAL_UNIX);
198  $from = strtotime("00:00:00", $from);
199  $where[] = "created >= " . $ilDB->quote($from, "integer");
200  }
201  if ($a_filter["date"]["to"]) {
202  $to = $a_filter["date"]["to"]->get(IL_CAL_UNIX);
203  $to = strtotime("23:59:59", $to);
204  $where[] = "created <= " . $ilDB->quote($to, "integer");
205  }
206 
207  if (count($where) > 0) {
208  $where = array_merge([' AND '], [implode(' AND ', $where)]);
209  }
210  }
211 
212  $set = $ilDB->query("SELECT COUNT(*) FROM rbac_log WHERE ref_id = " . $ilDB->quote(
213  $a_ref_id,
214  "integer"
215  ) . implode('', $where));
216  $res = $ilDB->fetchAssoc($set);
217  $count = array_pop($res);
218 
219  $ilDB->setLimit($a_limit, $a_offset);
220  $set = $ilDB->query("SELECT * FROM rbac_log WHERE ref_id = " . $ilDB->quote($a_ref_id, "integer") .
221  implode('', $where) . " ORDER BY created DESC");
222  $result = array();
223  while ($row = $ilDB->fetchAssoc($set)) {
224  $row["data"] = unserialize($row["data"]);
225  $result[] = $row;
226  }
227  return ["cnt" => $count, "set" => $result];
228  }
$res
Definition: ltiservices.php:69
const IL_CAL_UNIX
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ isActive()

static ilRbacLog::isActive ( )
static

◆ isValidAction()

static ilRbacLog::isValidAction ( int  $a_action)
staticprotected

Definition at line 164 of file class.ilRbacLog.php.

164  : bool
165  {
166  if (in_array(
167  $a_action,
168  [
169  self::EDIT_PERMISSIONS,
170  self::MOVE_OBJECT,
171  self::LINK_OBJECT,
172  self::COPY_OBJECT,
173  self::CREATE_OBJECT,
174  self::EDIT_TEMPLATE,
175  self::EDIT_TEMPLATE_EXISTING,
176  self::CHANGE_OWNER
177  ]
178  )) {
179  return true;
180  }
181  return false;
182  }

Field Documentation

◆ CHANGE_OWNER

const ilRbacLog::CHANGE_OWNER = 8

◆ COPY_OBJECT

const ilRbacLog::COPY_OBJECT = 4

◆ CREATE_OBJECT

◆ EDIT_PERMISSIONS

const ilRbacLog::EDIT_PERMISSIONS = 1

◆ EDIT_TEMPLATE

const ilRbacLog::EDIT_TEMPLATE = 6

◆ EDIT_TEMPLATE_EXISTING

const ilRbacLog::EDIT_TEMPLATE_EXISTING = 7

◆ LINK_OBJECT

◆ MOVE_OBJECT

const ilRbacLog::MOVE_OBJECT = 2

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