ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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...
 
 _getCommands ()
 get commands More...
 
 _checkGoto ($a_target)
 check whether goto script will succeed More...
 
 _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. 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...
 
 _getCommands ()
 get commands More...
 
 _checkGoto ($a_target)
 check whether goto script will succeed More...
 
 _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. More...
 

Static Public Member Functions

static _registrationEnabled ($a_obj_id)
 
static lookupRegistrationInfo ($a_obj_id)
 Lookup registration info @global ilDB $ilDB @global ilObjUser $ilUser @global ilLanguage $lng. More...
 
static _usingRegistrationCode ()
 Using Registration code. More...
 
- Static Public Member Functions inherited from ilObjectAccess
static _isOffline ($a_obj_id)
 Type-specific implementation of general status, has to be overwritten. 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

Reimplemented from ilObjectAccess.

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

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.ilGroupParticipants.php';
81 if(!ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id))
82 {
83 return false;
84 }
85 }
86 // Waiting list
87 if($a_permission == 'join')
88 {
89 include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
90 if(!ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id))
91 {
92 return false;
93 }
94 }
95 break;
96
97 }
98
99 switch ($a_permission)
100 {
101
102 }
103 return true;
104 }
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
static _isOnList($a_usr_id, $a_obj_id)
Check if a user on the waiting list.
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15

References $ilUser, $lng, ilWaitingList\_isOnList(), and ilGroupParticipants\_isParticipant().

+ Here is the call graph for this function:

◆ _checkGoto()

ilObjGroupAccess::_checkGoto (   $a_target)

check whether goto script will succeed

Reimplemented from ilObjectAccess.

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

166 {
167 global $ilAccess,$ilUser;
168
169 $t_arr = explode("_", $a_target);
170 // registration codes
171 if(substr($t_arr[2],0,5) == 'rcode' and $ilUser->getId() != ANONYMOUS_USER_ID)
172 {
173 self::$using_code = true;
174 return true;
175 }
176
177 if ($t_arr[0] != "grp" || ((int) $t_arr[1]) <= 0)
178 {
179 return false;
180 }
181
182 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
183 $ilAccess->checkAccess("visible", "", $t_arr[1]))
184 {
185 return true;
186 }
187 return false;
188 }

References $ilUser.

◆ _getCommands()

ilObjGroupAccess::_getCommands ( )

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

Reimplemented from ilObjectAccess.

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

119 {
120 $commands = array();
121 $commands[] = array("permission" => "grp_linked", "cmd" => "", "lang_var" => "show", "default" => true);
122
123 include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
124 if(ilFMSettings::getInstance()->isEnabled())
125 {
126 $commands[] = array(
127 'permission' => 'read',
128 'cmd' => 'fileManagerLaunch',
129 'lang_var' => 'fm_start',
130 'enable_anonymous' => false
131 );
132 }
133
134 $commands[] = array("permission" => "join", "cmd" => "join", "lang_var" => "join");
135
136 // on waiting list
137 $commands[] = array('permission' => "join", "cmd" => "leave", "lang_var" => "leave_waiting_list");
138
139 // regualar users
140 $commands[] = array('permission' => "leave", "cmd" => "leave", "lang_var" => "grp_btn_unsubscribe");
141
142 include_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
144 {
145 include_once './Services/WebDAV/classes/class.ilDAVUtils.php';
146 if(ilDAVUtils::getInstance()->isLocalPasswordInstructionRequired())
147 {
148 $commands[] = array('permission' => 'read', 'cmd' => 'showPasswordInstruction', 'lang_var' => 'mount_webfolder', 'enable_anonymous' => 'false');
149 }
150 else
151 {
152 $commands[] = array("permission" => "read", "cmd" => "mount_webfolder", "lang_var" => "mount_webfolder", "enable_anonymous" => "false");
153 }
154 }
155
156 $commands[] = array("permission" => "write", "cmd" => "enableAdministrationPanel", "lang_var" => "edit_content");
157 $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "settings");
158
159 return $commands;
160 }
static getInstance()
Get singleton instance.
static getInstance()
Get singleton instance.

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

Referenced by ilObjGroupListGUI\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _preloadData()

ilObjGroupAccess::_preloadData (   $a_obj_ids,
  $a_ref_ids 
)

Preload data.

Parameters
array$a_obj_idsarray of object ids

Reimplemented from ilObjectAccess.

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

240 {
241 global $ilDB, $ilUser;
242
243 include_once("./Modules/Group/classes/class.ilGroupWaitingList.php");
245 }
_preloadOnListInfo($a_usr_ids, $a_obj_ids)
Preload on list info.
global $ilDB

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

+ 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 195 of file class.ilObjGroupAccess.php.

196 {
197 global $ilDB;
198
199 $query = "SELECT * FROM grp_settings ".
200 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
201
202 $res = $ilDB->query($query);
203
204 $enabled = $unlimited = false;
205 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
206 {
207 $enabled = $row->registration_enabled;
208 $unlimited = $row->registration_unlimited;
209 $start = $row->registration_start;
210 $end = $row->registration_end;
211 }
212
213 if(!$enabled)
214 {
215 return false;
216 }
217 if($unlimited)
218 {
219 return true;
220 }
221
222 if(!$unlimited)
223 {
224 $start = new ilDateTime($start,IL_CAL_DATETIME);
225 $end = new ilDateTime($end,IL_CAL_DATETIME);
226 $time = new ilDateTime(time(),IL_CAL_UNIX);
227
228 return ilDateTime::_after($time, $start) and ilDateTime::_before($time,$end);
229 }
230 return false;
231 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling
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.

References $ilDB, $query, $res, $row, ilDateTime\_after(), ilDateTime\_before(), DB_FETCHMODE_OBJECT, IL_CAL_DATETIME, and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ _usingRegistrationCode()

static ilObjGroupAccess::_usingRegistrationCode ( )
static

Using Registration code.

Returns
bool

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

355 {
356 return self::$using_code;
357 }

References $using_code.

Referenced by ilObjGroup\register().

+ Here is the caller graph for this function:

◆ lookupRegistrationInfo()

static ilObjGroupAccess::lookupRegistrationInfo (   $a_obj_id)
static

Lookup registration info @global ilDB $ilDB @global ilObjUser $ilUser @global ilLanguage $lng.

Parameters
int$a_obj_id
Returns
array

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

256 {
257 global $ilDB, $ilUser, $lng;
258
259 $query = 'SELECT registration_type, registration_enabled, registration_unlimited, registration_start, '.
260 'registration_end, registration_mem_limit, registration_max_members FROM grp_settings '.
261 'WHERE obj_id = '.$ilDB->quote($a_obj_id);
262 $res = $ilDB->query($query);
263
264 $info = array();
265 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
266 {
267 $info['reg_info_start'] = new ilDateTime($row->registration_start, IL_CAL_DATETIME);
268 $info['reg_info_end'] = new ilDateTime($row->registration_end, IL_CAL_DATETIME);
269 $info['reg_info_type'] = $row->registration_type;
270 $info['reg_info_max_members'] = $row->registration_max_members;
271 $info['reg_info_mem_limit'] = $row->registration_mem_limit;
272 $info['reg_info_unlimited'] = $row->registration_unlimited;
273
274 $info['reg_info_max_members'] = 0;
275 if($info['reg_info_mem_limit'])
276 {
277 $info['reg_info_max_members'] = $row->registration_max_members;
278 }
279
280 $info['reg_info_enabled'] = $row->registration_enabled;
281 }
282
283 $registration_possible = $info['reg_info_enabled'];
284
285 // Limited registration (added $registration_possible, see bug 0010157)
286 if(!$info['reg_info_unlimited'] && $registration_possible)
287 {
288 $dt = new ilDateTime(time(),IL_CAL_UNIX);
289 if(ilDateTime::_before($dt, $info['reg_info_start']))
290 {
291 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_start');
292 $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_start']);
293 }
294 elseif(ilDateTime::_before($dt, $info['reg_info_end']))
295 {
296 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_end');
297 $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_end']);
298 }
299 else
300 {
301 $registration_possible = false;
302 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_period');
303 $info['reg_info_list_prop']['value'] = $lng->txt('grp_list_reg_noreg');
304 }
305 }
306 else
307 {
308 // added !$registration_possible, see bug 0010157
309 if (!$registration_possible)
310 {
311 $registration_possible = false;
312 $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_period');
313 $info['reg_info_list_prop']['value'] = $lng->txt('grp_list_reg_noreg');
314 }
315 }
316
317 if($info['reg_info_mem_limit'] && $registration_possible)
318 {
319 // Check for free places
320 include_once './Modules/Group/classes/class.ilGroupParticipants.php';
322
323 include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
324 $info['reg_info_list_size'] = ilCourseWaitingList::lookupListSize($a_obj_id);
325 if($info['reg_info_list_size'])
326 {
327 $info['reg_info_free_places'] = 0;
328 }
329 else
330 {
331 $info['reg_info_free_places'] = max(0,$info['reg_info_max_members'] - $part->getCountMembers());
332 }
333
334 if($info['reg_info_free_places'])
335 {
336 $info['reg_info_list_prop_limit']['property'] = $lng->txt('grp_list_reg_limit_places');
337 $info['reg_info_list_prop_limit']['value'] = $info['reg_info_free_places'];
338 }
339 else
340 {
341 $info['reg_info_list_prop_limit']['property'] = '';
342 $info['reg_info_list_prop_limit']['value'] = $lng->txt('grp_list_reg_limit_full');
343 }
344 }
345
346 return $info;
347 }
static formatDate(ilDateTime $date)
Format a date @access public.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static lookupListSize($a_obj_id)
Lookup waiting lit size.

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

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

ilObjGroupAccess::$using_code = false
staticprotected

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

Referenced by _usingRegistrationCode().


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