ILIAS  release_4-4 Revision
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_folder_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 164 of file class.ilRbacLog.php.

References $ilUser.

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

165  {
166  global $ilUser, $ilDB;
167 
168  if(self::isValidAction($a_action) && sizeof($a_diff))
169  {
170  if($a_source_ref_id)
171  {
172  $a_diff["src"] = $a_source_ref_id;
173  }
174 
175  $ilDB->query("INSERT INTO rbac_log (user_id, created, ref_id, action, data)".
176  " VALUES (".$ilDB->quote($ilUser->getId(), "integer").",".$ilDB->quote(time(), "integer").
177  ",".$ilDB->quote($a_ref_id, "integer").",".$ilDB->quote($a_action, "integer").
178  ",".$ilDB->quote(serialize($a_diff), "text").")");
179  return true;
180  }
181  return false;
182  }
global $ilUser
Definition: imgupload.php:15
+ Here is the caller graph for this function:

◆ delete()

static ilRbacLog::delete (   $a_ref_id)
static

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

Referenced by ilObject\delete().

240  {
241  global $ilDB;
242 
243  $ilDB->query("DELETE FROM rbac_log WHERE ref_id = ".$ilDB->quote($a_ref_id, "integer"));
244 
245  self::garbageCollection();
246  }
+ Here is the caller graph for this function:

◆ diffFaPa()

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

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

References $result.

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

80  {
81  $result = array();
82 
83  // roles
84  foreach((array) $a_old["ops"] as $role_id => $ops)
85  {
86  $diff = array_diff($ops, $a_new["ops"][$role_id]);
87  if(sizeof($diff))
88  {
89  $result["ops"][$role_id]["rmv"] = array_values($diff);
90  }
91  $diff = array_diff($a_new["ops"][$role_id], $ops);
92  if(sizeof($diff))
93  {
94  $result["ops"][$role_id]["add"] = array_values($diff);
95  }
96  }
97 
98  if(isset($a_old["inht"]) || isset($a_new["inht"]))
99  {
100  if(isset($a_old["inht"]) && !isset($a_new["inht"]))
101  {
102  $result["inht"]["rmv"] = $a_old["inht"];
103  }
104  else if(!isset($a_old["inht"]) && isset($a_new["inht"]))
105  {
106  $result["inht"]["add"] = $a_new["inht"];
107  }
108  else
109  {
110  $diff = array_diff($a_old["inht"], $a_new["inht"]);
111  if(sizeof($diff))
112  {
113  $result["inht"]["rmv"] = array_values($diff);
114  }
115  $diff = array_diff($a_new["inht"], $a_old["inht"]);
116  if(sizeof($diff))
117  {
118  $result["inht"]["add"] = array_values($diff);
119  }
120  }
121  }
122 
123  return $result;
124  }
$result
+ Here is the caller graph for this function:

◆ diffTemplate()

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

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

References $result.

Referenced by ilObjRoleGUI\permSaveObject().

134  {
135  $result = array();
136  $types = array_unique(array_merge(array_keys($a_old), array_keys($a_new)));
137  foreach($types as $type)
138  {
139  if(!isset($a_old[$type]))
140  {
141  $result[$type]["add"] = $a_new[$type];
142  }
143  else if(!isset($a_new[$type]))
144  {
145  $result[$type]["rmv"] = $a_old[$type];
146  }
147  else
148  {
149  $diff = array_diff($a_old[$type], $a_new[$type]);
150  if(sizeof($diff))
151  {
152  $result[$type]["rmv"] = array_values($diff);
153  }
154  $diff = array_diff($a_new[$type], $a_old[$type]);
155  if(sizeof($diff))
156  {
157  $result[$type]["add"] = array_values($diff);
158  }
159  }
160  }
161  return $result;
162  }
$result
+ Here is the caller graph for this function:

◆ garbageCollection()

static ilRbacLog::garbageCollection ( )
static

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

References ilPrivacySettings\_getInstance().

249  {
250  global $ilDB;
251 
252  include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
253  $settings = ilPrivacySettings::_getInstance();
254  $max = $settings->getRbacLogAge();
255 
256  $ilDB->query("DELETE FROM rbac_log WHERE created < ".$ilDB->quote(strtotime("-".$max."months"), "integer"));
257  }
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 36 of file class.ilRbacLog.php.

References $result.

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

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

◆ gatherTemplate()

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

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

Referenced by ilObjRoleGUI\permSaveObject().

127  {
128  global $rbacreview;
129 
130  return $rbacreview->getAllOperationsOfRole($a_role_id, $a_role_folder_ref_id);
131  }
+ 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 195 of file class.ilRbacLog.php.

References $result, $row, and IL_CAL_UNIX.

Referenced by ilRbacLogTableGUI\getItems().

196  {
197  global $ilDB, $rbacreview;
198 
199  if($a_filter)
200  {
201  $where = NULL;
202  if($a_filter["action"])
203  {
204  $where[] = "action = ".$ilDB->quote($a_filter["action"], "integer");
205  }
206  if($a_filter["date"]["from"])
207  {
208  $from = $a_filter["date"]["from"]->get(IL_CAL_UNIX);
209  $from = strtotime("00:00:00", $from);
210  $where[] = "created >= ".$ilDB->quote($from, "integer");
211  }
212  if($a_filter["date"]["to"])
213  {
214  $to = $a_filter["date"]["to"]->get(IL_CAL_UNIX);
215  $to = strtotime("23:59:59", $to);
216  $where[] = "created <= ".$ilDB->quote($to, "integer");
217  }
218  if(sizeof($where))
219  {
220  $where = " AND ".implode(" AND ", $where);
221  }
222  }
223 
224  $set = $ilDB->query("SELECT COUNT(*) FROM rbac_log WHERE ref_id = ".$ilDB->quote($a_ref_id, "integer").$where);
225  $count = array_pop($ilDB->fetchAssoc($set));
226 
227  $ilDB->setLimit($a_limit, $a_offset);
228  $set = $ilDB->query("SELECT * FROM rbac_log WHERE ref_id = ".$ilDB->quote($a_ref_id, "integer").
229  $where." ORDER BY created DESC");
230  $result = array();
231  while($row = $ilDB->fetchAssoc($set))
232  {
233  $row["data"] = unserialize($row["data"]);
234  $result[] = $row;
235  }
236  return array("cnt"=>$count, "set"=>$result);
237  }
$result
const IL_CAL_UNIX
+ 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(), ilObjectCopyGUI\copySingleObject(), 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  {
31  return true;
32  }
33  return false;
34  }
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 184 of file class.ilRbacLog.php.

185  {
186  if(in_array($a_action, array(self::EDIT_PERMISSIONS, self::MOVE_OBJECT, self::LINK_OBJECT,
187  self::COPY_OBJECT, self::CREATE_OBJECT, self::EDIT_TEMPLATE, self::EDIT_TEMPLATE_EXISTING,
188  self::CHANGE_OWNER)))
189  {
190  return true;
191  }
192  return false;
193  }

Field Documentation

◆ CHANGE_OWNER

const ilRbacLog::CHANGE_OWNER = 8

◆ COPY_OBJECT

◆ 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

const ilRbacLog::LINK_OBJECT = 3

◆ MOVE_OBJECT

const ilRbacLog::MOVE_OBJECT = 2

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