27 include_once
"Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
29 if($settings->enabledRbacLog())
36 static public function gatherFaPa($a_ref_id,
array $a_role_ids, $a_add_action =
false)
46 foreach($a_role_ids as $role_id)
48 if ($role_id != SYSTEM_ROLE_ID)
52 $result[
"ops"][$role_id][
"add"] = $rbacreview->getRoleOperationsOnObject($role_id, $a_ref_id);
56 $result[
"ops"][$role_id] = $rbacreview->getRoleOperationsOnObject($role_id, $a_ref_id);
62 if($a_ref_id && $a_ref_id != ROLE_FOLDER_ID)
66 $result[
"inht"][
"add"] = $rbacreview->getRolesOfRoleFolder($a_ref_id);
70 $result[
"inht"] = $rbacreview->getRolesOfRoleFolder($a_ref_id);
82 foreach((
array) $a_old[
"ops"] as $role_id => $ops)
84 $diff = array_diff($ops, $a_new[
"ops"][$role_id]);
87 $result[
"ops"][$role_id][
"rmv"] = array_values($diff);
89 $diff = array_diff($a_new[
"ops"][$role_id], $ops);
92 $result[
"ops"][$role_id][
"add"] = array_values($diff);
96 if(isset($a_old[
"inht"]) || isset($a_new[
"inht"]))
98 if(isset($a_old[
"inht"]) && !isset($a_new[
"inht"]))
100 $result[
"inht"][
"rmv"] = $a_old[
"inht"];
102 else if(!isset($a_old[
"inht"]) && isset($a_new[
"inht"]))
104 $result[
"inht"][
"add"] = $a_new[
"inht"];
108 $diff = array_diff($a_old[
"inht"], $a_new[
"inht"]);
111 $result[
"inht"][
"rmv"] = array_values($diff);
113 $diff = array_diff($a_new[
"inht"], $a_old[
"inht"]);
116 $result[
"inht"][
"add"] = array_values($diff);
128 return $rbacreview->getAllOperationsOfRole($a_role_id, $a_role_ref_id);
134 $types = array_unique(array_merge(array_keys($a_old), array_keys($a_new)));
135 foreach($types as $type)
137 if(!isset($a_old[$type]))
139 $result[$type][
"add"] = $a_new[$type];
141 else if(!isset($a_new[$type]))
143 $result[$type][
"rmv"] = $a_old[$type];
147 $diff = array_diff($a_old[$type], $a_new[$type]);
150 $result[$type][
"rmv"] = array_values($diff);
152 $diff = array_diff($a_new[$type], $a_old[$type]);
155 $result[$type][
"add"] = array_values($diff);
162 static public function add($a_action, $a_ref_id,
array $a_diff, $a_source_ref_id =
false)
166 if(self::isValidAction($a_action) &&
sizeof($a_diff))
170 $a_diff[
"src"] = $a_source_ref_id;
172 $id = $ilDB->nextId(
'rbac_log');
174 $ilDB->query(
"INSERT INTO rbac_log (log_id, user_id, created, ref_id, action, data)".
175 " VALUES (".$ilDB->quote($id,
"integer").
",".$ilDB->quote($ilUser->getId(),
"integer").
176 ",".$ilDB->quote(
time(),
"integer").
177 ",".$ilDB->quote($a_ref_id,
"integer").
",".$ilDB->quote($a_action,
"integer").
178 ",".$ilDB->quote(serialize($a_diff),
"text").
")");
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)))
197 global
$ilDB, $rbacreview;
202 if($a_filter[
"action"])
204 $where[] =
"action = ".$ilDB->quote($a_filter[
"action"],
"integer");
206 if($a_filter[
"date"][
"from"])
208 $from = $a_filter[
"date"][
"from"]->get(
IL_CAL_UNIX);
209 $from = strtotime(
"00:00:00", $from);
210 $where[] =
"created >= ".$ilDB->quote($from,
"integer");
212 if($a_filter[
"date"][
"to"])
215 $to = strtotime(
"23:59:59", $to);
216 $where[] =
"created <= ".$ilDB->quote($to,
"integer");
220 $where =
" AND ".implode(
" AND ", $where);
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));
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");
231 while(
$row = $ilDB->fetchAssoc($set))
233 $row[
"data"] = unserialize(
$row[
"data"]);
239 static function delete($a_ref_id)
243 $ilDB->query(
"DELETE FROM rbac_log WHERE ref_id = ".$ilDB->quote($a_ref_id,
"integer"));
245 self::garbageCollection();
252 include_once
"Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
254 $max = $settings->getRbacLogAge();
256 $ilDB->query(
"DELETE FROM rbac_log WHERE created < ".$ilDB->quote(strtotime(
"-".$max.
"months"),
"integer"));
static garbageCollection()
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
static diffFaPa(array $a_old, array $a_new)
Create styles array
The data for the language used.
static gatherTemplate($a_role_ref_id, $a_role_id)
static getLogItems($a_ref_id, $a_limit, $a_offset, array $a_filter=NULL)
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
static diffTemplate(array $a_old, array $a_new)
const EDIT_TEMPLATE_EXISTING
static _getInstance()
Get instance of ilPrivacySettings.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static isValidAction($a_action)
class ilRbacLog Log changes in Rbac-related settings