ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilECSDataMappingSetting.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
33{
34 const MAPPING_EXPORT = 1;
37
38 private $server_id = 0;
39 private $mapping_type = 0;
40 private $ecs_field = 0;
41 private $advmd_id = 0;
42
43
49 public function __construct($a_server_id = 0, $mapping_type = 0, $ecs_field = '')
50 {
51 $this->setServerId($a_server_id);
53 $this->setECSField($ecs_field);
54 }
55
60 public function setServerId($a_server_id)
61 {
62 $this->server_id = $a_server_id;
63 }
64
68 public function getServerId()
69 {
70 return $this->server_id;
71 }
72
77 public function setECSField($ecs_field)
78 {
79 $this->ecs_field = $ecs_field;
80 }
81
85 public function getECSField()
86 {
87 return $this->ecs_field;
88 }
89
95 {
96 $this->mapping_type = $mapping_type;
97 }
98
102 public function getMappingType()
103 {
104 return $this->mapping_type;
105 }
106
107
112 public function getAdvMDId()
113 {
114 return $this->advmd_id;
115 }
116
117 public function setAdvMDId($a_id)
118 {
119 $this->advmd_id = $a_id;
120 }
121
127 public function save()
128 {
129 global $ilDB;
130
131 $query = 'SELECT * FROM ecs_data_mapping ' .
132 'WHERE sid = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ' .
133 'AND mapping_type = ' . $ilDB->quote($this->getMappingType(), 'integer') . ' ' .
134 'AND ecs_field = ' . $ilDB->quote($this->getECSField(), 'text');
135 $res = $ilDB->query($query);
136 if ($res->numRows()) {
137 $this->update();
138 } else {
139 $this->create();
140 }
141 }
142
147 protected function update()
148 {
149 global $ilDB;
150
151 $query = 'UPDATE ecs_data_mapping ' .
152 'SET advmd_id = ' . $ilDB->quote($this->getAdvMDId(), 'integer') . ' ' .
153 'WHERE sid = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ' .
154 'AND mapping_type = ' . $ilDB->quote($this->getMappingType(), 'integer') . ' ' .
155 'AND ecs_field = ' . $ilDB->quote($this->getECSField(), 'text');
156 $ilDB->manipulate($query);
157 }
158
159 protected function create()
160 {
161 global $ilDB;
162
163 $query = 'INSERT INTO ecs_data_mapping (sid,mapping_type,ecs_field,advmd_id) ' .
164 'VALUES(' .
165 $ilDB->quote($this->getServerId(), 'integer') . ', ' .
166 $ilDB->quote($this->getMappingType(), 'integer') . ', ' .
167 $ilDB->quote($this->getECSField(), 'text') . ', ' .
168 $ilDB->quote($this->getAdvMDId(), 'integer') . ' ) ';
169 $res = $ilDB->manipulate($query);
170 return true;
171 }
172
173
180 private function read()
181 {
182 global $ilDB;
183
184 if ($this->getServerId() and $this->getMappingType() and $this->getECSField()) {
185 $query = 'SELECT * FROM ecs_data_mapping ' .
186 'WHERE sid = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ' .
187 'AND mapping_type = ' . $ilDB->quote($this->getMappingType(), 'integer') . ' ' .
188 'AND ecs_field = ' . $ilDB->quote($this->getECSField(), 'text');
189 $res = $ilDB->query($query);
190 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
191 $this->setAdvMDId($row->advmd_id);
192 }
193 }
194 }
195
196 public static function deleteByServerId($a_server_id)
197 {
198 global $ilDB;
199
200 $query = 'DELETE FROM ecs_data_mapping' .
201 ' WHERE sid = ' . $ilDB->quote($a_server_id, 'integer');
202 $ilDB->manipulate($query);
203 return true;
204 }
205}
An exception for terminatinating execution or to throw for unit testing.
setServerId($a_server_id)
set server id
__construct($a_server_id=0, $mapping_type=0, $ecs_field='')
constructor @access public
setMappingType($mapping_type)
Set mapping type.
update()
Update setting @global ilDB $ilDB.
$query
foreach($_POST as $key=> $value) $res
global $ilDB