3 declare(strict_types=0);
40 $this->
access = $DIC->access();
41 $this->
user = $DIC->user();
42 $this->
lng = $DIC->language();
43 $this->rbacSystem = $DIC->rbac()->system();
61 int $a_trigger_obj_id,
66 switch ($a_operator) {
76 public function _checkAccess(
string $cmd,
string $permission,
int $ref_id,
int $obj_id, ?
int $user_id = null): bool
78 if (is_null($user_id)) {
79 $user_id = $this->
user->getId();
81 if ($this->
user->getId() === $user_id) {
89 if ($participants->isBlocked($user_id) && $participants->isAssigned($user_id)) {
90 $this->
access->addInfoItem(
92 $this->
lng->txt(
"crs_status_blocked")
100 if ($permission ==
'leave') {
103 $this->
access->addInfoItem(
106 $this->
lng->txt(
"crs_cancellation_end_rbac_info"),
113 if (!$participants->isAssigned($user_id)) {
119 case 'leaveWaitList':
121 if ($permission ==
'join') {
137 switch ($permission) {
140 $active = self::_isActivated($obj_id, $visible);
141 $tutor = $this->rbacSystem->checkAccessOfUser($user_id,
'write', $ref_id);
145 if (!$tutor && !$active && !$visible) {
151 $tutor = $this->rbacSystem->checkAccessOfUser($user_id,
'write', $ref_id);
155 $active = self::_isActivated($obj_id);
160 if ($participants->isBlocked($user_id) && $participants->isAssigned($user_id)) {
161 $this->
access->addInfoItem(
163 $this->
lng->txt(
"crs_status_blocked")
170 if (!self::_registrationEnabled($obj_id)) {
174 if ($participants->isAssigned($user_id)) {
191 $commands[] = array(
"permission" =>
"crs_linked",
"cmd" =>
"",
"lang_var" =>
"view",
"default" =>
true);
193 $commands[] = array(
"permission" =>
"join",
"cmd" =>
"join",
"lang_var" =>
"join");
196 $commands[] = array(
'permission' =>
"join",
"cmd" =>
"leaveWaitList",
"lang_var" =>
"leave_waiting_list");
199 $commands[] = array(
'permission' =>
"leave",
"cmd" =>
"leave",
"lang_var" =>
"crs_unsubscribe");
203 $commands[] = $webdav_obj->retrieveWebDAVCommandArrayForActionMenu();
206 $commands[] = array(
"permission" =>
"write",
207 "cmd" =>
"enableAdministrationPanel",
208 "lang_var" =>
"edit_content" 210 $commands[] = array(
"permission" =>
"write",
"cmd" =>
"edit",
"lang_var" =>
"settings");
221 $ilAccess = $DIC[
'ilAccess'];
224 $t_arr = explode(
"_", $target);
228 self::$using_code =
true;
232 if ($t_arr[0] !=
"crs" || ((
int) $t_arr[1]) <= 0) {
238 if ($ilAccess->checkAccess(
"read",
"", $t_arr[1]) ||
239 $ilAccess->checkAccess(
"visible",
"", $t_arr[1])) {
250 $ilDB = $DIC->database();
252 $query =
"SELECT view_mode FROM crs_settings WHERE obj_id = " .
$ilDB->quote($a_id,
'integer') .
" ";
255 return $row->view_mode;
260 public static function _isActivated(
int $a_obj_id, ?
bool &$a_visible_flag = null,
bool $a_mind_member_view =
true): bool
263 if ($a_mind_member_view) {
265 $a_visible_flag =
true;
271 $a_visible_flag =
true;
274 switch ($item[
'timing_type']) {
276 if (time() < $item[
'timing_start'] || time() > $item[
'timing_end']) {
277 $a_visible_flag = $item[
'visible'];
292 $ilDB = $DIC->database();
295 $query =
"SELECT * FROM crs_settings " .
296 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" ";
298 $reg_start = $reg_end = 0;
301 $type = $row->sub_limitation_type;
302 $reg_start = $row->sub_start;
303 $reg_end = $row->sub_end;
314 if (time() > $reg_start && time() < $reg_end) {
327 $ilDB = $DIC->database();
329 $lng = $DIC->language();
331 $query =
'SELECT sub_limitation_type, sub_start, sub_end, sub_mem_limit, sub_max_members FROM crs_settings ' .
339 $info[
'reg_info_type'] = (
int) $row->sub_limitation_type;
340 $info[
'reg_info_max_members'] = (
int) $row->sub_max_members;
341 $info[
'reg_info_mem_limit'] = (
int) $row->sub_mem_limit;
344 $registration_possible =
true;
350 $info[
'reg_info_list_prop'][
'property'] = $lng->
txt(
'crs_list_reg_start');
353 $info[
'reg_info_list_prop'][
'property'] = $lng->
txt(
'crs_list_reg_end');
356 $registration_possible =
false;
357 $info[
'reg_info_list_prop'][
'property'] = $lng->
txt(
'crs_list_reg_period');
358 $info[
'reg_info_list_prop'][
'value'] = $lng->
txt(
'crs_list_reg_noreg');
361 $registration_possible =
true;
363 $registration_possible =
false;
364 $info[
'reg_info_list_prop'][
'property'] = $lng->
txt(
'crs_list_reg');
365 $info[
'reg_info_list_prop'][
'value'] = $lng->
txt(
'crs_list_reg_noreg');
368 if (($info[
'reg_info_mem_limit'] ??
false) && $info[
'reg_info_max_members'] && $registration_possible) {
373 if ($info[
'reg_info_list_size']) {
374 $info[
'reg_info_free_places'] = 0;
376 $info[
'reg_info_free_places'] = max(0, $info[
'reg_info_max_members'] - $part->getNumberOfMembers());
379 if ($info[
'reg_info_free_places']) {
380 $info[
'reg_info_list_prop_limit'][
'property'] = $lng->
txt(
'crs_list_reg_limit_places');
381 $info[
'reg_info_list_prop_limit'][
'value'] = $info[
'reg_info_free_places'];
383 $info[
'reg_info_list_prop_limit'][
'property'] =
'';
384 $info[
'reg_info_list_prop_limit'][
'value'] = $lng->
txt(
'crs_list_reg_limit_full');
393 return !self::_isActivated($obj_id, $dummy,
false);
399 public static function _preloadData(array $obj_ids, array $ref_ids): void
412 $coursePreload->preLoad(
$ilUser->getId(), $obj_ids);
415 self::$booking_repo =
$f->getRepoWithContextObjCache($obj_ids);
420 return self::$booking_repo;
425 return self::$using_code;
432 $ilDB = $DIC->database();
433 $lng = $DIC->language();
435 $start = $end = null;
436 $query =
'SELECT period_start, period_end, period_time_indication FROM crs_settings ' .
441 if (!$row->period_time_indication) {
442 $start = ($row->period_start
445 $end = ($row->period_end
449 $start = ($row->period_start
452 $end = ($row->period_end
457 if ($start && $end) {
462 'crs_start' => $start,
464 'property' => $lng->
txt(
'crs_period'),
static getConditionOperators()
Get operators.
const IL_NO_OBJECT_ACCESS
static _preloadOnListInfo(array $a_usr_ids, array $a_obj_ids)
Preload on list info.
const SUBSCRIPTION_LIMITED
static getBookingInfoRepo()
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static checkCondition(int $a_trigger_obj_id, string $a_operator, string $a_value, int $a_usr_id)
const IL_CRS_SUBSCRIPTION_DEACTIVATED
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
static lookupRegistrationInfo(int $a_obj_id)
static _getInstanceByObjId(int $a_obj_id, int $a_usr_id)
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
Interface for condition handling.
loadLanguageModule(string $a_module)
Load language module.
static _hasPassed(int $a_obj_id, int $a_usr_id)
Check if user has passed course.
static _usingRegistrationCode()
static mayLeave(int $a_course_id, int $a_user_id=0, &$a_date=null)
const IL_CRS_SUBSCRIPTION_LIMITED
static _getInstanceByObjId(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static ilBookingReservationDBRepository $booking_repo
static _lookupViewMode(int $a_id)
static _isOffline(int $obj_id)
const SUBSCRIPTION_UNLIMITED
static _isActivated(int $a_obj_id, ?bool &$a_visible_flag=null, bool $a_mind_member_view=true)
static _registrationEnabled(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getItem(int $ref_id)
const IL_CRS_SUBSCRIPTION_UNLIMITED
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
static lookupPeriodInfo(int $a_obj_id)
static _checkGoto(string $target)
static lookupListSize(int $a_obj_id)
static _isOnList(int $a_usr_id, int $a_obj_id)
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
static _preloadData(array $obj_ids, array $ref_ids)
Preload data.