ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMD5295.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 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
24
32include_once 'class.ilMD5295Base.php';
33
35{
36 /*
37 * meta elements
38 *
39 */
40 public function &getGeneral()
41 {
42 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295General.php';
43
44 if ($id = ilMD5295General::_getId($this->getRBACId(), $this->getObjId())) {
45 $gen = new ilMD5295General();
46 $gen->setMetaId($id);
47
48 return $gen;
49 }
50 return false;
51 }
52 public function &addGeneral()
53 {
54 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295General.php';
55
56 $gen = new ilMD5295General($this->getRBACId(), $this->getObjId(), $this->getObjType());
57
58 return $gen;
59 }
60
61
62 public function &getLifecycle()
63 {
64 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Lifecycle.php';
65
66 if ($id = ilMD5295Lifecycle::_getId($this->getRBACId(), $this->getObjId())) {
67 $lif = new ilMD5295Lifecycle();
68 $lif->setMetaId($id);
69
70 return $lif;
71 }
72 return false;
73 }
74 public function &addLifecycle()
75 {
76 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Lifecycle.php';
77
78 $lif = new ilMD5295Lifecycle($this->getRBACId(), $this->getObjId(), $this->getObjType());
79
80 return $lif;
81 }
82
83 public function &getMetaMetadata()
84 {
85 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295MetaMetadata.php';
86
87 if ($id = ilMD5295MetaMetadata::_getId($this->getRBACId(), $this->getObjId())) {
88 $met = new ilMD5295MetaMetadata();
89 $met->setMetaId($id);
90
91 return $met;
92 }
93 return false;
94 }
95 public function &addMetaMetadata()
96 {
97 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295MetaMetadata.php';
98
99 $met = new ilMD5295MetaMetadata($this->getRBACId(), $this->getObjId(), $this->getObjType());
100
101 return $met;
102 }
103
104 public function &getTechnical()
105 {
106 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Technical.php';
107
108 if ($id = ilMD5295Technical::_getId($this->getRBACId(), $this->getObjId())) {
109 $tec = new ilMD5295Technical();
110 $tec->setMetaId($id);
111
112 return $tec;
113 }
114 return false;
115 }
116 public function &addTechnical()
117 {
118 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Technical.php';
119
120 $tec = new ilMD5295Technical($this->getRBACId(), $this->getObjId(), $this->getObjType());
121
122 return $tec;
123 }
124
125 public function &getEducational()
126 {
127 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Educational.php';
128
129 if ($id = ilMD5295Educational::_getId($this->getRBACId(), $this->getObjId())) {
130 $edu = new ilMD5295Educational();
131 $edu->setMetaId($id);
132
133 return $edu;
134 }
135 return false;
136 }
137 public function &addEducational()
138 {
139 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Educational.php';
140
141 $edu = new ilMD5295Educational($this->getRBACId(), $this->getObjId(), $this->getObjType());
142
143 return $edu;
144 }
145 public function &getRights()
146 {
147 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Rights.php';
148
149 if ($id = ilMD5295Rights::_getId($this->getRBACId(), $this->getObjId())) {
150 $rig = new ilMD5295Rights();
151 $rig->setMetaId($id);
152
153 return $rig;
154 }
155 return false;
156 }
157 public function &addRights()
158 {
159 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Rights.php';
160
161 $rig = new ilMD5295Rights($this->getRBACId(), $this->getObjId(), $this->getObjType());
162
163 return $rig;
164 }
165
166 public function &getRelationIds()
167 {
168 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Relation.php';
169
170 return ilMD5295Relation::_getIds($this->getRBACId(), $this->getObjId());
171 }
172 public function &getRelation($a_relation_id)
173 {
174 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Relation.php';
175
176 if (!$a_relation_id) {
177 return false;
178 }
179
180 $rel = new ilMD5295Relation();
181 $rel->setMetaId($a_relation_id);
182
183 return $rel;
184 }
185 public function &addRelation()
186 {
187 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Relation.php';
188
189 $rel = new ilMD5295Relation($this->getRBACId(), $this->getObjId(), $this->getObjType());
190
191 return $rel;
192 }
193
194
195 public function &getAnnotationIds()
196 {
197 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Annotation.php';
198
199 return ilMD5295Annotation::_getIds($this->getRBACId(), $this->getObjId());
200 }
201 public function &getAnnotation($a_annotation_id)
202 {
203 if (!$a_annotation_id) {
204 return false;
205 }
206 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Annotation.php';
207
208 $ann = new ilMD5295Annotation();
209 $ann->setMetaId($a_annotation_id);
210
211 return $ann;
212 }
213 public function &addAnnotation()
214 {
215 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Annotation.php';
216
217 $ann = new ilMD5295Annotation($this->getRBACId(), $this->getObjId(), $this->getObjType());
218
219 return $ann;
220 }
221
222 public function &getClassificationIds()
223 {
224 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Classification.php';
225
226 return ilMD5295Classification::_getIds($this->getRBACId(), $this->getObjId());
227 }
228 public function &getClassification($a_classification_id)
229 {
230 if (!$a_classification_id) {
231 return false;
232 }
233
234 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Classification.php';
235
236 $cla = new ilMD5295Classification();
237 $cla->setMetaId($a_classification_id);
238
239 return $cla;
240 }
241 public function &addClassification()
242 {
243 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295Classification.php';
244
245 $cla = new ilMD5295Classification($this->getRBACId(), $this->getObjId(), $this->getObjType());
246
247 return $cla;
248 }
249
250 /*
251 * XML Export of all meta data
252 * @param object (xml writer) see class.ilMD52952XML.php
253 *
254 */
255 public function toXML(&$writer)
256 {
257 $writer->xmlStartTag('MetaData');
258
259 // General
260 if (is_object($gen = &$this->getGeneral())) {
261 $gen->setExportMode($this->getExportMode());
262 $gen->toXML($writer);
263 } else {
264 // Defaults
265 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295General.php';
266 $gen = new ilMD5295General($this->getRBACId(), $this->getObjId(), $this->getObjType()); // added type, alex, 31 Oct 2007
267 $gen->setExportMode($this->getExportMode());
268 $gen->toXML($writer);
269 }
270
271
272 // Lifecycle
273 if (is_object($lif = &$this->getLifecycle())) {
274 $lif->toXML($writer);
275 }
276
277 // Meta-Metadata
278 if (is_object($met = &$this->getMetaMetadata())) {
279 $met->toXML($writer);
280 }
281
282 // Technical
283 if (is_object($tec = &$this->getTechnical())) {
284 $tec->toXML($writer);
285 }
286
287 // Educational
288 if (is_object($edu = &$this->getEducational())) {
289 $edu->toXML($writer);
290 }
291
292 // Rights
293 if (is_object($rig = &$this->getRights())) {
294 $rig->toXML($writer);
295 }
296
297 // Relations
298 foreach ($this->getRelationIds() as $id) {
299 $rel = &$this->getRelation($id);
300 $rel->toXML($writer);
301 }
302
303 // Annotations
304 foreach ($this->getAnnotationIds() as $id) {
305 $ann = &$this->getAnnotation($id);
306 $ann->toXML($writer);
307 }
308
309 // Classification
310 foreach ($this->getClassificationIds() as $id) {
311 $cla = &$this->getClassification($id);
312 $cla->toXML($writer);
313 }
314
315 $writer->xmlEndTag('MetaData');
316 }
317
318 /*
319 * Clone all meta data of an object
320 * @param int rbac_id obj_id of rbac object
321 * @param int obj_id obj_id of meta object
322 * @param string type of meta object
323 * @return object new cloned md object
324 *
325 */
326 public function &cloneMD($a_rbac_id, $a_obj_id, $a_obj_type)
327 {
328 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD52952XML.php';
329
330 // this method makes an xml export of the original meta data set
331 // and uses this xml string to clone the object
332 $md2xml = new ilMD52952XML($this->getRBACId(), $this->getObjId(), $this->getObjType());
333 $md2xml->startExport();
334
335 // Create copier instance. For pg objects one could instantiate a ilMD5295XMLPageCopier class
336 switch ($a_obj_type) {
337 default:
338 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295XMLCopier.php';
339 $mdxmlcopier = new ilMD5295XMLCopier($md2xml->getXML(), $a_rbac_id, $a_obj_id, $a_obj_type);
340 break;
341 }
342 $mdxmlcopier->startParsing();
343
344 return $mdxmlcopier->getMDObject();
345 }
346
347 public function deleteAll()
348 {
349 global $DIC;
350
351 $ilDB = $DIC['ilDB'];
352
353 $tables = array('il_meta_annotation',
354 'il_meta_classification',
355 'il_meta_contribute',
356 'il_meta_description',
357 'il_meta_educational',
358 'il_meta_entity',
359 'il_meta_format',
360 'il_meta_general',
361 'il_meta_identifier',
362 'il_meta_identifier_',
363 'il_meta_keyword',
364 'il_meta_language',
365 'il_meta_lifecycle',
366 'il_meta_location',
367 'il_meta_meta_data',
368 'il_meta_relation',
369 'il_meta_requirement',
370 'il_meta_rights',
371 'il_meta_taxon',
372 'il_meta_taxon_path',
373 'il_meta_technical',
374 'il_meta_tar');
375
376 foreach ($tables as $table) {
377 $query = "DELETE FROM " . $table . " " .
378 "WHERE rbac_id = " . $ilDB->quote($this->getRBACId()) . " " .
379 "AND obj_id = " . $ilDB->quote($this->getObjId());
380
381 $this->db->query($query);
382 }
383
384 return true;
385 }
386
387 public static function _deleteAllByType($a_type)
388 {
389 global $ilDB;
390
391 $tables = array('il_meta_annotation',
392 'il_meta_classification',
393 'il_meta_contribute',
394 'il_meta_description',
395 'il_meta_educational',
396 'il_meta_entity',
397 'il_meta_format',
398 'il_meta_general',
399 'il_meta_identifier',
400 'il_meta_identifier_',
401 'il_meta_keyword',
402 'il_meta_language',
403 'il_meta_lifecycle',
404 'il_meta_location',
405 'il_meta_meta_data',
406 'il_meta_relation',
407 'il_meta_requirement',
408 'il_meta_rights',
409 'il_meta_taxon',
410 'il_meta_taxon_path',
411 'il_meta_technical',
412 'il_meta_tar');
413
414 foreach ($tables as $table) {
415 $query = "DELETE FROM " . $table . " " .
416 "WHERE obj_type = " . $ilDB->quote($a_type, 'text') . " ";
417 $res = $ilDB->query($query);
418 }
419
420 return true;
421 }
422}
An exception for terminatinating execution or to throw for unit testing.
static _getIds($a_rbac_id, $a_obj_id)
static _getIds($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
static _getIds($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
static _getId($a_rbac_id, $a_obj_id)
& getAnnotation($a_annotation_id)
& getEducational()
toXML(&$writer)
& getAnnotationIds()
& getLifecycle()
& getMetaMetadata()
& addMetaMetadata()
& addEducational()
& getRelationIds()
static _deleteAllByType($a_type)
& addLifecycle()
& addClassification()
& getClassificationIds()
& cloneMD($a_rbac_id, $a_obj_id, $a_obj_type)
& getRelation($a_relation_id)
& getClassification($a_classification_id)
$query
foreach($_POST as $key=> $value) $res
global $ilDB
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46