ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilObjCourseAccess Class Reference

Class ilObjCourseAccess. More...

+ Inheritance diagram for ilObjCourseAccess:
+ Collaboration diagram for ilObjCourseAccess:

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...
 
 _lookupViewMode ($a_id)
 Lookup view mode. 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 getConditionOperators ()
 Get operators. More...
 
static checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 @global ilObjUser $ilUser More...
 
static _isActivated ($a_obj_id, &$a_visible_flag=null, $a_mind_member_view=true)
 Is activated? More...
 
static _registrationEnabled ($a_obj_id)
 
static lookupRegistrationInfo ($a_obj_id)
 Lookup registration info @global ilDB $ilDB @global ilObjUser $ilUser @global ilLanguage $lng. More...
 
static _isOffline ($a_obj_id)
 Type-specific implementation of general status. More...
 
static _usingRegistrationCode ()
 Using Registration code. More...
 
static _isOffline ($a_obj_id)
 Type-specific implementation of general status, has to be overwritten. More...
 
static getConditionOperators ()
 Returns an array with valid operators for the specific object type. More...
 
static checkCondition ($a_trigger_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition for a specific user and object More...
 

Static Protected Member Functions

static _isOnline ($a_obj_id)
 Check if online setting is active. More...
 

Static Protected Attributes

static $using_code = false
 

Detailed Description

Class ilObjCourseAccess.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 19 of file class.ilObjCourseAccess.php.

Member Function Documentation

◆ _checkAccess()

ilObjCourseAccess::_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 69 of file class.ilObjCourseAccess.php.

70 {
71 global $ilUser, $lng, $rbacsystem, $ilAccess, $ilias;
72
73
74 if ($a_user_id == "")
75 {
76 $a_user_id = $ilUser->getId();
77 }
78
79 if($ilUser->getId() == $a_user_id)
80 {
81 $participants = ilCourseParticipant::_getInstanceByObjId($a_obj_id,$a_user_id);
82 }
83 else
84 {
85 $participants = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
86 }
87
88
89 switch ($a_cmd)
90 {
91 case "view":
92 if($participants->isBlocked($a_user_id) and $participants->isAssigned($a_user_id))
93 {
94 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
95 return false;
96 }
97 break;
98
99 case 'leave':
100
101 // Regular member
102 if($a_permission == 'leave')
103 {
104 include_once './Modules/Course/classes/class.ilCourseParticipants.php';
105 if(!$participants->isAssigned($a_user_id))
106 {
107 return false;
108 }
109 }
110 // Waiting list
111 if($a_permission == 'join')
112 {
113 include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
114 if(!ilCourseWaitingList::_isOnList($a_user_id, $a_obj_id))
115 {
116 return false;
117 }
118 return true;
119 }
120 break;
121
122 case 'join':
123
124 include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
125 if(ilCourseWaitingList::_isOnList($a_user_id, $a_obj_id))
126 {
127 return false;
128 }
129 break;
130 }
131
132 switch ($a_permission)
133 {
134 case 'visible':
135 $visible = null;
136 $active = self::_isActivated($a_obj_id, $visible);
137 $tutor = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
138 if(!$active)
139 {
140 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
141 }
142 if(!$tutor and !$active && !$visible)
143 {
144 return false;
145 }
146 break;
147
148 case 'read':
149 $tutor = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
150 if($tutor)
151 {
152 return true;
153 }
154 $active = self::_isActivated($a_obj_id);
155 if(!$active)
156 {
157 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
158 return false;
159 }
160 if($participants->isBlocked($a_user_id) and $participants->isAssigned($a_user_id))
161 {
162 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
163 return false;
164 }
165 break;
166
167 case 'join':
168 if(!self::_registrationEnabled($a_obj_id))
169 {
170 return false;
171 }
172
173 if($participants->isAssigned($a_user_id))
174 {
175 return false;
176 }
177 break;
178 }
179 return true;
180 }
const IL_NO_OBJECT_ACCESS
static _getInstanceByObjId($a_obj_id, $a_usr_id)
Get singleton instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _isActivated($a_obj_id, &$a_visible_flag=null, $a_mind_member_view=true)
Is activated?
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, ilCourseParticipants\_getInstanceByObjId(), ilCourseParticipant\_getInstanceByObjId(), _isActivated(), ilWaitingList\_isOnList(), and IL_NO_OBJECT_ACCESS.

+ Here is the call graph for this function:

◆ _checkGoto()

ilObjCourseAccess::_checkGoto (   $a_target)

check whether goto script will succeed

Reimplemented from ilObjectAccess.

Definition at line 240 of file class.ilObjCourseAccess.php.

241 {
242 global $ilAccess,$ilUser;
243
244 $t_arr = explode("_", $a_target);
245
246 // registration codes
247 if(substr($t_arr[2],0,5) == 'rcode' and $ilUser->getId() != ANONYMOUS_USER_ID)
248 {
249 self::$using_code = true;
250 return true;
251 }
252
253
254 if ($t_arr[0] != "crs" || ((int) $t_arr[1]) <= 0)
255 {
256 return false;
257 }
258
259 // checking for read results in endless loop, if read is given
260 // but visible is not given (-> see bug 5323)
261 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
262 $ilAccess->checkAccess("visible", "", $t_arr[1]))
263 //if ($ilAccess->checkAccess("visible", "", $t_arr[1]))
264 {
265 return true;
266 }
267 return false;
268 }

References $ilUser.

◆ _getCommands()

ilObjCourseAccess::_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 194 of file class.ilObjCourseAccess.php.

195 {
196 $commands = array();
197 $commands[] = array("permission" => "crs_linked", "cmd" => "", "lang_var" => "view", "default" => true);
198
199 include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
200 if(ilFMSettings::getInstance()->isEnabled())
201 {
202 $commands[] = array(
203 'permission' => 'read',
204 'cmd' => 'fileManagerLaunch',
205 'lang_var' => 'fm_start',
206 'enable_anonymous' => false
207 );
208 }
209
210 $commands[] = array("permission" => "join", "cmd" => "join", "lang_var" => "join");
211
212 // on waiting list
213 $commands[] = array('permission' => "join", "cmd" => "leave", "lang_var" => "leave_waiting_list");
214
215 // regualar users
216 $commands[] = array('permission' => "leave", "cmd" => "leave", "lang_var" => "crs_unsubscribe");
217
218 include_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
220 {
221 include_once './Services/WebDAV/classes/class.ilDAVUtils.php';
222 if(ilDAVUtils::getInstance()->isLocalPasswordInstructionRequired())
223 {
224 $commands[] = array('permission' => 'read', 'cmd' => 'showPasswordInstruction', 'lang_var' => 'mount_webfolder', 'enable_anonymous' => 'false');
225 }
226 else
227 {
228 $commands[] = array("permission" => "read", "cmd" => "mount_webfolder", "lang_var" => "mount_webfolder", "enable_anonymous" => "false");
229 }
230 }
231
232 $commands[] = array("permission" => "write", "cmd" => "enableAdministrationPanel", "lang_var" => "edit_content");
233 $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "settings");
234 return $commands;
235 }
static getInstance()
Get singleton instance.
static getInstance()
Get singleton instance.

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

Referenced by ilObjCourseReferenceAccess\_getCommands(), and ilObjCourseListGUI\init().

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

◆ _isActivated()

static ilObjCourseAccess::_isActivated (   $a_obj_id,
$a_visible_flag = null,
  $a_mind_member_view = true 
)
static

Is activated?

See also
ilStartupGUI
Parameters
int$a_obj_id
bool&$a_visible_flag
bool$a_mind_member_view
Returns
boolean

Definition at line 315 of file class.ilObjCourseAccess.php.

316 {
317 // #7669
318 if($a_mind_member_view)
319 {
320 include_once './Services/Container/classes/class.ilMemberViewSettings.php';
321 if(ilMemberViewSettings::getInstance()->isActive())
322 {
323 $a_visible_flag = true;
324 return true;
325 }
326 }
327
328 // offline?
329 if(!self::_isOnline($a_obj_id))
330 {
331 $a_visible_flag = false;
332 return false;
333 }
334
336 $ref_id = array_pop($ref_id);
337
338 $a_visible_flag = true;
339
340 include_once './Services/Object/classes/class.ilObjectActivation.php';
342 switch($item['timing_type'])
343 {
345 if(time() < $item['timing_start'] or
346 time() > $item['timing_end'])
347 {
348 $a_visible_flag = $item['visible'];
349 return false;
350 }
351 // fallthrough
352
353 default:
354 return true;
355 }
356 }
static getInstance()
Get instance.
static getItem($a_ref_id)
Get item data.
static _getAllReferences($a_id)
get all reference ids of object
$ref_id
Definition: sahs_server.php:39

References $ref_id, ilObject\_getAllReferences(), ilMemberViewSettings\getInstance(), ilObjectActivation\getItem(), and ilObjectActivation\TIMINGS_ACTIVATION.

Referenced by _checkAccess(), ilObjCourse\_isActivated(), _isOffline(), and ilPortfolioPageGUI\getCoursesOfUser().

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

◆ _isOffline()

static ilObjCourseAccess::_isOffline (   $a_obj_id)
static

Type-specific implementation of general status.

Used in ListGUI and Learning Progress

Parameters
int$a_obj_id
Returns
bool

Reimplemented from ilObjectAccess.

Definition at line 499 of file class.ilObjCourseAccess.php.

500 {
501 $dummy = null;
502 return !self::_isActivated($a_obj_id, $dummy, false);
503 }

References _isActivated().

Referenced by ilObjCourseListGUI\getProperties().

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

◆ _isOnline()

static ilObjCourseAccess::_isOnline (   $a_obj_id)
staticprotected

Check if online setting is active.

Parameters
int$a_obj_id
Returns
bool

Definition at line 295 of file class.ilObjCourseAccess.php.

296 {
297 global $ilDB;
298
299 $query = "SELECT * FROM crs_settings ".
300 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
301 $res = $ilDB->query($query);
302 $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
303 return (bool)$row->activation_type;
304 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

◆ _lookupViewMode()

ilObjCourseAccess::_lookupViewMode (   $a_id)

Lookup view mode.

This is placed here to the need that ilObjFolder must always instantiate a Course object.

Returns
Parameters
object$a_id

Definition at line 276 of file class.ilObjCourseAccess.php.

277 {
278 global $ilDB;
279
280 $query = "SELECT view_mode FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id ,'integer')." ";
281 $res = $ilDB->query($query);
282 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
283 {
284 return $row->view_mode;
285 }
286 return false;
287 }

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilObjFolder\getViewMode().

+ Here is the caller graph for this function:

◆ _preloadData()

ilObjCourseAccess::_preloadData (   $a_obj_ids,
  $a_ref_ids 
)

Preload data.

Parameters
array$a_obj_idsarray of object ids

Reimplemented from ilObjectAccess.

Definition at line 510 of file class.ilObjCourseAccess.php.

511 {
512 global $ilUser;
513
514 include_once("./Modules/Course/classes/class.ilCourseWaitingList.php");
516
517 include_once "./Modules/Course/classes/class.ilCourseCertificateAdapter.php";
519 }
static _preloadListData($a_usr_ids, $a_obj_ids)
Get certificate/passed status for all given objects and users.
_preloadOnListInfo($a_usr_ids, $a_obj_ids)
Preload on list info.

References $ilUser, ilCourseCertificateAdapter\_preloadListData(), and ilWaitingList\_preloadOnListInfo().

+ Here is the call graph for this function:

◆ _registrationEnabled()

static ilObjCourseAccess::_registrationEnabled (   $a_obj_id)
static
Returns
Parameters
object$a_obj_id

Definition at line 363 of file class.ilObjCourseAccess.php.

364 {
365 global $ilDB;
366
367 $query = "SELECT * FROM crs_settings ".
368 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
369
370 $res = $ilDB->query($query);
371 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
372 {
373 $type = $row->sub_limitation_type;
374 $reg_start = $row->sub_start;
375 $reg_end = $row->sub_end;
376 }
377
378 switch($type)
379 {
381 return true;
382
384 return false;
385
387 if(time() > $reg_start and
388 time() < $reg_end)
389 {
390 return true;
391 }
392 default:
393 return false;
394 }
395 return false;
396 }
const IL_CRS_SUBSCRIPTION_LIMITED
const IL_CRS_SUBSCRIPTION_UNLIMITED
const IL_CRS_SUBSCRIPTION_DEACTIVATED

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, IL_CRS_SUBSCRIPTION_DEACTIVATED, IL_CRS_SUBSCRIPTION_LIMITED, and IL_CRS_SUBSCRIPTION_UNLIMITED.

Referenced by ilObjCourse\_registrationEnabled().

+ Here is the caller graph for this function:

◆ _usingRegistrationCode()

static ilObjCourseAccess::_usingRegistrationCode ( )
static

Using Registration code.

Returns
bool

Definition at line 526 of file class.ilObjCourseAccess.php.

527 {
528 return self::$using_code;
529 }

References $using_code.

Referenced by ilObjCourse\register().

+ Here is the caller graph for this function:

◆ checkCondition()

static ilObjCourseAccess::checkCondition (   $a_obj_id,
  $a_operator,
  $a_value,
  $a_usr_id 
)
static

@global ilObjUser $ilUser

Parameters
type$a_obj_id
type$a_operator
type$a_value
type$a_usr_id
Returns
boolean

Implements ilConditionHandling.

Definition at line 44 of file class.ilObjCourseAccess.php.

45 {
46 include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
47 include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
48
49 switch($a_operator)
50 {
52 return ilCourseParticipants::_hasPassed($a_obj_id,$a_usr_id);
53 }
54 return FALSE;
55 }
static _hasPassed($a_obj_id, $a_usr_id)
Check if user has passed course.

References ilParticipants\_hasPassed(), and ilConditionHandler\OPERATOR_PASSED.

+ Here is the call graph for this function:

◆ getConditionOperators()

static ilObjCourseAccess::getConditionOperators ( )
static

Get operators.

Implements ilConditionHandling.

Definition at line 27 of file class.ilObjCourseAccess.php.

28 {
29 include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
30 return array(
32 );
33 }

References ilConditionHandler\OPERATOR_PASSED.

◆ lookupRegistrationInfo()

static ilObjCourseAccess::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 406 of file class.ilObjCourseAccess.php.

407 {
408 global $ilDB, $ilUser, $lng;
409
410 $query = 'SELECT sub_limitation_type, sub_start, sub_end, sub_mem_limit, sub_max_members FROM crs_settings '.
411 'WHERE obj_id = '.$ilDB->quote($a_obj_id);
412 $res = $ilDB->query($query);
413
414 $info = array();
415 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
416 {
417 $info['reg_info_start'] = new ilDateTime($row->sub_start, IL_CAL_UNIX);
418 $info['reg_info_end'] = new ilDateTime($row->sub_end, IL_CAL_UNIX);
419 $info['reg_info_type'] = $row->sub_limitation_type;
420 $info['reg_info_max_members'] = $row->sub_max_members;
421 $info['reg_info_mem_limit'] = $row->sub_mem_limit;
422 }
423
424 $registration_possible = true;
425
426 // Limited registration
427 if($info['reg_info_type'] == ilCourseConstants::SUBSCRIPTION_LIMITED)
428 {
429 $dt = new ilDateTime(time(),IL_CAL_UNIX);
430 if(ilDateTime::_before($dt, $info['reg_info_start']))
431 {
432 $info['reg_info_list_prop']['property'] = $lng->txt('crs_list_reg_start');
433 $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_start']);
434 }
435 elseif(ilDateTime::_before($dt, $info['reg_info_end']))
436 {
437 $info['reg_info_list_prop']['property'] = $lng->txt('crs_list_reg_end');
438 $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_end']);
439 }
440 else
441 {
442 $registration_possible = false;
443 $info['reg_info_list_prop']['property'] = $lng->txt('crs_list_reg_period');
444 $info['reg_info_list_prop']['value'] = $lng->txt('crs_list_reg_noreg');
445 }
446 }
447 else if($info['reg_info_type'] == ilCourseConstants::SUBSCRIPTION_UNLIMITED)
448 {
449 $registration_possible = true;
450 }
451 else
452 {
453 $registration_possible = false;
454 $info['reg_info_list_prop']['property'] = $lng->txt('crs_list_reg_period');
455 $info['reg_info_list_prop']['value'] = $lng->txt('crs_list_reg_noreg');
456 }
457
458 if($info['reg_info_mem_limit'] && $registration_possible)
459 {
460 // Check for free places
461 include_once './Modules/Course/classes/class.ilCourseParticipant.php';
462 $part = ilCourseParticipant::_getInstanceByObjId($a_obj_id, $ilUser->getId());
463
464 include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
465 $info['reg_info_list_size'] = ilCourseWaitingList::lookupListSize($a_obj_id);
466 $GLOBALS['ilLog']->write(__METHOD__.' list_size: ' . $info['reg_info_list_size']);
467 if($info['reg_info_list_size'])
468 {
469 $info['reg_info_free_places'] = 0;
470 }
471 else
472 {
473 $info['reg_info_free_places'] = max(0,$info['reg_info_max_members'] - $part->getNumberOfMembers());
474 }
475
476 if($info['reg_info_free_places'])
477 {
478 $info['reg_info_list_prop_limit']['property'] = $lng->txt('crs_list_reg_limit_places');
479 $info['reg_info_list_prop_limit']['value'] = $info['reg_info_free_places'];
480 }
481 else
482 {
483 $info['reg_info_list_prop_limit']['property'] = '';
484 $info['reg_info_list_prop_limit']['value'] = $lng->txt('crs_list_reg_limit_full');
485 }
486 }
487
488 return $info;
489 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
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 lookupListSize($a_obj_id)
Lookup waiting lit size.
$GLOBALS['ct_recipient']

References $GLOBALS, $ilDB, $ilUser, $lng, $query, $res, $row, ilDateTime\_before(), ilCourseParticipant\_getInstanceByObjId(), DB_FETCHMODE_OBJECT, ilDatePresentation\formatDate(), IL_CAL_UNIX, ilWaitingList\lookupListSize(), ilCourseConstants\SUBSCRIPTION_LIMITED, and ilCourseConstants\SUBSCRIPTION_UNLIMITED.

Referenced by ilCourseRegistrationGUI\fillMaxMembers(), ilObjCourseListGUI\getProperties(), and ilObjCourseGUI\infoScreen().

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

Field Documentation

◆ $using_code

ilObjCourseAccess::$using_code = false
staticprotected

Definition at line 22 of file class.ilObjCourseAccess.php.

Referenced by _usingRegistrationCode().


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