• 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-2005 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 
00131         function _lookupOnline($a_id)
00132         {
00133                 global $ilDB;
00134 
00135                 $q = "SELECT * FROM content_object WHERE id = '".$a_id."'";
00136                 $lm_set = $ilDB->query($q);
00137                 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00138 
00139                 return ilUtil::yn2tf($lm_rec["online"]);
00140         }
00141 
00148         function _getLastAccessedPage($a_ref_id, $a_user_id = "")
00149         {
00150                 global $ilDB, $ilUser;
00151                 
00152                 if ($a_user_id == "")
00153                 {
00154                         $a_user_id = $ilUser->getId();
00155                 }
00156 
00157                 $q = "SELECT * FROM lo_access WHERE ".
00158                         "usr_id = ".$ilDB->quote($a_user_id)." AND ".
00159                         "lm_id = ".$ilDB->quote($a_ref_id);
00160                         
00161                 $lm_id = ilObject::_lookupObjId($a_ref_id);
00162 
00163                 $acc_set = $ilDB->query($q);
00164 
00165                 if ($acc_rec = $acc_set->fetchRow(DB_FETCHMODE_ASSOC))
00166                 {
00167                         $mtree = new ilTree($lm_id);
00168                         $mtree->setTableNames('lm_tree','lm_data');
00169                         $mtree->setTreeTablePK("lm_id");
00170                         if ($mtree->isInTree($acc_rec["obj_id"]))
00171                         {
00172                                 return $acc_rec["obj_id"];
00173                         }
00174                 }
00175                 
00176                 return 0;
00177         }
00178 
00179 }
00180 
00181 ?>

Generated on Fri Dec 13 2013 11:57:56 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1