ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilUserActionAdmin.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21
22
28{
29 private array $data = [];
30
31 public function __construct(
32 private ilDBInterface $db
33 ) {
34 $this->data = $this->loadData();
35 }
36
37 public function activateAction(
38 string $context_comp,
39 string $context_id,
40 string $action_comp,
41 string $action_type,
42 bool $active
43 ): void {
44 $this->db->replace(
45 "user_action_activation",
46 [
47 "context_comp" => ["text", $context_comp],
48 "context_id" => ["text", $context_id],
49 "action_comp" => ["text", $action_comp],
50 "action_type" => ["text", $action_type],
51 ],
52 [
53 "active" => ["integer", $active]
54 ]
55 );
56
57 $this->data[$context_comp][$context_id][$action_comp][$action_type] = $active;
58 }
59
60 public function isActionActive(
61 string $context_comp,
62 string $context_id,
63 string $action_comp,
64 string $action_type
65 ): bool {
66 if (
67 !isset($this->data[$context_comp])
68 || !isset($this->data[$context_comp][$context_id])
69 || !isset($this->data[$context_comp][$context_id][$action_comp])
70 || !isset($this->data[$context_comp][$context_id][$action_comp][$action_type])
71 ) {
72 return false;
73 }
74 return $this->data[$context_comp][$context_id][$action_comp][$action_type];
75 }
76
77 private function loadData(): array
78 {
79 $data = [];
80 $set = $this->db->query("SELECT * FROM user_action_activation");
81 while ($rec = $this->db->fetchAssoc($set)) {
82 $data[$rec["context_comp"]][$rec["context_id"]][$rec["action_comp"]][$rec["action_type"]] = (bool) $rec["active"];
83 }
84
85 return $data;
86 }
87}
User action administration.
isActionActive(string $context_comp, string $context_id, string $action_comp, string $action_type)
activateAction(string $context_comp, string $context_id, string $action_comp, string $action_type, bool $active)
__construct(private ilDBInterface $db)
Interface ilDBInterface.
if(!file_exists('../ilias.ini.php'))