ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjLinkResourceAccess.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
30 public static array $item = [];
31 public static array $single_link = [];
32
33 public static function _getCommands(): array
34 {
35 return array(
36 array("permission" => "read",
37 "cmd" => "",
38 "lang_var" => "show",
39 "default" => true
40 ),
41 array("permission" => "read",
42 "cmd" => "exportHTML",
43 "lang_var" => "export_html"
44 ),
45 array("permission" => "write",
46 "cmd" => "editLinks",
47 "lang_var" => "edit_content"
48 ),
49 array("permission" => "write",
50 "cmd" => "settings",
51 "lang_var" => "settings"
52 )
53 );
54 }
55
56 public static function _checkGoto(string $target): bool
57 {
58 global $DIC;
59
60 $ilAccess = $DIC->access();
61
62 $t_arr = explode("_", $target);
63 $type = $t_arr[0] ?? '';
64 $ref_id = (int) ($t_arr[1] ?? 0);
65
66 if ($type !== 'webr' || $ref_id <= 0) {
67 return false;
68 }
69 return $ilAccess->checkAccess('read', '', $ref_id) ||
70 $ilAccess->checkAccess('visible', '', $ref_id);
71 }
72
73 public function _checkAccess(
74 string $cmd,
75 string $permission,
76 int $ref_id,
77 int $obj_id,
78 ?int $user_id = null
79 ): bool {
80 global $DIC;
81 $rbacsystem = $DIC->rbac()->system();
82 $web_link_repo = new ilWebLinkDatabaseRepository($obj_id);
83
84 // Set offline if no valid link exists
85 if ($permission == 'read') {
86 if (!$web_link_repo->getAllItemsAsContainer(true)
87 ->getFirstItem() &&
88 !$rbacsystem->checkAccessOfUser(
90 'write',
92 )) {
93 return false;
94 }
95 }
96 return parent::_checkAccess(
97 $cmd,
98 $permission,
99 $ref_id,
100 $obj_id,
102 );
103 }
104
109 public static function _getFirstLink(int $a_webr_id): ilWebLinkItem
110 {
111 if (isset(self::$item[$a_webr_id])) {
112 return self::$item[$a_webr_id];
113 }
114
115 $web_link_repo = new ilWebLinkDatabaseRepository($a_webr_id);
116
117 $current_item = $web_link_repo->getAllItemsAsContainer(true)
118 ->getFirstItem();
119
120 self::$item[$current_item->getWebrId()] = $current_item;
121
122 return $current_item;
123 }
124
125 public static function _preloadData(array $obj_ids, array $ref_ids): void
126 {
127 foreach ($obj_ids as $id) {
128 $web_link_repo = new ilWebLinkDatabaseRepository($id);
129 $first_item = $web_link_repo->getAllItemsAsContainer(true)
130 ->getFirstItem();
131 self::$item[$id] = $first_item;
132 }
133 }
134
139 public static function _checkDirectLink($a_obj_id): bool
140 {
141 if (isset(self::$single_link[$a_obj_id])) {
142 return self::$single_link[$a_obj_id];
143 }
144
145 $web_link_repo = new ilWebLinkDatabaseRepository($a_obj_id);
146
147 return self::$single_link[$a_obj_id] = $web_link_repo->doesOnlyOneItemExist(true);
148 }
149}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class ilObjLinkResourceAccess.
static _checkGoto(string $target)
check whether goto script will succeed
static _checkDirectLink($a_obj_id)
Check whether there is only one active link in the web resource.
static _preloadData(array $obj_ids, array $ref_ids)
Preload data.
_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 _getFirstLink(int $a_webr_id)
Get first link item Check before with _isSingular() if there is more or less than one.
Class ilObjectAccess.
Immutable class for Web Link items.
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26