• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/class.ilObjFileBasedLM.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                 // this also calls read() method! (if $a_id is set)
00052                 $this->type = "htlm";
00053                 $this->ilObject($a_id,$a_call_by_reference);
00054 
00055 /*
00056                 if ($a_id == 0)
00057                 {
00058                         $new_meta =& new ilMetaData();
00059                         $this->assignMetaData($new_meta);
00060                 }
00061 */
00062 
00063         }
00064 
00070 /*
00071         function getTitle()
00072         {
00073                 return parent::getTitle();
00074                 //return $this->meta_data->getTitle();
00075         }
00076 */
00077 
00083 /*
00084         function setTitle($a_title)
00085         {
00086                 parent::setTitle($a_title);
00087                 $this->meta_data->setTitle($a_title);
00088         }
00089 */
00090 
00096 /*
00097         function getDescription()
00098         {
00099                 return $this->meta_data->getDescription();
00100         }
00101 */
00102 
00108 /*
00109         function setDescription($a_description)
00110         {
00111                 $this->meta_data->setDescription($a_description);
00112         }
00113 */
00114 
00120 /*
00121         function assignMetaData(&$a_meta_data)
00122         {
00123                 $this->meta_data =& $a_meta_data;
00124         }
00125 */
00126 
00132 /*
00133         function &getMetaData()
00134         {
00135                 return $this->meta_data;
00136         }
00137 */
00138 
00142 /*
00143         function updateMetaData()
00144         {
00145                 $this->meta_data->update();
00146                 if ($this->meta_data->section != "General")
00147                 {
00148                         $meta = $this->meta_data->getElement("Title", "General");
00149                         $this->meta_data->setTitle($meta[0]["value"]);
00150                         $meta = $this->meta_data->getElement("Description", "General");
00151                         $this->meta_data->setDescription($meta[0]["value"]);
00152                 }
00153                 else
00154                 {
00155                         $this->setTitle($this->meta_data->getTitle());
00156                         $this->setDescription($this->meta_data->getDescription());
00157                 }
00158                 parent::update();
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 //              $this->meta_data =& new ilMetaData($this->getType(), $this->getId());
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                 $this->meta_data->setId($this->getId());
00224                 $this->meta_data->setType($this->getType());
00225                 $this->meta_data->setTitle($this->getTitle());
00226                 $this->meta_data->setDescription($this->getDescription());
00227                 $this->meta_data->setObject($this);
00228                 $this->meta_data->create();
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                 // always call parent ilClone function first!!
00297                 $new_ref_id = parent::ilClone($a_parent_ref);
00298 
00299                 // get object instance of ilCloned object
00300                 //$newObj =& $this->ilias->obj_factory->getInstanceByRefId($new_ref_id);
00301 
00302                 // create a local role folder & default roles
00303                 //$roles = $newObj->initDefaultRoles();
00304 
00305                 // ...finally assign role to creator of object
00306                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "n");
00307 
00308                 // always destroy objects in ilClone method because ilClone() is recursive and creates instances for each object in subtree!
00309                 //unset($newObj);
00310 
00311                 // ... and finally always return new reference ID!!
00312                 return $new_ref_id;
00313         }
00314 
00325         function delete()
00326         {
00327                 global $ilDB;
00328 
00329                 // always call parent delete function first!!
00330                 if (!parent::delete())
00331                 {
00332                         return false;
00333                 }
00334 
00335                 // delete meta data of content object
00336 /*
00337                 $nested = new ilNestedSetXML();
00338                 $nested->init($this->getId(), $this->getType());
00339                 $nested->deleteAllDBData();
00340 */
00341 
00342                 // Delete meta data
00343                 $this->deleteMetaData();
00344 
00345                 // delete bibliographical items of object
00346                 include_once("classes/class.ilNestedSetXML.php");
00347                 $nested = new ilNestedSetXML();
00348                 $nested->init($this->getId(), "bib");
00349                 $nested->deleteAllDBData();
00350 
00351                 // delete file_based_lm record
00352                 $q = "DELETE FROM file_based_lm WHERE id = ".
00353                         $ilDB->quote($this->getID());
00354                 $ilDB->query($q);
00355 
00356                 // delete data directory
00357                 ilUtil::delDir($this->getDataDirectory());
00358 
00359                 return true;
00360         }
00361 
00371         function initDefaultRoles()
00372         {
00373                 global $rbacadmin;
00374 
00375                 // create a local role folder
00376                 //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
00377 
00378                 // create moderator role and assign role to rolefolder...
00379                 //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
00380                 //$roles[] = $roleObj->getId();
00381 
00382                 //unset($rfoldObj);
00383                 //unset($roleObj);
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                                 //var_dump("<pre>",$a_params,"</pre>");
00410                                 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
00411                                 //exit;
00412                                 break;
00413 
00414                         case "cut":
00415 
00416                                 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
00417                                 //exit;
00418                                 break;
00419 
00420                         case "copy":
00421 
00422                                 //var_dump("<pre>",$a_params,"</pre>");
00423                                 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
00424                                 //exit;
00425                                 break;
00426 
00427                         case "paste":
00428 
00429                                 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
00430                                 //exit;
00431                                 break;
00432 
00433                         case "new":
00434 
00435                                 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
00436                                 //exit;
00437                                 break;
00438                 }
00439 
00440                 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
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 }
00456 ?>

Generated on Fri Dec 13 2013 10:18:29 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1