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
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
00056
00057
00058
00059
00060
00061
00062
00063 }
00064
00070
00071
00072
00073
00074
00075
00076
00077
00083
00084
00085
00086
00087
00088
00089
00090
00096
00097
00098
00099
00100
00101
00102
00108
00109
00110
00111
00112
00113
00114
00120
00121
00122
00123
00124
00125
00126
00132
00133
00134
00135
00136
00137
00138
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00168 function update()
00169 {
00170 $this->updateMetaData();
00171 parent::update();
00172
00173 $q = "UPDATE file_based_lm SET ".
00174 " online = '".ilUtil::tf2yn($this->getOnline())."',".
00175 " startfile = '".ilUtil::prepareDBString($this->getStartFile())."'".
00176 " WHERE id = '".$this->getId()."'";
00177 $this->ilias->db->query($q);
00178
00179 return true;
00180 }
00181
00185 function read()
00186 {
00187 parent::read();
00188
00189
00190 $q = "SELECT * FROM file_based_lm WHERE id = '".$this->getId()."'";
00191 $lm_set = $this->ilias->db->query($q);
00192 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00193 $this->setOnline(ilUtil::yn2tf($lm_rec["online"]));
00194 $this->setStartFile($lm_rec["startfile"]);
00195
00196 }
00197
00201 function initBibItemObject()
00202 {
00203 include_once("content/classes/class.ilBibItem.php");
00204
00205 $this->bib_obj =& new ilBibItem($this);
00206 $this->bib_obj->read();
00207
00208 return true;
00209 }
00210
00211
00215 function create()
00216 {
00217 global $ilDB;
00218
00219 parent::create();
00220 $this->createDataDirectory();
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 $q = "INSERT INTO file_based_lm (id, online, startfile) VALUES ".
00232 " (".$ilDB->quote($this->getID()).",".$ilDB->quote("n").",".
00233 $ilDB->quote("").")";
00234 $ilDB->query($q);
00235
00236 $this->createMetaData();
00237 }
00238
00239 function getDataDirectory($mode = "filesystem")
00240 {
00241 $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
00242 $lm_dir = $lm_data_dir."/lm_".$this->getId();
00243
00244 return $lm_dir;
00245 }
00246
00247 function createDataDirectory()
00248 {
00249 ilUtil::makeDir($this->getDataDirectory());
00250 }
00251
00252 function getStartFile()
00253 {
00254 return $this->start_file;
00255 }
00256
00257 function setStartFile($a_file)
00258 {
00259 $this->start_file = $a_file;
00260 }
00261
00262 function setOnline($a_online)
00263 {
00264 $this->online = $a_online;
00265 }
00266
00267 function getOnline()
00268 {
00269 return $this->online;
00270 }
00271
00275 function _lookupOnline($a_id)
00276 {
00277 $q = "SELECT * FROM file_based_lm WHERE id = '".$a_id."'";
00278 $lm_set = $this->ilias->db->query($q);
00279 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00280
00281 return ilUtil::yn2tf($lm_rec["online"]);
00282 }
00283
00284
00292 function ilClone($a_parent_ref)
00293 {
00294 global $rbacadmin;
00295
00296
00297 $new_ref_id = parent::ilClone($a_parent_ref);
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312 return $new_ref_id;
00313 }
00314
00325 function delete()
00326 {
00327 global $ilDB;
00328
00329
00330 if (!parent::delete())
00331 {
00332 return false;
00333 }
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343 $this->deleteMetaData();
00344
00345
00346 include_once("classes/class.ilNestedSetXML.php");
00347 $nested = new ilNestedSetXML();
00348 $nested->init($this->getId(), "bib");
00349 $nested->deleteAllDBData();
00350
00351
00352 $q = "DELETE FROM file_based_lm WHERE id = ".
00353 $ilDB->quote($this->getID());
00354 $ilDB->query($q);
00355
00356
00357 ilUtil::delDir($this->getDataDirectory());
00358
00359 return true;
00360 }
00361
00371 function initDefaultRoles()
00372 {
00373 global $rbacadmin;
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 return $roles ? $roles : array();
00386 }
00387
00401 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00402 {
00403 global $tree;
00404
00405 switch ($a_event)
00406 {
00407 case "link":
00408
00409
00410
00411
00412 break;
00413
00414 case "cut":
00415
00416
00417
00418 break;
00419
00420 case "copy":
00421
00422
00423
00424
00425 break;
00426
00427 case "paste":
00428
00429
00430
00431 break;
00432
00433 case "new":
00434
00435
00436
00437 break;
00438 }
00439
00440
00441 if ($a_node_id==$_GET["ref_id"])
00442 {
00443 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00444 $parent_type = $parent_obj->getType();
00445 if($parent_type == $this->getType())
00446 {
00447 $a_node_id = (int) $tree->getParentId($a_node_id);
00448 }
00449 }
00450
00451 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00452 }
00453
00454 }
00455 ?>