ILIAS  release_8 Revision v8.24
class.ilObjLearningSequenceAccess.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22{
23 public static bool $using_code = false;
24
28 public static function _getCommands(): array
29 {
30 return array(
31 [
33 'permission' => 'read',
34 'lang_var' => 'show',
35 'default' => true
36 ],
37 [
39 'permission' => 'read',
40 'lang_var' => 'show',
41 ],
42 [
44 'permission' => 'write',
45 'lang_var' => 'edit_content'
46 ],
47 [
49 'permission' => 'write',
50 'lang_var' => 'settings'
51 ],
52 [
54 'permission' => 'unparticipate',
55 'lang_var' => 'unparticipate'
56 ]
57 );
58 }
59
60 public function usingRegistrationCode(): bool
61 {
62 return self::$using_code;
63 }
64
65 public static function isOffline(int $ref_id): bool
66 {
68 $act = $obj->getLSActivation();
69 $online = $act->getIsOnline();
70
71 if (!$online
72 && ($act->getActivationStart() !== null ||
73 $act->getActivationEnd() !== null)
74 ) {
75 $ts_now = time();
76 $activation_start = $act->getActivationStart();
77 if ($activation_start !== null) {
78 $after_activation_start = $ts_now >= $activation_start->getTimestamp();
79 } else {
80 $after_activation_start = true;
81 }
82 $activation_end = $act->getActivationEnd();
83 if ($activation_end !== null) {
84 $before_activation_end = $ts_now <= $activation_end->getTimestamp();
85 } else {
86 $before_activation_end = true;
87 }
88
89 $online = ($after_activation_start && $before_activation_end);
90 }
91
92 if ($act->getEffectiveOnlineStatus() === false && $online === true) {
93 $obj->setEffectiveOnlineStatus(true);
94 $obj->announceLSOOnline();
95 }
96 if ($act->getEffectiveOnlineStatus() === true && $online === false) {
97 $obj->setEffectiveOnlineStatus(false);
98 $obj->announceLSOOffline();
99 }
100
101
102 return !$online;
103 }
104
105 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
106 {
107 list($rbacsystem, $il_access, $lng) = $this->getDICDependencies();
108
109 switch ($permission) {
110 case 'visible':
111 $has_any_administrative_permission = false;
112 if (!is_null($user_id)) {
113 $has_any_administrative_permission = (
114 $rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id) ||
115 $rbacsystem->checkAccessOfUser($user_id, 'edit_members', $ref_id) ||
116 $rbacsystem->checkAccessOfUser($user_id, 'edit_learning_progress', $ref_id)
117 );
118 }
119
120 $is_offine = $this->isOffline($ref_id);
121
122 if ($is_offine && !$has_any_administrative_permission) {
123 $il_access->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
124 return false;
125 }
126 return true;
127
128 default:
129 if (is_null($user_id)) {
130 return false;
131 }
132 return $rbacsystem->checkAccessOfUser($user_id, $permission, $ref_id);
133 }
134 }
135
139 protected function getDICDependencies(): array
140 {
141 global $DIC;
142 $rbacsystem = $DIC['rbacsystem'];
143 $il_access = $DIC['ilAccess'];
144 $lng = $DIC['lng'];
145
146 return [
147 $rbacsystem,
148 $il_access,
149 $lng
150 ];
151 }
152}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcc...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
$lng