3 declare(strict_types=1);
42 public static function gatherFaPa(
int $a_ref_id, array $a_role_ids,
bool $a_add_action =
false): array
46 $rbacreview = $DIC->rbac()->review();
53 foreach ($a_role_ids as $role_id) {
56 $result[
"ops"][$role_id][
"add"] = $rbacreview->getRoleOperationsOnObject($role_id, $a_ref_id);
58 $result[
"ops"][$role_id] = $rbacreview->getRoleOperationsOnObject($role_id, $a_ref_id);
66 $result[
"inht"][
"add"] = $rbacreview->getRolesOfRoleFolder($a_ref_id);
68 $result[
"inht"] = $rbacreview->getRolesOfRoleFolder($a_ref_id);
75 public static function diffFaPa(array $a_old, array $a_new): array
80 foreach ((array) $a_old[
"ops"] as $role_id => $ops) {
81 $diff = array_diff($ops, $a_new[
"ops"][$role_id]);
83 $result[
"ops"][$role_id][
"rmv"] = array_values($diff);
85 $diff = array_diff($a_new[
"ops"][$role_id], $ops);
87 $result[
"ops"][$role_id][
"add"] = array_values($diff);
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"];
97 $diff = array_diff($a_old[
"inht"], $a_new[
"inht"]);
99 $result[
"inht"][
"rmv"] = array_values($diff);
101 $diff = array_diff($a_new[
"inht"], $a_old[
"inht"]);
103 $result[
"inht"][
"add"] = array_values($diff);
114 $rbacreview = $DIC->rbac()->review();
115 return $rbacreview->getAllOperationsOfRole($a_role_id, $a_role_ref_id);
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])) {
125 } elseif (!isset($a_new[$type])) {
128 $diff = array_diff($a_old[$type], $a_new[$type]);
130 $result[
$type][
"rmv"] = array_values($diff);
132 $diff = array_diff($a_new[$type], $a_old[$type]);
134 $result[
$type][
"add"] = array_values($diff);
141 public static function add(
int $a_action,
int $a_ref_id, array $a_diff,
bool $a_source_ref_id =
false): bool
146 $ilDB = $DIC->database();
148 if (self::isValidAction($a_action) && count($a_diff)) {
149 if ($a_source_ref_id) {
150 $a_diff[
"src"] = $a_source_ref_id;
154 $ilDB->query(
"INSERT INTO rbac_log (log_id, user_id, created, ref_id, action, data)" .
156 "," .
$ilDB->quote(time(),
"integer") .
157 "," .
$ilDB->quote($a_ref_id,
"integer") .
"," .
$ilDB->quote($a_action,
"integer") .
158 "," .
$ilDB->quote(serialize($a_diff),
"text") .
")");
169 self::EDIT_PERMISSIONS,
175 self::EDIT_TEMPLATE_EXISTING,
184 public static function getLogItems(
int $a_ref_id,
int $a_limit,
int $a_offset, array $a_filter = null): array
188 $ilDB = $DIC->database();
189 $rbacreview = $DIC->rbac()->review();
193 if ($a_filter[
"action"]) {
194 $where[] =
"action = " .
$ilDB->quote($a_filter[
"action"],
"integer");
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");
201 if ($a_filter[
"date"][
"to"]) {
203 $to = strtotime(
"23:59:59", $to);
204 $where[] =
"created <= " .
$ilDB->quote($to,
"integer");
207 if (count($where) > 0) {
208 $where = array_merge([
' AND '], [implode(
' AND ', $where)]);
212 $set =
$ilDB->query(
"SELECT COUNT(*) FROM rbac_log WHERE ref_id = " .
$ilDB->quote(
215 ) . implode(
'', $where));
217 $count = array_pop(
$res);
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");
223 while ($row =
$ilDB->fetchAssoc($set)) {
224 $row[
"data"] = unserialize($row[
"data"]);
227 return [
"cnt" => $count,
"set" => $result];
230 public static function delete(
int $a_ref_id):
void 234 $ilDB = $DIC->database();
235 $ilDB->query(
"DELETE FROM rbac_log WHERE ref_id = " .
$ilDB->quote($a_ref_id,
"integer"));
236 self::garbageCollection();
243 $ilDB = $DIC->database();
248 $ilDB->query(
"DELETE FROM rbac_log WHERE created < " .
$ilDB->quote(
249 strtotime(
"-" . $max .
"months"),
static gatherFaPa(int $a_ref_id, array $a_role_ids, bool $a_add_action=false)
static garbageCollection()
static getLogItems(int $a_ref_id, int $a_limit, int $a_offset, array $a_filter=null)
static gatherTemplate(int $a_role_ref_id, int $a_role_id)
static diffFaPa(array $a_old, array $a_new)
static add(int $a_action, int $a_ref_id, array $a_diff, bool $a_source_ref_id=false)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static diffTemplate(array $a_old, array $a_new)
const EDIT_TEMPLATE_EXISTING
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static isValidAction(int $a_action)