ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 _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(), and ilObjGroup\mayLeave().

31  {
32 
33  global $ilUser, $lng, $rbacsystem, $ilAccess;
34 
35  if ($a_user_id == "")
36  {
37  $a_user_id = $ilUser->getId();
38  }
39 
40  switch ($a_cmd)
41  {
42  case "info":
43 
44  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
45  if(ilGroupParticipants::_isParticipant($a_ref_id,$a_user_id))
46  {
47  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_member"));
48  }
49  else
50  {
51  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_not_member"));
52  }
53  break;
54 
55  case "join":
56 
57  if(!self::_registrationEnabled($a_obj_id))
58  {
59  return false;
60  }
61 
62  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
63  if(ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id))
64  {
65  return false;
66  }
67 
68  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
69  if(ilGroupParticipants::_isParticipant($a_ref_id,$a_user_id))
70  {
71  return false;
72  }
73  break;
74 
75  case 'leave':
76 
77  // Regular member
78  if($a_permission == 'leave')
79  {
80  include_once './Modules/Group/classes/class.ilObjGroup.php';
81  $limit = null;
82  if(!ilObjGroup::mayLeave($a_obj_id, $a_user_id, $limit))
83  {
84  $ilAccess->addInfoItem(IL_STATUS_MESSAGE,
85  sprintf($lng->txt("grp_cancellation_end_rbac_info"), ilDatePresentation::formatDate($limit)));
86  return false;
87  }
88 
89  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
90  if(!ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id))
91  {
92  return false;
93  }
94  }
95  // Waiting list
96  if($a_permission == 'join')
97  {
98  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
99  if(!ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id))
100  {
101  return false;
102  }
103  }
104  break;
105 
106  }
107 
108  switch ($a_permission)
109  {
110  case 'leave':
111  include_once './Modules/Group/classes/class.ilObjGroup.php';
112  return ilObjGroup::mayLeave($a_obj_id, $a_user_id);
113  }
114  return true;
115  }
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)
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 176 of file class.ilObjGroupAccess.php.

References $ilUser.

177  {
178  global $ilAccess,$ilUser;
179 
180  $t_arr = explode("_", $a_target);
181  // registration codes
182  if(substr($t_arr[2],0,5) == 'rcode' and $ilUser->getId() != ANONYMOUS_USER_ID)
183  {
184  self::$using_code = true;
185  return true;
186  }
187 
188  if ($t_arr[0] != "grp" || ((int) $t_arr[1]) <= 0)
189  {
190  return false;
191  }
192 
193  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
194  $ilAccess->checkAccess("visible", "", $t_arr[1]))
195  {
196  return true;
197  }
198  return false;
199  }
$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 129 of file class.ilObjGroupAccess.php.

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

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

130  {
131  $commands = array();
132  $commands[] = array("permission" => "grp_linked", "cmd" => "", "lang_var" => "show", "default" => true);
133 
134  include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
135  if(ilFMSettings::getInstance()->isEnabled())
136  {
137  $commands[] = array(
138  'permission' => 'read',
139  'cmd' => 'fileManagerLaunch',
140  'lang_var' => 'fm_start',
141  'enable_anonymous' => false
142  );
143  }
144 
145  $commands[] = array("permission" => "join", "cmd" => "join", "lang_var" => "join");
146 
147  // on waiting list
148  $commands[] = array('permission' => "join", "cmd" => "leave", "lang_var" => "leave_waiting_list");
149 
150  // regualar users
151  $commands[] = array('permission' => "leave", "cmd" => "leave", "lang_var" => "grp_btn_unsubscribe");
152 
153  include_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
155  {
156  include_once './Services/WebDAV/classes/class.ilDAVUtils.php';
157  if(ilDAVUtils::getInstance()->isLocalPasswordInstructionRequired())
158  {
159  $commands[] = array('permission' => 'read', 'cmd' => 'showPasswordInstruction', 'lang_var' => 'mount_webfolder', 'enable_anonymous' => 'false');
160  }
161  else
162  {
163  $commands[] = array("permission" => "read", "cmd" => "mount_webfolder", "lang_var" => "mount_webfolder", "enable_anonymous" => "false");
164  }
165  }
166 
167  $commands[] = array("permission" => "write", "cmd" => "enableAdministrationPanel", "lang_var" => "edit_content");
168  $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "settings");
169 
170  return $commands;
171  }
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 250 of file class.ilObjGroupAccess.php.

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

251  {
252  global $ilDB, $ilUser;
253 
254  include_once("./Modules/Group/classes/class.ilGroupWaitingList.php");
255  ilGroupWaitingList::_preloadOnListInfo($ilUser->getId(), $a_obj_ids);
256  }
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 206 of file class.ilObjGroupAccess.php.

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

207  {
208  global $ilDB;
209 
210  $query = "SELECT * FROM grp_settings ".
211  "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
212 
213  $res = $ilDB->query($query);
214 
215  $enabled = $unlimited = false;
216  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
217  {
218  $enabled = $row->registration_enabled;
219  $unlimited = $row->registration_unlimited;
220  $start = $row->registration_start;
221  $end = $row->registration_end;
222  }
223 
224  if(!$enabled)
225  {
226  return false;
227  }
228  if($unlimited)
229  {
230  return true;
231  }
232 
233  if(!$unlimited)
234  {
236  $end = new ilDateTime($end,IL_CAL_DATETIME);
237  $time = new ilDateTime(time(),IL_CAL_UNIX);
238 
239  return ilDateTime::_after($time, $start) and ilDateTime::_before($time,$end);
240  }
241  return false;
242  }
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
Date and time handling
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 365 of file class.ilObjGroupAccess.php.

Referenced by ilObjGroup\register().

366  {
367  return self::$using_code;
368  }
+ 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 266 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().

267  {
268  global $ilDB, $ilUser, $lng;
269 
270  $query = 'SELECT registration_type, registration_enabled, registration_unlimited, registration_start, '.
271  'registration_end, registration_mem_limit, registration_max_members FROM grp_settings '.
272  'WHERE obj_id = '.$ilDB->quote($a_obj_id);
273  $res = $ilDB->query($query);
274 
275  $info = array();
276  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
277  {
278  $info['reg_info_start'] = new ilDateTime($row->registration_start, IL_CAL_DATETIME);
279  $info['reg_info_end'] = new ilDateTime($row->registration_end, IL_CAL_DATETIME);
280  $info['reg_info_type'] = $row->registration_type;
281  $info['reg_info_max_members'] = $row->registration_max_members;
282  $info['reg_info_mem_limit'] = $row->registration_mem_limit;
283  $info['reg_info_unlimited'] = $row->registration_unlimited;
284 
285  $info['reg_info_max_members'] = 0;
286  if($info['reg_info_mem_limit'])
287  {
288  $info['reg_info_max_members'] = $row->registration_max_members;
289  }
290 
291  $info['reg_info_enabled'] = $row->registration_enabled;
292  }
293 
294  $registration_possible = $info['reg_info_enabled'];
295 
296  // Limited registration (added $registration_possible, see bug 0010157)
297  if(!$info['reg_info_unlimited'] && $registration_possible)
298  {
299  $dt = new ilDateTime(time(),IL_CAL_UNIX);
300  if(ilDateTime::_before($dt, $info['reg_info_start']))
301  {
302  $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_start');
303  $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_start']);
304  }
305  elseif(ilDateTime::_before($dt, $info['reg_info_end']))
306  {
307  $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_end');
308  $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_end']);
309  }
310  else
311  {
312  $registration_possible = false;
313  $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_period');
314  $info['reg_info_list_prop']['value'] = $lng->txt('grp_list_reg_noreg');
315  }
316  }
317  else
318  {
319  // added !$registration_possible, see bug 0010157
320  if (!$registration_possible)
321  {
322  $registration_possible = false;
323  $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_period');
324  $info['reg_info_list_prop']['value'] = $lng->txt('grp_list_reg_noreg');
325  }
326  }
327 
328  if($info['reg_info_mem_limit'] && $info['reg_info_max_members'] && $registration_possible)
329  {
330  // Check for free places
331  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
332  $part = ilGroupParticipants::_getInstanceByObjId($a_obj_id);
333 
334  include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
335  $info['reg_info_list_size'] = ilCourseWaitingList::lookupListSize($a_obj_id);
336  if($info['reg_info_list_size'])
337  {
338  $info['reg_info_free_places'] = 0;
339  }
340  else
341  {
342  $info['reg_info_free_places'] = max(0,$info['reg_info_max_members'] - $part->getCountMembers());
343  }
344 
345  if($info['reg_info_free_places'])
346  {
347  $info['reg_info_list_prop_limit']['property'] = $lng->txt('grp_list_reg_limit_places');
348  $info['reg_info_list_prop_limit']['value'] = $info['reg_info_free_places'];
349  }
350  else
351  {
352  $info['reg_info_list_prop_limit']['property'] = '';
353  $info['reg_info_list_prop_limit']['value'] = $lng->txt('grp_list_reg_limit_full');
354  }
355  }
356 
357  return $info;
358  }
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
$info
Definition: example_052.php:80
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
$ilUser
Definition: imgupload.php:18
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.
+ 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: