ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMediaPoolItem.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
13 protected $import_id;
14
20 function __construct($a_id = 0)
21 {
22 if ($a_id > 0)
23 {
24 $this->setId($a_id);
25 $this->read();
26 }
27 }
28
34 function setId($a_val)
35 {
36 $this->id = $a_val;
37 }
38
44 function getId()
45 {
46 return $this->id;
47 }
48
54 function setType($a_val)
55 {
56 $this->type = $a_val;
57 }
58
64 function getType()
65 {
66 return $this->type;
67 }
68
74 function setForeignId($a_val)
75 {
76 $this->foreign_id = $a_val;
77 }
78
84 function getForeignId()
85 {
86 return $this->foreign_id;
87 }
88
94 function setImportId($a_val)
95 {
96 $this->import_id = $a_val;
97 }
98
104 function getImportId()
105 {
106 return $this->import_id;
107 }
108
114 function setTitle($a_val)
115 {
116 $this->title = $a_val;
117 }
118
124 function getTitle()
125 {
126 return $this->title;
127 }
128
132 function create()
133 {
134 global $ilDB;
135
136 $nid = $ilDB->nextId("mep_item");
137 $ilDB->manipulate("INSERT INTO mep_item ".
138 "(obj_id, type, foreign_id, title, import_id) VALUES (".
139 $ilDB->quote($nid, "integer").",".
140 $ilDB->quote($this->getType(), "text").",".
141 $ilDB->quote($this->getForeignId(), "integer").",".
142 $ilDB->quote($this->getTitle(), "text").",".
143 $ilDB->quote($this->getImportId(), "text").
144 ")");
145 $this->setId($nid);
146 }
147
151 function read()
152 {
153 global $ilDB;
154
155 $set = $ilDB->query("SELECT * FROM mep_item WHERE ".
156 "obj_id = ".$ilDB->quote($this->getId(), "integer")
157 );
158 if ($rec = $ilDB->fetchAssoc($set))
159 {
160 $this->setType($rec["type"]);
161 $this->setForeignId($rec["foreign_id"]);
162 $this->setTitle($rec["title"]);
163 $this->setImportId($rec["import_id"]);
164 }
165 }
166
173 function update()
174 {
175 global $ilDB;
176
177 $ilDB->manipulate("UPDATE mep_item SET ".
178 " type = ".$ilDB->quote($this->getType(), "text").",".
179 " foreign_id = ".$ilDB->quote($this->getForeignId(), "integer").",".
180 " title = ".$ilDB->quote($this->getTitle(), "text").",".
181 " import_id = ".$ilDB->quote($this->getImportId(), "text").
182 " WHERE obj_id = ".$ilDB->quote($this->getId(), "integer")
183 );
184 }
185
192 function delete()
193 {
194 global $ilDB;
195
196 $ilDB->manipulate("DELETE FROM mep_item WHERE "
197 ." obj_id = ".$ilDB->quote($this->getId(), "integer")
198 );
199 }
200
207 private static function lookup($a_id, $a_field)
208 {
209 global $ilDB;
210
211 $set = $ilDB->query("SELECT ".$a_field." FROM mep_item WHERE ".
212 " obj_id = ".$ilDB->quote($a_id, "integer"));
213 if ($rec = $ilDB->fetchAssoc($set))
214 {
215 return $rec[$a_field];
216 }
217 return false;
218 }
219
225 static function lookupForeignId($a_id)
226 {
227 return self::lookup($a_id, "foreign_id");
228 }
229
235 static function lookupType($a_id)
236 {
237 return self::lookup($a_id, "type");
238 }
239
245 static function lookupTitle($a_id)
246 {
247 return self::lookup($a_id, "title");
248 }
249
256 static function updateObjectTitle($a_obj)
257 {
258 global $ilDB;
259
260 if (ilObject::_lookupType($a_obj) == "mob")
261 {
262 $title = ilObject::_lookupTitle($a_obj);
263 $ilDB->manipulate("UPDATE mep_item SET ".
264 " title = ".$ilDB->quote($title, "text").
265 " WHERE foreign_id = ".$ilDB->quote($a_obj, "integer").
266 " AND type = ".$ilDB->quote("mob", "text")
267 );
268 }
269 }
270
274 static function getPoolForItemId($a_id)
275 {
276 global $ilDB;
277
278 $set = $ilDB->query("SELECT * FROM mep_tree ".
279 " WHERE child = ".$ilDB->quote($a_id, "integer")
280 );
281 $pool_ids = array();
282 while ($rec = $ilDB->fetchAssoc($set))
283 {
284 $pool_ids[] = $rec["mep_id"];
285 }
286 return $pool_ids; // currently this array should contain only one id
287 }
288
295 static function getIdsForType($a_id, $a_type)
296 {
297 global $ilDB;
298
299 $set = $ilDB->query("SELECT mep_tree.child as id".
300 " FROM mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) WHERE ".
301 " mep_tree.mep_id = ".$ilDB->quote($a_id, "integer")." AND ".
302 " mep_item.type = ".$ilDB->quote($a_type, "text")
303 );
304
305 $ids = array();
306 while ($rec = $ilDB->fetchAssoc($set))
307 {
308 $ids[] = $rec["id"];
309 }
310 return $ids;
311 }
312
313}
314?>
static getPoolForItemId($a_id)
Get media pools for item id.
static lookupForeignId($a_id)
Lookup Foreign Id.
getImportId()
Get import id.
getForeignId()
Get foreign id.
static lookupType($a_id)
Lookup type.
setTitle($a_val)
Set title.
static getIdsForType($a_id, $a_type)
Get all ids for type.
static updateObjectTitle($a_obj)
Update object title.
setImportId($a_val)
Set import id.
setType($a_val)
Set type.
__construct($a_id=0)
Construtor.
setForeignId($a_val)
Set foreign id.
static lookupTitle($a_id)
Lookup title.
static lookup($a_id, $a_field)
Lookup.
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilDB