ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjSessionAccess.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 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
24include_once './Services/Object/classes/class.ilObjectAccess.php';
25
35{
36 protected static $registrations = null;
37 protected static $registered = null;
38
42 protected static $booking_repo = null;
43
51 public static function _getCommands()
52 {
53 $commands = array(
54 array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "info_short", "default" => true),
55 array("permission" => "read", "cmd" => "register", "lang_var" => "join_session"),
56 array("permission" => "read", "cmd" => "unregister", "lang_var" => "event_unregister"),
57 array("permission" => "write", "cmd" => "edit", "lang_var" => "settings"),
58 array("permission" => "manage_materials", "cmd" => "materials", "lang_var" => "crs_objective_add_mat"),
59 array('permission' => 'manage_members', 'cmd' => 'members', 'lang_var' => 'event_edit_members')
60 );
61
62 return $commands;
63 }
64
77 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
78 {
79 global $DIC;
80
81 $ilUser = $DIC['ilUser'];
82 $lng = $DIC['lng'];
83 $rbacsystem = $DIC['rbacsystem'];
84 $ilAccess = $DIC['ilAccess'];
85
86 if (!$a_user_id) {
87 $a_user_id = $ilUser->getId();
88 }
89
90 switch ($a_cmd) {
91 case 'register':
92
93 if (!self::_lookupRegistration($a_obj_id)) {
94 return false;
95 }
96 if ($ilUser->isAnonymous()) {
97 return false;
98 }
99 if (self::_lookupRegistered($a_user_id, $a_obj_id)) {
100 return false;
101 }
102 if (\ilSessionParticipants::_isSubscriber($a_obj_id, $a_user_id)) {
103 return false;
104 }
105 include_once './Modules/Session/classes/class.ilSessionWaitingList.php';
106 if (ilSessionWaitingList::_isOnList($a_user_id, $a_obj_id)) {
107 return false;
108 }
109 break;
110
111 case 'unregister':
112 if (self::_lookupRegistration($a_obj_id) && $a_user_id != ANONYMOUS_USER_ID) {
113 return self::_lookupRegistered($a_user_id, $a_obj_id);
114 }
115 return false;
116 }
117 return true;
118 }
119
120
124 public static function _checkGoto($a_target)
125 {
126 global $DIC;
127
128 $ilAccess = $DIC['ilAccess'];
129
130 $t_arr = explode("_", $a_target);
131
132 if ($t_arr[0] != "sess" || ((int) $t_arr[1]) <= 0) {
133 return false;
134 }
135
136 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
137 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
138 return true;
139 }
140 return false;
141 }
142
151 public static function _lookupRegistration($a_obj_id)
152 {
153 if (!is_null(self::$registrations)) {
154 return self::$registrations[$a_obj_id];
155 }
156
157 global $DIC;
158
159 $ilDB = $DIC['ilDB'];
160
161 $query = "SELECT registration,obj_id FROM event ";
162 $res = $ilDB->query($query);
163 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
164 self::$registrations[$row->obj_id] = (bool) $row->registration;
165 }
166 return self::$registrations[$a_obj_id];
167 }
168
178 public static function _lookupRegistered($a_usr_id, $a_obj_id)
179 {
180 if (isset(self::$registered[$a_usr_id])) {
181 return (bool) self::$registered[$a_usr_id][$a_obj_id];
182 }
183
184 global $DIC;
185
186 $ilDB = $DIC['ilDB'];
187 $ilUser = $DIC['ilUser'];
188
189 $query = "SELECT event_id, registered FROM event_participants WHERE usr_id = " . $ilDB->quote($ilUser->getId(), 'integer');
190 $res = $ilDB->query($query);
191 self::$registered[$a_usr_id] = array();
192 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
193 self::$registered[$a_usr_id][$row->event_id] = (bool) $row->registered;
194 }
195 return (bool) self::$registered[$a_usr_id][$a_obj_id];
196 }
197
203 public static function _preloadData($a_obj_ids, $a_ref_ids)
204 {
206 self::$booking_repo = $f->getRepoWithContextObjCache($a_obj_ids);
207 }
208
213 public static function getBookingInfoRepo()
214 {
215 return self::$booking_repo;
216 }
217}
An exception for terminatinating execution or to throw for unit testing.
static _getCommands()
get list of command/permission combinations
static getBookingInfoRepo()
Get booking info repo.
static _lookupRegistration($a_obj_id)
lookup registrations
static _preloadData($a_obj_ids, $a_ref_ids)
Preload data.
static _lookupRegistered($a_usr_id, $a_obj_id)
lookup if user has registered
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcce...
static _checkGoto($a_target)
check whether goto script will succeed
Class ilObjectAccess.
static _isSubscriber($a_obj_id, $a_usr_id)
check if user is subscriber
static _isOnList($a_usr_id, $a_obj_id)
Check if a user on the waiting list.
$query
$lng
foreach($_POST as $key=> $value) $res
global $ilDB
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46