ILIAS  Release_4_0_x_branch Revision 61816
 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-2009 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  $ilDB->manipulate("UPDATE file_based_lm SET ".
168  " is_online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline()), "text").",".
169  " startfile = ".$ilDB->quote($this->getStartFile(), "text")." ".
170  " WHERE id = ".$ilDB->quote($this->getId(), "integer"));
171 
172  return true;
173  }
174 
178  function read()
179  {
180  global $ilDB;
181 
182  parent::read();
183 
184  $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($this->getId(), "integer");
185  $lm_set = $ilDB->query($q);
186  $lm_rec = $ilDB->fetchAssoc($lm_set);
187  $this->setOnline(ilUtil::yn2tf($lm_rec["is_online"]));
188  $this->setStartFile((string) $lm_rec["startfile"]);
189 
190  }
191 
195  function initBibItemObject()
196  {
197  include_once("./Modules/LearningModule/classes/class.ilBibItem.php");
198 
199  $this->bib_obj =& new ilBibItem($this);
200  $this->bib_obj->read();
201 
202  return true;
203  }
204 
205 
209  function create()
210  {
211  global $ilDB;
212 
213  parent::create();
214  $this->createDataDirectory();
215 
216  $ilDB->manipulate("INSERT INTO file_based_lm (id, is_online, startfile) VALUES ".
217  " (".$ilDB->quote($this->getID(), "integer").",".
218  $ilDB->quote("n", "text").",".
219  $ilDB->quote("", "text").")");
220 
221  $this->createMetaData();
222  }
223 
224  function getDataDirectory($mode = "filesystem")
225  {
226  $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
227  $lm_dir = $lm_data_dir."/lm_".$this->getId();
228 
229  return $lm_dir;
230  }
231 
233  {
235  }
236 
237  function getStartFile()
238  {
239  return $this->start_file;
240  }
241 
242  function setStartFile($a_file)
243  {
244  $this->start_file = $a_file;
245  }
246 
247  function setOnline($a_online)
248  {
249  $this->online = $a_online;
250  }
251 
252  function getOnline()
253  {
254  return $this->online;
255  }
256 
260  function _lookupOnline($a_id)
261  {
262  global $ilDB;
263 
264  $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($a_id, "integer");
265  $lm_set = $ilDB->query($q);
266  $lm_rec = $ilDB->fetchAssoc($lm_set);
267 
268  return ilUtil::yn2tf($lm_rec["is_online"]);
269  }
270 
277  function getDiskUsage()
278  {
279  require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php");
281  }
282 
283 
284 
295  function delete()
296  {
297  global $ilDB;
298 
299  // always call parent delete function first!!
300  if (!parent::delete())
301  {
302  return false;
303  }
304 
305  // delete meta data of content object
306 /*
307  $nested = new ilNestedSetXML();
308  $nested->init($this->getId(), $this->getType());
309  $nested->deleteAllDBData();
310 */
311 
312  // Delete meta data
313  $this->deleteMetaData();
314 
315  // delete bibliographical items of object
316  include_once("classes/class.ilNestedSetXML.php");
317  $nested = new ilNestedSetXML();
318  $nested->init($this->getId(), "bib");
319  $nested->deleteAllDBData();
320 
321  // delete file_based_lm record
322  $ilDB->manipulate("DELETE FROM file_based_lm WHERE id = ".
323  $ilDB->quote($this->getID(), "integer"));
324 
325  // delete data directory
327 
328  return true;
329  }
330 
340  function initDefaultRoles()
341  {
342  global $rbacadmin;
343 
344  // create a local role folder
345  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
346 
347  // create moderator role and assign role to rolefolder...
348  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
349  //$roles[] = $roleObj->getId();
350 
351  //unset($rfoldObj);
352  //unset($roleObj);
353 
354  return $roles ? $roles : array();
355  }
356 
370  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
371  {
372  global $tree;
373 
374  switch ($a_event)
375  {
376  case "link":
377 
378  //var_dump("<pre>",$a_params,"</pre>");
379  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
380  //exit;
381  break;
382 
383  case "cut":
384 
385  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
386  //exit;
387  break;
388 
389  case "copy":
390 
391  //var_dump("<pre>",$a_params,"</pre>");
392  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
393  //exit;
394  break;
395 
396  case "paste":
397 
398  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
399  //exit;
400  break;
401 
402  case "new":
403 
404  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
405  //exit;
406  break;
407  }
408 
409  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
410  if ($a_node_id==$_GET["ref_id"])
411  {
412  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
413  $parent_type = $parent_obj->getType();
414  if($parent_type == $this->getType())
415  {
416  $a_node_id = (int) $tree->getParentId($a_node_id);
417  }
418  }
419 
420  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
421  }
422 
423 }
424 ?>