ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMDTechnical.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 
31 include_once 'class.ilMDBase.php';
32 
33 class ilMDTechnical extends ilMDBase
34 {
35  function ilMDTechnical($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
36  {
37  parent::ilMDBase($a_rbac_id,
38  $a_obj_id,
39  $a_obj_type);
40  }
41 
42  // Methods for child objects (Format, Location, Requirement OrComposite)
43  function &getFormatIds()
44  {
45  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDFormat.php';
46 
47  return ilMDFormat::_getIds($this->getRBACId(),$this->getObjId());
48  }
49  function &getFormat($a_format_id)
50  {
51  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDFormat.php';
52 
53  if(!$a_format_id)
54  {
55  return false;
56  }
57  $for =& new ilMDFormat($this,$a_format_id);
58  $for->setMetaId($a_format_id);
59 
60  return $for;
61  }
62  function &addFormat()
63  {
64  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDFormat.php';
65 
66  $for =& new ilMDFormat($this->getRBACId(),$this->getObjId(),$this->getObjType());
67 
68  return $for;
69  }
70  function &getLocationIds()
71  {
72  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLocation.php';
73 
74  return ilMDLocation::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_technical');
75  }
76  function &getLocation($a_location_id)
77  {
78  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLocation.php';
79 
80  if(!$a_location_id)
81  {
82  return false;
83  }
84  $loc =& new ilMDLocation();
85  $loc->setMetaId($a_location_id);
86 
87  return $loc;
88  }
89  function &addLocation()
90  {
91  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLocation.php';
92 
93  $loc =& new ilMDLocation($this->getRBACId(),$this->getObjId(),$this->getObjType());
94  $loc->setParentId($this->getMetaId());
95  $loc->setParentType('meta_technical');
96 
97  return $loc;
98  }
99  function &getRequirementIds()
100  {
101  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRequirement.php';
102 
103  return ilMDRequirement::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_technical');
104  }
105  function &getRequirement($a_requirement_id)
106  {
107  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRequirement.php';
108 
109  if(!$a_requirement_id)
110  {
111  return false;
112  }
113  $rec =& new ilMDRequirement();
114  $rec->setMetaId($a_requirement_id);
115 
116  return $rec;
117  }
118  function &addRequirement()
119  {
120  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRequirement.php';
121 
122  $rec =& new ilMDRequirement($this->getRBACId(),$this->getObjId(),$this->getObjType());
123  $rec->setParentId($this->getMetaId());
124  $rec->setParentType('meta_technical');
125 
126  return $rec;
127  }
128  function &getOrCompositeIds()
129  {
130  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDOrComposite.php';
131 
132  return ilMDOrComposite::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_technical');
133  }
134  function &getOrComposite($a_or_composite_id)
135  {
136  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDOrComposite.php';
137 
138  if(!$a_or_composite_id)
139  {
140  return false;
141  }
142  $orc =& new ilMDOrComposite($this->getRBACId(),$this->getObjId(),$this->getObjType());
143  $orc->setOrCompositeId($a_or_composite_id);
144  $orc->setParentId($this->getMetaId());
145  $orc->setParentType('meta_technical');
146 
147  return $orc;
148  }
149  function &addOrComposite()
150  {
151  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDOrComposite.php';
152 
153  $orc =& new ilMDOrComposite($this->getRBACId(),$this->getObjId(),$this->getObjType());
154  $orc->setParentId($this->getMetaId());
155  $orc->setParentType('meta_technical');
156 
157  return $orc;
158  }
159 
160  // SET/GET
161  function setSize($a_size)
162  {
163  $this->size = $a_size;
164  }
165  function getSize()
166  {
167  return $this->size;
168  }
169  function setInstallationRemarks($a_val)
170  {
171  $this->installation_remarks = $a_val;
172  }
174  {
175  return $this->installation_remarks;
176  }
177  function setInstallationRemarksLanguage(&$lng_obj)
178  {
179  if(is_object($lng_obj))
180  {
181  $this->installation_remarks_language =& $lng_obj;
182  }
183  }
185  {
186  return is_object($this->installation_remarks_language) ? $this->installation_remarks_language : false;
187  }
189  {
190  return is_object($this->installation_remarks_language) ? $this->installation_remarks_language->getLanguageCode() : false;
191  }
193  {
194  $this->other_platform_requirements = $a_val;
195  }
197  {
198  return $this->other_platform_requirements;
199  }
201  {
202  if(is_object($lng_obj))
203  {
204  $this->other_platform_requirements_language =& $lng_obj;
205  }
206  }
208  {
209  return is_object($this->other_platform_requirements_language) ? $this->other_platform_requirements_language : false;
210  }
212  {
213  return is_object($this->other_platform_requirements_language)
214  ? $this->other_platform_requirements_language->getLanguageCode()
215  : false;
216  }
217  function setDuration($a_val)
218  {
219  $this->duration = $a_val;
220  }
221  function getDuration()
222  {
223  return $this->duration;
224  }
225 
226 
227 
228  function save()
229  {
230  if($this->db->autoExecute('il_meta_technical',
231  $this->__getFields(),
232  DB_AUTOQUERY_INSERT))
233  {
234  $this->setMetaId($this->db->getLastInsertId());
235 
236  return $this->getMetaId();
237  }
238 
239  return false;
240  }
241 
242  function update()
243  {
244  global $ilDB;
245 
246  if($this->getMetaId())
247  {
248  if($this->db->autoExecute('il_meta_technical',
249  $this->__getFields(),
250  DB_AUTOQUERY_UPDATE,
251  "meta_technical_id = ".$ilDB->quote($this->getMetaId())))
252  {
253  return true;
254  }
255  }
256  return false;
257  }
258 
259  function delete()
260  {
261  global $ilDB;
262 
263  if($this->getMetaId())
264  {
265  $query = "DELETE FROM il_meta_technical ".
266  "WHERE meta_technical_id = ".$ilDB->quote($this->getMetaId());
267 
268  $this->db->query($query);
269 
270  foreach($this->getFormatIds() as $id)
271  {
272  $for =& $this->getFormat($id);
273  $for->delete();
274  }
275 
276  foreach($this->getLocationIds() as $id)
277  {
278  $loc =& $this->getLocation($id);
279  $loc->delete();
280  }
281  foreach($this->getRequirementIds() as $id)
282  {
283  $req =& $this->getRequirement($id);
284  $req->delete();
285  }
286  foreach($this->getOrCompositeIds() as $id)
287  {
288  $orc =& $this->getOrComposite($id);
289  $orc->delete();
290  }
291 
292  return true;
293 
294  }
295  return false;
296  }
297 
298 
299  function __getFields()
300  {
301  return array('rbac_id' => $this->getRBACId(),
302  'obj_id' => $this->getObjId(),
303  'obj_type' => ilUtil::prepareDBString($this->getObjType()),
304  'size' => ilUtil::prepareDBString($this->getSize()),
305  'installation_remarks' => ilUtil::prepareDBString($this->getInstallationRemarks()),
306  'installation_remarks_language' => ilUtil::prepareDBString($this->getInstallationRemarksLanguageCode()),
307  'other_platform_requirements' => ilUtil::prepareDBString($this->getOtherPlatformRequirements()),
308  'other_platform_requirements_language' => ilUtil::prepareDBString($this->getOtherPlatformRequirementsLanguageCode()),
309  'duration' => ilUtil::prepareDBString($this->getDuration()));
310  }
311 
312  function read()
313  {
314  global $ilDB;
315 
316  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguageItem.php';
317 
318  if($this->getMetaId())
319  {
320 
321  $query = "SELECT * FROM il_meta_technical ".
322  "WHERE meta_technical_id = ".$ilDB->quote($this->getMetaId());
323 
324 
325  $res = $this->db->query($query);
326  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
327  {
328  $this->setRBACId($row->rbac_id);
329  $this->setObjId($row->obj_id);
330  $this->setObjType($row->obj_type);
331  $this->setSize(ilUtil::stripSlashes($row->size));
332  $this->setInstallationRemarks(ilUtil::stripSlashes($row->installation_remarks));
333  $this->setInstallationRemarksLanguage(new ilMDLanguageItem($row->installation_remarks_language));
334  $this->setOtherPlatformRequirements(ilUtil::stripSlashes($row->other_platform_requirements));
335  $this->setOtherPlatformRequirementsLanguage(new ilMDLanguageItem($row->other_platform_requirements_language));
336  $this->setDuration(ilUtil::stripSlashes($row->duration));
337  }
338  return true;
339  }
340  return false;
341  }
342 
343  /*
344  * XML Export of all meta data
345  * @param object (xml writer) see class.ilMD2XML.php
346  *
347  */
348  function toXML(&$writer)
349  {
350  $writer->xmlStartTag('Technical');
351 
352  // Format
353  foreach($this->getFormatIds() as $id)
354  {
355  $for =& $this->getFormat($id);
356  $for->toXML($writer);
357  }
358 
359  // Size
360  if(strlen($this->getSize()))
361  {
362  $writer->xmlElement('Size',null,$this->getSize());
363  }
364 
365  // Location
366  foreach($this->getLocationIds() as $id)
367  {
368  $loc =& $this->getLocation($id);
369  $loc->toXML($writer);
370  }
371 
372  // Requirement
373  foreach($this->getRequirementIds() as $id)
374  {
375  $req =& $this->getRequirement($id);
376  $req->toXML($writer);
377  }
378 
379  // OrComposite
380  foreach($this->getOrCompositeIds() as $id)
381  {
382  $orc =& $this->getOrComposite($id);
383  $orc->toXML($writer);
384  }
385 
386  // InstallationRemarks
387  if(strlen($this->getInstallationRemarks()))
388  {
389  $writer->xmlElement('InstallationRemarks',
390  array('Language' => $this->getInstallationRemarksLanguageCode()),
391  $this->getInstallationRemarks());
392  }
393 
394  // OtherPlatformRequirements
395  if(strlen($this->getOtherPlatformRequirements()))
396  {
397  $writer->xmlElement('OtherPlatformRequirements',
398  array('Language' => $this->getOtherPlatformRequirementsLanguageCode()),
400  }
401  // Durtation
402  if(strlen($this->getDuration()))
403  {
404  $writer->xmlElement('Duration',null,$this->getDuration());
405  }
406 
407  $writer->xmlEndTag('Technical');
408 
409  }
410  // STATIC
411  function _getId($a_rbac_id,$a_obj_id)
412  {
413  global $ilDB;
414 
415  $query = "SELECT meta_technical_id FROM il_meta_technical ".
416  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
417  "AND obj_id = ".$ilDB->quote($a_obj_id);
418 
419  $res = $ilDB->query($query);
420  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
421  {
422  return $row->meta_technical_id;
423  }
424  return false;
425  }
426 }
427 ?>