ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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)
 _getCommands ()
 get commands
 _checkGoto ($a_target)
 check whether goto script will succeed
 _lookupViewMode ($a_id)
 Lookup view mode.
 _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data.
- Public Member Functions inherited from ilObjectAccess
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition

Static Public Member Functions

static getConditionOperators ()
 Get operators.
static checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 ilObjUser $ilUser
static _isActivated ($a_obj_id, &$a_visible_flag=null, $a_mind_member_view=true)
 Is activated?
static _registrationEnabled ($a_obj_id)
static lookupRegistrationInfo ($a_obj_id)
 Lookup registration info ilDB $ilDB ilObjUser $ilUser ilLanguage $lng.
static _isOffline ($a_obj_id)
 Type-specific implementation of general status.
static _usingRegistrationCode ()
 Using Registration code.

Static Protected Member Functions

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

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:
class.ilObjCourseAccess.php 57377 2015-01-22 16:21:31Z fwolf

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

Member Function Documentation

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.

References $ilUser, $lng, ilCourseParticipants\_getInstanceByObjId(), ilCourseParticipant\_getInstanceByObjId(), _isActivated(), ilWaitingList\_isOnList(), and IL_NO_OBJECT_ACCESS.

{
global $ilUser, $lng, $rbacsystem, $ilAccess, $ilias;
if ($a_user_id == "")
{
$a_user_id = $ilUser->getId();
}
if($ilUser->getId() == $a_user_id)
{
$participants = ilCourseParticipant::_getInstanceByObjId($a_obj_id,$a_user_id);
}
else
{
$participants = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
}
switch ($a_cmd)
{
case "view":
if($participants->isBlocked($a_user_id) and $participants->isAssigned($a_user_id))
{
$ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
return false;
}
break;
case 'leave':
// Regular member
if($a_permission == 'leave')
{
include_once './Modules/Course/classes/class.ilCourseParticipants.php';
if(!$participants->isAssigned($a_user_id))
{
return false;
}
}
// Waiting list
if($a_permission == 'join')
{
include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
if(!ilCourseWaitingList::_isOnList($a_user_id, $a_obj_id))
{
return false;
}
return true;
}
break;
case 'join':
include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
if(ilCourseWaitingList::_isOnList($a_user_id, $a_obj_id))
{
return false;
}
break;
}
switch ($a_permission)
{
case 'visible':
$visible = null;
$active = self::_isActivated($a_obj_id, $visible);
$tutor = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
if(!$active)
{
$ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
}
if(!$tutor and !$active && !$visible)
{
return false;
}
break;
case 'read':
$tutor = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
if($tutor)
{
return true;
}
$active = self::_isActivated($a_obj_id);
if(!$active)
{
$ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
return false;
}
if($participants->isBlocked($a_user_id) and $participants->isAssigned($a_user_id))
{
$ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
return false;
}
break;
case 'join':
if(!self::_registrationEnabled($a_obj_id))
{
return false;
}
if($participants->isAssigned($a_user_id))
{
return false;
}
break;
}
return true;
}

+ Here is the call graph for this function:

ilObjCourseAccess::_checkGoto (   $a_target)

check whether goto script will succeed

Reimplemented from ilObjectAccess.

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

References $ilUser.

{
global $ilAccess,$ilUser;
$t_arr = explode("_", $a_target);
// registration codes
if(substr($t_arr[2],0,5) == 'rcode' and $ilUser->getId() != ANONYMOUS_USER_ID)
{
self::$using_code = true;
return true;
}
if ($t_arr[0] != "crs" || ((int) $t_arr[1]) <= 0)
{
return false;
}
// checking for read results in endless loop, if read is given
// but visible is not given (-> see bug 5323)
if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
$ilAccess->checkAccess("visible", "", $t_arr[1]))
//if ($ilAccess->checkAccess("visible", "", $t_arr[1]))
{
return true;
}
return false;
}
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.

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

Referenced by ilObjCourseListGUI\init().

{
$commands = array();
$commands[] = array("permission" => "crs_linked", "cmd" => "", "lang_var" => "view", "default" => true);
include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
if(ilFMSettings::getInstance()->isEnabled())
{
$commands[] = array(
'permission' => 'read',
'cmd' => 'fileManagerLaunch',
'lang_var' => 'fm_start',
'enable_anonymous' => false
);
}
$commands[] = array("permission" => "join", "cmd" => "join", "lang_var" => "join");
// on waiting list
$commands[] = array('permission' => "join", "cmd" => "leave", "lang_var" => "leave_waiting_list");
// regualar users
$commands[] = array('permission' => "leave", "cmd" => "leave", "lang_var" => "crs_unsubscribe");
include_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
{
include_once './Services/WebDAV/classes/class.ilDAVUtils.php';
if(ilDAVUtils::getInstance()->isLocalPasswordInstructionRequired())
{
$commands[] = array('permission' => 'read', 'cmd' => 'showPasswordInstruction', 'lang_var' => 'mount_webfolder', 'enable_anonymous' => 'false');
}
else
{
$commands[] = array("permission" => "read", "cmd" => "mount_webfolder", "lang_var" => "mount_webfolder", "enable_anonymous" => "false");
}
}
$commands[] = array("permission" => "write", "cmd" => "enableAdministrationPanel", "lang_var" => "edit_content");
$commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "settings");
return $commands;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

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

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

{
// #7669
if($a_mind_member_view)
{
include_once './Services/Container/classes/class.ilMemberViewSettings.php';
{
$a_visible_flag = true;
return true;
}
}
// offline?
if(!self::_isOnline($a_obj_id))
{
$a_visible_flag = false;
return false;
}
$ref_id = array_pop($ref_id);
$a_visible_flag = true;
include_once './Services/Object/classes/class.ilObjectActivation.php';
switch($item['timing_type'])
{
if(time() < $item['timing_start'] or
time() > $item['timing_end'])
{
$a_visible_flag = $item['visible'];
return false;
}
// fallthrough
default:
return true;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 492 of file class.ilObjCourseAccess.php.

References _isActivated().

Referenced by ilObjCourseListGUI\getProperties().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

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

{
global $ilDB;
$query = "SELECT * FROM crs_settings ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
$res = $ilDB->query($query);
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
return (bool)$row->activation_type;
}
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.

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

Referenced by ilObjFolder\getViewMode().

{
global $ilDB;
$query = "SELECT view_mode FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id ,'integer')." ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->view_mode;
}
return false;
}

+ Here is the caller graph for this function:

ilObjCourseAccess::_preloadData (   $a_obj_ids,
  $a_ref_ids 
)

Preload data.

Parameters
array$a_obj_idsarray of object ids

Reimplemented from ilObjectAccess.

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

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

{
global $ilUser;
include_once("./Modules/Course/classes/class.ilCourseWaitingList.php");
ilCourseWaitingList::_preloadOnListInfo($ilUser->getId(), $a_obj_ids);
include_once "./Modules/Course/classes/class.ilCourseCertificateAdapter.php";
ilCourseCertificateAdapter::_preloadListData($ilUser->getId(), $a_obj_ids);
}

+ Here is the call graph for this function:

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

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

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

{
global $ilDB;
$query = "SELECT * FROM crs_settings ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$type = $row->sub_limitation_type;
$reg_start = $row->sub_start;
$reg_end = $row->sub_end;
}
switch($type)
{
return true;
return false;
if(time() > $reg_start and
time() < $reg_end)
{
return true;
}
default:
return false;
}
return false;
}
static ilObjCourseAccess::_usingRegistrationCode ( )
static

Using Registration code.

Returns
bool

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

References $using_code.

Referenced by ilObjCourse\register().

{
}

+ Here is the caller graph for this function:

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

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.

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

{
include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
switch($a_operator)
{
return ilCourseParticipants::_hasPassed($a_obj_id,$a_usr_id);
}
return FALSE;
}

+ Here is the call graph for this function:

static ilObjCourseAccess::getConditionOperators ( )
static

Get operators.

Implements ilConditionHandling.

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

References ilConditionHandler\OPERATOR_PASSED.

{
include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
return array(
);
}
static ilObjCourseAccess::lookupRegistrationInfo (   $a_obj_id)
static

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

Parameters
int$a_obj_id
Returns
array

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

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

Referenced by ilObjCourseListGUI\getProperties().

{
global $ilDB, $ilUser, $lng;
$query = 'SELECT sub_limitation_type, sub_start, sub_end, sub_mem_limit, sub_max_members FROM crs_settings '.
'WHERE obj_id = '.$ilDB->quote($a_obj_id);
$res = $ilDB->query($query);
$info = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$info['reg_info_start'] = new ilDateTime($row->sub_start, IL_CAL_UNIX);
$info['reg_info_end'] = new ilDateTime($row->sub_end, IL_CAL_UNIX);
$info['reg_info_type'] = $row->sub_limitation_type;
$info['reg_info_max_members'] = $row->sub_max_members;
$info['reg_info_mem_limit'] = $row->sub_mem_limit;
}
$registration_possible = true;
// Limited registration
if($info['reg_info_type'] == ilCourseConstants::SUBSCRIPTION_LIMITED)
{
$dt = new ilDateTime(time(),IL_CAL_UNIX);
if(ilDateTime::_before($dt, $info['reg_info_start']))
{
$info['reg_info_list_prop']['property'] = $lng->txt('crs_list_reg_start');
$info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_start']);
}
elseif(ilDateTime::_before($dt, $info['reg_info_end']))
{
$info['reg_info_list_prop']['property'] = $lng->txt('crs_list_reg_end');
$info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_end']);
}
else
{
$registration_possible = false;
$info['reg_info_list_prop']['property'] = $lng->txt('crs_list_reg_period');
$info['reg_info_list_prop']['value'] = $lng->txt('crs_list_reg_noreg');
}
}
else if($info['reg_info_type'] == ilCourseConstants::SUBSCRIPTION_UNLIMITED)
{
$registration_possible = true;
}
else
{
$registration_possible = false;
$info['reg_info_list_prop']['property'] = $lng->txt('crs_list_reg_period');
$info['reg_info_list_prop']['value'] = $lng->txt('crs_list_reg_noreg');
}
if($info['reg_info_mem_limit'] && $registration_possible)
{
// Check if users are on waiting list
// @todo
// Check for free places
$part = ilCourseParticipant::_getInstanceByObjId($a_obj_id, $ilUser->getId());
if($part->getNumberOfMembers() <= $info['reg_info_max_members'])
{
$info['reg_info_list_prop_limit']['property'] = $lng->txt('crs_list_reg_limit_places');
$info['reg_info_list_prop_limit']['value'] = max(
0,
$info['reg_info_max_members'] - $part->getNumberOfMembers()
);
}
else
{
$info['reg_info_list_prop_limit']['property'] = '';
$info['reg_info_list_prop_limit']['value'] = $lng->txt('crs_list_reg_limit_full');
}
}
return $info;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

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: