ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSNodeMappingAssignment.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 private int $server_id;
27 private int $mid;
28 private int $cs_root;
29 private int $cs_id;
30 private int $ref_id;
31 private int $obj_id;
32
33 private bool $title_update = false;
34 private bool $position_update = false;
35 private bool $tree_update = false;
36
37 private bool $mapped = false;
38
40
41 public function __construct(int $a_server_id, int $mid, int $cs_root, int $cs_id)
42 {
43 global $DIC;
44
45 $this->db = $DIC->database();
46
47 $this->server_id = $a_server_id;
48 $this->mid = $mid;
49 $this->cs_root = $cs_root;
50 $this->cs_id = $cs_id;
51
52 $this->read();
53 }
54
55 public function isMapped(): bool
56 {
57 return $this->mapped;
58 }
59
60 public function getServerId(): int
61 {
62 return $this->server_id;
63 }
64
65 public function setServerId(int $a_id): void
66 {
67 $this->server_id = $a_id;
68 }
69
70 public function setMembershipId(int $a_member_id): void
71 {
72 $this->mid = $a_member_id;
73 }
74
75 public function getMembershipId(): int
76 {
77 return $this->mid;
78 }
79
80 public function getTreeId(): int
81 {
82 return $this->cs_root;
83 }
84
85 public function setTreeId(int $root): void
86 {
87 $this->cs_root = $root;
88 }
89
90 public function getCSId(): int
91 {
92 return $this->cs_id;
93 }
94
95 public function setCSId(int $id): void
96 {
97 $this->cs_id = $id;
98 }
99
100 public function getRefId(): int
101 {
102 return $this->ref_id;
103 }
104
105 public function setRefId(int $a_id): void
106 {
107 $this->ref_id = $a_id;
108 }
109
110 public function getObjId(): int
111 {
112 return $this->obj_id;
113 }
114
115 public function setObjId(int $id): void
116 {
117 $this->obj_id = $id;
118 }
119
120 public function isTitleUpdateEnabled(): bool
121 {
122 return $this->title_update;
123 }
124
125 public function enableTitleUpdate(bool $enabled): void
126 {
127 $this->title_update = $enabled;
128 }
129
130 public function isPositionUpdateEnabled(): bool
131 {
133 }
134
135 public function enablePositionUpdate(bool $enabled): void
136 {
137 $this->position_update = $enabled;
138 }
139
140 public function isTreeUpdateEnabled(): bool
141 {
142 return $this->tree_update;
143 }
144
145 public function enableTreeUpdate(bool $enabled): void
146 {
147 $this->tree_update = $enabled;
148 }
149
153 public function update(): void
154 {
155 $this->delete();
156 $this->create();
157 }
158
159 public function create(): bool
160 {
161 $query = 'INSERT INTO ecs_node_mapping_a (server_id,mid,cs_root,cs_id,ref_id,obj_id,title_update,position_update,tree_update) ' .
162 'VALUES( ' .
163 $this->db->quote($this->getServerId(), 'integer') . ', ' .
164 $this->db->quote($this->getMembershipId(), 'integer') . ', ' .
165 $this->db->quote($this->getTreeId(), 'integer') . ', ' .
166 $this->db->quote($this->getCSId(), 'integer') . ', ' .
167 $this->db->quote($this->getRefId(), 'integer') . ', ' .
168 $this->db->quote($this->getObjId(), 'integer') . ', ' .
169 $this->db->quote($this->isTitleUpdateEnabled(), 'integer') . ', ' .
170 $this->db->quote($this->isPositionUpdateEnabled(), 'integer') . ', ' .
171 $this->db->quote($this->isTreeUpdateEnabled(), 'integer') . ' ' .
172 ')';
173 $this->db->manipulate($query);
174 return true;
175 }
176
177
181 public function delete(): void
182 {
183 $query = 'DELETE FROM ecs_node_mapping_a ' .
184 'WHERE server_id = ' . $this->db->quote($this->getServerId(), 'integer') . ' ' .
185 'AND mid = ' . $this->db->quote($this->getMembershipId(), 'integer') . ' ' .
186 'AND cs_root = ' . $this->db->quote($this->getTreeId(), 'integer') . ' ' .
187 'AND cs_id = ' . $this->db->quote($this->getCSId(), 'integer');
188 $this->db->manipulate($query);
189 }
190
191
192
196 protected function read(): void
197 {
198 $query = 'SELECT * FROM ecs_node_mapping_a ' .
199 'WHERE server_id = ' . $this->db->quote($this->getServerId(), 'integer') . ' ' .
200 'AND mid = ' . $this->db->quote($this->getMembershipId(), 'integer') . ' ' .
201 'AND cs_root = ' . $this->db->quote($this->getTreeId(), 'integer') . ' ' .
202 'AND cs_id = ' . $this->db->quote($this->getCSId(), 'integer') . ' ';
203 $res = $this->db->query($query);
204
205 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
206 $this->setObjId($row->obj_id);
207 $this->setRefId($row->ref_id);
208 $this->enableTitleUpdate($row->title_update);
209 $this->enablePositionUpdate($row->position_update);
210 $this->enableTreeUpdate($row->tree_update);
211 $this->mapped = true;
212 }
213 }
214
215 public static function deleteByServerId($a_server_id): bool
216 {
217 global $DIC;
218
219 $ilDB = $DIC['ilDB'];
220
221 $query = 'DELETE FROM ecs_node_mapping_a' .
222 ' WHERE server_id = ' . $ilDB->quote($a_server_id, 'integer');
223 $ilDB->manipulate($query);
224 return true;
225 }
226}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(int $a_server_id, int $mid, int $cs_root, int $cs_id)
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26