ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjBibliographicAccess.php
Go to the documentation of this file.
1<?php
2
27{
41 #[\Override]
42 public static function _getCommands(): array
43 {
44 return [
45 [
46 "permission" => "read",
47 "cmd" => "render",
48 "lang_var" => "show",
49 "default" => true,
50 ],
51 ["permission" => "write", "cmd" => "view", "lang_var" => "edit_content"],
52 ["permission" => "write", "cmd" => "settings", "lang_var" => "settings"],
53 ];
54 }
55
56
57 #[\Override]
58 public static function _checkGoto(string $target): bool
59 {
60 global $DIC;
61 $ilAccess = $DIC['ilAccess'];
62 $t_arr = explode('_', $target);
63 if ($t_arr[0] !== 'bibl' || ((int) $t_arr[1]) <= 0) {
64 return false;
65 }
66 return (bool) $ilAccess->checkAccess('read', '', $t_arr[1]);
67 }
68
69
74 #[\Override]
75 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
76 {
77 global $DIC;
78 $ilUser = $DIC['ilUser'];
79 $lng = $DIC['lng'];
80 $rbacsystem = $DIC['rbacsystem'];
81 $ilAccess = $DIC['ilAccess'];
82 if (is_null($user_id)) {
83 $user_id = $ilUser->getId();
84 }
85
86 if ($DIC->http()->wrapper()->query()->has(ilObjBibliographicGUI::P_ENTRY_ID)) {
87 $entry_id = $DIC->http()->wrapper()->query()->retrieve(
89 $DIC->refinery()->kindlyTo()->int()
90 );
91 if (!$this->checkEntryIdMatch($obj_id, $entry_id)) {
92 return false;
93 }
94 }
95
96 switch ($cmd) {
97 case "view":
98 if (!self::_lookupOnline($obj_id)
99 && !$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id)
100 ) {
101 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
102
103 return false;
104 }
105 break;
106 // for permission query feature
107 case "infoScreen":
108 if (!self::_lookupOnline($obj_id)) {
109 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
110 } else {
111 $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_MESSAGE, $lng->txt("online"));
112 }
113 break;
114 }
115 switch ($permission) {
116 case "read":
117 case "visible":
118 if (!self::_lookupOnline($obj_id)
119 && (!$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id))
120 ) {
121 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
122
123 return false;
124 }
125 break;
126 }
127
128 return true;
129 }
130
131
132 private function checkEntryIdMatch(int $obj_id, int $entry_id): bool
133 {
137 $ilBiblEntry = ilBiblEntry::find($entry_id);
138 if (is_null($ilBiblEntry)) {
139 return false;
140 }
141
142 return ($ilBiblEntry->getDataId() === $obj_id);
143 }
144
145
149 public static function _lookupOnline(int $a_id): bool
150 {
151 $bibl_obj = new ilObjBibliographic($a_id);
152 return $bibl_obj->getObjectProperties()->getPropertyIsOnline()->getIsOnline();
153 }
154}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _checkGoto(string $target)
check whether goto script will succeed
_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(int $a_id)
Check wether bibliographic is online or not.
Class ilObjBibliographic.
Class ilObjectAccess.
$ref_id
Definition: ltiauth.php:66
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26