ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjCourseAccess.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("classes/class.ilObjectAccess.php");
25 
35 {
48  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
49  {
50  global $ilUser, $lng, $rbacsystem, $ilAccess, $ilias;
51 
52  if ($a_user_id == "")
53  {
54  $a_user_id = $ilUser->getId();
55  }
56 
57  switch ($a_cmd)
58  {
59  case "view":
60  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
61  if(ilCourseParticipants::_isBlocked($a_obj_id,$a_user_id) and ilCourseParticipants::_isParticipant($a_ref_id,$a_user_id))
62  {
63  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
64  return false;
65  }
66  /*
67  if($members->isBlocked($a_user_id) and $members->isAssigned($a_user_id))
68  {
69  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
70  return false;
71  }
72  */
73  break;
74 
75  case 'join':
76 
77  include_once './Modules/Course/classes/class.ilObjCourse.php';
78  $registration = ilObjCourse::_registrationEnabled($a_obj_id);
79 
80  if(!$registration)
81  {
82  return false;
83  }
84 
85  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
86  if(ilCourseParticipants::_isParticipant($a_ref_id,$a_user_id))
87  {
88  return false;
89  }
90 
91  /*
92  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
93 
94  $members = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
95  if($members->isAssigned($a_user_id))
96  {
97  return false;
98  }
99  */
100  break;
101  }
102 
103  switch ($a_permission)
104  {
105  case "visible":
106  include_once './Modules/Course/classes/class.ilObjCourse.php';
107  $active = ilObjCourse::_isActivated($a_obj_id);
108  $registration = ilObjCourse::_registrationEnabled($a_obj_id);
109  $tutor = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
110 
111  if(!$active)
112  {
113  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
114  }
115  if(!$tutor and !$active)
116  {
117  return false;
118  }
119  break;
120 
121  case 'read':
122  $tutor = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
123  if($tutor)
124  {
125  return true;
126  }
127  include_once 'Modules/Course/classes/class.ilObjCourse.php';
128  $active = ilObjCourse::_isActivated($a_obj_id);
129 
130  if(!$active)
131  {
132  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
133  return false;
134  }
135 
136  include_once('Modules/Course/classes/class.ilCourseParticipants.php');
137  if(ilCourseParticipants::_isBlocked($a_obj_id,$a_user_id) and ilCourseParticipants::_isParticipant($a_ref_id,$a_user_id))
138  {
139  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
140  return false;
141  }
142 
143  /*
144  $members = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
145  if($members->isBlocked($a_user_id) and $members->isAssigned($a_user_id))
146  {
147  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
148  return false;
149  }
150  */
151  break;
152  }
153  return true;
154  }
155 
168  function _getCommands()
169  {
170  $commands = array();
171  $commands[] = array("permission" => "read", "cmd" => "", "lang_var" => "view", "default" => true);
172  $commands[] = array("permission" => "join", "cmd" => "join", "lang_var" => "join");
173  // BEGIN WebDAV: Mount as webfolder.
174  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
176  {
177  $commands[] = array("permission" => "read", "cmd" => "mount_webfolder", "lang_var" => "mount_webfolder", "enable_anonymous" => "false");
178  }
179  // END WebDAV: Mount as webfolder.
180  $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "edit");
181  return $commands;
182  }
183 
187  function _checkGoto($a_target)
188  {
189  global $ilAccess;
190 
191  $t_arr = explode("_", $a_target);
192 
193  if ($t_arr[0] != "crs" || ((int) $t_arr[1]) <= 0)
194  {
195  return false;
196  }
197 
198  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
199  $ilAccess->checkAccess("visible", "", $t_arr[1]))
200  {
201  return true;
202  }
203  return false;
204  }
205 
211  public static function isSelfRegistrationDeactivated($a_obj_id)
212  {
213  global $ilDB;
214 
215  include_once './Modules/Course/classes/class.ilObjCourse.php';
216  $query = "SELECT subscription_limitation_type FROM crs_settings ".
217  "WHERE obj_id = ".$ilDB->quote($a_obj_id);
218  $res = $ilDB->query($query);
219  $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
220  return $row->subscription_limitation_type == IL_CRS_SUBSCRIPTION_DEACTIVATED;
221  }
222 }
223 
224 ?>