ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilRbacLog Class Reference

class ilRbacLog Log changes in Rbac-related settings More...

+ Collaboration diagram for ilRbacLog:

Static Public Member Functions

static isActive ()
 
static gatherFaPa ($a_ref_id, array $a_role_ids, $a_add_action=false)
 
static diffFaPa (array $a_old, array $a_new)
 
static gatherTemplate ($a_role_ref_id, $a_role_id)
 
static diffTemplate (array $a_old, array $a_new)
 
static add ($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
 
static getLogItems ($a_ref_id, $a_limit, $a_offset, array $a_filter=null)
 
static delete ($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 ($a_action)
 

Detailed Description

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
Version
Id
class.ilRbacReview.php 24262 2010-06-15 06:48:14Z nkrzywon

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

Member Function Documentation

◆ add()

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

Definition at line 137 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(), ilSoapUtils\internalLinkNode(), ilSoapUtils\linkNode(), ilContainerGUI\performPasteIntoMultipleObjectsObject(), ilObjRoleGUI\permSaveObject(), ilObject2GUI\putObjectInTree(), ilObjectGUI\putObjectInTree(), ilPermissionGUI\savePermissions(), and ilObjChatroomGUI\settings().

138  {
139  global $DIC;
140 
141  $ilUser = $DIC['ilUser'];
142  $ilDB = $DIC['ilDB'];
143 
144  if (self::isValidAction($a_action) && sizeof($a_diff)) {
145  if ($a_source_ref_id) {
146  $a_diff["src"] = $a_source_ref_id;
147  }
148  $id = $ilDB->nextId('rbac_log');
149 
150  $ilDB->query("INSERT INTO rbac_log (log_id, user_id, created, ref_id, action, data)" .
151  " VALUES (" . $ilDB->quote($id, "integer") . "," . $ilDB->quote($ilUser->getId(), "integer") .
152  "," . $ilDB->quote(time(), "integer") .
153  "," . $ilDB->quote($a_ref_id, "integer") . "," . $ilDB->quote($a_action, "integer") .
154  "," . $ilDB->quote(serialize($a_diff), "text") . ")");
155  return true;
156  }
157  return false;
158  }
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
$ilUser
Definition: imgupload.php:18
global $ilDB
+ Here is the caller graph for this function:

◆ delete()

static ilRbacLog::delete (   $a_ref_id)
static

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

References $DIC, and $ilDB.

Referenced by ilObject\countReferences().

213  {
214  global $DIC;
215 
216  $ilDB = $DIC['ilDB'];
217 
218  $ilDB->query("DELETE FROM rbac_log WHERE ref_id = " . $ilDB->quote($a_ref_id, "integer"));
219 
220  self::garbageCollection();
221  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ diffFaPa()

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

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

References $result.

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

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

◆ diffTemplate()

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

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

References $result, and $type.

Referenced by ilObjRoleGUI\permSaveObject().

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

◆ garbageCollection()

static ilRbacLog::garbageCollection ( )
static

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

References $DIC, $ilDB, and ilPrivacySettings\_getInstance().

224  {
225  global $DIC;
226 
227  $ilDB = $DIC['ilDB'];
228 
229  include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
230  $settings = ilPrivacySettings::_getInstance();
231  $max = $settings->getRbacLogAge();
232 
233  $ilDB->query("DELETE FROM rbac_log WHERE created < " . $ilDB->quote(strtotime("-" . $max . "months"), "integer"));
234  }
global $DIC
Definition: saml.php:7
global $ilDB
static _getInstance()
Get instance of ilPrivacySettings.
+ Here is the call graph for this function:

◆ gatherFaPa()

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

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

References $DIC, and $result.

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

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

◆ gatherTemplate()

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

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

References $DIC.

Referenced by ilObjRoleGUI\permSaveObject().

106  {
107  global $DIC;
108 
109  $rbacreview = $DIC['rbacreview'];
110 
111  return $rbacreview->getAllOperationsOfRole($a_role_id, $a_role_ref_id);
112  }
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ getLogItems()

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

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

References $DIC, $from, $ilDB, $result, $row, and IL_CAL_UNIX.

Referenced by ilRbacLogTableGUI\getItems().

171  {
172  global $DIC;
173 
174  $ilDB = $DIC['ilDB'];
175  $rbacreview = $DIC['rbacreview'];
176 
177  $where = [];
178  if ($a_filter) {
179  if ($a_filter["action"]) {
180  $where[] = "action = " . $ilDB->quote($a_filter["action"], "integer");
181  }
182  if ($a_filter["date"]["from"]) {
183  $from = $a_filter["date"]["from"]->get(IL_CAL_UNIX);
184  $from = strtotime("00:00:00", $from);
185  $where[] = "created >= " . $ilDB->quote($from, "integer");
186  }
187  if ($a_filter["date"]["to"]) {
188  $to = $a_filter["date"]["to"]->get(IL_CAL_UNIX);
189  $to = strtotime("23:59:59", $to);
190  $where[] = "created <= " . $ilDB->quote($to, "integer");
191  }
192 
193  if (count($where) > 0) {
194  $where = array_merge([' AND '], [implode(' AND ', $where)]);
195  }
196  }
197 
198  $set = $ilDB->query("SELECT COUNT(*) FROM rbac_log WHERE ref_id = " . $ilDB->quote($a_ref_id, "integer") . implode('', $where));
199  $count = array_pop($ilDB->fetchAssoc($set));
200 
201  $ilDB->setLimit($a_limit, $a_offset);
202  $set = $ilDB->query("SELECT * FROM rbac_log WHERE ref_id = " . $ilDB->quote($a_ref_id, "integer") .
203  implode('', $where) . " ORDER BY created DESC");
204  $result = array();
205  while ($row = $ilDB->fetchAssoc($set)) {
206  $row["data"] = unserialize($row["data"]);
207  $result[] = $row;
208  }
209  return array("cnt" => $count, "set" => $result);
210  }
$result
global $DIC
Definition: saml.php:7
$from
const IL_CAL_UNIX
$row
global $ilDB
+ Here is the caller graph for this function:

◆ isActive()

static ilRbacLog::isActive ( )
static

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

References ilPrivacySettings\_getInstance().

Referenced by ilPermission2GUI\__initSubTabs(), ilRbacAdmin\adjustMovedObjectPermissions(), ilObjRole\adjustPermissions(), ilPermission2GUI\changeOwner(), ilObjectCopyGUI\copyMultipleNonContainer(), ilPermission2GUI\log(), ilContainerGUI\performPasteIntoMultipleObjectsObject(), and ilObjRoleGUI\permSaveObject().

26  {
27  include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
28  $settings = ilPrivacySettings::_getInstance();
29  if ($settings->enabledRbacLog()) {
30  return true;
31  }
32  return false;
33  }
static _getInstance()
Get instance of ilPrivacySettings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValidAction()

static ilRbacLog::isValidAction (   $a_action)
staticprotected

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

161  {
162  if (in_array($a_action, array(self::EDIT_PERMISSIONS, self::MOVE_OBJECT, self::LINK_OBJECT,
163  self::COPY_OBJECT, self::CREATE_OBJECT, self::EDIT_TEMPLATE, self::EDIT_TEMPLATE_EXISTING,
164  self::CHANGE_OWNER))) {
165  return true;
166  }
167  return false;
168  }

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: