ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilObjLinkResourceAccess Class Reference

Class ilObjLinkResourceAccess. More...

+ Inheritance diagram for ilObjLinkResourceAccess:
+ Collaboration diagram for ilObjLinkResourceAccess:

Public Member Functions

 _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::checkAccess) More...
 
- Public Member Functions inherited from ilObjectAccess
 _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::checkAccess) More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
 canBeDelivered (ilWACPath $ilWACPath)
 

Static Public Member Functions

static _getCommands ()
 get commands More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _getFirstLink (int $a_webr_id)
 Get first link item Check before with _isSingular() if there is more or less than one. More...
 
static _preloadData (array $obj_ids, array $ref_ids)
 Preload data. More...
 
static _checkDirectLink ($a_obj_id)
 Check whether there is only one active link in the web resource. More...
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _isOffline (int $obj_id)
 Type-specific implementation of general status, has to be overwritten if object type does not support centralized offline handling. More...
 
static _preloadData (array $obj_ids, array $ref_ids)
 Preload data. More...
 

Static Public Attributes

static array $item = []
 
static array $single_link = []
 

Detailed Description

Member Function Documentation

◆ _checkAccess()

ilObjLinkResourceAccess::_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::checkAccess)

Please do not check any preconditions handled by ilConditionHandler here. Also don't do any RBAC checks.

Reimplemented from ilObjectAccess.

Definition at line 73 of file class.ilObjLinkResourceAccess.php.

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 }
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26

◆ _checkDirectLink()

static ilObjLinkResourceAccess::_checkDirectLink (   $a_obj_id)
static

Check whether there is only one active link in the web resource.

In this case this link is shown in a new browser window

Definition at line 139 of file class.ilObjLinkResourceAccess.php.

139 : 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 }

Referenced by ilObjLinkResourceListGUI\getCommandFrame(), ilObjLinkResourceListGUI\getCommandLink(), ilObjLinkResourceListGUI\getDescription(), and ilObjLinkResourceListGUI\getTitle().

+ Here is the caller graph for this function:

◆ _checkGoto()

static ilObjLinkResourceAccess::_checkGoto ( string  $target)
static

check whether goto script will succeed

Reimplemented from ilObjectAccess.

Definition at line 56 of file class.ilObjLinkResourceAccess.php.

56 : 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 }

References $DIC, $ref_id, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ _getCommands()

static ilObjLinkResourceAccess::_getCommands ( )
static

get commands

this method returns an array of all possible commands/permission combinations

example: $commands = array ( array("permission" => "read", "cmd" => "view", "lang_var" => "show"), array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), );

Returns
array{permission?:string, cmd?:string, lang_var?:string, default?:bool}[]

Reimplemented from ilObjectAccess.

Definition at line 33 of file class.ilObjLinkResourceAccess.php.

33 : 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 }

Referenced by ilObjLinkResourceListGUI\init().

+ Here is the caller graph for this function:

◆ _getFirstLink()

static ilObjLinkResourceAccess::_getFirstLink ( int  $a_webr_id)
static

Get first link item Check before with _isSingular() if there is more or less than one.

Definition at line 109 of file class.ilObjLinkResourceAccess.php.

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 }
Immutable class for Web Link items.

Referenced by ilObjLinkResourceGUI\callDirectLink(), ilObjLinkResourceListGUI\getCommandFrame(), ilObjLinkResourceListGUI\getDescription(), and ilObjLinkResourceListGUI\getTitle().

+ Here is the caller graph for this function:

◆ _preloadData()

static ilObjLinkResourceAccess::_preloadData ( array  $obj_ids,
array  $ref_ids 
)
static

Preload data.

Reimplemented from ilObjectAccess.

Definition at line 125 of file class.ilObjLinkResourceAccess.php.

125 : 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 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id.

Field Documentation

◆ $item

array ilObjLinkResourceAccess::$item = []
static

Definition at line 30 of file class.ilObjLinkResourceAccess.php.

◆ $single_link

array ilObjLinkResourceAccess::$single_link = []
static

Definition at line 31 of file class.ilObjLinkResourceAccess.php.


The documentation for this class was generated from the following file: