ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilECSParticipantSetting.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 AUTH_VERSION_4 = 1;
35 const AUTH_VERSION_5 = 2;
36
37 const PERSON_EPPN = 1;
38 const PERSON_LUID = 2;
39 const PERSON_LOGIN = 3;
40 const PERSON_UID = 4;
41
42 protected static $instances = array();
43
44
45 // :TODO: what types are needed?
47 const IMPORT_RCRS = 1;
48 const IMPORT_CRS = 2;
49 const IMPORT_CMS = 3;
50
51 private $server_id = 0;
52 private $mid = 0;
53 private $export = false;
54 private $import = false;
55 private $import_type = 1;
56 private $title = '';
57 private $cname = '';
58 private $token = true;
59 private $dtoken = true;
60
63
64
65 private $export_types = array();
66 private $import_types = array();
67
68 private $exists = false;
69
70
77 public function __construct($a_server_id, $mid)
78 {
79 $this->server_id = $a_server_id;
80 $this->mid = $mid;
81 $this->read();
82 }
83
90 public static function getInstance($a_server_id, $mid)
91 {
92 if (self::$instances[$a_server_id . '_' . $mid]) {
93 return self::$instances[$a_server_id . '_' . $mid];
94 }
95 return self::$instances[$a_server_id . '_' . $mid] = new self($a_server_id, $mid);
96 }
97
98
103 public function getServerId()
104 {
105 return $this->server_id;
106 }
107
108 public function setMid($a_mid)
109 {
110 $this->mid = $a_mid;
111 }
112
113 public function getMid()
114 {
115 return $this->mid;
116 }
117
118 public function enableExport($a_status)
119 {
120 $this->export = $a_status;
121 }
122
123 public function isExportEnabled()
124 {
125 return (bool) $this->export;
126 }
127
128 public function enableImport($a_status)
129 {
130 $this->import = $a_status;
131 }
132
133 public function isImportEnabled()
134 {
135 return $this->import;
136 }
137
138 public function setImportType($a_type)
139 {
140 if ($a_type != self::IMPORT_UNCHANGED) {
141 $this->import_type = $a_type;
142 }
143 }
144
145 public function getImportType()
146 {
147 return $this->import_type;
148 }
149
150 public function setTitle($a_title)
151 {
152 $this->title = $a_title;
153 }
154
155 public function getTitle()
156 {
157 return $this->title;
158 }
159
160 public function getCommunityName()
161 {
162 return $this->cname;
163 }
164
165 public function setCommunityName($a_name)
166 {
167 $this->cname = $a_name;
168 }
169
170 public function isTokenEnabled()
171 {
172 return (bool) $this->token;
173 }
174
175 public function enableToken($a_stat)
176 {
177 $this->token = $a_stat;
178 }
179
180 public function setExportTypes($a_types)
181 {
182 $this->export_types = $a_types;
183 }
184
185 public function getExportTypes()
186 {
187 return $this->export_types;
188 }
189
190 public function setImportTypes($a_types)
191 {
192 $this->import_types = $a_types;
193 }
194
195 public function isDeprecatedTokenEnabled()
196 {
197 return (bool) $this->dtoken;
198 }
199
200 public function enableDeprecatedToken($a_stat)
201 {
202 $this->dtoken = $a_stat;
203 }
204
205 public function getImportTypes()
206 {
207 return $this->import_types;
208 }
209
210 private function exists()
211 {
212 return $this->exists;
213 }
214
219 public function update()
220 {
221 global $DIC;
222
223 $ilDB = $DIC['ilDB'];
224
225 if (!$this->exists()) {
226 return $this->create();
227 }
228 $query = 'UPDATE ecs_part_settings ' .
229 'SET ' .
230 'sid = ' . $ilDB->quote((int) $this->getServerId(), 'integer') . ', ' .
231 'mid = ' . $ilDB->quote((int) $this->getMid(), 'integer') . ', ' .
232 'export = ' . $ilDB->quote((int) $this->isExportEnabled(), 'integer') . ', ' .
233 'import = ' . $ilDB->quote((int) $this->isImportEnabled(), 'integer') . ', ' .
234 'import_type = ' . $ilDB->quote((int) $this->getImportType(), 'integer') . ', ' .
235 'title = ' . $ilDB->quote($this->getTitle(), 'text') . ', ' .
236 'cname = ' . $ilDB->quote($this->getCommunityName(), 'text') . ', ' .
237 'token = ' . $ilDB->quote($this->isTokenEnabled(), 'integer') . ', ' .
238 'dtoken = ' . $ilDB->quote($this->isDeprecatedTokenEnabled(), 'integer') . ', ' .
239 'export_types = ' . $ilDB->quote(serialize($this->getExportTypes()), 'text') . ', ' .
240 'import_types = ' . $ilDB->quote(serialize($this->getImportTypes()), 'text') . ' ' .
241 'WHERE sid = ' . $ilDB->quote((int) $this->getServerId(), 'integer') . ' ' .
242 'AND mid = ' . $ilDB->quote((int) $this->getMid(), 'integer');
243 $aff = $ilDB->manipulate($query);
244 return true;
245 }
246
247 private function create()
248 {
249 global $DIC;
250
251 $ilDB = $DIC['ilDB'];
252
253 $query = 'INSERT INTO ecs_part_settings ' .
254 '(sid,mid,export,import,import_type,title,cname,token,dtoken,export_types, import_types) ' .
255 'VALUES( ' .
256 $ilDB->quote($this->getServerId(), 'integer') . ', ' .
257 $ilDB->quote($this->getMid(), 'integer') . ', ' .
258 $ilDB->quote((int) $this->isExportEnabled(), 'integer') . ', ' .
259 $ilDB->quote((int) $this->isImportEnabled(), 'integer') . ', ' .
260 $ilDB->quote((int) $this->getImportType(), 'integer') . ', ' .
261 $ilDB->quote($this->getTitle(), 'text') . ', ' .
262 $ilDB->quote($this->getCommunityName(), 'text') . ', ' .
263 $ilDB->quote($this->isTokenEnabled(), 'integer') . ', ' .
264 $ilDB->quote($this->isDeprecatedTokenEnabled(), 'integer') . ', ' .
265 $ilDB->quote(serialize($this->getExportTypes()), 'text') . ', ' .
266 $ilDB->quote(serialize($this->getImportTypes()), 'text') . ' ' .
267 ')';
268 $aff = $ilDB->manipulate($query);
269 return true;
270 }
271
277 public function delete()
278 {
279 global $DIC;
280
281 $ilDB = $DIC['ilDB'];
282
283 $query = 'DELETE FROM ecs_part_settings ' .
284 'WHERE sid = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ' .
285 'AND mid = ' . $ilDB->quote($this->getMid(), 'integer');
286 $ilDB->manipulate($query);
287 return true;
288 }
289
294 public function read()
295 {
296 global $DIC;
297
298 $ilDB = $DIC['ilDB'];
299
300 $query = 'SELECT * FROM ecs_part_settings ' .
301 'WHERE sid = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ' .
302 'AND mid = ' . $ilDB->quote($this->getMid(), 'integer');
303
304 $res = $ilDB->query($query);
305
306 $this->exists = ($res->numRows() ? true : false);
307
308 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
309 $this->enableExport($row->export);
310 $this->enableImport($row->import);
311 $this->setImportType($row->import_type);
312 $this->setTitle($row->title);
313 $this->setCommunityName($row->cname);
314 $this->enableToken($row->token);
315 $this->enableDeprecatedToken($row->dtoken);
316
317 $this->setExportTypes((array) unserialize($row->export_types));
318 $this->setImportTypes((array) unserialize($row->import_types));
319 }
320 return true;
321 }
322
323 public static function deleteByServerId($a_server_id)
324 {
325 global $DIC;
326
327 $ilDB = $DIC['ilDB'];
328
329 $query = 'DELETE FROM ecs_events' .
330 ' WHERE server_id = ' . $ilDB->quote($a_server_id, 'integer');
331 $ilDB->manipulate($query);
332 return true;
333 }
334}
An exception for terminatinating execution or to throw for unit testing.
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
update()
Update Calls create automatically when no entry exists.
static getInstance($a_server_id, $mid)
Get instance by server id and mid.
__construct($a_server_id, $mid)
Constructor.
global $DIC
Definition: goto.php:24
$query
foreach($_POST as $key=> $value) $res
global $ilDB