ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB;
139
140 $this->delete();
141 $this->create();
142 }
143
144 public function create()
145 {
146 global $ilDB;
147
148 $query = 'INSERT INTO ecs_node_mapping_a (server_id,mid,cs_root,cs_id,ref_id,obj_id,title_update,position_update,tree_update) ' .
149 'VALUES( ' .
150 $ilDB->quote($this->getServerId(), 'integer') . ', ' .
151 $ilDB->quote($this->getMemberId(), 'integer') . ', ' .
152 $ilDB->quote($this->getTreeId(), 'integer') . ', ' .
153 $ilDB->quote($this->getCSId(), 'integer') . ', ' .
154 $ilDB->quote($this->getRefId(), 'integer') . ', ' .
155 $ilDB->quote($this->getObjId(), 'integer') . ', ' .
156 $ilDB->quote($this->isTitleUpdateEnabled(), 'integer') . ', ' .
157 $ilDB->quote($this->isPositionUpdateEnabled(), 'integer') . ', ' .
158 $ilDB->quote($this->isTreeUpdateEnabled(), 'integer') . ' ' .
159 ')';
160 $ilDB->manipulate($query);
161 return true;
162 }
163
164
169 public function delete()
170 {
171 global $ilDB;
172
173 $query = 'DELETE FROM ecs_node_mapping_a ' .
174 'WHERE server_id = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ' .
175 'AND mid = ' . $ilDB->quote($this->getMemberId(), 'integer') . ' ' .
176 'AND cs_root = ' . $ilDB->quote($this->getTreeId(), 'integer') . ' ' .
177 'AND cs_id = ' . $ilDB->quote($this->getCSId(), 'integer');
178 $ilDB->manipulate($query);
179 }
180
181
182
187 protected function read()
188 {
189 global $ilDB;
190
191 $query = 'SELECT * FROM ecs_node_mapping_a ' .
192 'WHERE server_id = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ' .
193 'AND mid = ' . $ilDB->quote($this->getMemberId(), 'integer') . ' ' .
194 'AND cs_root = ' . $ilDB->quote($this->getTreeId(), 'integer') . ' ' .
195 'AND cs_id = ' . $ilDB->quote($this->getCSId(), 'integer') . ' ';
196 $res = $ilDB->query($query);
197
198 #$GLOBALS['ilLog']->write(__METHOD__.': '.$query);
199
200 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
201 $this->setObjId($row->obj_id);
202 $this->setRefId($row->ref_id);
203 $this->enableTitleUpdate($row->title_update);
204 $this->enablePositionUpdate($row->position_update);
205 $this->enableTreeUpdate($row->tree_update);
206 $this->mapped = true;
207 }
208 }
209
210 public static function deleteByServerId($a_server_id)
211 {
212 global $ilDB;
213
214 $query = 'DELETE FROM ecs_node_mapping_a' .
215 ' WHERE server_id = ' . $ilDB->quote($a_server_id, 'integer');
216 $ilDB->manipulate($query);
217 return true;
218 }
219}
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.
if(!array_key_exists('StateId', $_REQUEST)) $id
$query
foreach($_POST as $key=> $value) $res
global $ilDB