ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjFileBasedLM.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
8 require_once "classes/class.ilObject.php";
9 //require_once "Services/MetaData/classes/class.ilMDLanguageItem.php";
10 
21 {
22  var $tree;
23 
30  function ilObjFileBasedLM($a_id = 0,$a_call_by_reference = true)
31  {
32  // this also calls read() method! (if $a_id is set)
33  $this->type = "htlm";
34  $this->ilObject($a_id,$a_call_by_reference);
35  }
36 
37 
44  function update()
45  {
46  global $ilDB;
47 
48  $this->updateMetaData();
50 
51  $ilDB->manipulate("UPDATE file_based_lm SET ".
52  " is_online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline()), "text").",".
53  " startfile = ".$ilDB->quote($this->getStartFile(), "text")." ".
54  " WHERE id = ".$ilDB->quote($this->getId(), "integer"));
55 
56  return true;
57  }
58 
62  function read()
63  {
64  global $ilDB;
65 
66  parent::read();
67 
68  $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($this->getId(), "integer");
69  $lm_set = $ilDB->query($q);
70  $lm_rec = $ilDB->fetchAssoc($lm_set);
71  $this->setOnline(ilUtil::yn2tf($lm_rec["is_online"]));
72  $this->setStartFile((string) $lm_rec["startfile"]);
73 
74  }
75 
79  function initBibItemObject()
80  {
81  include_once("./Modules/LearningModule/classes/class.ilBibItem.php");
82 
83  $this->bib_obj =& new ilBibItem($this);
84  $this->bib_obj->read();
85 
86  return true;
87  }
88 
89 
93  function create()
94  {
95  global $ilDB;
96 
98  $this->createDataDirectory();
99 
100  $ilDB->manipulate("INSERT INTO file_based_lm (id, is_online, startfile) VALUES ".
101  " (".$ilDB->quote($this->getID(), "integer").",".
102  $ilDB->quote("n", "text").",".
103  $ilDB->quote($this->getStartfile(), "text").")");
104 
105  $this->createMetaData();
106  }
107 
108  function getDataDirectory($mode = "filesystem")
109  {
110  $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
111  $lm_dir = $lm_data_dir."/lm_".$this->getId();
112 
113  return $lm_dir;
114  }
115 
117  {
119  }
120 
121  function getStartFile()
122  {
123  return $this->start_file;
124  }
125 
126  function setStartFile($a_file)
127  {
128  $this->start_file = $a_file;
129  }
130 
131  function setOnline($a_online)
132  {
133  $this->online = $a_online;
134  }
135 
136  function getOnline()
137  {
138  return $this->online;
139  }
140 
144  function _lookupOnline($a_id)
145  {
146  global $ilDB;
147 
148  $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($a_id, "integer");
149  $lm_set = $ilDB->query($q);
150  $lm_rec = $ilDB->fetchAssoc($lm_set);
151 
152  return ilUtil::yn2tf($lm_rec["is_online"]);
153  }
154 
161  function getDiskUsage()
162  {
163  require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php");
165  }
166 
167 
168 
179  function delete()
180  {
181  global $ilDB;
182 
183  // always call parent delete function first!!
184  if (!parent::delete())
185  {
186  return false;
187  }
188 
189  // delete meta data of content object
190 /*
191  $nested = new ilNestedSetXML();
192  $nested->init($this->getId(), $this->getType());
193  $nested->deleteAllDBData();
194 */
195 
196  // Delete meta data
197  $this->deleteMetaData();
198 
199  // delete bibliographical items of object
200  include_once("classes/class.ilNestedSetXML.php");
201  $nested = new ilNestedSetXML();
202  $nested->init($this->getId(), "bib");
203  $nested->deleteAllDBData();
204 
205  // delete file_based_lm record
206  $ilDB->manipulate("DELETE FROM file_based_lm WHERE id = ".
207  $ilDB->quote($this->getID(), "integer"));
208 
209  // delete data directory
211 
212  return true;
213  }
214 
224  function initDefaultRoles()
225  {
226  global $rbacadmin;
227 
228  // create a local role folder
229  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
230 
231  // create moderator role and assign role to rolefolder...
232  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
233  //$roles[] = $roleObj->getId();
234 
235  //unset($rfoldObj);
236  //unset($roleObj);
237 
238  return $roles ? $roles : array();
239  }
240 
254  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
255  {
256  global $tree;
257 
258  switch ($a_event)
259  {
260  case "link":
261 
262  //var_dump("<pre>",$a_params,"</pre>");
263  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
264  //exit;
265  break;
266 
267  case "cut":
268 
269  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
270  //exit;
271  break;
272 
273  case "copy":
274 
275  //var_dump("<pre>",$a_params,"</pre>");
276  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
277  //exit;
278  break;
279 
280  case "paste":
281 
282  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
283  //exit;
284  break;
285 
286  case "new":
287 
288  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
289  //exit;
290  break;
291  }
292 
293  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
294  if ($a_node_id==$_GET["ref_id"])
295  {
296  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
297  $parent_type = $parent_obj->getType();
298  if($parent_type == $this->getType())
299  {
300  $a_node_id = (int) $tree->getParentId($a_node_id);
301  }
302  }
303 
304  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
305  }
306 
307 }
308 ?>