ILIAS  release_8 Revision v8.23
ilObjGroupAccess Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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)
 
- 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)
 

Static Public Member Functions

static _getCommands ()
 
static _checkGoto (string $target)
 
static _registrationEnabled (int $a_obj_id)
 
static _preloadData (array $obj_ids, array $ref_ids)
 
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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 30 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 
)

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

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

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

◆ _checkGoto()

static ilObjGroupAccess::_checkGoto ( string  $target)
static

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

References $DIC, $ilUser, and ANONYMOUS_USER_ID.

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

◆ _getCommands()

static ilObjGroupAccess::_getCommands ( )
static

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

References ilDAVActivationChecker\_isActive().

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

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

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

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

200  : void
201  {
202  global $DIC;
203 
204  $ilDB = $DIC->database();
205  $ilUser = $DIC->user();
206 
207  ilGroupWaitingList::_preloadOnListInfo([$ilUser->getId()], $obj_ids);
208  }
static _preloadOnListInfo(array $a_usr_ids, array $a_obj_ids)
Preload on list info.
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

◆ _registrationEnabled()

static ilObjGroupAccess::_registrationEnabled ( int  $a_obj_id)
static

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

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

165  : bool
166  {
167  global $DIC;
168 
169  $ilDB = $DIC->database();
170  $query = "SELECT * FROM grp_settings " .
171  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
172 
173  $res = $ilDB->query($query);
174 
175  $enabled = $unlimited = false;
176  $start = $end = 0;
177  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
178  $enabled = $row->registration_enabled;
179  $unlimited = $row->registration_unlimited;
180  $start = $row->registration_start;
181  $end = $row->registration_end;
182  }
183 
184  if (!$enabled) {
185  return false;
186  }
187  if ($unlimited) {
188  return true;
189  }
190  $start = new ilDateTime($start, IL_CAL_DATETIME);
191  $end = new ilDateTime($end, IL_CAL_DATETIME);
192  $time = new ilDateTime(time(), IL_CAL_UNIX);
193  return ilDateTime::_after($time, $start) and ilDateTime::_before($time, $end);
194  }
$res
Definition: ltiservices.php:69
bool $enabled
Whether the system instance is enabled to accept connection requests.
Definition: System.php:123
const IL_CAL_DATETIME
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.
const IL_CAL_UNIX
global $DIC
Definition: feed.php:28
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.
$query
+ Here is the call graph for this function:

◆ _usingRegistrationCode()

static ilObjGroupAccess::_usingRegistrationCode ( )
static

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

Referenced by ilObjGroup\register().

332  : bool
333  {
334  return self::$using_code;
335  }
+ 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 291 of file class.ilObjGroupAccess.php.

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

Referenced by ilObjGroupListGUI\getProperties().

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

References $DIC, $ilDB, $lng, $query, $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().

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


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