ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
46 public static function _getCommands()
47 {
48 $commands = array
49 (
50 array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "info_short", "default" => true),
51 array("permission" => "read", "cmd" => "register", "lang_var" => "join_session"),
52 array("permission" => "read", "cmd" => "unregister", "lang_var" => "event_unregister"),
53 array("permission" => "write", "cmd" => "edit", "lang_var" => "settings"),
54 array("permission" => "write", "cmd" => "materials", "lang_var" => "crs_objective_add_mat"),
55 array('permission' => 'write', 'cmd' => 'members', 'lang_var' => 'event_edit_members')
56 );
57
58 return $commands;
59 }
60
73 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
74 {
75 global $ilUser, $lng, $rbacsystem, $ilAccess;
76
77 if(!$a_user_id)
78 {
79 $a_user_id = $ilUser->getId();
80 }
81 include_once './Modules/Session/classes/class.ilSessionParticipants.php';
83
84 switch($a_cmd)
85 {
86 case 'register':
87
88 if(!self::_lookupRegistration($a_obj_id))
89 {
90 //ilLoggerFactory::getLogger('sess')->debug('Lookup registration failed: register access denied.');
91 return false;
92 }
93 if($ilUser->isAnonymous())
94 {
95 //ilLoggerFactory::getLogger('sess')->debug('User is anoynmous: register access denied.');
96 return false;
97 }
98 if($part->isAssigned($a_user_id))
99 {
100 //ilLoggerFactory::getLogger('sess')->debug('User is assigned: register access denied.');
101 return false;
102 }
103 if($part->isSubscriber($a_user_id))
104 {
105 //ilLoggerFactory::getLogger('sess')->debug('User is subscriber: register access denied.');
106 return false;
107 }
108 include_once './Modules/Session/classes/class.ilSessionWaitingList.php';
109 if(ilSessionWaitingList::_isOnList($a_user_id, $a_obj_id))
110 {
111 //ilLoggerFactory::getLogger('sess')->debug('User is on waiting list: register access denied.');
112 return false;
113 }
114 break;
115
116 case 'unregister':
117 if(self::_lookupRegistration($a_obj_id) && $a_user_id != ANONYMOUS_USER_ID)
118 {
119 return self::_lookupRegistered($a_user_id,$a_obj_id);
120 }
121 return false;
122 }
123 return true;
124 }
125
126
130 public static function _checkGoto($a_target)
131 {
132 global $ilAccess;
133
134 $t_arr = explode("_", $a_target);
135
136 if ($t_arr[0] != "sess" || ((int) $t_arr[1]) <= 0)
137 {
138 return false;
139 }
140
141 if($ilAccess->checkAccess("read", "", $t_arr[1]))
142 {
143 return true;
144 }
145 return false;
146 }
147
156 public static function _lookupRegistration($a_obj_id)
157 {
158 if(!is_null(self::$registrations))
159 {
160 return self::$registrations[$a_obj_id];
161 }
162
163 global $ilDB;
164
165 $query = "SELECT registration,obj_id FROM event ";
166 $res = $ilDB->query($query);
167 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
168 {
169 self::$registrations[$row->obj_id] = (bool) $row->registration;
170 }
171 return self::$registrations[$a_obj_id];
172 }
173
183 public static function _lookupRegistered($a_usr_id,$a_obj_id)
184 {
185 if(isset(self::$registered[$a_usr_id]))
186 {
187 return (bool) self::$registered[$a_usr_id][$a_obj_id];
188 }
189
190 global $ilDB,$ilUser;
191
192 $query = "SELECT event_id, registered FROM event_participants WHERE usr_id = ".$ilDB->quote($ilUser->getId(),'integer');
193 $res = $ilDB->query($query);
194 self::$registered[$a_usr_id] = array();
195 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
196 {
197 self::$registered[$a_usr_id][$row->event_id] = (bool) $row->registered;
198 }
199 return (bool) self::$registered[$a_usr_id][$a_obj_id];
200 }
201
202}
203?>
An exception for terminatinating execution or to throw for unit testing.
static _getCommands()
get list of command/permission combinations
static _lookupRegistration($a_obj_id)
lookup registrations
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="")
static _checkGoto($a_target)
check whether goto script will succeed
Class ilObjectAccess.
static getInstanceByObjId($a_obj_id)
Get instance by obj type.
static _isOnList($a_usr_id, $a_obj_id)
Check if a user on the waiting list.
global $lng
Definition: privfeed.php:17
global $ilDB
$ilUser
Definition: imgupload.php:18