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

Modules/LearningModule/classes/class.ilObjContentObjectAccess.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 ilObjContentObjectAccess 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(!ilObjContentObjectAccess::_lookupOnline($a_obj_id)
00063                                         && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
00064                                 {
00065                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00066                                         return false;
00067                                 }
00068                                 break;
00069                                 
00070                         case "continue":
00071                         
00072                                 // no continue command for anonymous user
00073                                 if ($ilUser->getId() == ANONYMOUS_USER_ID)
00074                                 {
00075                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("lm_no_continue_for_anonym"));
00076                                         return false;
00077                                 }
00078                         
00079                                 if(!ilObjContentObjectAccess::_lookupOnline($a_obj_id)
00080                                         && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
00081                                 {
00082                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00083                                         return false;
00084                                 }
00085 
00086                                 if (ilObjContentObjectAccess::_getLastAccessedPage($a_ref_id,$a_user_id) <= 0)
00087                                 {
00088                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("not_accessed_yet"));
00089                                         return false;
00090                                 }
00091                                 break;
00092                                 
00093                         // for permission query feature
00094                         case "info":
00095                                 if(!ilObjContentObjectAccess::_lookupOnline($a_obj_id))
00096                                 {
00097                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00098                                 }
00099                                 else
00100                                 {
00101                                         $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
00102                                 }
00103                                 break;
00104 
00105                 }
00106 
00107                 switch ($a_permission)
00108                 {
00109                         case "read":
00110                         case "visible":
00111                                 if (!ilObjContentObjectAccess::_lookupOnline($a_obj_id) &&
00112                                         (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
00113                                 {
00114                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00115                                         return false;
00116                                 }
00117                                 break;
00118                 }
00119 
00120 
00121                 return true;
00122         }
00123 
00124         //
00125         // access relevant methods
00126         //
00127 
00133         function _lookupOnline($a_id)
00134         {
00135                 global $ilDB;
00136 
00137                 $q = "SELECT * FROM content_object WHERE id = ".$ilDB->quote($a_id);
00138                 $lm_set = $ilDB->query($q);
00139                 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00140 
00141                 return ilUtil::yn2tf($lm_rec["online"]);
00142         }
00143 
00150         function _getLastAccessedPage($a_ref_id, $a_user_id = "")
00151         {
00152                 global $ilDB, $ilUser;
00153                 
00154                 if ($a_user_id == "")
00155                 {
00156                         $a_user_id = $ilUser->getId();
00157                 }
00158 
00159                 $q = "SELECT * FROM lo_access WHERE ".
00160                         "usr_id = ".$ilDB->quote($a_user_id)." AND ".
00161                         "lm_id = ".$ilDB->quote($a_ref_id);
00162                         
00163                 $lm_id = ilObject::_lookupObjId($a_ref_id);
00164 
00165                 $acc_set = $ilDB->query($q);
00166 
00167                 if ($acc_rec = $acc_set->fetchRow(DB_FETCHMODE_ASSOC))
00168                 {
00169                         $mtree = new ilTree($lm_id);
00170                         $mtree->setTableNames('lm_tree','lm_data');
00171                         $mtree->setTreeTablePK("lm_id");
00172                         if ($mtree->isInTree($acc_rec["obj_id"]))
00173                         {
00174                                 return $acc_rec["obj_id"];
00175                         }
00176                 }
00177                 
00178                 return 0;
00179         }
00180 
00184         function _checkGoto($a_target)
00185         {
00186                 global $ilAccess;
00187                 
00188                 $t_arr = explode("_", $a_target);
00189 
00190                 if (($t_arr[0] != "lm" &&  $t_arr[0] != "dbk" &&  $t_arr[0] != "st"
00191                         &&  $t_arr[0] != "pg")
00192                         || ((int) $t_arr[1]) <= 0)
00193                 {
00194                         return false;
00195                 }
00196 
00197                 if ($t_arr[0] == "lm" || $t_arr[0] == "dbk")
00198                 {
00199                         if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
00200                                 $ilAccess->checkAccess("visible", "", $t_arr[1]))
00201                         {
00202                                 return true;
00203                         }
00204                 }
00205                 else
00206                 {
00207                         if ($t_arr[2] > 0)
00208                         {
00209                                 $ref_ids = array($t_arr[2]);
00210                         }
00211                         else
00212                         {
00213                                 // determine learning object
00214                                 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
00215                                 $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
00216                                 $ref_ids = ilObject::_getAllReferences($lm_id);
00217                         }
00218                         // check read permissions
00219                         foreach ($ref_ids as $ref_id)
00220                         {
00221                                 // Permission check
00222                                 if ($ilAccess->checkAccess("read", "", $ref_id))
00223                                 {
00224                                         return true;
00225                                 }
00226                         }
00227 
00228                 }
00229                 return false;
00230         }
00231 
00232 }
00233 
00234 ?>

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