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