ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 133 of file class.ilRbacLog.php.

134 {
135 global $ilUser, $ilDB;
136
137 if (self::isValidAction($a_action) && sizeof($a_diff)) {
138 if ($a_source_ref_id) {
139 $a_diff["src"] = $a_source_ref_id;
140 }
141 $id = $ilDB->nextId('rbac_log');
142
143 $ilDB->query("INSERT INTO rbac_log (log_id, user_id, created, ref_id, action, data)" .
144 " VALUES (" . $ilDB->quote($id, "integer") . "," . $ilDB->quote($ilUser->getId(), "integer") .
145 "," . $ilDB->quote(time(), "integer") .
146 "," . $ilDB->quote($a_ref_id, "integer") . "," . $ilDB->quote($a_action, "integer") .
147 "," . $ilDB->quote(serialize($a_diff), "text") . ")");
148 return true;
149 }
150 return false;
151 }
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilDB
$ilUser
Definition: imgupload.php:18

References $id, $ilDB, and $ilUser.

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

+ Here is the caller graph for this function:

◆ delete()

static ilRbacLog::delete (   $a_ref_id)
static

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

203 {
204 global $ilDB;
205
206 $ilDB->query("DELETE FROM rbac_log WHERE ref_id = " . $ilDB->quote($a_ref_id, "integer"));
207
209 }
static garbageCollection()

References $ilDB, and garbageCollection().

+ Here is the call graph for this function:

◆ diffFaPa()

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

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

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

References $result.

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

+ Here is the caller graph for this function:

◆ diffTemplate()

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

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

111 {
112 $result = array();
113 $types = array_unique(array_merge(array_keys($a_old), array_keys($a_new)));
114 foreach ($types as $type) {
115 if (!isset($a_old[$type])) {
116 $result[$type]["add"] = $a_new[$type];
117 } elseif (!isset($a_new[$type])) {
118 $result[$type]["rmv"] = $a_old[$type];
119 } else {
120 $diff = array_diff($a_old[$type], $a_new[$type]);
121 if (sizeof($diff)) {
122 $result[$type]["rmv"] = array_values($diff);
123 }
124 $diff = array_diff($a_new[$type], $a_old[$type]);
125 if (sizeof($diff)) {
126 $result[$type]["add"] = array_values($diff);
127 }
128 }
129 }
130 return $result;
131 }
$type

References $result, and $type.

Referenced by ilObjRoleGUI\permSaveObject().

+ Here is the caller graph for this function:

◆ garbageCollection()

static ilRbacLog::garbageCollection ( )
static

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

212 {
213 global $ilDB;
214
215 include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
217 $max = $settings->getRbacLogAge();
218
219 $ilDB->query("DELETE FROM rbac_log WHERE created < " . $ilDB->quote(strtotime("-" . $max . "months"), "integer"));
220 }
static _getInstance()
Get instance of ilPrivacySettings.

References $ilDB, and ilPrivacySettings\_getInstance().

Referenced by delete().

+ Here is the call graph for this function:
+ Here is the caller 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.

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

References $result.

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

+ Here is the caller graph for this function:

◆ gatherTemplate()

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

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

104 {
105 global $rbacreview;
106
107 return $rbacreview->getAllOperationsOfRole($a_role_id, $a_role_ref_id);
108 }

Referenced by ilObjRoleGUI\permSaveObject().

+ 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 163 of file class.ilRbacLog.php.

164 {
165 global $ilDB, $rbacreview;
166
167 $where = [];
168 if ($a_filter) {
169 if ($a_filter["action"]) {
170 $where[] = "action = " . $ilDB->quote($a_filter["action"], "integer");
171 }
172 if ($a_filter["date"]["from"]) {
173 $from = $a_filter["date"]["from"]->get(IL_CAL_UNIX);
174 $from = strtotime("00:00:00", $from);
175 $where[] = "created >= " . $ilDB->quote($from, "integer");
176 }
177 if ($a_filter["date"]["to"]) {
178 $to = $a_filter["date"]["to"]->get(IL_CAL_UNIX);
179 $to = strtotime("23:59:59", $to);
180 $where[] = "created <= " . $ilDB->quote($to, "integer");
181 }
182
183 if (count($where) > 0) {
184 $where = array_merge([' AND '], [implode(' AND ', $where)]);
185 }
186 }
187
188 $set = $ilDB->query("SELECT COUNT(*) FROM rbac_log WHERE ref_id = " . $ilDB->quote($a_ref_id, "integer") . implode('', $where));
189 $count = array_pop($ilDB->fetchAssoc($set));
190
191 $ilDB->setLimit($a_limit, $a_offset);
192 $set = $ilDB->query("SELECT * FROM rbac_log WHERE ref_id = " . $ilDB->quote($a_ref_id, "integer") .
193 implode('', $where) . " ORDER BY created DESC");
194 $result = array();
195 while ($row = $ilDB->fetchAssoc($set)) {
196 $row["data"] = unserialize($row["data"]);
197 $result[] = $row;
198 }
199 return array("cnt"=>$count, "set"=>$result);
200 }
const IL_CAL_UNIX
$from

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

Referenced by ilRbacLogTableGUI\getItems().

+ Here is the caller graph for this function:

◆ isActive()

static ilRbacLog::isActive ( )
static

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

26 {
27 include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
29 if ($settings->enabledRbacLog()) {
30 return true;
31 }
32 return false;
33 }

References ilPrivacySettings\_getInstance().

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

+ 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 153 of file class.ilRbacLog.php.

154 {
155 if (in_array($a_action, array(self::EDIT_PERMISSIONS, self::MOVE_OBJECT, self::LINK_OBJECT,
156 self::COPY_OBJECT, self::CREATE_OBJECT, self::EDIT_TEMPLATE, self::EDIT_TEMPLATE_EXISTING,
157 self::CHANGE_OWNER))) {
158 return true;
159 }
160 return false;
161 }

Field Documentation

◆ CHANGE_OWNER

const ilRbacLog::CHANGE_OWNER = 8

◆ COPY_OBJECT

const ilRbacLog::COPY_OBJECT = 4

◆ CREATE_OBJECT

const ilRbacLog::CREATE_OBJECT = 5

◆ 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

const ilRbacLog::LINK_OBJECT = 3

◆ MOVE_OBJECT

const ilRbacLog::MOVE_OBJECT = 2

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