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

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 
00035 class ilObjCourseAccess 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, $ilias;
00052 
00053                 if ($a_user_id == "")
00054                 {
00055                         $a_user_id = $ilUser->getId();
00056                 }
00057 
00058                 switch ($a_cmd)
00059                 {
00060                         case "view":
00061                                 include_once 'course/classes/class.ilCourseMembers.php';
00062                                 if(ilCourseMembers::_isBlocked($a_obj_id,$a_user_id))
00063                                 {
00064                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
00065                                         return false;
00066                                 }                                       
00067                                 break;
00068 
00069                         case "info":
00070                                 // Used for permission query ?!
00071                                 include_once 'course/classes/class.ilCourseMembers.php';
00072                                 if(ilCourseMembers::_isMember($a_user_id,$a_obj_id))
00073                                 {
00074                                         $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_member"));
00075                                 }
00076                                 else
00077                                 {
00078                                         $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_not_member"));
00079                                 }                       
00080                                 break;
00081 
00082                         case 'join':
00083                                 include_once 'course/classes/class.ilCourseMembers.php';
00084 
00085                                 if(ilCourseMembers::_isMember($a_user_id,$a_obj_id))
00086                                 {
00087                                         return false;
00088                                 }
00089                                 break;
00090                 }
00091 
00092                 switch ($a_permission)
00093                 {
00094                         case "visible":
00095                                 include_once 'course/classes/class.ilObjCourse.php';
00096                                 $active = ilObjCourse::_isActivated($a_obj_id);
00097                                 $registration = ilObjCourse::_registrationEnabled($a_obj_id);
00098                                 $tutor = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
00099 
00100                                 if(!$active)
00101                                 {
00102                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00103                                 }
00104                                 if(!$tutor and !$active and !$registration)
00105                                 {
00106                                         return false;
00107                                 }
00108                                 break;
00109 
00110                         case 'read':
00111                                 include_once 'course/classes/class.ilObjCourse.php';
00112                                 $active = ilObjCourse::_isActivated($a_obj_id);
00113                                 $tutor = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
00114 
00115                                 if(!$tutor and !$active)
00116                                 {
00117                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00118                                         return false;
00119                                 }
00120                                 break;
00121                                         
00122                                 
00123                 }
00124                 return true;
00125         }
00126 
00139         function _getCommands()
00140         {
00141                 $commands = array
00142                 (
00143                         array("permission" => "read", "cmd" => "view", "lang_var" => "view",
00144                                   "default" => true),
00145                         array("permission" => "join", "cmd" => "join", "lang_var" => "join"),
00146                         array("permission" => "write", "cmd" => "edit", "lang_var" => "edit")
00147                 );
00148                 
00149                 return $commands;
00150         }
00151 }
00152 
00153 ?>

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