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

content/classes/class.ilObjContentObjectAccess.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 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                         case "info":
00094                                 if(!ilObjContentObjectAccess::_lookupOnline($a_obj_id))
00095                                 {
00096                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00097                                 }
00098                                 else
00099                                 {
00100                                         $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
00101                                 }
00102                                 break;
00103 
00104                 }
00105 
00106                 switch ($a_permission)
00107                 {
00108                         case "visible":
00109                                 if (!ilObjContentObjectAccess::_lookupOnline($a_obj_id) &&
00110                                         (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
00111                                 {
00112                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00113                                         return false;
00114                                 }
00115                                 break;
00116                 }
00117 
00118 
00119                 return true;
00120         }
00121 
00122         //
00123         // access relevant methods
00124         //
00125 
00129         function _lookupOnline($a_id)
00130         {
00131                 global $ilDB;
00132 
00133                 $q = "SELECT * FROM content_object WHERE id = '".$a_id."'";
00134                 $lm_set = $ilDB->query($q);
00135                 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00136 
00137                 return ilUtil::yn2tf($lm_rec["online"]);
00138         }
00139 
00146         function _getLastAccessedPage($a_ref_id, $a_user_id = "")
00147         {
00148                 global $ilDB, $ilUser;
00149                 
00150                 if ($a_user_id == "")
00151                 {
00152                         $a_user_id = $ilUser->getId();
00153                 }
00154 
00155                 $q = "SELECT * FROM lo_access WHERE ".
00156                         "usr_id = ".$ilDB->quote($a_user_id)." AND ".
00157                         "lm_id = ".$ilDB->quote($a_ref_id);
00158                         
00159                 $lm_id = ilObject::_lookupObjId($a_ref_id);
00160 
00161                 $acc_set = $ilDB->query($q);
00162 
00163                 if ($acc_rec = $acc_set->fetchRow(DB_FETCHMODE_ASSOC))
00164                 {
00165                         $mtree = new ilTree($lm_id);
00166                         $mtree->setTableNames('lm_tree','lm_data');
00167                         $mtree->setTreeTablePK("lm_id");
00168                         if ($mtree->isInTree($acc_rec["obj_id"]))
00169                         {
00170                                 return $acc_rec["obj_id"];
00171                         }
00172                 }
00173                 
00174                 return 0;
00175         }
00176 
00177 }
00178 
00179 ?>

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