ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjFileBasedLM.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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 
37 require_once "classes/class.ilObject.php";
38 //require_once "Services/MetaData/classes/class.ilMDLanguageItem.php";
39 
41 {
42  var $tree;
43 
50  function ilObjFileBasedLM($a_id = 0,$a_call_by_reference = true)
51  {
52  // this also calls read() method! (if $a_id is set)
53  $this->type = "htlm";
54  $this->ilObject($a_id,$a_call_by_reference);
55  }
56 
62 /*
63  function getTitle()
64  {
65  return parent::getTitle();
66  //return $this->meta_data->getTitle();
67  }
68 */
69 
75 /*
76  function setTitle($a_title)
77  {
78  parent::setTitle($a_title);
79  $this->meta_data->setTitle($a_title);
80  }
81 */
82 
88 /*
89  function getDescription()
90  {
91  return $this->meta_data->getDescription();
92  }
93 */
94 
100 /*
101  function setDescription($a_description)
102  {
103  $this->meta_data->setDescription($a_description);
104  }
105 */
106 
112 /*
113  function assignMetaData(&$a_meta_data)
114  {
115  $this->meta_data =& $a_meta_data;
116  }
117 */
118 
124 /*
125  function &getMetaData()
126  {
127  return $this->meta_data;
128  }
129 */
130 
134 /*
135  function updateMetaData()
136  {
137  $this->meta_data->update();
138  if ($this->meta_data->section != "General")
139  {
140  $meta = $this->meta_data->getElement("Title", "General");
141  $this->meta_data->setTitle($meta[0]["value"]);
142  $meta = $this->meta_data->getElement("Description", "General");
143  $this->meta_data->setDescription($meta[0]["value"]);
144  }
145  else
146  {
147  $this->setTitle($this->meta_data->getTitle());
148  $this->setDescription($this->meta_data->getDescription());
149  }
150  parent::update();
151  }
152 */
153 
160  function update()
161  {
162  global $ilDB;
163 
164  $this->updateMetaData();
165  parent::update();
166 
167  $q = "UPDATE file_based_lm SET ".
168  " online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline())).",".
169  " startfile = ".$ilDB->quote($this->getStartFile())." ".
170  " WHERE id = ".$ilDB->quote($this->getId())." ";
171  $this->ilias->db->query($q);
172 
173  return true;
174  }
175 
179  function read()
180  {
181  global $ilDB;
182 
183  parent::read();
184 
185  $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($this->getId());
186  $lm_set = $this->ilias->db->query($q);
187  $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
188  $this->setOnline(ilUtil::yn2tf($lm_rec["online"]));
189  $this->setStartFile($lm_rec["startfile"]);
190 
191  }
192 
196  function initBibItemObject()
197  {
198  include_once("./Modules/LearningModule/classes/class.ilBibItem.php");
199 
200  $this->bib_obj =& new ilBibItem($this);
201  $this->bib_obj->read();
202 
203  return true;
204  }
205 
206 
210  function create()
211  {
212  global $ilDB;
213 
214  parent::create();
215  $this->createDataDirectory();
216 
217 /*
218  $this->meta_data->setId($this->getId());
219  $this->meta_data->setType($this->getType());
220  $this->meta_data->setTitle($this->getTitle());
221  $this->meta_data->setDescription($this->getDescription());
222  $this->meta_data->setObject($this);
223  $this->meta_data->create();
224 */
225 
226  $q = "INSERT INTO file_based_lm (id, online, startfile) VALUES ".
227  " (".$ilDB->quote($this->getID()).",".$ilDB->quote("n").",".
228  $ilDB->quote("").")";
229  $ilDB->query($q);
230 
231  $this->createMetaData();
232  }
233 
234  function getDataDirectory($mode = "filesystem")
235  {
236  $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
237  $lm_dir = $lm_data_dir."/lm_".$this->getId();
238 
239  return $lm_dir;
240  }
241 
243  {
245  }
246 
247  function getStartFile()
248  {
249  return $this->start_file;
250  }
251 
252  function setStartFile($a_file)
253  {
254  $this->start_file = $a_file;
255  }
256 
257  function setOnline($a_online)
258  {
259  $this->online = $a_online;
260  }
261 
262  function getOnline()
263  {
264  return $this->online;
265  }
266 
270  function _lookupOnline($a_id)
271  {
272  global $ilDB;
273 
274  $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($a_id);
275  $lm_set = $this->ilias->db->query($q);
276  $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
277 
278  return ilUtil::yn2tf($lm_rec["online"]);
279  }
280 
281 
282 
293  function delete()
294  {
295  global $ilDB;
296 
297  // always call parent delete function first!!
298  if (!parent::delete())
299  {
300  return false;
301  }
302 
303  // delete meta data of content object
304 /*
305  $nested = new ilNestedSetXML();
306  $nested->init($this->getId(), $this->getType());
307  $nested->deleteAllDBData();
308 */
309 
310  // Delete meta data
311  $this->deleteMetaData();
312 
313  // delete bibliographical items of object
314  include_once("classes/class.ilNestedSetXML.php");
315  $nested = new ilNestedSetXML();
316  $nested->init($this->getId(), "bib");
317  $nested->deleteAllDBData();
318 
319  // delete file_based_lm record
320  $q = "DELETE FROM file_based_lm WHERE id = ".
321  $ilDB->quote($this->getID());
322  $ilDB->query($q);
323 
324  // delete data directory
326 
327  return true;
328  }
329 
339  function initDefaultRoles()
340  {
341  global $rbacadmin;
342 
343  // create a local role folder
344  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
345 
346  // create moderator role and assign role to rolefolder...
347  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
348  //$roles[] = $roleObj->getId();
349 
350  //unset($rfoldObj);
351  //unset($roleObj);
352 
353  return $roles ? $roles : array();
354  }
355 
369  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
370  {
371  global $tree;
372 
373  switch ($a_event)
374  {
375  case "link":
376 
377  //var_dump("<pre>",$a_params,"</pre>");
378  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
379  //exit;
380  break;
381 
382  case "cut":
383 
384  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
385  //exit;
386  break;
387 
388  case "copy":
389 
390  //var_dump("<pre>",$a_params,"</pre>");
391  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
392  //exit;
393  break;
394 
395  case "paste":
396 
397  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
398  //exit;
399  break;
400 
401  case "new":
402 
403  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
404  //exit;
405  break;
406  }
407 
408  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
409  if ($a_node_id==$_GET["ref_id"])
410  {
411  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
412  $parent_type = $parent_obj->getType();
413  if($parent_type == $this->getType())
414  {
415  $a_node_id = (int) $tree->getParentId($a_node_id);
416  }
417  }
418 
419  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
420  }
421 
422 }
423 ?>