ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilECSNodeMappingAssignment.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
12 private $server_id;
13 private $mid;
14 private $cs_root;
15 private $cs_id;
16 private $ref_id;
17 private $obj_id;
18
19 private $title_update = false;
20 private $position_update = false;
21 private $tree_update = false;
22
23 private $mapped = false;
24
28 public function __construct($a_server_id, $mid, $cs_root, $cs_id)
29 {
30 $this->server_id = $a_server_id;
31 $this->mid = $mid;
32 $this->cs_root = $cs_root;
33 $this->cs_id = $cs_id;
34
35 $this->read();
36 }
37
38 public function isMapped()
39 {
40 return $this->mapped;
41 }
42
43 public function getServerId()
44 {
45 return $this->server_id;
46 }
47
48 public function setServerId($a_id)
49 {
50 $this->server_id = $a_id;
51 }
52
53 public function setMemberId($a_member_id)
54 {
55 $this->mid = $a_member_id;
56 }
57
58 public function getMemberId()
59 {
60 return $this->mid;
61 }
62
63 public function getTreeId()
64 {
65 return $this->cs_root;
66 }
67
68 public function setTreeId($root)
69 {
70 $this->cs_root = $root;
71 }
72
73 public function getCSId()
74 {
75 return $this->cs_id;
76 }
77
78 public function setCSId($id)
79 {
80 $this->cs_id = $id;
81 }
82
83 public function getRefId()
84 {
85 return $this->ref_id;
86 }
87
88 public function setRefId($a_id)
89 {
90 $this->ref_id = $a_id;
91 }
92
93 public function getObjId()
94 {
95 return $this->obj_id;
96 }
97
98 public function setObjId($id)
99 {
100 $this->obj_id = $id;
101 }
102
103 public function isTitleUpdateEnabled()
104 {
105 return $this->title_update;
106 }
107
108 public function enableTitleUpdate($enabled)
109 {
110 $this->title_update = $enabled;
111 }
112
113 public function isPositionUpdateEnabled()
114 {
116 }
117
118 public function enablePositionUpdate($enabled)
119 {
120 $this->position_update = $enabled;
121 }
122
123 public function isTreeUpdateEnabled()
124 {
125 return $this->tree_update;
126 }
127
128 public function enableTreeUpdate($enabled)
129 {
130 $this->tree_update = $enabled;
131 }
132
136 public function update()
137 {
138 global $DIC;
139
140 $ilDB = $DIC['ilDB'];
141
142 $this->delete();
143 $this->create();
144 }
145
146 public function create()
147 {
148 global $DIC;
149
150 $ilDB = $DIC['ilDB'];
151
152 $query = 'INSERT INTO ecs_node_mapping_a (server_id,mid,cs_root,cs_id,ref_id,obj_id,title_update,position_update,tree_update) ' .
153 'VALUES( ' .
154 $ilDB->quote($this->getServerId(), 'integer') . ', ' .
155 $ilDB->quote($this->getMemberId(), 'integer') . ', ' .
156 $ilDB->quote($this->getTreeId(), 'integer') . ', ' .
157 $ilDB->quote($this->getCSId(), 'integer') . ', ' .
158 $ilDB->quote($this->getRefId(), 'integer') . ', ' .
159 $ilDB->quote($this->getObjId(), 'integer') . ', ' .
160 $ilDB->quote($this->isTitleUpdateEnabled(), 'integer') . ', ' .
161 $ilDB->quote($this->isPositionUpdateEnabled(), 'integer') . ', ' .
162 $ilDB->quote($this->isTreeUpdateEnabled(), 'integer') . ' ' .
163 ')';
164 $ilDB->manipulate($query);
165 return true;
166 }
167
168
173 public function delete()
174 {
175 global $DIC;
176
177 $ilDB = $DIC['ilDB'];
178
179 $query = 'DELETE FROM ecs_node_mapping_a ' .
180 'WHERE server_id = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ' .
181 'AND mid = ' . $ilDB->quote($this->getMemberId(), 'integer') . ' ' .
182 'AND cs_root = ' . $ilDB->quote($this->getTreeId(), 'integer') . ' ' .
183 'AND cs_id = ' . $ilDB->quote($this->getCSId(), 'integer');
184 $ilDB->manipulate($query);
185 }
186
187
188
193 protected function read()
194 {
195 global $DIC;
196
197 $ilDB = $DIC['ilDB'];
198
199 $query = 'SELECT * FROM ecs_node_mapping_a ' .
200 'WHERE server_id = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ' .
201 'AND mid = ' . $ilDB->quote($this->getMemberId(), 'integer') . ' ' .
202 'AND cs_root = ' . $ilDB->quote($this->getTreeId(), 'integer') . ' ' .
203 'AND cs_id = ' . $ilDB->quote($this->getCSId(), 'integer') . ' ';
204 $res = $ilDB->query($query);
205
206 #$GLOBALS['DIC']['ilLog']->write(__METHOD__.': '.$query);
207
208 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
209 $this->setObjId($row->obj_id);
210 $this->setRefId($row->ref_id);
211 $this->enableTitleUpdate($row->title_update);
212 $this->enablePositionUpdate($row->position_update);
213 $this->enableTreeUpdate($row->tree_update);
214 $this->mapped = true;
215 }
216 }
217
218 public static function deleteByServerId($a_server_id)
219 {
220 global $DIC;
221
222 $ilDB = $DIC['ilDB'];
223
224 $query = 'DELETE FROM ecs_node_mapping_a' .
225 ' WHERE server_id = ' . $ilDB->quote($a_server_id, 'integer');
226 $ilDB->manipulate($query);
227 return true;
228 }
229}
An exception for terminatinating execution or to throw for unit testing.
read()
read settings @global ilDB $ilDB
__construct($a_server_id, $mid, $cs_root, $cs_id)
Constructor.
$query
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46