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

Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.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 
00024 include_once("classes/class.ilObjectAccess.php");
00025 
00035 class ilObjFileBasedLMAccess extends ilObjectAccess
00036 {
00049         function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
00050         {
00051                 global $ilUser, $lng, $rbacsystem, $ilAccess;
00052 
00053                 if ($a_user_id == "")
00054                 {
00055                         $a_user_id = $ilUser->getId();
00056                 }
00057 
00058                 switch ($a_cmd)
00059                 {
00060                         case "view":
00061 
00062                                 if ((!ilObjFileBasedLMAccess::_lookupOnline($a_obj_id)
00063                                         && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id)) ||
00064                                         ilObjFileBasedLMAccess::_determineStartUrl($a_obj_id) == "")
00065                                 {
00066                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00067                                         return false;
00068                                 }
00069                                 break;
00070                 }
00071 
00072                 switch ($a_permission)
00073                 {
00074                         case "visible":
00075                                 if (!ilObjFileBasedLMAccess::_lookupOnline($a_obj_id) &&
00076                                         (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
00077                                 {
00078                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00079                                         return false;
00080                                 }
00081                                 break;
00082                 }
00083 
00084 
00085                 return true;
00086         }
00087         
00100         function _getCommands()
00101         {
00102                 $commands = array
00103                 (
00104                         array("permission" => "read", "cmd" => "view", "lang_var" => "show",
00105                                 "default" => true),
00106                         array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"),
00107                 );
00108                 
00109                 return $commands;
00110         }
00111 
00112         //
00113         // access relevant methods
00114         //
00115 
00119         function _lookupOnline($a_id)
00120         {
00121                 global $ilDB;
00122 
00123                 $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($a_id);
00124                 $set = $ilDB->query($q);
00125                 $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
00126 
00127                 return ilUtil::yn2tf($rec["online"]);
00128         }
00129 
00133         function _determineStartUrl($a_id)
00134         {
00135                 global $ilDB;
00136 
00137                 $q = "SELECT * FROM file_based_lm WHERE id = ".$ilDB->quote($a_id);
00138                 $set = $ilDB->query($q);
00139                 $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
00140                 $start_file = $rec["startfile"];
00141                 $dir = ilUtil::getWebspaceDir()."/lm_data/lm_".$a_id;
00142                 
00143                 if (($start_file != "") &&
00144                         (@is_file($dir."/".$start_file)))
00145                 {
00146                         return "./".$dir."/".$start_file;
00147                 }
00148                 else if (@is_file($dir."/index.html"))
00149                 {
00150                         return "./".$dir."/index.html";
00151                 }
00152                 else if (@is_file($dir."/index.htm"))
00153                 {
00154                         return "./".$dir."/index.htm";
00155                 }
00156 
00157                 return "";
00158         }
00159 
00163         function _checkGoto($a_target)
00164         {
00165                 global $ilAccess;
00166                 
00167                 $t_arr = explode("_", $a_target);
00168 
00169                 if ($t_arr[0] != "htlm" || ((int) $t_arr[1]) <= 0)
00170                 {
00171                         return false;
00172                 }
00173 
00174                 if ($ilAccess->checkAccess("visible", "", $t_arr[1]))
00175                 {
00176                         return true;
00177                 }
00178                 return false;
00179         }
00180 
00181 
00182 }
00183 
00184 ?>

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