• 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                 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                 //return $this->meta_data->getTitle();
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                 // always call parent ilClone function first!!
00276                 $new_ref_id = parent::ilClone($a_parent_ref);
00277 
00278                 // get object instance of ilCloned object
00279                 //$newObj =& $this->ilias->obj_factory->getInstanceByRefId($new_ref_id);
00280 
00281                 // create a local role folder & default roles
00282                 //$roles = $newObj->initDefaultRoles();
00283 
00284                 // ...finally assign role to creator of object
00285                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "n");
00286 
00287                 // always destroy objects in ilClone method because ilClone() is recursive and creates instances for each object in subtree!
00288                 //unset($newObj);
00289 
00290                 // ... and finally always return new reference ID!!
00291                 return $new_ref_id;
00292         }
00293 
00304         function delete()
00305         {
00306                 global $ilDB;
00307 
00308                 // always call parent delete function first!!
00309                 if (!parent::delete())
00310                 {
00311                         return false;
00312                 }
00313 
00314                 // delete meta data of content object
00315                 $nested = new ilNestedSetXML();
00316                 $nested->init($this->getId(), $this->getType());
00317                 $nested->deleteAllDBData();
00318 
00319                 // delete bibliographical items of object
00320                 $nested = new ilNestedSetXML();
00321                 $nested->init($this->getId(), "bib");
00322                 $nested->deleteAllDBData();
00323 
00324                 // delete file_based_lm record
00325                 $q = "DELETE FROM file_based_lm WHERE id = ".
00326                         $ilDB->quote($this->getID());
00327                 $ilDB->query($q);
00328 
00329                 // delete data directory
00330                 ilUtil::delDir($this->getDataDirectory());
00331 
00332                 return true;
00333         }
00334 
00344         function initDefaultRoles()
00345         {
00346                 global $rbacadmin;
00347 
00348                 // create a local role folder
00349                 //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
00350 
00351                 // create moderator role and assign role to rolefolder...
00352                 //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
00353                 //$roles[] = $roleObj->getId();
00354 
00355                 //unset($rfoldObj);
00356                 //unset($roleObj);
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                                 //var_dump("<pre>",$a_params,"</pre>");
00383                                 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
00384                                 //exit;
00385                                 break;
00386 
00387                         case "cut":
00388 
00389                                 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
00390                                 //exit;
00391                                 break;
00392 
00393                         case "copy":
00394 
00395                                 //var_dump("<pre>",$a_params,"</pre>");
00396                                 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
00397                                 //exit;
00398                                 break;
00399 
00400                         case "paste":
00401 
00402                                 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
00403                                 //exit;
00404                                 break;
00405 
00406                         case "new":
00407 
00408                                 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
00409                                 //exit;
00410                                 break;
00411                 }
00412 
00413                 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
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 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1