ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\COPage\Link\ExtLinkMapper Class Reference
+ Collaboration diagram for ILIAS\COPage\Link\ExtLinkMapper:

Public Member Functions

 __construct (protected \ilObjectDefinition $object_def, string $ilias_http_path, protected array $mapping, protected $client_id="")
 
 getRefId (string $href)
 
 getNewHref (int $ref_id)
 

Protected Attributes

array $ilias_url
 

Detailed Description

Definition at line 23 of file ExtLinkMapper.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\COPage\Link\ExtLinkMapper::__construct ( protected \ilObjectDefinition  $object_def,
string  $ilias_http_path,
protected array  $mapping,
protected  $client_id = "" 
)

Definition at line 27 of file ExtLinkMapper.php.

32 {
33 $this->ilias_url = parse_url($ilias_http_path);
34 if ($client_id === "") {
35 $this->client_id = CLIENT_ID;
36 }
37 }
string $client_id
Definition: class.ilias.php:36
const CLIENT_ID
Definition: constants.php:41

References ILIAS\$client_id, and CLIENT_ID.

Member Function Documentation

◆ getNewHref()

ILIAS\COPage\Link\ExtLinkMapper::getNewHref ( int  $ref_id)

Definition at line 101 of file ExtLinkMapper.php.

101 : string
102 {
103 if ($ref_id > 0) {
104 $new_ref_id = ($this->mapping[$ref_id] ?? 0);
105 if ($new_ref_id > 0) {
106 return \ilLink::_getLink($new_ref_id);
107 }
108 }
109 return "";
110 }
$ref_id
Definition: ltiauth.php:66

References $ref_id.

◆ getRefId()

ILIAS\COPage\Link\ExtLinkMapper::getRefId ( string  $href)

Definition at line 39 of file ExtLinkMapper.php.

39 : int
40 {
41 $url = parse_url($href);
42
43 // only handle links on same host
44 if (($url["host"] ?? "") !== "" && $url["host"] !== $this->ilias_url["host"]) {
45 return 0;
46 }
47
48 $ref_id = 0;
49
50 // get parameters
51 $par = [];
52 $type = "";
53
54 // links ending with .html, e.g. goto_client_cat_581.html
55 if (substr($href, strlen($href) - 5) === ".html") {
56 $parts = explode(
57 "_",
58 basename(
59 substr($url["path"], 0, strlen($url["path"]) - 5)
60 )
61 );
62 if (array_shift($parts) !== "goto") {
63 return 0;
64 }
65 $par["client_id"] = array_shift($parts);
66 $par["target"] = implode("_", $parts); // e.g. cat_581
67 $t = explode("_", $par["target"]);
68 $type = $t[0] ?? "";
69 $ref_id = (int) ($t[1] ?? 0);
70 } elseif (is_int($p = strpos($href, "/goto.php/"))) {
71 $parts = explode("/", substr($href, $p + 10));
72 $ref_id = (int) ($parts[1] ?? 0);
73 $type = ($parts[0] ?? "");
74 } elseif (is_int($p = strpos($href, "/go/"))) {
75 $parts = explode("/", substr($href, $p + 4));
76 $ref_id = (int) ($parts[1] ?? 0);
77 $type = ($parts[0] ?? "");
78 } else {
79 // extract all query parameter
80 foreach (explode("&", ($url["query"] ?? "")) as $p) {
81 $p = explode("=", $p);
82 if (isset($p[0]) && isset($p[1])) {
83 $par[$p[0]] = $p[1];
84 }
85 }
86 $ref_id = (int) ($par["ref_id"] ?? 0);
87 }
88
89 if ($ref_id > 0 && $type !== "" && !$this->object_def->isRBACObject($type)) {
90 $ref_id = 0;
91 }
92
93 // we have a client and it's the wrong client -> return ""
94 $target_client_id = $par["client_id"] ?? "";
95 if ($target_client_id !== "" && $target_client_id !== $this->client_id) {
96 return 0;
97 }
98 return $ref_id;
99 }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
$url
Definition: shib_logout.php:68

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

+ Here is the call graph for this function:

Field Documentation

◆ $ilias_url

array ILIAS\COPage\Link\ExtLinkMapper::$ilias_url
protected

Definition at line 25 of file ExtLinkMapper.php.


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