ILIAS  release_8 Revision v8.23
class.ilLTIPlatform.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 //use ILIAS\LTI\ToolProvider\Platform;
23 //use ILIAS\LTI\ToolProvider\DataConnector\DataConnector;
26 //use ILIAS\LTIOAuth;
28 
35 class ilLTIPlatform extends ToolProvider\Platform
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  {
159  return $this->ext_consumer_id;
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  {
236  return $this->user_language;
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 
317  public static function fromRecordId(int $id, ilLTIDataConnector $dataConnector): \ilLTIPlatform
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);
325  $dataConnector->loadGlobalToolConsumerSettings($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);
341  if (!$dataConnector->loadGlobalToolConsumerSettings($platform)) {
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  {
375  $dataConnector->saveGlobalToolConsumerSettings($this);
376  }
377 
383  {
384  $dataConnector->deleteGlobalToolConsumerSettings($this);
385  }
386 
393  {
394  $ok = $dataConnector->saveToolConsumerILIAS($this);
395  return $ok;
396  }
397 }
setActive(bool $value)
bool $enabled
Whether the system instance is enabled to accept connection requests.
Definition: System.php:123
static getLogger(string $a_component_id)
Get component logger.
saveGlobalToolConsumerSettings(ilLTIDataConnector $dataConnector)
Save global consumer settings.
Class ChatMainBarProvider .
$clientId
Definition: ltiregend.php:27
static getDataConnector(object $db=null, string $dbTableNamePrefix='', string $type='')
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
deleteGlobalToolConsumerSettings(ilLTIDataConnector $dataConnector)
Delete global tool consumer settings.
loadPlatform(\ILIAS\LTI\ToolProvider\Platform $platform)
Load platform object.
string $secret
Shared secret.
Definition: System.php:43
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.
lookupRecordIdByGlobalSettingsAndRefId(ilLTIPlatform $platform)
Load extended tool consumer object with ILIAS extension.
setRole(int $role_id)
static fromGlobalSettingsAndRefId(int $a_ext_consumer_id, int $a_ref_id, ilLTIDataConnector $a_data_connector)
Load consumer from global settings and ref_id.
setDescription(string $description)
int $id
System ID value.
setEnabled(bool $a_status)
LTI provider for LTI launch.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: AccessToken.php:19
createSecret()
Create a secret.
static fromRecordId(int $id, ilLTIDataConnector $dataConnector)
Load the platform from the database by its record ID.
__construct(ilLTIDataConnector $dataConnector=null)
Class constructor.
const ID_SCOPE_ID_ONLY
Use ID value only.
Definition: Tool.php:51
setSecret(string $secret)
setExtConsumerId(int $a_id)
string $key
Consumer key/client ID value.
saveLTI(ilLTIDataConnector $dataConnector)
Save the tool consumer to the database with ILIAS extension.
ilLTIDataConnector $dataConnector
Data connector object.
Definition: System.php:64
$lang
Definition: xapiexit.php:26
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...
setLanguage(string $lang)
initialize()
Initialise the platform.
saveToolConsumerILIAS(ilLTIPlatform $platform)
Save extended tool consumer object with ILIAS extensions.
static fromExternalConsumerId(int $id, ilLTIDataConnector $dataConnector)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveGlobalToolConsumerSettings(ilLTIPlatform $platform)
Save platform object.
setTitle(string $title)
static fromConsumerKey(?string $key=null, $dataConnector=null, bool $autoEnable=false)
Load the platform from the database by its consumer key.
loadGlobalToolConsumerSettings(ilLTIPlatform $platform)
Load tool consumer settings.
deleteGlobalToolConsumerSettings(ilLTIPlatform $platform)
Delete global tool consumer settings.
setRefId(int $a_ref_id)
setPrefix(string $prefix)