ILIAS  Release_3_10_x_branch Revision 61812
 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  $q = "SELECT * FROM aicc_object WHERE obj_id = ".$ilDB->quote($this->getId());
143 
144  $obj_set = $this->ilias->db->query($q);
145  $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
146  $this->setTitle($obj_rec["title"]);
147  $this->setType($obj_rec["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  function create()
155  {
156  global $ilDB;
157 
158  $q = "INSERT INTO aicc_object (title, type, slm_id, description, developer_id, system_id) VALUES (";
159  $q.=$ilDB->quote($this->getTitle()).", ";
160  $q.=$ilDB->quote($this->getType()).", ";
161  $q.=$ilDB->quote($this->getALMId()).", ";
162  $q.=$ilDB->quote($this->getDescription()).", ";
163  $q.=$ilDB->quote($this->getDeveloperId()).", ";
164  $q.=$ilDB->quote($this->getSystemId()).") ";
165  $this->ilias->db->query($q);
166  $this->setId($this->ilias->db->getLastInsertId());
167  }
168 
169  function update()
170  {
171  global $ilDB;
172 
173  $q = "UPDATE aicc_object SET ";
174  $q.="title = ".$ilDB->quote($this->getTitle()).", ";
175  $q.="type = ".$ilDB->quote($this->getType()).", ";
176  $q.="slm_id = ".$ilDB->quote($this->getALMId()).", ";
177  $q.="description = ".$ilDB->quote($this->getDescription()).", ";
178  $q.="developer_id = ".$ilDB->quote($this->getDeveloperId()).", ";
179  $q.="system_id = ".$ilDB->quote($this->getSystemId())." ";
180  $q.="WHERE obj_id = ".$ilDB->quote($this->getId());
181 
182  $this->ilias->db->query($q);
183  }
184 
185  function delete()
186  {
187  global $ilDB;
188 
189  $q = "DELETE FROM aicc_object WHERE obj_id =".$ilDB->quote($this->getId());
190  $ilDB->query($q);
191  }
192 
198  function &_getInstance($a_id, $a_slm_id)
199  {
200  global $ilDB;
201 
202  $sc_set = $ilDB->query("SELECT type FROM aicc_object WHERE obj_id =".$ilDB->quote($a_id).
203  " AND slm_id = ".$ilDB->quote($a_slm_id));
204  $sc_rec = $sc_set->fetchRow(DB_FETCHMODE_ASSOC);
205 
206  switch($sc_rec["type"])
207  {
208  case "sbl": // Block
209  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCBlock.php");
210  $block =& new ilAICCBlock($a_id);
211  return $block;
212  break;
213 
214  case "sau": // assignable unit
215  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
216  $sau =& new ilAICCUnit($a_id);
217  return $sau;
218  break;
219 
220  case "shd": // course
221  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCCourse.php");
222  $shd =& new ilAICCCourse($a_id);
223  return $shd;
224  break;
225  }
226 
227  }
228 
229 }
230 ?>