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

Modules/Course/classes/class.ilObjCourseAccess.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 
00034 class ilObjCourseAccess extends ilObjectAccess
00035 {
00048         function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
00049         {
00050                 global $ilUser, $lng, $rbacsystem, $ilAccess, $ilias;
00051 
00052                 if ($a_user_id == "")
00053                 {
00054                         $a_user_id = $ilUser->getId();
00055                 }
00056 
00057                 switch ($a_cmd)
00058                 {
00059                         case "view":
00060                                 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00061                                 if(ilCourseParticipants::_isBlocked($a_obj_id,$a_user_id) and ilCourseParticipants::_isParticipant($a_ref_id,$a_user_id))
00062                                 {
00063                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
00064                                         return false;
00065                                 } 
00066                                 /*                              
00067                                 if($members->isBlocked($a_user_id) and $members->isAssigned($a_user_id))
00068                                 {
00069                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
00070                                         return false;
00071                                 }
00072                                 */                                      
00073                                 break;
00074 
00075                         /*
00076                         case "info":
00077                                 // Used for permission query ?!
00078                                 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00079                                 if(ilCourseParticipants::_isAssigned($a_user_id,$a_obj_id))
00080                                 {
00081                                         $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_member"));
00082                                 }
00083                                 else
00084                                 {
00085                                         $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_not_member"));
00086                                 }                       
00087                                 break;
00088                         */      
00089                         case 'join':
00090                                 
00091                                 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00092                                 if(ilCourseParticipants::_isParticipant($a_ref_id,$a_user_id))
00093                                 {
00094                                         return false;
00095                                 }
00096                                 /*
00097                                 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00098 
00099                                 $members = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
00100                                 if($members->isAssigned($a_user_id))
00101                                 {
00102                                         return false;
00103                                 }
00104                                 */                              
00105                                 break;
00106                 }
00107 
00108                 switch ($a_permission)
00109                 {
00110                         case "visible":
00111                                 include_once './Modules/Course/classes/class.ilObjCourse.php';
00112                                 $active = ilObjCourse::_isActivated($a_obj_id);
00113                                 $registration = ilObjCourse::_registrationEnabled($a_obj_id);
00114                                 $tutor = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
00115 
00116                                 if(!$active)
00117                                 {
00118                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00119                                 }
00120                                 if(!$tutor and !$active)
00121                                 {
00122                                         return false;
00123                                 }
00124                                 break;
00125 
00126                         case 'read':
00127                                 $tutor = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
00128                                 if($tutor)
00129                                 {
00130                                         return true;
00131                                 }                               
00132                                 include_once 'Modules/Course/classes/class.ilObjCourse.php';
00133                                 $active = ilObjCourse::_isActivated($a_obj_id);
00134 
00135                                 if(!$active)
00136                                 {
00137                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00138                                         return false;
00139                                 }
00140                                 
00141                                 include_once('Modules/Course/classes/class.ilCourseParticipants.php');
00142                                 if(ilCourseParticipants::_isBlocked($a_obj_id,$a_user_id) and ilCourseParticipants::_isParticipant($a_ref_id,$a_user_id))
00143                                 {
00144                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
00145                                         return false;
00146                                 } 
00147                                 
00148                                 /*
00149                                 $members = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
00150                                 if($members->isBlocked($a_user_id) and $members->isAssigned($a_user_id))  
00151                                 {
00152                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
00153                                         return false;
00154                                 }
00155                                 */
00156                                 break;
00157                 }
00158                 return true;
00159         }
00160 
00173         function _getCommands()
00174         {
00175                 $commands = array
00176                 (
00177                         array("permission" => "read", "cmd" => "", "lang_var" => "view",
00178                                   "default" => true),
00179                         array("permission" => "join", "cmd" => "join", "lang_var" => "join"),
00180                         array("permission" => "write", "cmd" => "edit", "lang_var" => "edit")
00181                 );
00182                 
00183                 return $commands;
00184         }
00185         
00189         function _checkGoto($a_target)
00190         {
00191                 global $ilAccess;
00192                 
00193                 $t_arr = explode("_", $a_target);
00194 
00195                 if ($t_arr[0] != "crs" || ((int) $t_arr[1]) <= 0)
00196                 {
00197                         return false;
00198                 }
00199 
00200                 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
00201                         $ilAccess->checkAccess("visible", "", $t_arr[1]))
00202                 {
00203                         return true;
00204                 }
00205                 return false;
00206         }
00207 
00208 }
00209 
00210 ?>

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