ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilAICCObject.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 
33 {
34  var $id;
35  var $title;
36  var $objType;
37  var $alm_id;
41 
42 
49  function ilAICCObject($a_id = 0)
50  {
51  global $ilias;
52 
53  $this->ilias =& $ilias;
54  $this->id = $a_id;
55  if ($a_id > 0)
56  {
57  $this->read();
58  }
59  }
60 
61  function getId()
62  {
63  return $this->id;
64  }
65 
66  function setId($a_id)
67  {
68  $this->id = $a_id;
69  }
70 
71  function getType()
72  {
73  return $this->objType;
74  }
75 
76  function setType($a_objType)
77  {
78  $this->objType = $a_objType;
79  }
80 
81  function getTitle()
82  {
83  return $this->title;
84  }
85 
86  function setTitle($a_title)
87  {
88  $this->title = $a_title;
89  }
90 
91  function getDescription()
92  {
93  return $this->description;
94  }
95 
96  function setDescription($a_description)
97  {
98  $this->description = $a_description;
99  }
100 
101  function getDeveloperId()
102  {
103  return $this->developer_id;
104  }
105 
106  function setDeveloperId($a_developer_id)
107  {
108  $this->developer_id = $a_developer_id;
109  }
110 
111  function getSystemId()
112  {
113  return $this->system_id;
114  }
115 
116  function setSystemId($a_system_id)
117  {
118  $this->system_id = $a_system_id;
119  }
120 
121  function getALMId()
122  {
123  return $this->alm_id;
124  }
125 
126  function setALMId($a_alm_id)
127  {
128  $this->alm_id = $a_alm_id;
129  }
130 
131  function prepForStore($string) {
132  if (!get_magic_quotes_runtime()) {
133  $string = addslashes($string);
134  }
135  return $string;
136  }
137 
138  function read()
139  {
140  global $ilDB;
141 
142  $obj_set = $ilDB->queryF('SELECT * FROM aicc_object WHERE obj_id = %s',
143  array('integer'),array($this->getId()));
144  while($obj_rec = $ilDB->fetchAssoc($obj_set))
145  {
146  $this->setTitle($obj_rec["title"]);
147  $this->setType($obj_rec["c_type"]);
148  $this->setALMId($obj_rec["alm_id"]);
149  $this->setDescription($obj_rec["description"]);
150  $this->setDeveloperId($obj_rec["developer_id"]);
151  $this->setSystemId($obj_rec["system_id"]);
152  }
153  }
154 
155  function create()
156  {
157  global $ilDB;
158 
159  $nextId = $ilDB->nextId('aicc_object');
160 
161  $ilDB->insert('aicc_object', array(
162  'obj_id' => array('integer', $nextId),
163  'title' => array('text', $this->getTitle()),
164  'c_type' => array('text', $this->getType()),
165  'slm_id' => array('integer', $this->getALMId()),
166  'description' => array('clob', $this->getDescription()),
167  'developer_id' => array('text',$this->getDeveloperId()),
168  'system_id' => array('integer', $this->getSystemId())
169  ));
170 
171  $this->setId($nextId);
172  }
173 
174  function update()
175  {
176  global $ilDB;
177 
178  $ilDB->update('aicc_object',
179  array(
180  'title' => array('text', $this->getTitle()),
181  'c_type' => array('text', $this->getType()),
182  'slm_id' => array('integer', $this->getALMId()),
183  'description' => array('clob', $this->getDescription()),
184  'developer_id' => array('text',$this->getDeveloperId()),
185  'system_id' => array('integer', $this->getSystemId())
186  ),
187  array(
188  'obj_id' => array('integer', $this->getId())
189  )
190  );
191  }
192 
193  function delete()
194  {
195  global $ilDB;
196 
197  $statement = $ilDB->manipulateF('DELETE FROM aicc_object WHERE obj_id = %s',
198  array('integer'),array($this->getId()));
199  }
200 
206  function &_getInstance($a_id, $a_slm_id)
207  {
208  global $ilDB;
209 
210  $sc_set = $ilDB->queryF('
211  SELECT c_type FROM aicc_object
212  WHERE obj_id = %s
213  AND slm_id = %s',
214  array('integer', 'integer'),
215  array($a_id,$a_slm_id)
216  );
217 
218  while($sc_rec = $ilDB->fetchAssoc($sc_set))
219  {
220  break;
221  }
222 
223  switch($sc_rec["c_type"])
224  {
225  case "sbl": // Block
226  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCBlock.php");
227  $block =& new ilAICCBlock($a_id);
228  return $block;
229  break;
230 
231  case "sau": // assignable unit
232  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
233  $sau =& new ilAICCUnit($a_id);
234  return $sau;
235  break;
236 
237  case "shd": // course
238  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCCourse.php");
239  $shd =& new ilAICCCourse($a_id);
240  return $shd;
241  break;
242  }
243 
244  }
245 
246 }
247 ?>