ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilECSExport.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
35{
36 protected $db = null;
37
38 protected $server_id = 0;
39 protected $obj_id = 0;
40 protected $econtent_id = 0;
41 protected $exported = false;
42
50 public function __construct($a_server_id,$a_obj_id)
51 {
52 global $ilDB;
53
54 $this->server_id = $a_server_id;
55 $this->obj_id = $a_obj_id;
56
57 $this->db = $ilDB;
58 $this->read();
59 }
60
65 public function getServerId()
66 {
67 return $this->server_id;
68 }
69
74 public function setServerId($a_server_id)
75 {
76 $this->server_id = $a_server_id;
77 }
78
84 public static function _isExported($a_obj_id)
85 {
86 global $ilDB;
87
88 $query = 'SELECT * FROM ecs_export '.
89 'WHERE obj_id = '.$ilDB->quote($a_obj_id,'integer');
90 $res = $ilDB->query($query);
91 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
92 {
93 return true;
94 }
95 return false;
96 }
97
98
106 public static function _getAllEContentIds($a_server_id)
107 {
108 global $ilDB;
109
110 $query = "SELECT econtent_id,obj_id FROM ecs_export ".
111 'WHERE server_id = '.$ilDB->quote($a_server_id,'integer');
112
113 $res = $ilDB->query($query);
114 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
115 {
116 $econtent_ids[$row->econtent_id] = $row->obj_id;
117 }
118 return $econtent_ids ? $econtent_ids : array();
119 }
120
126 public static function getExportedIds()
127 {
128 global $ilDB;
129 $query = "SELECT obj_id FROM ecs_export ";
130 $res = $ilDB->query($query);
131 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
132 {
133 $obj_ids[] = $row->obj_id;
134 }
135 return $obj_ids ? $obj_ids : array();
136 }
137
143 public static function getExportedIdsByType($a_type)
144 {
145 global $ilDB;
146 $query = "SELECT e.obj_id FROM ecs_export e".
147 " JOIN object_data o ON (e.obj_id = o.obj_id)".
148 " WHERE o.type = ".$ilDB->quote($a_type, "text");
149 $res = $ilDB->query($query);
150 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
151 {
152 $obj_ids[] = $row->obj_id;
153 }
154 return $obj_ids ? $obj_ids : array();
155 }
156
163 public static function getExportServerIds($a_obj_id)
164 {
165 global $ilDB;
166
167 $query = 'SELECT * FROM ecs_export '.
168 'WHERE obj_id = '.$ilDB->quote($a_obj_id,'integer');
169 $res = $ilDB->query($query);
170
171 $sids = array();
172 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
173 {
174 $sids[] = $row->server_id;
175 }
176 return $sids;
177 }
178
186 public static function _getExportedIDsByServer($a_server_id)
187 {
188 global $ilDB;
189 $query = "SELECT obj_id FROM ecs_export ".
190 'WHERE server_id = '.$ilDB->quote($a_server_id,'integer');
191 $res = $ilDB->query($query);
192 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
193 {
194 $obj_ids[] = $row->obj_id;
195 }
196 return $obj_ids ? $obj_ids : array();
197 }
198
205 public static function lookupServerIds($a_obj_id)
206 {
207 global $ilDB;
208
209 $query = 'SELECT * FROM ecs_export '.
210 'WHERE obj_id = '.$ilDB->quote($a_obj_id,'integer').' ';
211 $res = $ilDB->query($query);
212 $sids = array();
213 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
214 {
215 $sids[] = $row->server_id;
216 }
217 return $sids;
218 }
219
228 public static function _deleteEContentIds($a_server_id,$a_ids)
229 {
230 global $ilDB;
231
232 if(!is_array($a_ids) or !count($a_ids))
233 {
234 return true;
235 }
236 #$query = "DELETE FROM ecs_export WHERE econtent_id IN (".implode(',',ilUtil::quoteArray($a_ids)).')';
237 $query = "DELETE FROM ecs_export WHERE ".$ilDB->in('econtent_id',$a_ids,false,'integer').' '.
238 'AND server_id = '.$ilDB->quote($a_server_id,'integer');
239 $res = $ilDB->manipulate($query);
240 return true;
241 }
242
248 public static function deleteByServer($a_server_id)
249 {
250 global $ilDB;
251
252 $query = 'DELETE FROM ecs_export '.
253 'WHERE server_id = '.$ilDB->quote($a_server_id,'integer');
254 $ilDB->manipulate($query);
255 }
256
265 public static function _isRemote($a_server_id,$a_econtent_id)
266 {
267 global $ilDB;
268
269 $query = "SELECT obj_id FROM ecs_export ".
270 "WHERE econtent_id = ".$ilDB->quote($a_econtent_id,'integer')." ".
271 'AND server_id = '.$ilDB->quote($a_server_id,'integer');
272 $res = $ilDB->query($query);
273 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
274 {
275 return false;
276 }
277 return true;
278 }
279
287 public function setExported($a_status)
288 {
289 $this->exported = $a_status;
290 }
291
298 public function isExported()
299 {
300 return (bool) $this->exported;
301 }
302
310 public function setEContentId($a_id)
311 {
312 $this->econtent_id = $a_id;
313 }
314
322 public function getEContentId()
323 {
324 return $this->econtent_id;
325 }
326
332 public function save()
333 {
334 global $ilDB;
335
336 $query = "DELETE FROM ecs_export ".
337 "WHERE obj_id = ".$this->db->quote($this->obj_id,'integer')." ".
338 'AND server_id = '.$ilDB->quote($this->getServerId());
339 $res = $ilDB->manipulate($query);
340
341 if($this->isExported())
342 {
343 $query = "INSERT INTO ecs_export (server_id,obj_id,econtent_id) ".
344 "VALUES ( ".
345 $this->db->quote($this->getServerId(),'integer').', '.
346 $this->db->quote($this->obj_id,'integer').", ".
347 $this->db->quote($this->getEContentId(),'integer')." ".
348 ")";
349 $res = $ilDB->manipulate($query);
350 }
351
352 return true;
353 }
354
359 private function read()
360 {
361 global $ilDB;
362
363 $query = "SELECT * FROM ecs_export WHERE ".
364 "obj_id = ".$this->db->quote($this->obj_id,'integer')." AND ".
365 'server_id = '.$ilDB->quote($this->getServerId(),'integer');
366 $res = $this->db->query($query);
367 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
368 {
369 $this->econtent_id = $row->econtent_id;
370 $this->exported = true;
371 }
372 }
373
374 public static function deleteByServerId($a_server_id)
375 {
376 global $ilDB;
377
378 $query = 'DELETE FROM ecs_export'.
379 ' WHERE server_id = '.$ilDB->quote($a_server_id,'integer');
380 $ilDB->manipulate($query);
381 return true;
382 }
383}
384?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
Storage of ECS exported objects.
static deleteByServer($a_server_id)
Delete by server id @global ilDB $ilDB.
getEContentId()
get econtent id
setServerId($a_server_id)
Set server id.
static getExportedIds()
Get exported ids @global ilDB $ilDB.
static _isRemote($a_server_id, $a_econtent_id)
is remote object
getServerId()
Get server id.
setExported($a_status)
Set exported.
isExported()
check if an object is exported or not
static getExportedIdsByType($a_type)
Get exported ids by type @global ilDB $ilDB.
static _isExported($a_obj_id)
Check if object is exported.
static _deleteEContentIds($a_server_id, $a_ids)
Delete econtent ids for server.
__construct($a_server_id, $a_obj_id)
Constructor.
static lookupServerIds($a_obj_id)
Lookup server ids of exported objects @global ilDB $ilDB.
static _getAllEContentIds($a_server_id)
get all exported econtent ids per server
read()
Read @access private.
static getExportServerIds($a_obj_id)
lookup server ids of exported materials @global ilDB $ilDB
setEContentId($a_id)
set econtent id
static _getExportedIDsByServer($a_server_id)
get exported ids for server
static deleteByServerId($a_server_id)
global $ilDB