ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 

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. 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 $ilUser, $lng, ilWaitingList\_isOnList(), ilGroupParticipants\_isParticipant(), ilDatePresentation\formatDate(), ilAccessInfo\IL_STATUS_INFO, and ilObjGroup\mayLeave().

31  {
32  global $ilUser, $lng, $rbacsystem, $ilAccess;
33 
34  if ($a_user_id == "") {
35  $a_user_id = $ilUser->getId();
36  }
37 
38  switch ($a_cmd) {
39  case "info":
40 
41  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
42  if (ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id)) {
43  $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_INFO, $lng->txt("info_is_member"));
44  } else {
45  $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_INFO, $lng->txt("info_is_not_member"));
46  }
47  break;
48 
49  case "join":
50 
51  if (!self::_registrationEnabled($a_obj_id)) {
52  return false;
53  }
54 
55  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
56  if (ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id)) {
57  return false;
58  }
59 
60  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
61  if (ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id)) {
62  return false;
63  }
64  break;
65 
66  case 'leave':
67 
68  // Regular member
69  if ($a_permission == 'leave') {
70  include_once './Modules/Group/classes/class.ilObjGroup.php';
71  $limit = null;
72  if (!ilObjGroup::mayLeave($a_obj_id, $a_user_id, $limit)) {
73  $ilAccess->addInfoItem(
75  sprintf($lng->txt("grp_cancellation_end_rbac_info"), ilDatePresentation::formatDate($limit))
76  );
77  return false;
78  }
79 
80  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
81  if (!ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id)) {
82  return false;
83  }
84  }
85  // Waiting list
86  if ($a_permission == 'join') {
87  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
88  if (!ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id)) {
89  return false;
90  }
91  }
92  break;
93 
94  }
95 
96  switch ($a_permission) {
97  case 'leave':
98  include_once './Modules/Group/classes/class.ilObjGroup.php';
99  return ilObjGroup::mayLeave($a_obj_id, $a_user_id);
100  }
101  return true;
102  }
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)
Format a date public.
$ilUser
Definition: imgupload.php:18
static _isOnList($a_usr_id, $a_obj_id)
Check if a user on the waiting list.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjGroupAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

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

References $ilUser.

159  {
160  global $ilAccess,$ilUser;
161 
162  $t_arr = explode("_", $a_target);
163  // registration codes
164  if (substr($t_arr[2], 0, 5) == 'rcode' and $ilUser->getId() != ANONYMOUS_USER_ID) {
165  self::$using_code = true;
166  return true;
167  }
168 
169  if ($t_arr[0] != "grp" || ((int) $t_arr[1]) <= 0) {
170  return false;
171  }
172 
173  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
174  $ilAccess->checkAccess("visible", "", $t_arr[1])) {
175  return true;
176  }
177  return false;
178  }
$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 116 of file class.ilObjGroupAccess.php.

References ilDAVActivationChecker\_isActive(), array, ilDAVUtils\getInstance(), and ilFMSettings\getInstance().

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

117  {
118  $commands = array();
119  $commands[] = array("permission" => "grp_linked", "cmd" => "", "lang_var" => "show", "default" => true);
120 
121  include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
122  if (ilFMSettings::getInstance()->isEnabled()) {
123  $commands[] = array(
124  'permission' => 'read',
125  'cmd' => 'fileManagerLaunch',
126  'lang_var' => 'fm_start',
127  'enable_anonymous' => false
128  );
129  }
130 
131  $commands[] = array("permission" => "join", "cmd" => "join", "lang_var" => "join");
132 
133  // on waiting list
134  $commands[] = array('permission' => "join", "cmd" => "leave", "lang_var" => "leave_waiting_list");
135 
136  // regualar users
137  $commands[] = array('permission' => "leave", "cmd" => "leave", "lang_var" => "grp_btn_unsubscribe");
138 
139  include_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
141  include_once './Services/WebDAV/classes/class.ilDAVUtils.php';
142  if (ilDAVUtils::getInstance()->isLocalPasswordInstructionRequired()) {
143  $commands[] = array('permission' => 'read', 'cmd' => 'showPasswordInstruction', 'lang_var' => 'mount_webfolder', 'enable_anonymous' => 'false');
144  } else {
145  $commands[] = array("permission" => "read", "cmd" => "mount_webfolder", "lang_var" => "mount_webfolder", "enable_anonymous" => "false");
146  }
147  }
148 
149  $commands[] = array("permission" => "write", "cmd" => "enableAdministrationPanel", "lang_var" => "edit_content");
150  $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "settings");
151 
152  return $commands;
153  }
static _isActive()
Static getter.
Create styles array
The data for the language used.
static getInstance()
Get singleton instance.
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 $ilDB, $ilUser, and ilWaitingList\_preloadOnListInfo().

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

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

186  {
187  global $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);
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.
$end
Definition: saml1-acs.php:18
const IL_CAL_UNIX
$time
Definition: cron.php:21
foreach($_POST as $key=> $value) $res
Date and time handling
$query
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ _usingRegistrationCode()

static ilObjGroupAccess::_usingRegistrationCode ( )
static

Using Registration code.

Returns
bool

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

Referenced by ilObjGroup\register().

358  {
359  return self::$using_code;
360  }
+ 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 323 of file class.ilObjGroupAccess.php.

References $end, $ilDB, $lng, $query, $row, array, ilDatePresentation\formatPeriod(), and IL_CAL_UNIX.

Referenced by ilObjGroupListGUI\getProperties().

324  {
325  global $ilDB, $lng;
326 
327  $start = $end = null;
328 
329  $query = 'SELECT grp_start, grp_end FROM grp_settings' .
330  ' WHERE obj_id = ' . $ilDB->quote($a_obj_id);
331  $set = $ilDB->query($query);
332  while ($row = $ilDB->fetchAssoc($set)) {
333  $start = $row['grp_start']
334  ? new ilDate($row['grp_start'], IL_CAL_UNIX)
335  : null;
336  $end = $row['grp_end']
337  ? new ilDate($row['grp_end'], IL_CAL_UNIX)
338  : null;
339  }
340 
341  if ($start && $end) {
342  $lng->loadLanguageModule('grp');
343 
344  return array(
345  'property' => $lng->txt('grp_period'),
346  'value' => ilDatePresentation::formatPeriod($start, $end)
347  );
348  }
349  }
$end
Definition: saml1-acs.php:18
const IL_CAL_UNIX
Class for single dates.
$query
Create styles array
The data for the language used.
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
global $lng
Definition: privfeed.php:17
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 241 of file class.ilObjGroupAccess.php.

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

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

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