ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjLearningSequenceAccess.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
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 $new_status = ($online)
102 ? $obj->getObjectProperties()->getPropertyIsOnline()->withOnline()
103 : $obj->getObjectProperties()->getPropertyIsOnline()->withOffline();
104 $obj->getObjectProperties()->storePropertyIsOnline($new_status);
105
106 return !$online;
107 }
108
109 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
110 {
111 list($rbacsystem, $il_access, $lng) = $this->getDICDependencies();
112
113 switch ($permission) {
114 case 'visible':
115 $has_any_administrative_permission = false;
116 if (!is_null($user_id)) {
117 $has_any_administrative_permission = (
118 $rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id) ||
119 $rbacsystem->checkAccessOfUser($user_id, 'edit_members', $ref_id) ||
120 $rbacsystem->checkAccessOfUser($user_id, 'edit_learning_progress', $ref_id)
121 );
122 }
123
124 $is_offine = $this->isOffline($ref_id);
125
126 if ($is_offine && !$has_any_administrative_permission) {
127 $il_access->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
128 return false;
129 }
130 return true;
131
132 default:
133 if (is_null($user_id)) {
134 return false;
135 }
136 return $rbacsystem->checkAccessOfUser($user_id, $permission, $ref_id);
137 }
138 }
139
143 protected function getDICDependencies(): array
144 {
145 global $DIC;
146 $rbacsystem = $DIC['rbacsystem'];
147 $il_access = $DIC['ilAccess'];
148 $lng = $DIC['lng'];
149
150 return [
151 $rbacsystem,
152 $il_access,
153 $lng
154 ];
155 }
156}
_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...
Class ilObjectAccess.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
$ref_id
Definition: ltiauth.php:66
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26