Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00036 require_once "classes/class.ilObject.php";
00037 require_once "classes/class.ilMetaData.php";
00038
00039 class ilObjFileBasedLM extends ilObject
00040 {
00041 var $tree;
00042
00049 function ilObjFileBasedLM($a_id = 0,$a_call_by_reference = true)
00050 {
00051
00052 $this->type = "htlm";
00053 $this->ilObject($a_id,$a_call_by_reference);
00054
00055 if ($a_id == 0)
00056 {
00057 $new_meta =& new ilMetaData();
00058 $this->assignMetaData($new_meta);
00059 }
00060
00061 }
00062
00068 function getTitle()
00069 {
00070 return parent::getTitle();
00071
00072 }
00073
00079 function setTitle($a_title)
00080 {
00081 parent::setTitle($a_title);
00082 $this->meta_data->setTitle($a_title);
00083 }
00084
00090 function getDescription()
00091 {
00092 return $this->meta_data->getDescription();
00093 }
00094
00100 function setDescription($a_description)
00101 {
00102 $this->meta_data->setDescription($a_description);
00103 }
00104
00110 function assignMetaData(&$a_meta_data)
00111 {
00112 $this->meta_data =& $a_meta_data;
00113 }
00114
00120 function &getMetaData()
00121 {
00122 return $this->meta_data;
00123 }
00124
00128 function updateMetaData()
00129 {
00130 $this->meta_data->update();
00131 if ($this->meta_data->section != "General")
00132 {
00133 $meta = $this->meta_data->getElement("Title", "General");
00134 $this->meta_data->setTitle($meta[0]["value"]);
00135 $meta = $this->meta_data->getElement("Description", "General");
00136 $this->meta_data->setDescription($meta[0]["value"]);
00137 }
00138 else
00139 {
00140 $this->setTitle($this->meta_data->getTitle());
00141 $this->setDescription($this->meta_data->getDescription());
00142 }
00143 parent::update();
00144
00145 }
00146
00153 function update()
00154 {
00155 $this->updateMetaData();
00156
00157 $q = "UPDATE file_based_lm SET ".
00158 " online = '".ilUtil::tf2yn($this->getOnline())."',".
00159 " startfile = '".ilUtil::prepareDBString($this->getStartFile())."'".
00160 " WHERE id = '".$this->getId()."'";
00161 $this->ilias->db->query($q);
00162
00163 return true;
00164 }
00165
00169 function read()
00170 {
00171 parent::read();
00172 $this->meta_data =& new ilMetaData($this->getType(), $this->getId());
00173
00174 $q = "SELECT * FROM file_based_lm WHERE id = '".$this->getId()."'";
00175 $lm_set = $this->ilias->db->query($q);
00176 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00177 $this->setOnline(ilUtil::yn2tf($lm_rec["online"]));
00178 $this->setStartFile($lm_rec["startfile"]);
00179
00180 }
00181
00185 function initBibItemObject()
00186 {
00187 include_once("content/classes/class.ilBibItem.php");
00188
00189 $this->bib_obj =& new ilBibItem($this);
00190 $this->bib_obj->read();
00191
00192 return true;
00193 }
00194
00195
00199 function create()
00200 {
00201 global $ilDB;
00202
00203 parent::create();
00204 $this->createDataDirectory();
00205 $this->meta_data->setId($this->getId());
00206 $this->meta_data->setType($this->getType());
00207 $this->meta_data->setTitle($this->getTitle());
00208 $this->meta_data->setDescription($this->getDescription());
00209 $this->meta_data->setObject($this);
00210 $this->meta_data->create();
00211
00212 $q = "INSERT INTO file_based_lm (id, online, startfile) VALUES ".
00213 " (".$ilDB->quote($this->getID()).",".$ilDB->quote("n").",".
00214 $ilDB->quote("").")";
00215 $ilDB->query($q);
00216 }
00217
00218 function getDataDirectory($mode = "filesystem")
00219 {
00220 $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
00221 $lm_dir = $lm_data_dir."/lm_".$this->getId();
00222
00223 return $lm_dir;
00224 }
00225
00226 function createDataDirectory()
00227 {
00228 ilUtil::makeDir($this->getDataDirectory());
00229 }
00230
00231 function getStartFile()
00232 {
00233 return $this->start_file;
00234 }
00235
00236 function setStartFile($a_file)
00237 {
00238 $this->start_file = $a_file;
00239 }
00240
00241 function setOnline($a_online)
00242 {
00243 $this->online = $a_online;
00244 }
00245
00246 function getOnline()
00247 {
00248 return $this->online;
00249 }
00250
00254 function _lookupOnline($a_id)
00255 {
00256 $q = "SELECT * FROM file_based_lm WHERE id = '".$a_id."'";
00257 $lm_set = $this->ilias->db->query($q);
00258 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00259
00260 return ilUtil::yn2tf($lm_rec["online"]);
00261 }
00262
00263
00271 function ilClone($a_parent_ref)
00272 {
00273 global $rbacadmin;
00274
00275
00276 $new_ref_id = parent::ilClone($a_parent_ref);
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291 return $new_ref_id;
00292 }
00293
00304 function delete()
00305 {
00306 global $ilDB;
00307
00308
00309 if (!parent::delete())
00310 {
00311 return false;
00312 }
00313
00314
00315 $nested = new ilNestedSetXML();
00316 $nested->init($this->getId(), $this->getType());
00317 $nested->deleteAllDBData();
00318
00319
00320 $nested = new ilNestedSetXML();
00321 $nested->init($this->getId(), "bib");
00322 $nested->deleteAllDBData();
00323
00324
00325 $q = "DELETE FROM file_based_lm WHERE id = ".
00326 $ilDB->quote($this->getID());
00327 $ilDB->query($q);
00328
00329
00330 ilUtil::delDir($this->getDataDirectory());
00331
00332 return true;
00333 }
00334
00344 function initDefaultRoles()
00345 {
00346 global $rbacadmin;
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358 return $roles ? $roles : array();
00359 }
00360
00374 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00375 {
00376 global $tree;
00377
00378 switch ($a_event)
00379 {
00380 case "link":
00381
00382
00383
00384
00385 break;
00386
00387 case "cut":
00388
00389
00390
00391 break;
00392
00393 case "copy":
00394
00395
00396
00397
00398 break;
00399
00400 case "paste":
00401
00402
00403
00404 break;
00405
00406 case "new":
00407
00408
00409
00410 break;
00411 }
00412
00413
00414 if ($a_node_id==$_GET["ref_id"])
00415 {
00416 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00417 $parent_type = $parent_obj->getType();
00418 if($parent_type == $this->getType())
00419 {
00420 $a_node_id = (int) $tree->getParentId($a_node_id);
00421 }
00422 }
00423
00424 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00425 }
00426
00427
00428 }
00429 ?>