ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
8require_once "./Services/Object/classes/class.ilObject.php";
9//require_once "Services/MetaData/classes/class.ilMDLanguageItem.php";
10
21{
22 var $tree;
23
24 protected $online; // [bool]
25
32 function __construct($a_id = 0,$a_call_by_reference = true)
33 {
34 // this also calls read() method! (if $a_id is set)
35 $this->type = "htlm";
36 parent::__construct($a_id,$a_call_by_reference);
37
38 }
39
40
47 function update($a_skip_meta = false)
48 {
49 global $ilDB;
50
51 if (!$a_skip_meta)
52 {
53 $this->updateMetaData();
54 }
55 parent::update();
56
57 $ilDB->manipulate($q = "UPDATE file_based_lm SET ".
58 " is_online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline()), "text").
59 ", startfile = ".$ilDB->quote($this->getStartFile(), "text")." ".
60 " WHERE id = ".$ilDB->quote($this->getId(), "integer"));
61 return true;
62 }
63
67 function read()
68 {
69 global $ilDB;
70
71 parent::read();
72
73 $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($this->getId(), "integer");
74 $lm_set = $ilDB->query($q);
75 $lm_rec = $ilDB->fetchAssoc($lm_set);
76 $this->setOnline(ilUtil::yn2tf($lm_rec["is_online"]));
77 $this->setStartFile((string) $lm_rec["startfile"]);
78 }
79
80
81
85 function create($a_skip_meta = false)
86 {
87 global $ilDB;
88
89 parent::create();
90 $this->createDataDirectory();
91
92 $ilDB->manipulate("INSERT INTO file_based_lm (id, is_online, startfile) VALUES ".
93 " (".$ilDB->quote($this->getID(), "integer").",".
94 $ilDB->quote("n", "text").",".
95 $ilDB->quote($this->getStartfile(), "text").")");
96 if (!$a_skip_meta)
97 {
98 $this->createMetaData();
99 }
100 }
101
102 function getDataDirectory($mode = "filesystem")
103 {
104 $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
105 $lm_dir = $lm_data_dir."/lm_".$this->getId();
106
107 return $lm_dir;
108 }
109
111 {
113 }
114
115 function getStartFile()
116 {
117 return $this->start_file;
118 }
119
120 function setStartFile($a_file, $a_omit_file_check = false)
121 {
122 if($a_file &&
123 (file_exists($this->getDataDirectory()."/".$a_file) || $a_omit_file_check))
124 {
125 $this->start_file = $a_file;
126 }
127 }
128
129 function setOnline($a_online)
130 {
131 $this->online = $a_online;
132 }
133
134 function getOnline()
135 {
136 return $this->online;
137 }
138
142 static function _lookupOnline($a_id)
143 {
144 global $ilDB;
145
146 $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($a_id, "integer");
147 $lm_set = $ilDB->query($q);
148 $lm_rec = $ilDB->fetchAssoc($lm_set);
149
150 return ilUtil::yn2tf($lm_rec["is_online"]);
151 }
152
159 function getDiskUsage()
160 {
161 require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php");
163 }
164
165
166
177 function delete()
178 {
179 global $ilDB;
180
181 // always call parent delete function first!!
182 if (!parent::delete())
183 {
184 return false;
185 }
186
187 // Delete meta data
188 $this->deleteMetaData();
189
190 // delete file_based_lm record
191 $ilDB->manipulate("DELETE FROM file_based_lm WHERE id = ".
192 $ilDB->quote($this->getID(), "integer"));
193
194 // delete data directory
196
197 return true;
198 }
199
209 function populateByDirectoy($a_dir, $a_filename = "")
210 {
211 preg_match("/.*htlm_([0-9]*)\.zip/", $a_filename, $match);
212 if (is_dir($a_dir."/htlm_".$match[1]))
213 {
214 $a_dir = $a_dir."/htlm_".$match[1];
215 }
216 ilUtil::rCopy($a_dir, $this->getDataDirectory());
218 }
219
226 public function cloneObject($a_target_id,$a_copy_id = 0, $a_omit_tree = false)
227 {
228 global $ilDB, $ilUser, $ilias;
229
230 $new_obj = parent::cloneObject($a_target_id,$a_copy_id, $a_omit_tree);
231 $this->cloneMetaData($new_obj);
232
233 //copy online status if object is not the root copy object
234 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
235
236 if(!$cp_options->isRootNode($this->getRefId()))
237 {
238 $new_obj->setOnline($this->getOnline());
239 }
240
241 $new_obj->setTitle($this->getTitle());
242 $new_obj->setDescription($this->getDescription());
243
244 // copy content
245 $new_obj->populateByDirectoy($this->getDataDirectory());
246
247 $new_obj->setStartFile($this->getStartFile());
248 $new_obj->update();
249
250 return $new_obj;
251 }
252
253}
254?>
An exception for terminatinating execution or to throw for unit testing.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static _lookupDiskUsage($a_id)
Returns the number of bytes used on the harddisk by the learning module with the specified object id.
File Based Learning Module (HTML) object.
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
update($a_skip_meta=false)
update object data
getDiskUsage()
Gets the disk usage of the object in bytes.
setStartFile($a_file, $a_omit_file_check=false)
populateByDirectoy($a_dir, $a_filename="")
Populate by directory.
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Clone HTML learning module.
static _lookupOnline($a_id)
check wether content object is online
create($a_skip_meta=false)
create file based lm
getDataDirectory($mode="filesystem")
Class ilObject Basic functions for all objects.
deleteMetaData()
delete meta data entry
updateMetaData()
update meta data entry
createMetaData()
create meta data entry
getDescription()
get object description
cloneMetaData($target_obj)
Copy meta data.
getId()
get object id @access public
getTitle()
get object title @access public
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static tf2yn($a_tf)
convert true/false to "y"/"n"
static getWebspaceDir($mode="filesystem")
get webspace directory
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static yn2tf($a_yn)
convert "y"/"n" to true/false
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
global $ilDB
$lm_set
$ilUser
Definition: imgupload.php:18