ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
145 public function create()
146 {
147 global $ilDB;
148
149 $query = 'INSERT INTO ecs_node_mapping_a (server_id,mid,cs_root,cs_id,ref_id,obj_id,title_update,position_update,tree_update) '.
150 'VALUES( '.
151 $ilDB->quote($this->getServerId(),'integer').', '.
152 $ilDB->quote($this->getMemberId(),'integer').', '.
153 $ilDB->quote($this->getTreeId(),'integer').', '.
154 $ilDB->quote($this->getCSId(),'integer').', '.
155 $ilDB->quote($this->getRefId(),'integer').', '.
156 $ilDB->quote($this->getObjId(),'integer').', '.
157 $ilDB->quote($this->isTitleUpdateEnabled(),'integer').', '.
158 $ilDB->quote($this->isPositionUpdateEnabled(),'integer').', '.
159 $ilDB->quote($this->isTreeUpdateEnabled(),'integer').' '.
160 ')';
161 $ilDB->manipulate($query);
162 return true;
163
164 }
165
166
171 public function delete()
172 {
173 global $ilDB;
174
175 $query = 'DELETE FROM ecs_node_mapping_a '.
176 'WHERE server_id = '.$ilDB->quote($this->getServerId(),'integer'). ' '.
177 'AND mid = '.$ilDB->quote($this->getMemberId(),'integer'). ' '.
178 'AND cs_root = '.$ilDB->quote($this->getTreeId(),'integer').' '.
179 'AND cs_id = '.$ilDB->quote($this->getCSId(),'integer');
180 $ilDB->manipulate($query);
181 }
182
183
184
189 protected function read()
190 {
191 global $ilDB;
192
193 $query = 'SELECT * FROM ecs_node_mapping_a '.
194 'WHERE server_id = '.$ilDB->quote($this->getServerId(), 'integer').' '.
195 'AND mid = '.$ilDB->quote($this->getMemberId(),'integer'). ' '.
196 'AND cs_root = '.$ilDB->quote($this->getTreeId(), 'integer').' '.
197 'AND cs_id = '.$ilDB->quote($this->getCSId(), 'integer').' ';
198 $res = $ilDB->query($query);
199
200 #$GLOBALS['ilLog']->write(__METHOD__.': '.$query);
201
202 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
203 {
204 $this->setObjId($row->obj_id);
205 $this->setRefId($row->ref_id);
206 $this->enableTitleUpdate($row->title_update);
207 $this->enablePositionUpdate($row->position_update);
208 $this->enableTreeUpdate($row->tree_update);
209 $this->mapped = true;
210 }
211 }
212
213 public static function deleteByServerId($a_server_id)
214 {
215 global $ilDB;
216
217 $query = 'DELETE FROM ecs_node_mapping_a'.
218 ' WHERE server_id = '.$ilDB->quote($a_server_id,'integer');
219 $ilDB->manipulate($query);
220 return true;
221 }
222
223}
224?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
read()
read settings @global ilDB $ilDB
__construct($a_server_id, $mid, $cs_root, $cs_id)
Constructor.
global $ilDB