ILIAS  release_7 Revision v7.30-3-g800a261c036
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...
 

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 ilDB $ilDB ilObjUser $ilUser 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

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

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

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 mayLeave($a_group_id, $a_user_id=null, &$a_date=null)
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
$lng
global $DIC
Definition: goto.php:24
static _isOnList($a_usr_id, $a_obj_id)
Check if a user on the waiting list.
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjGroupAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

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

References $DIC, $ilUser, and ANONYMOUS_USER_ID.

154  {
155  global $DIC;
156 
157  $ilAccess = $DIC['ilAccess'];
158  $ilUser = $DIC['ilUser'];
159 
160  $t_arr = explode("_", $a_target);
161  // registration codes
162  if (substr($t_arr[2], 0, 5) == 'rcode' and $ilUser->getId() != ANONYMOUS_USER_ID) {
163  self::$using_code = true;
164  return true;
165  }
166 
167  if ($t_arr[0] != "grp" || ((int) $t_arr[1]) <= 0) {
168  return false;
169  }
170 
171  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
172  $ilAccess->checkAccess("visible", "", $t_arr[1])) {
173  return true;
174  }
175  return false;
176  }
const ANONYMOUS_USER_ID
Definition: constants.php:25
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18

◆ _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"), );

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

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

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

122  {
123  $commands = array();
124  $commands[] = array("permission" => "grp_linked", "cmd" => "", "lang_var" => "show", "default" => true);
125 
126  $commands[] = array("permission" => "join", "cmd" => "join", "lang_var" => "join");
127 
128  // on waiting list
129  $commands[] = array('permission' => "join", "cmd" => "leave", "lang_var" => "leave_waiting_list");
130 
131  // regualar users
132  $commands[] = array('permission' => "leave", "cmd" => "leave", "lang_var" => "grp_btn_unsubscribe");
133 
134  include_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
136  include_once './Services/WebDAV/classes/class.ilWebDAVUtil.php';
137  if (ilWebDAVUtil::getInstance()->isLocalPasswordInstructionRequired()) {
138  $commands[] = array('permission' => 'read', 'cmd' => 'showPasswordInstruction', 'lang_var' => 'mount_webfolder', 'enable_anonymous' => 'false');
139  } else {
140  $commands[] = array("permission" => "read", "cmd" => "mount_webfolder", "lang_var" => "mount_webfolder", "enable_anonymous" => "false");
141  }
142  }
143 
144  $commands[] = array("permission" => "write", "cmd" => "enableAdministrationPanel", "lang_var" => "edit_content");
145  $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "settings");
146 
147  return $commands;
148  }
static _isActive()
Static getter.
static getInstance()
Get singleton instance.
+ 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

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

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

226  {
227  global $DIC;
228 
229  $ilDB = $DIC['ilDB'];
230  $ilUser = $DIC['ilUser'];
231 
232  include_once("./Modules/Group/classes/class.ilGroupWaitingList.php");
233  ilGroupWaitingList::_preloadOnListInfo($ilUser->getId(), $a_obj_ids);
234  }
static _preloadOnListInfo($a_usr_ids, $a_obj_ids)
Preload on list info.
global $DIC
Definition: goto.php:24
global $ilDB
$ilUser
Definition: imgupload.php:18
+ 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 183 of file class.ilObjGroupAccess.php.

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

184  {
185  global $DIC;
186 
187  $ilDB = $DIC['ilDB'];
188 
189  $query = "SELECT * FROM grp_settings " .
190  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
191 
192  $res = $ilDB->query($query);
193 
194  $enabled = $unlimited = false;
195  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
196  $enabled = $row->registration_enabled;
197  $unlimited = $row->registration_unlimited;
198  $start = $row->registration_start;
199  $end = $row->registration_end;
200  }
201 
202  if (!$enabled) {
203  return false;
204  }
205  if ($unlimited) {
206  return true;
207  }
208 
209  if (!$unlimited) {
210  $start = new ilDateTime($start, IL_CAL_DATETIME);
211  $end = new ilDateTime($end, IL_CAL_DATETIME);
212  $time = new ilDateTime(time(), IL_CAL_UNIX);
213 
214  return ilDateTime::_after($time, $start) and ilDateTime::_before($time, $end);
215  }
216  return false;
217  }
const IL_CAL_DATETIME
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.
const IL_CAL_UNIX
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the call graph for this function:

◆ _usingRegistrationCode()

static ilObjGroupAccess::_usingRegistrationCode ( )
static

Using Registration code.

Returns
bool

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

Referenced by ilObjGroup\register().

375  {
376  return self::$using_code;
377  }
+ 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 330 of file class.ilObjGroupAccess.php.

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

Referenced by ilObjGroupListGUI\getProperties().

331  {
332  global $DIC;
333 
334  $ilDB = $DIC['ilDB'];
335  $lng = $DIC['lng'];
336 
337  $start = $end = null;
338  $query = 'SELECT period_start, period_end, period_time_indication FROM grp_settings ' .
339  'WHERE obj_id = ' . $ilDB->quote($a_obj_id);
340 
341  $res = $ilDB->query($query);
342  while ($row = $res->fetchRow(\ilDBConstants::FETCHMODE_OBJECT)) {
343  if (!$row->period_time_indication) {
344  $start = ($row->period_start
345  ? new \ilDate($row->period_start, IL_CAL_DATETIME)
346  : null);
347  $end = ($row->period_end
348  ? new \ilDate($row->period_end, IL_CAL_DATETIME)
349  : null);
350  } else {
351  $start = ($row->period_start
352  ? new \ilDateTime($row->period_start, IL_CAL_DATETIME, \ilTimeZone::UTC)
353  : null);
354  $end = ($row->period_end
355  ? new \ilDateTime($row->period_end, IL_CAL_DATETIME, \ilTimeZone::UTC)
356  : null);
357  }
358  }
359  if ($start && $end) {
360  $lng->loadLanguageModule('grp');
361 
362  return
363  [
364  'property' => $lng->txt('grp_period'),
365  'value' => ilDatePresentation::formatPeriod($start, $end)
366  ];
367  }
368  }
const IL_CAL_DATETIME
foreach($_POST as $key=> $value) $res
$lng
global $DIC
Definition: goto.php:24
$query
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
global $ilDB
+ 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 ilDB $ilDB ilObjUser $ilUser ilLanguage $lng.

Parameters
int$a_obj_id
Returns
array

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

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().

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


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