ILIAS  release_8 Revision v8.24
class.ilLTIPlatform.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22//use ILIAS\LTI\ToolProvider\Platform;
23//use ILIAS\LTI\ToolProvider\DataConnector\DataConnector;
25use ILIAS\LTI\ToolProvider\Http\HTTPMessage;
26//use ILIAS\LTIOAuth;
28
36{
40 protected int $ref_id = 0;
41
45 protected int $ext_consumer_id = 0;
46
50 protected string $title = '';
51
55 protected string $description = '';
56
60 protected string $prefix = '';
61
65 protected string $user_language = '';
66
70 protected int $role = 0;
71
75 protected bool $active = false;
76
82 private ?array $settings = null;
83
89 private ?int $id = null;
90
96 private ?string $key = null;
97
103 {
104 $this->initialize();
105 if (empty($dataConnector)) {
107 }
108 $this->dataConnector = $dataConnector;
109 }
110
114 public function initialize(): void
115 {
116 $this->id = null;
117 $this->key = null;
118 $this->name = null;
119 $this->secret = null;
120 $this->signatureMethod = 'HMAC-SHA1';
121 $this->encryptionMethod = '';
122 $this->rsaKey = null;
123 $this->kid = null;
124 $this->jku = '';
125 $this->platformId = null;
126 $this->clientId = null;
127 $this->deploymentId = null;
128 $this->ltiVersion = null;
129 $this->consumerName = null;
130 $this->consumerVersion = null;
131 $this->consumerGuid = null;
132 $this->profile = null;
133 $this->toolProxy = null;
134 $this->settings = array();
135 $this->protected = false;
136 $this->enabled = false;
137 $this->enableFrom = null;
138 $this->enableUntil = null;
139 $this->lastAccess = null;
141 $this->defaultEmail = '';
142 $this->created = null;
143 $this->updated = null;
144 //added
145 $this->authorizationServerId = '';
146 $this->authenticationUrl = '';
147 $this->accessTokenUrl = '';
148 $this->debugMode = false;
149 }
150
151
152 public function setExtConsumerId(int $a_id): void
153 {
154 $this->ext_consumer_id = $a_id;
155 }
156
157 public function getExtConsumerId(): int
158 {
160 }
161
162 public function setRefId(int $a_ref_id): void
163 {
164 $this->ref_id = $a_ref_id;
165 }
166
167 public function getRefId(): int
168 {
169 return $this->ref_id;
170 }
171
172// public function getId() : ?int
173// {
174// return $this->getRecordId();
175// }
176
177 public function setTitle(string $title): void
178 {
179 $this->title = $title;
180 // $this->consumerName = $title;
181 }
182
183 public function getTitle(): string
184 {
185 return $this->title;
186 }
187
188 public function setDescription(string $description): void
189 {
190 $this->description = $description;
191 }
192
193 public function getDescription(): string
194 {
195 return $this->description;
196 }
197
198 public function setPrefix(string $prefix): void
199 {
200 $this->prefix = $prefix;
201 }
202
203 public function getPrefix(): string
204 {
205 return $this->prefix;
206 }
207
208 public function setSecret(string $secret): void
209 {
210 $this->secret = $secret;
211 }
212
213 public function getSecret(): ?string
214 {
215 return $this->secret;
216 }
217
221 public function createSecret(): void
222 {
223 $this->setSecret(\ILIAS\LTI\ToolProvider\Util::getRandomString(12));
224 }
225
229 public function setLanguage(string $lang): void
230 {
231 $this->user_language = $lang;
232 }
233
234 public function getLanguage(): string
235 {
237 }
238
239 public function setActive(bool $value): void
240 {
241 $this->active = $value;
242 }
243
244 public function getActive(): bool
245 {
246 return $this->active;
247 }
248
249 public function setRole(int $role_id): void
250 {
251 $this->role = $role_id;
252 }
253
254 public function getRole(): int
255 {
256 return $this->role;
257 }
258
259
260 public function setEnabled(bool $a_status): void
261 {
262 $this->enabled = $a_status;
263 }
264
265 public function getEnabled(): bool
266 {
267 return $this->enabled;
268 }
269
270 // local_role_always_member, default_skin
271
281 public static function fromPlatformId(string $platformId, string $clientId, string $deploymentId, ilLTIDataConnector $dataConnector = null, bool $autoEnable = false): ilLTIPlatform
282 {
283 $platform = new ilLTIPlatform($dataConnector);
284 $platform->initialize();
285 $platform->platformId = $platformId;
286 $platform->clientId = $clientId;
287 $platform->deploymentId = $deploymentId;
288 $dataConnector->loadPlatform($platform);
290 return $platform;
291 }
292
300 public static function fromConsumerKey(?string $key = null, $dataConnector = null, bool $autoEnable = false): \ilLTIPlatform
301 {
302 $platform = new ilLTIPlatform($dataConnector);
303 $platform->initialize();
304 $platform->setKey($key);
305 ilLoggerFactory::getLogger('ltis')->debug('Loading with key: ' . $platform->getKey());
306 $dataConnector->loadPlatform($platform);
308 return $platform;
309 }
310
318 {
319// $platform = new static($dataConnector);
320 $platform = new ilLTIPlatform($dataConnector);
321 $platform->initialize();
322 $platform->setRecordId((int) $id);
323 ilLoggerFactory::getLogger('ltis')->info('Loading with record id: ' . $platform->getRecordId());
324 $dataConnector->loadPlatform($platform);
326 return $platform;
327 }
328
335 {
336 $platform = new ilLTIPlatform($dataConnector);
337 //$platform->setRecordId((int) $id);
338 //$dataConnector->loadPlatform($platform);
339 $platform->initialize();
340 $platform->setExtConsumerId($id);
342 $platform->initialize();
343 }
344 return $platform;
345 }
346
354 public static function fromGlobalSettingsAndRefId(int $a_ext_consumer_id, int $a_ref_id, ilLTIDataConnector $a_data_connector): ilLTIPlatform
355 {
356 $toolConsumer = new ilLTIPlatform(null, $a_data_connector);
357 $toolConsumer->initialize();
358 $toolConsumer->setExtConsumerId($a_ext_consumer_id);
359 $toolConsumer->setRefId($a_ref_id);
360
361 $consumer_pk = $a_data_connector->lookupRecordIdByGlobalSettingsAndRefId($toolConsumer);
362 if ($consumer_pk != null) {
363 $toolConsumer = self::fromRecordId($consumer_pk, $a_data_connector);
364 }
365 return $toolConsumer;
366 }
367
368
374 {
376 }
377
383 {
385 }
386
393 {
395 return $ok;
396 }
397}
Class to represent a platform.
Definition: Platform.php:36
const ID_SCOPE_ID_ONLY
Use ID value only.
Definition: Tool.php:51
lookupRecordIdByGlobalSettingsAndRefId(ilLTIPlatform $platform)
Lookup record id for global settings and ref_id.
static getDataConnector(object $db=null, string $dbTableNamePrefix='', string $type='')
loadGlobalToolConsumerSettings(ilLTIPlatform $platform)
Load global tool consumer settings in consumer.
loadPlatform(\ILIAS\LTI\ToolProvider\Platform $platform)
Load platform object.
saveGlobalToolConsumerSettings(ilLTIPlatform $platform)
Save lti_ext_consumer.
deleteGlobalToolConsumerSettings(ilLTIPlatform $platform)
Delete global tool consumer settings.
saveToolConsumerILIAS(ilLTIPlatform $platform)
Save extended tool consumer object with ILIAS extensions.
LTI provider for LTI launch.
static fromExternalConsumerId(int $id, ilLTIDataConnector $dataConnector)
static fromGlobalSettingsAndRefId(int $a_ext_consumer_id, int $a_ref_id, ilLTIDataConnector $a_data_connector)
Load consumer from global settings and ref_id.
string $key
Consumer key/client ID value.
initialize()
Initialise the platform.
createSecret()
Create a secret.
setDescription(string $description)
static fromConsumerKey(?string $key=null, $dataConnector=null, bool $autoEnable=false)
Load the platform from the database by its consumer key.
saveGlobalToolConsumerSettings(ilLTIDataConnector $dataConnector)
Save global consumer settings.
setRefId(int $a_ref_id)
setTitle(string $title)
static fromPlatformId(string $platformId, string $clientId, string $deploymentId, ilLTIDataConnector $dataConnector=null, bool $autoEnable=false)
Load the platform from the database by its platform, client and deployment IDs.
setActive(bool $value)
deleteGlobalToolConsumerSettings(ilLTIDataConnector $dataConnector)
Delete global tool consumer settings.
setEnabled(bool $a_status)
static fromRecordId(int $id, ilLTIDataConnector $dataConnector)
Load the platform from the database by its record ID.
setSecret(string $secret)
setLanguage(string $lang)
setPrefix(string $prefix)
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
setExtConsumerId(int $a_id)
saveLTI(ilLTIDataConnector $dataConnector)
Save the tool consumer to the database with ILIAS extension.
setRole(int $role_id)
int $id
System ID value.
__construct(ilLTIDataConnector $dataConnector=null)
Class constructor.
static getLogger(string $a_component_id)
Get component logger.
$clientId
Definition: ltiregend.php:27
trait ApiHook
Trait to handle API hook registrations.
Definition: ApiHook.php:29
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...
Definition: AccessToken.php:19
ilLTIDataConnector $dataConnector
Data connector object.
Definition: System.php:64
bool $enabled
Whether the system instance is enabled to accept connection requests.
Definition: System.php:123
string $secret
Shared secret.
Definition: System.php:43
Class ChatMainBarProvider \MainMenu\Provider.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$lang
Definition: xapiexit.php:26