ILIAS  release_8 Revision v8.24
class.ilWebLinkParameter.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
26{
27 private int $webr_id;
28 private int $link_id;
29 private int $param_id;
30
32
33 public function __construct(
35 int $webr_id,
36 int $link_id,
37 int $param_id,
38 int $value,
39 string $name
40 ) {
41 $this->user = $user;
42 $this->webr_id = $webr_id;
43 $this->link_id = $link_id;
44 $this->param_id = $param_id;
46 }
47
48 //TODO inject the dependency on DIC->user as an argument into this method
49 public function appendToLink(string $link): string
50 {
51 if (!strpos($link, '?')) {
52 $link .= "?";
53 } else {
54 $link .= "&";
55 }
56 $link .= ($this->getName() . "=");
57 switch ($this->getValue()) {
58 case self::VALUES['login']:
59 $link .= (urlencode(
60 $this->user->getLogin()
61 ));
62 break;
63
64 case self::VALUES['session_id']:
65 $link .= (session_id());
66 break;
67
68 case self::VALUES['user_id']:
69 $link .= ($this->user->getId());
70 break;
71
72 case self::VALUES['matriculation']:
73 $link .= ($this->user->getMatriculation());
74 break;
75
76 default:
78 'Invalid parameter value'
79 );
80 }
81
82 return $link;
83 }
84
85 public function getInfo(): string
86 {
87 $info = $this->getName();
88
89 switch ($this->getValue()) {
90 case self::VALUES['user_id']:
91 return $info . '=USER_ID';
92
93 case self::VALUES['session_id']:
94 return $info . '=SESSION_ID';
95
96 case self::VALUES['login']:
97 return $info . '=LOGIN';
98
99 case self::VALUES['matriculation']:
100 return $info . '=MATRICULATION';
101
102 default:
104 'Invalid parameter value'
105 );
106 }
107 }
108
109 public function toXML(ilXmlWriter $writer): void
110 {
111 switch ($this->getValue()) {
112 case self::VALUES['user_id']:
113 $value = 'userId';
114 break;
115
116 case self::VALUES['login']:
117 $value = 'userName';
118 break;
119
120 case self::VALUES['matriculation']:
121 $value = 'matriculation';
122 break;
123
124 default:
125 return;
126 }
127
128 $writer->xmlElement(
129 'DynamicParameter',
130 [
131 'id' => $this->getParamId(),
132 'name' => $this->getName(),
133 'type' => $value
134 ]
135 );
136 }
137
138 public function getWebrId(): int
139 {
140 return $this->webr_id;
141 }
142
143 public function getLinkId(): int
144 {
145 return $this->link_id;
146 }
147
148 public function getParamId(): int
149 {
150 return $this->param_id;
151 }
152}
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
toXML(ilXmlWriter $writer)
__construct(ilObjUser $user, int $webr_id, int $link_id, int $param_id, int $value, string $name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc