ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjLearningSequenceAccess.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 include_once("./Services/Object/classes/class.ilObjectAccess.php");
6 
12 {
13  public static $using_code = false;
14 
15  public static function _getCommands() : array
16  {
17  $commands = array(
18  [
20  'permission' => 'read',
21  'lang_var' => 'show',
22  'default' => true
23  ],
24  [
26  'permission' => 'read',
27  'lang_var' => 'show',
28  ],
29  [
31  'permission' => 'write',
32  'lang_var' => 'edit_content'
33  ],
34  [
36  'permission' => 'write',
37  'lang_var' => 'settings'
38  ],
39  [
41  'permission' => 'unparticipate',
42  'lang_var' => 'unparticipate'
43  ]
44  );
45  return $commands;
46  }
47 
48  public function usingRegistrationCode()
49  {
50  return self::$using_code;
51  }
52 
53  public static function isOffline($ref_id)
54  {
56  $act = $obj->getLSActivation();
57  $online = $act->getIsOnline();
58 
59  if (!$online
60  && ($act->getActivationStart() !== null ||
61  $act->getActivationEnd() !== null)
62  ) {
63  $ts_now = time();
64  $activation_start = $act->getActivationStart();
65  if ($activation_start !== null) {
66  $after_activation_start = $ts_now >= $activation_start->getTimestamp();
67  } else {
68  $after_activation_start = true;
69  }
70  $activation_end = $act->getActivationEnd();
71  if ($activation_end !== null) {
72  $before_activation_end = $ts_now <= $activation_end->getTimestamp();
73  } else {
74  $before_activation_end = true;
75  }
76 
77  $online = ($after_activation_start && $before_activation_end);
78  }
79 
80  if ($act->getEffectiveOnlineStatus() === false && $online === true) {
81  $obj->setEffectiveOnlineStatus(true);
82  $obj->announceLSOOnline();
83  }
84  if ($act->getEffectiveOnlineStatus() === true && $online === false) {
85  $obj->setEffectiveOnlineStatus(false);
86  $obj->announceLSOOffline();
87  }
88 
89 
90  return !$online;
91  }
92 
93  public function _checkAccess($cmd, $permission, $ref_id, $obj_id, $usr_id = "")
94  {
95  list($rbacsystem, $il_access, $lng) = $this->getDICDependencies();
96 
97  switch ($permission) {
98  case 'visible':
99  $has_any_administrative_permission = (
100  $rbacsystem->checkAccessOfUser($usr_id, 'write', $ref_id) ||
101  $rbacsystem->checkAccessOfUser($usr_id, 'edit_members', $ref_id) ||
102  $rbacsystem->checkAccessOfUser($usr_id, 'edit_learning_progress', $ref_id)
103  );
104 
105  $is_offine = $this->isOffline($ref_id);
106 
107  if ($is_offine && !$has_any_administrative_permission) {
108  $il_access->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
109  return false;
110  }
111  return true;
112 
113  default:
114  return $rbacsystem->checkAccessOfUser($usr_id, $permission, $ref_id);
115  }
116  }
117 
118  protected function getDICDependencies() : array
119  {
120  global $DIC;
121  $rbacsystem = $DIC['rbacsystem'];
122  $il_access = $DIC['ilAccess'];
123  $lng = $DIC['lng'];
124 
125  return [
126  $rbacsystem,
127  $il_access,
128  $lng
129  ];
130  }
131 }
global $DIC
Definition: saml.php:7
const IL_NO_OBJECT_ACCESS
$lng
Class ilObjectAccess.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
_checkAccess($cmd, $permission, $ref_id, $obj_id, $usr_id="")
Class ilObjLearningSequenceAccess class.