ILIAS  release_8 Revision v8.24
class.ilObjBibliographicAccess.php
Go to the documentation of this file.
1<?php
2
27{
41 public static function _getCommands(): array
42 {
43 return array(
44 array(
45 "permission" => "read",
46 "cmd" => "render",
47 "lang_var" => "show",
48 "default" => true,
49 ),
50 array("permission" => "write", "cmd" => "view", "lang_var" => "edit_content"),
51 array("permission" => "write", "cmd" => "edit", "lang_var" => "settings"),
52 );
53 }
54
55
56 public static function _checkGoto(string $target): bool
57 {
58 global $DIC;
59 $ilAccess = $DIC['ilAccess'];
60 $t_arr = explode('_', $target);
61 if ($t_arr[0] != 'bibl' || ((int) $t_arr[1]) <= 0) {
62 return false;
63 }
64 return (bool) $ilAccess->checkAccess('read', '', $t_arr[1]);
65 }
66
67
72 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
73 {
74 global $DIC;
75 $ilUser = $DIC['ilUser'];
76 $lng = $DIC['lng'];
77 $rbacsystem = $DIC['rbacsystem'];
78 $ilAccess = $DIC['ilAccess'];
79 if (is_null($user_id)) {
80 $user_id = $ilUser->getId();
81 }
82
83 if ($DIC->http()->wrapper()->query()->has(ilObjBibliographicGUI::P_ENTRY_ID)) {
84 $entry_id = $DIC->http()->wrapper()->query()->retrieve(
86 $DIC->refinery()->kindlyTo()->int()
87 );
88 if (!self::checkEntryIdMatch($obj_id, $entry_id)) {
89 return false;
90 }
91 }
92
93 switch ($cmd) {
94 case "view":
95 if (!self::_lookupOnline($obj_id)
96 && !$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id)
97 ) {
98 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
99
100 return false;
101 }
102 break;
103 // for permission query feature
104 case "infoScreen":
105 if (!self::_lookupOnline($obj_id)) {
106 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
107 } else {
108 $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_MESSAGE, $lng->txt("online"));
109 }
110 break;
111 }
112 switch ($permission) {
113 case "read":
114 case "visible":
115 if (!self::_lookupOnline($obj_id)
116 && (!$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id))
117 ) {
118 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
119
120 return false;
121 }
122 break;
123 }
124
125 return true;
126 }
127
128
129 private static function checkEntryIdMatch(int $obj_id, int $entry_id): bool
130 {
134 $ilBiblEntry = ilBiblEntry::find($entry_id);
135 if (is_null($ilBiblEntry)) {
136 return false;
137 }
138
139 return ($ilBiblEntry->getDataId() === $obj_id);
140 }
141
142
146 public static function _lookupOnline(int $a_id): bool
147 {
148 global $DIC;
149 $ilDB = $DIC['ilDB'];
150 $q = "SELECT is_online FROM il_bibl_data WHERE id = " . $ilDB->quote($a_id, "integer");
151 $bibl_set = $ilDB->query($q);
152 $bibl_rec = $ilDB->fetchAssoc($bibl_set);
153
154 return (bool) $bibl_rec["is_online"] ?? false;
155 }
156}
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
$ref_id
Definition: ltiauth.php:67
$lng