ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjRemoteCourseAccess.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
32{
38
39 public function __construct()
40 {
41 global $DIC;
42
43 $this->logger = $DIC->logger()->rcrs();
44 $this->ilAccess = $DIC->access();
45 $this->ilUser = $DIC->user();
46 $this->lng = $DIC->language();
47 $this->rbacsystem = $DIC->rbac()->system();
48 }
53 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
54 {
55 $this->logger->debug('>' . $cmd . '< >' . $permission . '< >' . $ref_id . '< >' . $obj_id . '< >' . $user_id . '<');
56 if (is_null($user_id)) {
57 $user_id = $this->ilUser->getId();
58 }
59
60 switch ($permission) {
61 case "visible":
62 $active = ilObjRemoteCourse::_lookupOnline($obj_id);
63 $tutor = $this->rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id);
64
65 if (!$active) {
66 $this->ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $this->lng->txt("offline"));
67 }
68 if (!$tutor and !$active) {
69 return false;
70 }
71 break;
72
73 case 'read':
74 $tutor = $this->rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id);
75 if ($tutor) {
76 return true;
77 }
78 $active = ilObjRemoteCourse::_lookupOnline($obj_id);
79
80 if (!$active) {
81 $this->ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $this->lng->txt("offline"));
82 return false;
83 }
84 break;
85 }
86 return true;
87 }
88
89
102 public static function _getCommands(): array
103 {
104 $commands = array(
105 array("permission" => "read", "cmd" => "show", "lang_var" => "info",
106 "default" => true),
107 array("permission" => "write", "cmd" => "edit", "lang_var" => "edit")
108 );
109
110 return $commands;
111 }
112}
Class ilAccessHandler Checks access for ILIAS objects.
addInfoItem(string $a_type, string $a_text, string $a_data="")
add an info item to current info object
language handling
Component logger with individual log levels by component id.
_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...
static _lookupOnline($a_obj_id)
Lookup online.
User class.
Class ilObjectAccess.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26