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

Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 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 
00037 require_once "classes/class.ilObject.php";
00038 //require_once "Services/MetaData/classes/class.ilMDLanguageItem.php";
00039 
00040 class ilObjFileBasedLM extends ilObject
00041 {
00042         var $tree;
00043 
00050         function ilObjFileBasedLM($a_id = 0,$a_call_by_reference = true)
00051         {
00052                 // this also calls read() method! (if $a_id is set)
00053                 $this->type = "htlm";
00054                 $this->ilObject($a_id,$a_call_by_reference);
00055         }
00056 
00062 /*
00063         function getTitle()
00064         {
00065                 return parent::getTitle();
00066                 //return $this->meta_data->getTitle();
00067         }
00068 */
00069 
00075 /*
00076         function setTitle($a_title)
00077         {
00078                 parent::setTitle($a_title);
00079                 $this->meta_data->setTitle($a_title);
00080         }
00081 */
00082 
00088 /*
00089         function getDescription()
00090         {
00091                 return $this->meta_data->getDescription();
00092         }
00093 */
00094 
00100 /*
00101         function setDescription($a_description)
00102         {
00103                 $this->meta_data->setDescription($a_description);
00104         }
00105 */
00106 
00112 /*
00113         function assignMetaData(&$a_meta_data)
00114         {
00115                 $this->meta_data =& $a_meta_data;
00116         }
00117 */
00118 
00124 /*
00125         function &getMetaData()
00126         {
00127                 return $this->meta_data;
00128         }
00129 */
00130 
00134 /*
00135         function updateMetaData()
00136         {
00137                 $this->meta_data->update();
00138                 if ($this->meta_data->section != "General")
00139                 {
00140                         $meta = $this->meta_data->getElement("Title", "General");
00141                         $this->meta_data->setTitle($meta[0]["value"]);
00142                         $meta = $this->meta_data->getElement("Description", "General");
00143                         $this->meta_data->setDescription($meta[0]["value"]);
00144                 }
00145                 else
00146                 {
00147                         $this->setTitle($this->meta_data->getTitle());
00148                         $this->setDescription($this->meta_data->getDescription());
00149                 }
00150                 parent::update();
00151         }
00152 */
00153 
00160         function update()
00161         {
00162                 global $ilDB;
00163                 
00164                 $this->updateMetaData();
00165                 parent::update();
00166 
00167                 $q = "UPDATE file_based_lm SET ".
00168                         " online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline())).",".
00169                         " startfile = ".$ilDB->quote($this->getStartFile())." ".
00170                         " WHERE id = ".$ilDB->quote($this->getId())." ";
00171                 $this->ilias->db->query($q);
00172 
00173                 return true;
00174         }
00175 
00179         function read()
00180         {
00181                 global $ilDB;
00182                 
00183                 parent::read();
00184 
00185                 $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($this->getId());
00186                 $lm_set = $this->ilias->db->query($q);
00187                 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00188                 $this->setOnline(ilUtil::yn2tf($lm_rec["online"]));
00189                 $this->setStartFile($lm_rec["startfile"]);
00190 
00191         }
00192 
00196         function initBibItemObject()
00197         {
00198                 include_once("./Modules/LearningModule/classes/class.ilBibItem.php");
00199 
00200                 $this->bib_obj =& new ilBibItem($this);
00201                 $this->bib_obj->read();
00202 
00203                 return true;
00204         }
00205 
00206 
00210         function create()
00211         {
00212                 global $ilDB;
00213 
00214                 parent::create();
00215                 $this->createDataDirectory();
00216 
00217 /*
00218                 $this->meta_data->setId($this->getId());
00219                 $this->meta_data->setType($this->getType());
00220                 $this->meta_data->setTitle($this->getTitle());
00221                 $this->meta_data->setDescription($this->getDescription());
00222                 $this->meta_data->setObject($this);
00223                 $this->meta_data->create();
00224 */
00225 
00226                 $q = "INSERT INTO file_based_lm (id, online, startfile) VALUES ".
00227                         " (".$ilDB->quote($this->getID()).",".$ilDB->quote("n").",".
00228                         $ilDB->quote("").")";
00229                 $ilDB->query($q);
00230 
00231                 $this->createMetaData();
00232         }
00233 
00234         function getDataDirectory($mode = "filesystem")
00235         {
00236                 $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
00237                 $lm_dir = $lm_data_dir."/lm_".$this->getId();
00238 
00239                 return $lm_dir;
00240         }
00241 
00242         function createDataDirectory()
00243         {
00244                 ilUtil::makeDir($this->getDataDirectory());
00245         }
00246 
00247         function getStartFile()
00248         {
00249                 return $this->start_file;
00250         }
00251 
00252         function setStartFile($a_file)
00253         {
00254                 $this->start_file = $a_file;
00255         }
00256 
00257         function setOnline($a_online)
00258         {
00259                 $this->online = $a_online;
00260         }
00261 
00262         function getOnline()
00263         {
00264                 return $this->online;
00265         }
00266 
00270         function _lookupOnline($a_id)
00271         {
00272                 global $ilDB;
00273                 
00274                 $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($a_id);
00275                 $lm_set = $this->ilias->db->query($q);
00276                 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00277 
00278                 return ilUtil::yn2tf($lm_rec["online"]);
00279         }
00280 
00281 
00282 
00293         function delete()
00294         {
00295                 global $ilDB;
00296 
00297                 // always call parent delete function first!!
00298                 if (!parent::delete())
00299                 {
00300                         return false;
00301                 }
00302 
00303                 // delete meta data of content object
00304 /*
00305                 $nested = new ilNestedSetXML();
00306                 $nested->init($this->getId(), $this->getType());
00307                 $nested->deleteAllDBData();
00308 */
00309 
00310                 // Delete meta data
00311                 $this->deleteMetaData();
00312 
00313                 // delete bibliographical items of object
00314                 include_once("classes/class.ilNestedSetXML.php");
00315                 $nested = new ilNestedSetXML();
00316                 $nested->init($this->getId(), "bib");
00317                 $nested->deleteAllDBData();
00318 
00319                 // delete file_based_lm record
00320                 $q = "DELETE FROM file_based_lm WHERE id = ".
00321                         $ilDB->quote($this->getID());
00322                 $ilDB->query($q);
00323 
00324                 // delete data directory
00325                 ilUtil::delDir($this->getDataDirectory());
00326 
00327                 return true;
00328         }
00329 
00339         function initDefaultRoles()
00340         {
00341                 global $rbacadmin;
00342 
00343                 // create a local role folder
00344                 //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
00345 
00346                 // create moderator role and assign role to rolefolder...
00347                 //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
00348                 //$roles[] = $roleObj->getId();
00349 
00350                 //unset($rfoldObj);
00351                 //unset($roleObj);
00352 
00353                 return $roles ? $roles : array();
00354         }
00355 
00369         function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00370         {
00371                 global $tree;
00372 
00373                 switch ($a_event)
00374                 {
00375                         case "link":
00376 
00377                                 //var_dump("<pre>",$a_params,"</pre>");
00378                                 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
00379                                 //exit;
00380                                 break;
00381 
00382                         case "cut":
00383 
00384                                 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
00385                                 //exit;
00386                                 break;
00387 
00388                         case "copy":
00389 
00390                                 //var_dump("<pre>",$a_params,"</pre>");
00391                                 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
00392                                 //exit;
00393                                 break;
00394 
00395                         case "paste":
00396 
00397                                 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
00398                                 //exit;
00399                                 break;
00400 
00401                         case "new":
00402 
00403                                 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
00404                                 //exit;
00405                                 break;
00406                 }
00407 
00408                 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
00409                 if ($a_node_id==$_GET["ref_id"])
00410                 {
00411                         $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00412                         $parent_type = $parent_obj->getType();
00413                         if($parent_type == $this->getType())
00414                         {
00415                                 $a_node_id = (int) $tree->getParentId($a_node_id);
00416                         }
00417                 }
00418 
00419                 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00420         }
00421 
00422 }
00423 ?>

Generated on Fri Dec 13 2013 17:56:51 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1