ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilObjGroupAccess Class Reference

Class ilObjGroupAccess. More...

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

Public Member Functions

 _checkAccess (string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
 @inheritDoc More...
 
- Public Member Functions inherited from ilObjectAccess
 _checkAccess (string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
 Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
 canBeDelivered (ilWACPath $ilWACPath)
 

Static Public Member Functions

static _getCommands ()
 @inheritDoc More...
 
static _checkGoto (string $target)
 @inheritDoc More...
 
static _registrationEnabled (int $a_obj_id)
 
static _preloadData (array $obj_ids, array $ref_ids)
 @inheritDoc More...
 
static lookupRegistrationInfo (int $a_obj_id)
 
static lookupPeriodInfo (int $a_obj_id)
 
static _usingRegistrationCode ()
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _isOffline (int $obj_id)
 Type-specific implementation of general status, has to be overwritten if object type does not support centralized offline handling. More...
 
static _preloadData (array $obj_ids, array $ref_ids)
 Preload data. More...
 

Static Protected Attributes

static bool $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 29 of file class.ilObjGroupAccess.php.

Member Function Documentation

◆ _checkAccess()

ilObjGroupAccess::_checkAccess ( string  $cmd,
string  $permission,
int  $ref_id,
int  $obj_id,
?int  $user_id = null 
)

@inheritDoc

Reimplemented from ilObjectAccess.

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

36 : bool
37 {
38 global $DIC;
39
40 $ilUser = $DIC['ilUser'];
41 $lng = $DIC['lng'];
42 $ilAccess = $DIC['ilAccess'];
43
44 if (is_null($user_id)) {
45 $user_id = $ilUser->getId();
46 }
47
48 switch ($cmd) {
49 case "info":
50
52 $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_INFO, $lng->txt("info_is_member"));
53 } else {
54 $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_INFO, $lng->txt("info_is_not_member"));
55 }
56 break;
57
58 case "join":
59
60 if (!self::_registrationEnabled($obj_id)) {
61 return false;
62 }
63
64 if (ilGroupWaitingList::_isOnList($ilUser->getId(), $obj_id)) {
65 return false;
66 }
67
69 return false;
70 }
71 break;
72
73 case 'leave':
74 // Regular member
75 if ($permission == 'leave') {
76 $limit = null;
77 if (!ilObjGroup::mayLeave($obj_id, $user_id, $limit)) {
78 $ilAccess->addInfoItem(
80 sprintf($lng->txt("grp_cancellation_end_rbac_info"), ilDatePresentation::formatDate($limit))
81 );
82 return false;
83 }
84
86 return false;
87 }
88 }
89 break;
90
91 case 'leaveWaitList':
92 // Waiting list
93 if ($permission == 'join') {
94 if (!ilGroupWaitingList::_isOnList($ilUser->getId(), $obj_id)) {
95 return false;
96 }
97 }
98 break;
99 }
100
101 switch ($permission) {
102 case 'leave':
103 return ilObjGroup::mayLeave($obj_id, $user_id);
104 }
105 return true;
106 }
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.
static mayLeave(int $a_group_id, ?int $a_user_id=null, ?ilDate &$a_date=null)
static _isOnList(int $a_usr_id, int $a_obj_id)
$ref_id
Definition: ltiauth.php:66
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26

References $DIC, $lng, $ref_id, $user_id, 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 ( string  $target)
static

@inheritDoc

Reimplemented from ilObjectAccess.

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

138 : bool
139 {
140 global $DIC;
141
142 $ilAccess = $DIC->access();
143 $ilUser = $DIC->user();
144
145 $t_arr = explode("_", $target);
146 // registration codes
147 if (substr((string) ($t_arr[2] ?? ""), 0, 5) === 'rcode' and $ilUser->getId() != ANONYMOUS_USER_ID) {
148 self::$using_code = true;
149 return true;
150 }
151
152 if ($t_arr[0] != "grp" || ((int) $t_arr[1]) <= 0) {
153 return false;
154 }
155
156 if ($ilAccess->checkAccess("read", "", (int) $t_arr[1]) ||
157 $ilAccess->checkAccess("visible", "", (int) $t_arr[1])) {
158 return true;
159 }
160 return false;
161 }
const ANONYMOUS_USER_ID
Definition: constants.php:27

References $DIC, and ANONYMOUS_USER_ID.

◆ _getCommands()

static ilObjGroupAccess::_getCommands ( )
static

@inheritDoc

Reimplemented from ilObjectAccess.

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

111 : array
112 {
113 $commands = array();
114 $commands[] = array("permission" => "grp_linked", "cmd" => "", "lang_var" => "show", "default" => true);
115
116 $commands[] = array("permission" => "join", "cmd" => "join", "lang_var" => "join");
117
118 // on waiting list
119 $commands[] = array('permission' => "join", "cmd" => "leaveWaitList", "lang_var" => "leave_waiting_list");
120
121 // regualar users
122 $commands[] = array('permission' => "leave", "cmd" => "leave", "lang_var" => "grp_btn_unsubscribe");
123
125 $webdav_obj = new ilObjWebDAV();
126 $commands[] = $webdav_obj->retrieveWebDAVCommandArrayForActionMenu();
127 }
128
129 $commands[] = array("permission" => "write", "cmd" => "enableAdministrationPanel", "lang_var" => "edit_content");
130 $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "settings");
131
132 return $commands;
133 }

References ilDAVActivationChecker\_isActive().

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 ( array  $obj_ids,
array  $ref_ids 
)
static

@inheritDoc

Reimplemented from ilObjectAccess.

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

198 : void
199 {
200 global $DIC;
201
202 $ilDB = $DIC->database();
203 $ilUser = $DIC->user();
204
205 ilGroupWaitingList::_preloadOnListInfo([$ilUser->getId()], $obj_ids);
206 }
static _preloadOnListInfo(array $a_usr_ids, array $a_obj_ids)
Preload on list info.

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

+ Here is the call graph for this function:

◆ _registrationEnabled()

static ilObjGroupAccess::_registrationEnabled ( int  $a_obj_id)
static

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

163 : bool
164 {
165 global $DIC;
166
167 $ilDB = $DIC->database();
168 $query = "SELECT * FROM grp_settings " .
169 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
170
171 $res = $ilDB->query($query);
172
173 $enabled = $unlimited = false;
174 $start = $end = 0;
175 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
176 $enabled = $row->registration_enabled;
177 $unlimited = $row->registration_unlimited;
178 $start = $row->registration_start;
179 $end = $row->registration_end;
180 }
181
182 if (!$enabled) {
183 return false;
184 }
185 if ($unlimited) {
186 return true;
187 }
188 $start = new ilDateTime($start, IL_CAL_DATETIME);
189 $end = new ilDateTime($end, IL_CAL_DATETIME);
190 $time = new ilDateTime(time(), IL_CAL_UNIX);
191 return ilDateTime::_after($time, $start) and ilDateTime::_before($time, $end);
192 }
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
$res
Definition: ltiservices.php:69

References $DIC, $ilDB, $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

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

330 : bool
331 {
332 return self::$using_code;
333 }

References $using_code.

Referenced by ilObjGroup\register().

+ Here is the caller graph for this function:

◆ lookupPeriodInfo()

static ilObjGroupAccess::lookupPeriodInfo ( int  $a_obj_id)
static
Parameters
int$a_obj_id
Returns
array<{property: string, value: string}> | null
Exceptions
ilDateTimeException

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

289 : ?array
290 {
291 global $DIC;
292
293 $ilDB = $DIC->database();
294 $lng = $DIC->language();
295
296 $start = $end = null;
297 $query = 'SELECT period_start, period_end, period_time_indication FROM grp_settings ' .
298 'WHERE obj_id = ' . $ilDB->quote($a_obj_id, ilDBConstants::T_INTEGER);
299
300 $res = $ilDB->query($query);
301 while ($row = $res->fetchRow(\ilDBConstants::FETCHMODE_OBJECT)) {
302 if (!$row->period_time_indication) {
303 $start = ($row->period_start
304 ? new \ilDate($row->period_start, IL_CAL_DATETIME)
305 : null);
306 $end = ($row->period_end
307 ? new \ilDate($row->period_end, IL_CAL_DATETIME)
308 : null);
309 } else {
310 $start = ($row->period_start
311 ? new \ilDateTime($row->period_start, IL_CAL_DATETIME, \ilTimeZone::UTC)
312 : null);
313 $end = ($row->period_end
314 ? new \ilDateTime($row->period_end, IL_CAL_DATETIME, \ilTimeZone::UTC)
315 : null);
316 }
317 }
318 if ($start && $end) {
319 $lng->loadLanguageModule('grp');
320
321 return
322 [
323 'property' => $lng->txt('grp_period'),
324 'value' => ilDatePresentation::formatPeriod($start, $end)
325 ];
326 }
327 return null;
328 }
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.

References $DIC, $ilDB, $lng, $res, ilDBConstants\FETCHMODE_OBJECT, ilDatePresentation\formatPeriod(), IL_CAL_DATETIME, ilDBConstants\T_INTEGER, 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 ( int  $a_obj_id)
static

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

208 : array
209 {
210 global $DIC;
211
212 $ilDB = $DIC->database();
213 $lng = $DIC->language();
214
215 $query = 'SELECT registration_type, registration_enabled, registration_unlimited, registration_start, ' .
216 'registration_end, registration_mem_limit, registration_max_members FROM grp_settings ' .
217 'WHERE obj_id = ' . $ilDB->quote($a_obj_id, ilDBConstants::T_INTEGER);
218 $res = $ilDB->query($query);
219
220 $info = array();
221 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
222 $info['reg_info_start'] = new ilDateTime($row->registration_start, IL_CAL_DATETIME);
223 $info['reg_info_end'] = new ilDateTime($row->registration_end, IL_CAL_DATETIME);
224 $info['reg_info_type'] = $row->registration_type;
225 $info['reg_info_mem_limit'] = $row->registration_mem_limit;
226 $info['reg_info_unlimited'] = $row->registration_unlimited;
227
228 $info['reg_info_max_members'] = 0;
229 if ($info['reg_info_mem_limit']) {
230 $info['reg_info_max_members'] = $row->registration_max_members;
231 }
232
233 $info['reg_info_enabled'] = $row->registration_enabled;
234 }
235
236 $registration_possible = $info['reg_info_enabled'];
237
238 // Limited registration (added $registration_possible, see bug 0010157)
239 if (!$info['reg_info_unlimited'] && $registration_possible) {
240 $dt = new ilDateTime(time(), IL_CAL_UNIX);
241 if (ilDateTime::_before($dt, $info['reg_info_start'])) {
242 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_start');
243 $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_start']);
244 } elseif (ilDateTime::_before($dt, $info['reg_info_end'])) {
245 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_end');
246 $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_end']);
247 } else {
248 $registration_possible = false;
249 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_period');
250 $info['reg_info_list_prop']['value'] = $lng->txt('grp_list_reg_noreg');
251 }
252 } else {
253 // added !$registration_possible, see bug 0010157
254 if (!$registration_possible) {
255 $registration_possible = false;
256 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg');
257 $info['reg_info_list_prop']['value'] = $lng->txt('grp_list_reg_noreg');
258 }
259 }
260
261 if ($info['reg_info_mem_limit'] && $info['reg_info_max_members'] && $registration_possible) {
262 // Check for free places
264
265 $info['reg_info_list_size'] = ilCourseWaitingList::lookupListSize($a_obj_id);
266 if ($info['reg_info_list_size']) {
267 $info['reg_info_free_places'] = 0;
268 } else {
269 $info['reg_info_free_places'] = max(0, $info['reg_info_max_members'] - $part->getCountMembers());
270 }
271
272 if ($info['reg_info_free_places']) {
273 $info['reg_info_list_prop_limit']['property'] = $lng->txt('grp_list_reg_limit_places');
274 $info['reg_info_list_prop_limit']['value'] = $info['reg_info_free_places'];
275 } else {
276 $info['reg_info_list_prop_limit']['property'] = '';
277 $info['reg_info_list_prop_limit']['value'] = $lng->txt('grp_list_reg_limit_full');
278 }
279 }
280
281 return $info;
282 }
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
static lookupListSize(int $a_obj_id)
$info
Definition: entry_point.php:21

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

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

bool ilObjGroupAccess::$using_code = false
staticprotected

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

Referenced by _usingRegistrationCode().


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