ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilObjGroupAccess Class Reference

Class ilObjGroupAccess. More...

+ Inheritance diagram for ilObjGroupAccess:
+ Collaboration diagram for ilObjGroupAccess:

Public Member Functions

 _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::checkAccess) More...
 
- Public Member Functions inherited from ilObjectAccess
 _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::checkAccess) More...
 
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
Parameters
ilWACPath$ilWACPath
Returns
bool
More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 

Static Public Member Functions

static _getCommands ()
 get commands More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _registrationEnabled ($a_obj_id)
 
static _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. More...
 
static lookupRegistrationInfo ($a_obj_id)
 Lookup registration info @global ilDB $ilDB @global ilObjUser $ilUser @global ilLanguage $lng. More...
 
static lookupPeriodInfo ($a_obj_id)
 Lookup course period info. More...
 
static _usingRegistrationCode ()
 Using Registration code. More...
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _isOffline ($a_obj_id)
 Type-specific implementation of general status, has to be overwritten if object type does not support centralized offline handling. More...
 
static _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. More...
 

Static Protected Attributes

static $using_code = false
 

Detailed Description

Class ilObjGroupAccess.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 15 of file class.ilObjGroupAccess.php.

Member Function Documentation

◆ _checkAccess()

ilObjGroupAccess::_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::checkAccess)

Parameters
string$a_cmdcommand (not permission!)
string$a_permissionpermission
int$a_ref_idreference id
int$a_obj_idobject id
int$a_user_iduser id (if not provided, current user is taken)
Returns
boolean true, if everything is ok

Reimplemented from ilObjectAccess.

Definition at line 30 of file class.ilObjGroupAccess.php.

31 {
32 global $DIC;
33
34 $ilUser = $DIC['ilUser'];
35 $lng = $DIC['lng'];
36 $rbacsystem = $DIC['rbacsystem'];
37 $ilAccess = $DIC['ilAccess'];
38
39 if ($a_user_id == "") {
40 $a_user_id = $ilUser->getId();
41 }
42
43 switch ($a_cmd) {
44 case "info":
45
46 include_once './Modules/Group/classes/class.ilGroupParticipants.php';
47 if (ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id)) {
48 $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_INFO, $lng->txt("info_is_member"));
49 } else {
50 $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_INFO, $lng->txt("info_is_not_member"));
51 }
52 break;
53
54 case "join":
55
56 if (!self::_registrationEnabled($a_obj_id)) {
57 return false;
58 }
59
60 include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
61 if (ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id)) {
62 return false;
63 }
64
65 include_once './Modules/Group/classes/class.ilGroupParticipants.php';
66 if (ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id)) {
67 return false;
68 }
69 break;
70
71 case 'leave':
72
73 // Regular member
74 if ($a_permission == 'leave') {
75 include_once './Modules/Group/classes/class.ilObjGroup.php';
76 $limit = null;
77 if (!ilObjGroup::mayLeave($a_obj_id, $a_user_id, $limit)) {
78 $ilAccess->addInfoItem(
80 sprintf($lng->txt("grp_cancellation_end_rbac_info"), ilDatePresentation::formatDate($limit))
81 );
82 return false;
83 }
84
85 include_once './Modules/Group/classes/class.ilGroupParticipants.php';
86 if (!ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id)) {
87 return false;
88 }
89 }
90 // Waiting list
91 if ($a_permission == 'join') {
92 include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
93 if (!ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id)) {
94 return false;
95 }
96 }
97 break;
98
99 }
100
101 switch ($a_permission) {
102 case 'leave':
103 include_once './Modules/Group/classes/class.ilObjGroup.php';
104 return ilObjGroup::mayLeave($a_obj_id, $a_user_id);
105 }
106 return true;
107 }
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
static mayLeave($a_group_id, $a_user_id=null, &$a_date=null)
static _isOnList($a_usr_id, $a_obj_id)
Check if a user on the waiting list.
$lng
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46

References $DIC, $ilUser, $lng, ilWaitingList\_isOnList(), ilGroupParticipants\_isParticipant(), ilDatePresentation\formatDate(), ilAccessInfo\IL_STATUS_INFO, and ilObjGroup\mayLeave().

+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjGroupAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

Reimplemented from ilObjectAccess.

Definition at line 163 of file class.ilObjGroupAccess.php.

164 {
165 global $DIC;
166
167 $ilAccess = $DIC['ilAccess'];
168 $ilUser = $DIC['ilUser'];
169
170 $t_arr = explode("_", $a_target);
171 // registration codes
172 if (substr($t_arr[2], 0, 5) == 'rcode' and $ilUser->getId() != ANONYMOUS_USER_ID) {
173 self::$using_code = true;
174 return true;
175 }
176
177 if ($t_arr[0] != "grp" || ((int) $t_arr[1]) <= 0) {
178 return false;
179 }
180
181 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
182 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
183 return true;
184 }
185 return false;
186 }

References $DIC, and $ilUser.

◆ _getCommands()

static ilObjGroupAccess::_getCommands ( )
static

get commands

this method returns an array of all possible commands/permission combinations

example: $commands = array ( array("permission" => "read", "cmd" => "view", "lang_var" => "show"), array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), );

Reimplemented from ilObjectAccess.

Definition at line 121 of file class.ilObjGroupAccess.php.

122 {
123 $commands = array();
124 $commands[] = array("permission" => "grp_linked", "cmd" => "", "lang_var" => "show", "default" => true);
125
126 include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
127 if (ilFMSettings::getInstance()->isEnabled()) {
128 $commands[] = array(
129 'permission' => 'read',
130 'cmd' => 'fileManagerLaunch',
131 'lang_var' => 'fm_start',
132 'enable_anonymous' => false
133 );
134 }
135
136 $commands[] = array("permission" => "join", "cmd" => "join", "lang_var" => "join");
137
138 // on waiting list
139 $commands[] = array('permission' => "join", "cmd" => "leave", "lang_var" => "leave_waiting_list");
140
141 // regualar users
142 $commands[] = array('permission' => "leave", "cmd" => "leave", "lang_var" => "grp_btn_unsubscribe");
143
144 include_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
146 include_once './Services/WebDAV/classes/class.ilWebDAVUtil.php';
147 if (ilWebDAVUtil::getInstance()->isLocalPasswordInstructionRequired()) {
148 $commands[] = array('permission' => 'read', 'cmd' => 'showPasswordInstruction', 'lang_var' => 'mount_webfolder', 'enable_anonymous' => 'false');
149 } else {
150 $commands[] = array("permission" => "read", "cmd" => "mount_webfolder", "lang_var" => "mount_webfolder", "enable_anonymous" => "false");
151 }
152 }
153
154 $commands[] = array("permission" => "write", "cmd" => "enableAdministrationPanel", "lang_var" => "edit_content");
155 $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "settings");
156
157 return $commands;
158 }
static getInstance()
Get singleton instance.
static getInstance()
Get singleton instance.

References ilDAVActivationChecker\_isActive(), ilWebDAVUtil\getInstance(), and ilFMSettings\getInstance().

Referenced by ilObjGroupReferenceAccess\_getCommands(), and ilObjGroupListGUI\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _preloadData()

static ilObjGroupAccess::_preloadData (   $a_obj_ids,
  $a_ref_ids 
)
static

Preload data.

Parameters
array$a_obj_idsarray of object ids

Reimplemented from ilObjectAccess.

Definition at line 235 of file class.ilObjGroupAccess.php.

236 {
237 global $DIC;
238
239 $ilDB = $DIC['ilDB'];
240 $ilUser = $DIC['ilUser'];
241
242 include_once("./Modules/Group/classes/class.ilGroupWaitingList.php");
244 }
static _preloadOnListInfo($a_usr_ids, $a_obj_ids)
Preload on list info.
global $ilDB

References $DIC, $ilDB, $ilUser, and ilWaitingList\_preloadOnListInfo().

+ Here is the call graph for this function:

◆ _registrationEnabled()

static ilObjGroupAccess::_registrationEnabled (   $a_obj_id)
static
Returns
Parameters
object$a_obj_id

Definition at line 193 of file class.ilObjGroupAccess.php.

194 {
195 global $DIC;
196
197 $ilDB = $DIC['ilDB'];
198
199 $query = "SELECT * FROM grp_settings " .
200 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
201
202 $res = $ilDB->query($query);
203
204 $enabled = $unlimited = false;
205 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
206 $enabled = $row->registration_enabled;
207 $unlimited = $row->registration_unlimited;
208 $start = $row->registration_start;
209 $end = $row->registration_end;
210 }
211
212 if (!$enabled) {
213 return false;
214 }
215 if ($unlimited) {
216 return true;
217 }
218
219 if (!$unlimited) {
220 $start = new ilDateTime($start, IL_CAL_DATETIME);
221 $end = new ilDateTime($end, IL_CAL_DATETIME);
222 $time = new ilDateTime(time(), IL_CAL_UNIX);
223
224 return ilDateTime::_after($time, $start) and ilDateTime::_before($time, $end);
225 }
226 return false;
227 }
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
$query
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $query, $res, ilDateTime\_after(), ilDateTime\_before(), ilDBConstants\FETCHMODE_OBJECT, IL_CAL_DATETIME, and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ _usingRegistrationCode()

static ilObjGroupAccess::_usingRegistrationCode ( )
static

Using Registration code.

Returns
bool

Definition at line 384 of file class.ilObjGroupAccess.php.

385 {
386 return self::$using_code;
387 }

References $using_code.

Referenced by ilObjGroup\register().

+ Here is the caller graph for this function:

◆ lookupPeriodInfo()

static ilObjGroupAccess::lookupPeriodInfo (   $a_obj_id)
static

Lookup course period info.

Parameters
int$a_obj_id
Returns
array

Definition at line 340 of file class.ilObjGroupAccess.php.

341 {
342 global $DIC;
343
344 $ilDB = $DIC['ilDB'];
345 $lng = $DIC['lng'];
346
347 $start = $end = null;
348 $query = 'SELECT period_start, period_end, period_time_indication FROM grp_settings ' .
349 'WHERE obj_id = ' . $ilDB->quote($a_obj_id);
350
351 $res = $ilDB->query($query);
352 while ($row = $res->fetchRow(\ilDBConstants::FETCHMODE_OBJECT)) {
353 if (!$row->period_time_indication) {
354 $start = ($row->period_start
355 ? new \ilDate($row->period_start, IL_CAL_DATETIME)
356 : null);
357 $end = ($row->period_end
358 ? new \ilDate($row->period_end, IL_CAL_DATETIME)
359 : null);
360 } else {
361 $start = ($row->period_start
362 ? new \ilDateTime($row->period_start, IL_CAL_DATETIME, \ilTimeZone::UTC)
363 : null);
364 $end = ($row->period_end
365 ? new \ilDateTime($row->period_end, IL_CAL_DATETIME, \ilTimeZone::UTC)
366 : null);
367 }
368 }
369 if ($start && $end) {
370 $lng->loadLanguageModule('grp');
371
372 return
373 [
374 'property' => $lng->txt('grp_period'),
375 'value' => ilDatePresentation::formatPeriod($start, $end)
376 ];
377 }
378 }
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.

References $DIC, $ilDB, $lng, $query, $res, ilDBConstants\FETCHMODE_OBJECT, ilDatePresentation\formatPeriod(), IL_CAL_DATETIME, and ilTimeZone\UTC.

Referenced by ilObjGroupListGUI\getProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupRegistrationInfo()

static ilObjGroupAccess::lookupRegistrationInfo (   $a_obj_id)
static

Lookup registration info @global ilDB $ilDB @global ilObjUser $ilUser @global ilLanguage $lng.

Parameters
int$a_obj_id
Returns
array

Definition at line 254 of file class.ilObjGroupAccess.php.

255 {
256 global $DIC;
257
258 $ilDB = $DIC['ilDB'];
259 $ilUser = $DIC['ilUser'];
260 $lng = $DIC['lng'];
261
262 $query = 'SELECT registration_type, registration_enabled, registration_unlimited, registration_start, ' .
263 'registration_end, registration_mem_limit, registration_max_members FROM grp_settings ' .
264 'WHERE obj_id = ' . $ilDB->quote($a_obj_id);
265 $res = $ilDB->query($query);
266
267 $info = array();
268 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
269 $info['reg_info_start'] = new ilDateTime($row->registration_start, IL_CAL_DATETIME);
270 $info['reg_info_end'] = new ilDateTime($row->registration_end, IL_CAL_DATETIME);
271 $info['reg_info_type'] = $row->registration_type;
272 $info['reg_info_max_members'] = $row->registration_max_members;
273 $info['reg_info_mem_limit'] = $row->registration_mem_limit;
274 $info['reg_info_unlimited'] = $row->registration_unlimited;
275
276 $info['reg_info_max_members'] = 0;
277 if ($info['reg_info_mem_limit']) {
278 $info['reg_info_max_members'] = $row->registration_max_members;
279 }
280
281 $info['reg_info_enabled'] = $row->registration_enabled;
282 }
283
284 $registration_possible = $info['reg_info_enabled'];
285
286 // Limited registration (added $registration_possible, see bug 0010157)
287 if (!$info['reg_info_unlimited'] && $registration_possible) {
288 $dt = new ilDateTime(time(), IL_CAL_UNIX);
289 if (ilDateTime::_before($dt, $info['reg_info_start'])) {
290 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_start');
291 $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_start']);
292 } elseif (ilDateTime::_before($dt, $info['reg_info_end'])) {
293 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_end');
294 $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_end']);
295 } else {
296 $registration_possible = false;
297 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_period');
298 $info['reg_info_list_prop']['value'] = $lng->txt('grp_list_reg_noreg');
299 }
300 } else {
301 // added !$registration_possible, see bug 0010157
302 if (!$registration_possible) {
303 $registration_possible = false;
304 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg');
305 $info['reg_info_list_prop']['value'] = $lng->txt('grp_list_reg_noreg');
306 }
307 }
308
309 if ($info['reg_info_mem_limit'] && $info['reg_info_max_members'] && $registration_possible) {
310 // Check for free places
311 include_once './Modules/Group/classes/class.ilGroupParticipants.php';
313
314 include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
315 $info['reg_info_list_size'] = ilCourseWaitingList::lookupListSize($a_obj_id);
316 if ($info['reg_info_list_size']) {
317 $info['reg_info_free_places'] = 0;
318 } else {
319 $info['reg_info_free_places'] = max(0, $info['reg_info_max_members'] - $part->getCountMembers());
320 }
321
322 if ($info['reg_info_free_places']) {
323 $info['reg_info_list_prop_limit']['property'] = $lng->txt('grp_list_reg_limit_places');
324 $info['reg_info_list_prop_limit']['value'] = $info['reg_info_free_places'];
325 } else {
326 $info['reg_info_list_prop_limit']['property'] = '';
327 $info['reg_info_list_prop_limit']['value'] = $lng->txt('grp_list_reg_limit_full');
328 }
329 }
330
331 return $info;
332 }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static lookupListSize($a_obj_id)
Lookup waiting lit size.

References $DIC, $ilDB, $ilUser, $lng, $query, $res, ilDateTime\_before(), ilGroupParticipants\_getInstanceByObjId(), ilDBConstants\FETCHMODE_OBJECT, ilDatePresentation\formatDate(), IL_CAL_DATETIME, IL_CAL_UNIX, and ilWaitingList\lookupListSize().

Referenced by ilGroupRegistrationGUI\fillMaxMembers(), ilObjGroupListGUI\getProperties(), and ilObjGroupGUI\infoScreen().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $using_code

ilObjGroupAccess::$using_code = false
staticprotected

Definition at line 17 of file class.ilObjGroupAccess.php.

Referenced by _usingRegistrationCode().


The documentation for this class was generated from the following file: