ILIAS  release_8 Revision v8.24
class.ilLTIDataConnector.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21// namespace ILIAS\LTI\Tool\DataConnector;
29//use ILIAS\LTI\ToolProvider\User;
33//UK: added
35
37{
38 private ?\ilLogger $logger = null;
39
41
45 public function __construct()
46 {
47 global $DIC;
48 $this->database = $DIC->database();
49
50 $this->logger = ilLoggerFactory::getLogger('ltis');
51 $this->db = null;
52 $this->dbTableNamePrefix = "";
53 }
54
55 //
56 // next functions based on LTI Data Connector for MySQLi
57 //
63 public function loadPlatform(\ILIAS\LTI\ToolProvider\Platform $platform): bool
64 {
65 $ok = false;
66 $allowMultiple = false;
67 $id = $platform->getRecordId();
68 $query = 'SELECT consumer_pk, name, consumer_key, secret, ' .
69 'platform_id, client_id, deployment_id, public_key, ' .
70 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
71 'profile, tool_proxy, settings, protected, enabled, ' .
72 'enable_from, enable_until, last_access, created, updated, ext_consumer_id, ref_id ' .
73 'FROM lti2_consumer WHERE ';
74 if (!is_null($id)) {
75 $query .= 'consumer_pk = %s';
76 $types = array('integer');
77 $values = array($id);
78 } elseif (!empty($platform->platformId)) {
79 if (empty($platform->clientId)) {
80 $allowMultiple = true;
81 $query .= '(platform_id = %s)';
82 $types = array('text');
83 $values = array($platform->platformId);
84 } elseif (empty($platform->deploymentId)) {
85 $allowMultiple = true;
86 $query .= '(platform_id = %s) AND (client_id = %s)';
87 $types = array('text','text');
88 $values = array($platform->platformId, $platform->clientId);
89 } else {
90 $query .= '(platform_id = %s) AND (client_id = %s) AND (deployment_id = %s)';
91 $types = array('text','text','text');
92 $values = array($platform->platformId, $platform->clientId, $platform->deploymentId);
93 }
94 } elseif (!empty($platform->getKey())) {
95 $key = $platform->getKey();
96 $query .= 'consumer_key = %s';
97 $types = array('text');
98 $values = array($key);
99 } else {
100 return false;
101 }
102 // $ok = $this->executeQuery($sql, $stmt);
103 // if ($ok) {
104 // $rsConsumer = $stmt->get_result();
105 // $ok = $rsConsumer !== false;
106 // if ($ok) {
107 // $row = $rsConsumer->fetch_object();
108 // $ok = $row && ($allowMultiple || is_null($rsConsumer->fetch_object()));
109 // }
110 // }
111 // if ($ok) {
112 $res = $this->database->queryF($query, $types, $values);
113 while ($row = $this->database->fetchObject($res)) {
114 $platform->setRecordId(intval($row->consumer_pk));
115 $platform->name = $row->name;
116 $platform->setkey((string) $row->consumer_key);
117 $platform->secret = $row->secret;
118 $platform->platformId = $row->platform_id;
119 $platform->clientId = $row->client_id;
120 $platform->deploymentId = $row->deployment_id;
121 $platform->rsaKey = $row->public_key;
122 $platform->ltiVersion = $row->lti_version;
123 $platform->signatureMethod = $row->signature_method;
124 $platform->consumerName = $row->consumer_name;
125 $platform->consumerVersion = $row->consumer_version;
126 $platform->consumerGuid = $row->consumer_guid;
127 $platform->profile = json_decode((string) $row->profile);
128 $platform->toolProxy = $row->tool_proxy;
129 $settings = json_decode($row->settings, true);
130 if (!is_array($settings)) {
131 $settings = @unserialize($row->settings); // check for old serialized setting
132 }
133 if (!is_array($settings)) {
134 $settings = array();
135 }
136 $platform->setSettings($settings);
137 $platform->protected = (intval($row->protected) === 1);
138 $platform->enabled = (intval($row->enabled) === 1);
139 $platform->enableFrom = null;
140 if (!is_null($row->enable_from)) {
141 $platform->enableFrom = strtotime($row->enable_from);
142 }
143 $platform->enableUntil = null;
144 if (!is_null($row->enable_until)) {
145 $platform->enableUntil = strtotime($row->enable_until);
146 }
147 $platform->lastAccess = null;
148 if (!is_null($row->last_access)) {
149 $platform->lastAccess = strtotime($row->last_access);
150 }
151 $platform->created = strtotime($row->created);
152 $platform->updated = strtotime($row->updated);
153 //ILIAS specific
154 $platform->setExtConsumerId(intval($row->ext_consumer_id));
155 $platform->setRefId((int) $row->ref_id);
156 // if ($platform->setTitle) $platform->setTitle($row->title);
157 // if ($platform->setDescription) $platform->setDescription($row->description);
158 // if ($platform->setPrefix) $platform->setPrefix($row->prefix);
159 // if ($platform->setPrefix) $platform->setLanguage($row->user_language);
160 // if ($platform->setPrefix) $platform->setRole($row->role);
161 // local_role_always_member
162 // default_skin
163 $this->fixPlatformSettings($platform, false);
164 $ok = true;
165 }
166 return $ok;
167 }
168 #######
169 // /**
170 // * Load tool consumer settings
171 // * @param ilLTIPlatform $platform
172 // * @return bool
173 // */
174 // public function loadObjectToolConsumerSettings(ilLTIPlatform $platform) : bool
175 // {
176 // $this->loadGlobalToolConsumerSettings($platform);
177 //
178 // $ilDB = $this->database;
179 //
180 // $query = 'SELECT * from lti2_consumer where id = ' . $ilDB->quote($platform->getExtConsumerId(), 'integer');
181 // $res = $ilDB->query($query);
182 // while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
183 // $platform->setTitle($row->title);
184 // $platform->setDescription($row->description);
185 // $platform->setPrefix($row->prefix);
186 // $platform->setLanguage($row->user_language);
187 // $platform->setRole($row->role);
188 // $platform->setActive((bool) $row->active);
189 // return true;
190 // }
191 // return false;
192 // }
193
199 public function loadGlobalToolConsumerSettings(ilLTIPlatform $platform): bool
200 {
202
203 $query = 'SELECT * from lti_ext_consumer where id = ' . $ilDB->quote($platform->getExtConsumerId(), 'integer');
204 $res = $ilDB->query($query);
205 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
206 $platform->setTitle($row->title);
207 $platform->setDescription($row->description);
208 $platform->setPrefix($row->prefix);
209 $platform->setLanguage($row->user_language);
210 $platform->setRole((int) $row->role);
211 $platform->setActive((bool) $row->active);
212 return true;
213 }
214 return false;
215 }
216
217 // /**
218 // * Load extended tool consumer object with ILIAS extension.
219 // * @param Platform $platform Platform object
220 // * @return boolean True if the tool consumer object was successfully loaded
221 // */
222 // public function loadToolConsumerILIAS(ilLTIPlatform $platform) : bool
223 // {
224 // global $DIC;
225 // $ilDB = $DIC->database(); // TODO PHP8 Review: Move Global Access to Constructor
226 //
227 // $ok = false;
228 // $query = 'SELECT consumer_pk, name, consumer_key256, consumer_key, secret, lti_version, ' .
229 // 'consumer_name, consumer_version, consumer_guid, ' .
230 // 'profile, tool_proxy, settings, protected, enabled, ' .
231 // 'enable_from, enable_until, last_access, created, updated, ' .
232 // 'ext_consumer_id, ref_id ' .
233 // #'title, description, prefix, user_language, role, local_role_always_member, default_skin ' .
234 // 'FROM lti2_consumer ' .
235 // #'FROM lti2_consumer, lti_ext_consumer ' .
236 // 'WHERE ';
237 // #'WHERE lti_ext_consumer.id = consumer_pk AND ';
238 // if (!empty($platform->getRecordId())) {
239 // $query .= 'consumer_pk = %s';
240 // $types = array('integer');
241 // $values = array($platform->getRecordId());
242 // } else {
243 // $query .= 'consumer_key256 = %s';
244 // $types = array('text');
245 // $key256 = ilLTIDataConnector::getConsumerKey($platform->getKey());
246 // $values = array($key256);
247 // }
248 // // $rsConsumer = mysql_query($sql);
249 // $res = $ilDB->queryF($query, $types, $values);
250 // // if ($rsConsumer) {
251 // while ($row = $ilDB->fetchObject($res)) {
252 // // while ($row = mysql_fetch_object($rsConsumer)) {
253 // if (empty($key256) || empty($row->consumer_key) || ($platform->getKey() === $row->consumer_key)) {
254 // $platform->setRecordId(intval($row->consumer_pk));
255 // $platform->name = $row->name;
256 // $platform->setkey(empty($row->consumer_key) ? $row->consumer_key256 : $row->consumer_key);
257 // $platform->secret = $row->secret;
258 // $platform->ltiVersion = $row->lti_version;
259 // $platform->consumerName = $row->consumer_name;
260 // $platform->consumerVersion = $row->consumer_version;
261 // $platform->consumerGuid = $row->consumer_guid;
262 // $platform->profile = json_decode((string) $row->profile); // TODO PHP8 Review: Undefined Property
263 // $platform->toolProxy = $row->tool_proxy; // TODO PHP8 Review: Undefined Property
264 // $settings = unserialize($row->settings);
265 // if (!is_array($settings)) {
266 // $settings = array();
267 // }
268 // $platform->setSettings($settings);
269 // $platform->protected = (intval($row->protected) === 1);
270 // $platform->enabled = (intval($row->enabled) === 1);
271 // $platform->enableFrom = null;
272 // if (!is_null($row->enable_from)) {
273 // $platform->enableFrom = strtotime($row->enable_from);
274 // }
275 // $platform->enableUntil = null;
276 // if (!is_null($row->enable_until)) {
277 // $platform->enableUntil = strtotime($row->enable_until);
278 // }
279 // $platform->lastAccess = null;
280 // if (!is_null($row->last_access)) {
281 // $platform->lastAccess = strtotime($row->last_access);
282 // }
283 // $platform->created = strtotime($row->created);
284 // $platform->updated = strtotime($row->updated);
285 //
286 // //ILIAS specific
287 // $platform->setExtConsumerId((int) $row->ext_consumer_id);
288 // $platform->setRefId((int) $row->ref_id);
289 // #$platform->setTitle($row->title);
290 // #$platform->setDescription($row->description);
291 // #$platform->setPrefix($row->prefix);
292 // #$platform->setLanguage($row->user_language);
293 // #$platform->setRole($row->role);
294 // // local_role_always_member
295 // // default_skin
296 //
297 // $ok = true;
298 // break;
299 // }
300 // // }
301 // // mysql_free_result($rsConsumer);
302 // }
303 //
304 // $this->loadGlobalToolConsumerSettings($platform);
305 // return $ok;
306 // }
307
314 {
315 $db = $this->database;
316
317 $query = 'SELECT consumer_pk from lti2_consumer ' .
318 'WHERE ext_consumer_id = ' . $db->quote($platform->getExtConsumerId(), 'integer') . ' ' .
319 'AND ref_id = ' . $db->quote($platform->getRefId(), 'integer');
320 $res = $db->query($query);
321 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
322 return (int) $row->consumer_pk;
323 }
324 return null;
325 }
326
327 // /**
328 // * Save platform object.
329 // * @param Platform $platform Consumer object
330 // * @return bool True if the tool consumer object was successfully saved
331 // */
332 // public function saveToolConsumer(\ILIAS\LTI\ToolProvider\Platform $platform) : bool
333 // {
334 // global $DIC;
335 // $ilDB = $DIC->database(); // TODO PHP8 Review: Move Global Access to Constructor
336 //
337 // $id = $platform->getRecordId();
338 // $key = $platform->getKey();
339 // $key256 = ToolProvider\DataConnector\DataConnector::getConsumerKey($key);
340 // // $key256 = $this->getConsumerKey($key);
341 // if ($key === $key256) {
342 // $key = null;
343 // }
344 // $protected = ($platform->protected) ? 1 : 0;
345 // $enabled = ($platform->enabled) ? 1 : 0;
346 // $profile = (!empty($platform->profile)) ? json_encode($platform->profile) : null;
347 // $settingsValue = serialize($platform->getSettings());
348 // $time = time();
349 // $now = date("{$this->dateFormat} {$this->timeFormat}", $time);
350 // $from = null;
351 // if (!is_null($platform->enableFrom)) {
352 // $from = date("{$this->dateFormat} {$this->timeFormat}", $platform->enableFrom);
353 // }
354 // $until = null;
355 // if (!is_null($platform->enableUntil)) {
356 // $until = date("{$this->dateFormat} {$this->timeFormat}", $platform->enableUntil);
357 // }
358 // $last = null;
359 // if (!is_null($platform->lastAccess)) {
360 // $last = date($this->dateFormat, $platform->lastAccess);
361 // }
362 //
363 // if (empty($id)) {
364 // $platform->setRecordId($ilDB->nextId('lti_ext_consumer'));
365 // $id = $platform->getRecordId();
366 // $platform->created = $time;
367 // $platform->updated = $time;
368 // if ($key256 == null) {
369 // $key256 = $id . ToolProvider\DataConnector\DataConnector::getRandomString(10);
370 // }
371 //
372 // // $query = "INSERT INTO {$this->dbTableNamePrefix}" . $this->CONSUMER_TABLE_NAME . ' (consumer_key256, consumer_key, name, ' .
373 // $query = 'INSERT INTO lti2_consumer (consumer_key256, consumer_key, name, ' .
374 // 'secret, lti_version, consumer_name, consumer_version, consumer_guid, profile, tool_proxy, settings, protected, enabled, ' .
375 // 'enable_from, enable_until, last_access, created, updated, consumer_pk) ' .
376 // 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)';
377 // $types = array("text",
378 // "text",
379 // "text",
380 // "text",
381 // "text",
382 // "text",
383 // "text",
384 // "text",
385 // "text",
386 // "text",
387 // "text",
388 // "integer",
389 // "integer",
390 // "timestamp",
391 // "timestamp",
392 // "timestamp",
393 // "timestamp",
394 // "timestamp",
395 // "integer"
396 // );
397 // $values = array($key256,
398 // $key,
399 // $platform->name,
400 // $platform->secret,
401 // $platform->ltiVersion,
402 // $platform->consumerName,
403 // $platform->consumerVersion,
404 // $platform->consumerGuid,
405 // $profile,
406 // $platform->toolProxy, // TODO PHP8 Review: Undefined Property
407 // $settingsValue,
408 // $protected,
409 // $enabled,
410 // $from,
411 // $until,
412 // $last,
413 // $now,
414 // $now,
415 // $id
416 // );
417 // $ilDB->manipulateF($query, $types, $values);
418 // } else {
419 // $platform->updated = $time;
420 //
421 // $query = 'UPDATE lti2_consumer SET ' .
422 // 'consumer_key256 = %s, consumer_key = %s, name = %s, ' .
423 // 'secret= %s, lti_version = %s, consumer_name = %s, consumer_version = %s, consumer_guid = %s, ' .
424 // 'profile = %s, tool_proxy = %s, settings = %s, protected = %s, enabled = %s, ' .
425 // 'enable_from = %s, enable_until = %s, last_access = %s, updated = %s ' .
426 // 'WHERE consumer_pk = %s';
427 // $types = array("text",
428 // "text",
429 // "text",
430 // "text",
431 // "text",
432 // "text",
433 // "text",
434 // "text",
435 // "text",
436 // "text",
437 // "text",
438 // "integer",
439 // "integer",
440 // "timestamp",
441 // "timestamp",
442 // "timestamp",
443 // "timestamp",
444 // "integer"
445 // );
446 // $values = array($key256,
447 // $key,
448 // $platform->name,
449 // $platform->secret,
450 // $platform->ltiVersion,
451 // $platform->consumerName,
452 // $platform->consumerVersion,
453 // $platform->consumerGuid,
454 // $profile,
455 // $platform->toolProxy, // TODO PHP8 Review: Undefined Property
456 // $settingsValue,
457 // $protected,
458 // $enabled,
459 // $from,
460 // $until,
461 // $last,
462 // $now,
463 // $id
464 // );
465 // $ilDB->manipulateF($query, $types, $values);
466 // }
467 // return true;
468 // }
469
473 public function saveGlobalToolConsumerSettings(ilLTIPlatform $platform): bool
474 {
476
477 if (!$platform->getExtConsumerId()) {
478 // create
479 $new_id = $ilDB->nextId('lti_ext_consumer');
480 $query = 'INSERT INTO lti_ext_consumer (title, description, prefix, user_language, role, id, active) ' .
481 'VALUES (%s, %s, %s, %s, %s, %s, %s)';
482 $types = ["text", "text", "text", "text", "integer", "integer", 'integer'];
483 $values = [
484 $platform->getTitle(),
485 $platform->getDescription(),
486 $platform->getPrefix(),
487 $platform->getLanguage(),
488 $platform->getRole(),
489 $new_id,
490 $platform->getActive()
491 ];
492 $ilDB->manipulateF($query, $types, $values);
493 $platform->setExtConsumerId($new_id);
494 return true;
495 } else {
496 // update
497 $query = 'update lti_ext_consumer set ' .
498 'title = ' . $ilDB->quote($platform->getTitle(), 'text') . ', ' .
499 'description = ' . $ilDB->quote($platform->getDescription(), 'text') . ', ' .
500 'prefix = ' . $ilDB->quote($platform->getPrefix(), 'text') . ', ' .
501 'user_language = ' . $ilDB->quote($platform->getLanguage(), 'text') . ', ' .
502 'role = ' . $ilDB->quote($platform->getRole(), 'integer') . ', ' .
503 'active = ' . $ilDB->quote((int) $platform->getActive(), 'integer') . ' ' .
504 'where id = ' . $ilDB->quote($platform->getExtConsumerId(), 'integer');
505 $ilDB->manipulate($query);
506 return true;
507 }
508 }
509
515 public function saveToolConsumerILIAS(ilLTIPlatform $platform): bool
516 {
518
519 $id = $platform->getRecordId();
520 $key = $platform->getKey();
521 $protected = ($platform->protected) ? 1 : 0;
522 $enabled = ($platform->enabled) ? 1 : 0;
523 $profile = (!empty($platform->profile)) ? json_encode($platform->profile) : null;
524 // $settingsValue = '{}';
525 $this->fixPlatformSettings($platform, true);
526 $settingsValue = json_encode($platform->getSettings());
527 $this->fixPlatformSettings($platform, false);
528 $time = time();
529 $now = date("{$this->dateFormat} {$this->timeFormat}", $time);
530 $from = null;
531 if (!is_null($platform->enableFrom)) {
532 $from = date("{$this->dateFormat} {$this->timeFormat}", $platform->enableFrom);
533 }
534 $until = null;
535 if (!is_null($platform->enableUntil)) {
536 $until = date("{$this->dateFormat} {$this->timeFormat}", $platform->enableUntil);
537 }
538 $last = null;
539 if (!is_null($platform->lastAccess)) {
540 $last = date($this->dateFormat, $platform->lastAccess);
541 }
542
543 $platform->name = $platform->getTitle();//50UK
544 if (empty($id)) {
545 $platform->setRecordId($ilDB->nextId('lti2_consumer'));
546 $id = $platform->getRecordId();
547 $platform->created = $time;
548 $platform->updated = $time;
549
550 // $query = "INSERT INTO {$this->dbTableNamePrefix}" . $this->CONSUMER_TABLE_NAME . ' (consumer_key256, consumer_key, name, ' .
551 $query = 'INSERT INTO lti2_consumer (consumer_key, name, ' .
552 'secret, lti_version, consumer_name, consumer_version, consumer_guid, profile, tool_proxy, settings, protected, enabled, ' .
553 'enable_from, enable_until, last_access, created, updated, consumer_pk, ext_consumer_id, ref_id, platform_id, client_id, deployment_id, public_key) ' .
554 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)';
555 $types = array("text",
556 "text",
557 "text",
558 "text",
559 "text",
560 "text",
561 "text",
562 "text",
563 "text",
564 "text",
565 "integer",
566 "integer",
567 "timestamp",
568 "timestamp",
569 "timestamp",
570 "timestamp",
571 "timestamp",
572 "integer",
573 'integer',
574 'integer',
575 "text",
576 "text",
577 "text",
578 "text"
579 );
580 $values = array($key,
581 $platform->name,
582 $platform->secret,
583 $platform->ltiVersion,
584 $platform->consumerName,
585 $platform->consumerVersion,
586 $platform->consumerGuid,
587 $profile,
588 $platform->toolProxy,
589 $settingsValue,
590 $protected,
591 $enabled,
592 $from,
593 $until,
594 $last,
595 $now,
596 $now,
597 $id,
598 $platform->getExtConsumerId(),
599 $platform->getRefId(),
600 (string) $platform->platformId,
601 $platform->clientId,
602 $platform->deploymentId,
603 $platform->rsaKey
604 );
605 $ilDB->manipulateF($query, $types, $values);
606 } else {
607 $platform->updated = $time;
608
609 $query = 'UPDATE lti2_consumer SET ' .
610 'consumer_key = %s, name = %s, ' .
611 'secret= %s, lti_version = %s, consumer_name = %s, consumer_version = %s, consumer_guid = %s, ' .
612 'profile = %s, tool_proxy = %s, settings = %s, protected = %s, enabled = %s, ' .
613 'enable_from = %s, enable_until = %s, last_access = %s, updated = %s, ' .
614 'platform_id = %s, client_id = %s, deployment_id = %s, public_key = %s ' .
615 'WHERE consumer_pk = %s';
616 $types = array("text",
617 "text",
618 "text",
619 "text",
620 "text",
621 "text",
622 "text",
623 "text",
624 "text",
625 "text",
626 "integer",
627 "integer",
628 "timestamp",
629 "timestamp",
630 "timestamp",
631 "timestamp",
632 "text",
633 "text",
634 "text",
635 "text",
636 "integer"
637 );
638 $values = array($key,
639 $platform->name,
640 $platform->secret,
641 $platform->ltiVersion,
642 $platform->consumerName,
643 $platform->consumerVersion,
644 $platform->consumerGuid,
645 $profile,
646 $platform->toolProxy,
647 $settingsValue,
648 $protected,
649 $enabled,
650 $from,
651 $until,
652 $last,
653 $now,
654 $platform->platformId,
655 $platform->clientId,
656 $platform->deploymentId,
657 $platform->rsaKey,
658 $id
659 );
660 $ilDB->manipulateF($query, $types, $values);
661 }
662
663 return true;
664 }
665
669 public function deleteGlobalToolConsumerSettings(ilLTIPlatform $platform): bool
670 {
672
673 $query = 'DELETE FROM lti_ext_consumer WHERE id = %s';
674 $types = array("integer");
675 $values = array($platform->getExtConsumerId());
676 $ilDB->manipulateF($query, $types, $values);
677
678 $query = 'DELETE FROM lti_ext_consumer_otype WHERE consumer_id = %s';
679 $types = array("integer");
680 $values = array($platform->getExtConsumerId());
681 $ilDB->manipulateF($query, $types, $values);
682
683 $query = 'DELETE FROM lti2_consumer WHERE ext_consumer_id = %s';
684 $types = array("integer");
685 $values = array($platform->getExtConsumerId());
686 $ilDB->manipulateF($query, $types, $values);
687
688 // delete all assigned lti consumers
689 $platform->initialize();
690 return true;
691 }
692
698 public function deleteToolConsumer(\ILIAS\LTI\ToolProvider\Platform $platform): bool
699 {
701
702 // Delete any nonce values for this consumer
703 $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::NONCE_TABLE_NAME . ' WHERE consumer_pk = %s';
704 $types = array("integer");
705 $values = array($platform->getRecordId());
706 $ilDB->manipulateF($query, $types, $values);
707
708 // Delete any outstanding share keys for resource links for this consumer
709 $query = 'DELETE sk ' .
710 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' sk ' .
711 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON sk.resource_link_pk = rl.resource_link_pk ' .
712 'WHERE rl.consumer_pk = %s';
713 $types = array("integer");
714 $values = array($platform->getRecordId());
715 $ilDB->manipulateF($query, $types, $values);
716
717 // Delete any outstanding share keys for resource links for contexts in this consumer
718 $query = 'DELETE sk ' .
719 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' sk ' .
720 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON sk.resource_link_pk = rl.resource_link_pk ' .
721 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ON rl.context_pk = c.context_pk ' .
722 'WHERE c.consumer_pk = %s';
723 $types = array("integer");
724 $values = array($platform->getRecordId());
725 $ilDB->manipulateF($query, $types, $values);
726
727 // Delete any users in resource links for this consumer
728 $query = 'DELETE u ' .
729 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' u ' .
730 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON u.resource_link_pk = rl.resource_link_pk ' .
731 'WHERE rl.consumer_pk = %s';
732 $types = array("integer");
733 $values = array($platform->getRecordId());
734 $ilDB->manipulateF($query, $types, $values);
735
736 // Delete any users in resource links for contexts in this consumer
737 $query = 'DELETE u ' .
738 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' u ' .
739 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON u.resource_link_pk = rl.resource_link_pk ' .
740 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ON rl.context_pk = c.context_pk ' .
741 'WHERE c.consumer_pk = %s';
742 $types = array("integer");
743 $values = array($platform->getRecordId());
744 $ilDB->manipulateF($query, $types, $values);
745
746 // Update any resource links for which this consumer is acting as a primary resource link
747 $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' prl ' .
748 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON prl.primary_resource_link_pk = rl.resource_link_pk ' .
749 'SET prl.primary_resource_link_pk = NULL, prl.share_approved = NULL ' .
750 'WHERE rl.consumer_pk = %s';
751 $types = array("integer");
752 $values = array($platform->getRecordId());
753 $ilDB->manipulateF($query, $types, $values);
754
755 // Update any resource links for contexts in which this consumer is acting as a primary resource link
756 $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' prl ' .
757 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON prl.primary_resource_link_pk = rl.resource_link_pk ' .
758 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ON rl.context_pk = c.context_pk ' .
759 'SET prl.primary_resource_link_pk = NULL, prl.share_approved = NULL ' .
760 'WHERE c.consumer_pk = %s';
761 $types = array("integer");
762 $values = array($platform->getRecordId());
763 $ilDB->manipulateF($query, $types, $values);
764
765 // Delete any resource links for this consumer
766 $query = 'DELETE rl ' .
767 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ' .
768 'WHERE rl.consumer_pk = %s';
769 $types = array("integer");
770 $values = array($platform->getRecordId());
771 $ilDB->manipulateF($query, $types, $values);
772
773 // Delete any resource links for contexts in this consumer
774 $query = 'DELETE rl ' .
775 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ' .
776 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ON rl.context_pk = c.context_pk ' .
777 'WHERE c.consumer_pk = %s';
778 $types = array("integer");
779 $values = array($platform->getRecordId());
780 $ilDB->manipulateF($query, $types, $values);
781
782 // Delete any contexts for this consumer
783 $query = 'DELETE c ' .
784 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ' .
785 'WHERE c.consumer_pk = %s';
786 $types = array("integer");
787 $values = array($platform->getRecordId());
788 $ilDB->manipulateF($query, $types, $values);
789
790 // Delete consumer
791 $query = 'DELETE c ' .
792 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONSUMER_TABLE_NAME . ' c ' .
793 'WHERE c.consumer_pk = %s';
794 $types = array("integer");
795 $values = array($platform->getRecordId());
796 $ilDB->manipulateF($query, $types, $values);
797
798 // if ($ok) {
799 $platform->initialize();
800 // }
801
802 return true;
803 }
804
809 public function getGlobalToolConsumerSettings(): array
810 {
812
813 $platforms = array();
814 $query = 'SELECT * from lti_ext_consumer ';
815 $res = $ilDB->query($query);
816 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
817 $platform = new ilLTIPlatform(null, $this);
818 $platform->setExtConsumerId((int) $row->id);
819 $platform->setTitle($row->title);
820 $platform->setDescription($row->description);
821 $platform->setPrefix($row->prefix);
822 $platform->setLanguage($row->user_language);
823 $platform->setRole((int) $row->role);
824 $platform->setActive((bool) $row->active);
825 $platforms[] = $platform;
826 }
827 return $platforms;
828 }
829
830
831
832 ###
833 # Load all tool consumers from the database
834 ###
838 public function getToolConsumers(): array
839 {
841 $platforms = array();
842 $query = 'SELECT consumer_pk, name, consumer_key256, consumer_key, secret, lti_version, ' .
843 'consumer_name, consumer_version, consumer_guid, ' .
844 'profile, tool_proxy, settings, protected, enabled, ' .
845 'enable_from, enable_until, last_access, created, updated, ' .
846 'title, description, prefix, user_language, role, local_role_always_member, default_skin ' .
847 'FROM lti2_consumer, lti_ext_consumer ' .
848 'WHERE lti_ext_consumer.id = consumer_pk';
849
850 // $sql = 'SELECT consumer_pk, consumer_key, consumer_key, name, secret, lti_version, consumer_name, consumer_version, consumer_guid, ' .
851 // 'profile, tool_proxy, settings, ' .
852 // 'protected, enabled, enable_from, enable_until, last_access, created, updated ' .
853 // "FROM {$this->dbTableNamePrefix}" . Tool\DataConnector\DataConnector::CONSUMER_TABLE_NAME . ' ' .
854 // 'ORDER BY name';
855 // $rsConsumers = mysql_query($sql);
856 // if ($rsConsumers) {
857 // while ($row = mysql_fetch_object($rsConsumers)) {
858 $res = $ilDB->query($query);
859 // if ($rsConsumer) {
860 while ($row = $ilDB->fetchObject($res)) {
861 // $platform = new Tool\Platform($row->consumer_key, $this); //ACHTUNG: FEHLER IN BIBLIOTHEK; $row->consumer_key ist i.d.R. null
862 $platform = new ilLTIPlatform(null, $this);
863 $platform->setRecordId(intval($row->consumer_pk));
864 $platform->name = $row->name;
865 $platform->secret = $row->secret;
866 $platform->ltiVersion = $row->lti_version;
867 $platform->consumerName = $row->consumer_name;
868 $platform->consumerVersion = $row->consumer_version;
869 $platform->consumerGuid = $row->consumer_guid;
870 $platform->profile = json_decode($row->profile);
871 $platform->toolProxy = $row->tool_proxy;
872 $settings = unserialize($row->settings);
873 if (!is_array($settings)) {
874 $settings = array();
875 }
876 $platform->setSettings($settings);
877 $platform->protected = (intval($row->protected) === 1);
878 $platform->enabled = (intval($row->enabled) === 1);
879 $platform->enableFrom = null;
880 if (!is_null($row->enable_from)) {
881 $platform->enableFrom = strtotime($row->enable_from);
882 }
883 $platform->enableUntil = null;
884 if (!is_null($row->enable_until)) {
885 $platform->enableUntil = strtotime($row->enable_until);
886 }
887 $platform->lastAccess = null;
888 if (!is_null($row->last_access)) {
889 $platform->lastAccess = strtotime($row->last_access);
890 }
891 $platform->created = strtotime($row->created);
892 $platform->updated = strtotime($row->updated);
893 //ILIAS specific
894 $platform->setTitle($row->title);
895 $platform->setDescription($row->description);
896 $platform->setPrefix($row->prefix);
897 $platform->setLanguage($row->user_language);
898 $platform->setRole($row->role);
899 // local_role_always_member
900 // default_skin
901 $platform->setKey($row->consumer_key256);//ACHTUNG: hier müsste evtl. consumer_key sein
902 $platforms[] = $platform;
903 }
904 // mysql_free_result($rsConsumers);
905 // }
906
907 return $platforms;
908 }
909 ###
910 ### ToolProxy methods
911 ###
912
913 // ###
914 // # Load the tool proxy from the database
915 // ###
916 // public function loadToolProxy($toolProxy) : bool
917 // {
918 // return false;
919 // }
920 //
921 // ###
922 // # Save the tool proxy to the database
923 // ###
924 // public function saveToolProxy($toolProxy) : bool
925 // {
926 // return false;
927 // }
928 //
929 // ###
930 // # Delete the tool proxy from the database
931 // ###
932 // public function deleteToolProxy($toolProxy) : bool
933 // {
934 // return false;
935 // }
936
937 ###
938 ### Context methods
939 ###
940
946 public function loadContext(Context $context): bool
947 {
949 $ok = false;
950 if (!empty($context->getRecordId())) {
951 $query = 'SELECT context_pk, consumer_pk, lti_context_id, settings, created, updated ' .
952 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' ' .
953 'WHERE (context_pk = %s)';
954 $types = array("integer");
955 $values = array($context->getRecordId());
956 } else {
957 $query = 'SELECT context_pk, consumer_pk, lti_context_id, settings, created, updated ' .
958 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' ' .
959 'WHERE (consumer_pk = %s) AND (lti_context_id = %s)';
960 $types = array("integer", "text");
961 $values = array($context->getPlatform()->getRecordId(), $context->ltiContextId);
962 }
963 $rs_context = $ilDB->queryF($query, $types, $values);
964 if ($rs_context) {
965 $row = $ilDB->fetchObject($rs_context);
966 if ($row) {
967 $context->setRecordId(intval($row->context_pk));
968 $context->setPlatformId(intval($row->consumer_pk));
969 $context->ltiContextId = $row->lti_context_id;
970 $settings = json_decode($row->settings);
971 if (!is_array($settings)) {
972 $settings = array();
973 }
974 $context->setSettings($settings);
975 $context->created = strtotime($row->created);
976 $context->updated = strtotime($row->updated);
977 $ok = true;
978 }
979 }
980
981 return $ok;
982 }
983
989 public function saveContext(Context $context): bool
990 {
992
993 $time = time();
994 $now = date("{$this->dateFormat} {$this->timeFormat}", $time);
995 //old: $settingsValue = serialize($context->getSettings());
996 $settingsValue = json_encode($context->getSettings());
997 $id = $context->getRecordId();
998 $platform_pk = $context->getPlatform()->getRecordId();
999 if (empty($id)) {
1000 $context->setRecordId($ilDB->nextId(ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME));
1001 $id = $context->getRecordId();
1002 $context->created = $time;
1003 //Check remove context_pk, add type
1004 $query = "INSERT INTO {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME .
1005 ' (context_pk, consumer_pk, lti_context_id, settings, created, updated) ' .
1006 'VALUES (%s, %s, %s, %s, %s, %s)';
1007 $types = array("integer", "integer", "text", "text", "timestamp", "timestamp");
1008 $values = array($id, $platform_pk, $context->ltiContextId, $settingsValue, $now, $now);
1009 } else {
1010 $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' SET ' .
1011 'lti_context_id = %s, settings = %s, ' .
1012 'updated = %s' .
1013 'WHERE (consumer_pk = %s) AND (context_pk = %s)';
1014 $types = array("text", "text", "timestamp", "integer", "integer");
1015 $values = array($context->ltiContextId, $settingsValue, $now, $platform_pk, $id);
1016 }
1017 $ok = (bool) $ilDB->manipulateF($query, $types, $values);
1018 if ($ok) {
1019 $context->updated = $time;
1020 }
1021
1022 return $ok;
1023 }
1024
1030 public function deleteContext(Context $context): bool
1031 {
1033
1034 // Delete any outstanding share keys for resource links for this context
1035 $query = 'DELETE sk ' .
1036 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' sk ' .
1037 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON sk.resource_link_pk = rl.resource_link_pk ' .
1038 'WHERE rl.context_pk = %s';
1039 $types = array("integer");
1040 $values = array($context->getRecordId());
1041 $ilDB->manipulateF($query, $types, $values);
1042
1043 // Delete any users in resource links for this context
1044 $query = 'DELETE u ' .
1045 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' u ' .
1046 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON u.resource_link_pk = rl.resource_link_pk ' .
1047 'WHERE rl.context_pk = %s';
1048 $types = array("integer");
1049 $values = array($context->getRecordId());
1050 $ilDB->manipulateF($query, $types, $values);
1051
1052 // Update any resource links for which this consumer is acting as a primary resource link
1053 $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' prl ' .
1054 "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON prl.primary_resource_link_pk = rl.resource_link_pk ' .
1055 'SET prl.primary_resource_link_pk = null, prl.share_approved = null ' .
1056 'WHERE rl.context_pk = %s';
1057 $types = array("integer");
1058 $values = array($context->getRecordId());
1059 $ilDB->manipulateF($query, $types, $values);
1060
1061 // Delete any resource links for this consumer
1062 $query = 'DELETE rl ' .
1063 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ' .
1064 'WHERE rl.context_pk = %s';
1065 $types = array("integer");
1066 $values = array($context->getRecordId());
1067 $ilDB->manipulateF($query, $types, $values);
1068
1069 // Delete context
1070 $query = 'DELETE c ' .
1071 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ' .
1072 'WHERE c.context_pk = %s';
1073 $types = array("integer");
1074 $values = array($context->getRecordId());
1075 $ok = (bool) $ilDB->manipulateF($query, $types, $values);
1076 if ($ok) {
1077 $context->initialize();
1078 }
1079
1080 return $ok;
1081 }
1082
1083 ###
1084 ### ResourceLink methods
1085 ###
1086
1092 public function loadResourceLink(ResourceLink $resourceLink): bool
1093 {
1095
1096 $ok = false;
1097 $id = $resourceLink->getRecordId();
1098 $rid = 0;
1099 $cid = 0;
1100 if (!is_null($id)) {
1101 $query = 'SELECT resource_link_pk, context_pk, consumer_pk, lti_resource_link_id, settings, primary_resource_link_pk, share_approved, created, updated ' .
1102 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
1103 'WHERE (resource_link_pk = %s)';
1104 $types = array("integer");
1105 $values = array($id);
1106 } elseif (!is_null($resourceLink->getContext())) {
1107 $rid = $resourceLink->getId();
1108 $cid = $resourceLink->getContext()->getRecordId();
1109 $query = 'SELECT resource_link_pk, context_pk, consumer_pk, lti_resource_link_id, settings, primary_resource_link_pk, share_approved, created, updated ' .
1110 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' r ' .
1111 'WHERE (r.lti_resource_link_id = %s) AND ((r.context_pk = %s) OR (r.consumer_pk IN (' .
1112 'SELECT c.consumer_pk ' .
1113 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ' .
1114 'WHERE (c.context_pk = %s))))';
1115 $types = array("text", "integer", "integer");
1116 $values = array($rid, $cid, $cid);
1117 } else {
1118 $id = $resourceLink->getPlatform()->getRecordId();
1119 $rid = $resourceLink->getId();
1120 $query = 'SELECT r.resource_link_pk, r.context_pk, r.consumer_pk, r.lti_resource_link_id, r.settings, r.primary_resource_link_pk, r.share_approved, r.created, r.updated ' .
1121 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' r LEFT OUTER JOIN ' .
1122 $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ON r.context_pk = c.context_pk ' .
1123 ' WHERE ((r.consumer_pk = %s) OR (c.consumer_pk = %s)) AND (lti_resource_link_id = %s)';
1124 $types = array("integer", "integer", "text");
1125 $values = array($id, $id, $rid);
1126 }
1127 $this->logger->debug("loadResourceLink id = " . $id . " rid =" . $rid . " cid =" . $cid . " query = " . $query);
1128 $rsContext = $ilDB->queryF($query, $types, $values);
1129 if ($rsContext) {
1130 $row = $ilDB->fetchObject($rsContext);
1131 if ($row) {
1132 $resourceLink->setRecordId(intval($row->resource_link_pk));
1133 if (!is_null($row->context_pk)) {
1134 $resourceLink->setContextId(intval($row->context_pk));
1135 } else {
1136 $resourceLink->setContextId(null);
1137 }
1138 if (!is_null($row->consumer_pk)) {
1139 $resourceLink->setPlatformId(intval($row->consumer_pk));
1140 } else {
1141 $resourceLink->setPlatformId(null);
1142 }
1143 //$resourceLink->title = $row->title;
1144 $resourceLink->ltiResourceLinkId = $row->lti_resource_link_id;
1145 $settings = json_decode($row->settings, true);
1146 if (!is_array($settings)) {
1147 $settings = @unserialize($row->settings); // check for old serialized setting
1148 }
1149 if (!is_array($settings)) {
1150 $settings = array();
1151 }
1152 $resourceLink->setSettings($settings);
1153 if (!is_null($row->primary_resource_link_pk)) {
1154 // $resourceLink->primaryResourceLinkId = intval($row->primary_resource_link_pk); //UK Check
1155 $resourceLink->primaryResourceLinkId = (string) ($row->primary_resource_link_pk);
1156 } else {
1157 $resourceLink->primaryResourceLinkId = null;
1158 }
1159 $resourceLink->shareApproved = (is_null($row->share_approved)) ? null : (intval($row->share_approved) === 1);
1160 $resourceLink->created = strtotime($row->created);
1161 $resourceLink->updated = strtotime($row->updated);
1162 } else {
1163 $ok = false;
1164 }
1165 }
1166
1167
1168 return $ok;
1169 }
1170
1176 public function saveResourceLink(ResourceLink $resourceLink): bool
1177 {
1179
1180 if (is_null($resourceLink->shareApproved)) {
1181 $approved = null;
1182 } elseif ($resourceLink->shareApproved) {
1183 $approved = '1';
1184 } else {
1185 $approved = '0';
1186 }
1187 if (empty($resourceLink->primaryResourceLinkId) || $resourceLink->primaryResourceLinkId == '0') {
1188 $primaryResourceLinkId = null;//'NULL';
1189 $resourceLink->primaryResourceLinkId = null; //Bug in 7: 0 instead of null
1190 } else {
1191 $primaryResourceLinkId = strval($resourceLink->primaryResourceLinkId);
1192 }
1193 $time = time();
1194 $now = date("{$this->dateFormat} {$this->timeFormat}", $time);
1195 $settingsValue = serialize($resourceLink->getSettings());
1196 if (!is_null($resourceLink->getContext())) {
1197 // $platformId = null;
1198 $platformId = strval($resourceLink->getPlatform()->getRecordId());
1199 $contextId = strval($resourceLink->getContext()->getRecordId());
1200 } elseif (!is_null($resourceLink->getContextId())) {
1201 // $platformId = null;
1202 $platformId = strval($resourceLink->getPlatform()->getRecordId());
1203 $contextId = strval($resourceLink->getContextId());
1204 } else {
1205 $platformId = strval($resourceLink->getPlatform()->getRecordId());
1206 $contextId = null;
1207 }
1208 $id = $resourceLink->getRecordId();
1209 if (empty($id)) {
1210 $resourceLink->setRecordId($ilDB->nextId(ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME));
1211 $id = $resourceLink->getRecordId();
1212 $resourceLink->created = $time;
1213 $query = "INSERT INTO {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' (resource_link_pk, consumer_pk, context_pk, ' .
1214 'lti_resource_link_id, settings, primary_resource_link_pk, share_approved, created, updated) ' .
1215 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)';
1216 $types = array("integer",
1217 "integer",
1218 "integer",
1219 "text",
1220 "text",
1221 "integer",
1222 "integer",
1223 "timestamp",
1224 "timestamp"
1225 );
1226 $values = array($id,
1227 $platformId,
1228 $contextId,
1229 $resourceLink->getId(),
1230 $settingsValue,
1231 $primaryResourceLinkId,
1232 $approved,
1233 $now,
1234 $now
1235 );
1236 } elseif (!is_null($contextId)) {
1237 $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' SET ' .
1238 'consumer_pk = %s, lti_resource_link_id = %s, settings = %s, ' .
1239 'primary_resource_link_pk = %s, share_approved = %s, updated = %s ' .
1240 'WHERE (context_pk = %s) AND (resource_link_pk = %s)';
1241 $types = array("integer", "text", "text", "integer", "integer", "timestamp", "integer", "integer");
1242 $values = array($platformId,
1243 $resourceLink->getId(),
1244 $settingsValue,
1245 $primaryResourceLinkId,
1246 $approved,
1247 $now,
1248 $contextId,
1249 $id
1250 );
1251 } else {
1252 $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' SET ' .
1253 'context_pk = %s, lti_resource_link_id = %s, settings = %s, ' .
1254 'primary_resource_link_pk = %s, share_approved = %s, updated = %s ' .
1255 'WHERE (consumer_pk = %s) AND (resource_link_pk = %s)';
1256 $types = array("integer", "text", "text", "integer", "integer", "timestamp", "integer", "integer");
1257 $values = array($contextId,
1258 $resourceLink->getId(),
1259 $settingsValue,
1260 $primaryResourceLinkId,
1261 $approved,
1262 $now,
1263 $platformId,
1264 $id
1265 );
1266 }
1267 $ok = (bool) $ilDB->manipulateF($query, $types, $values);
1268 $this->logger->debug('Update resource link with query: ' . $query);
1269 // $this->logger->logStack();
1270 $this->logger->dump($values, ilLogLevel::DEBUG);
1271 $this->logger->dump($ok, ilLogLevel::DEBUG);
1272
1273 if ($ok) {
1274 $resourceLink->updated = $time;
1275 }
1276
1277 return $ok;
1278 }
1279
1285 public function deleteResourceLink(ResourceLink $resourceLink): bool
1286 {
1288
1289 // Delete any outstanding share keys for resource links for this consumer
1290 $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' ' .
1291 'WHERE (resource_link_pk = %s)';
1292 $types = array("integer");
1293 $values = array($resourceLink->getRecordId());
1294 $ok = $ilDB->manipulateF($query, $types, $values);
1295
1296 // Delete users
1297 if ($ok) {
1298 $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1299 'WHERE (resource_link_pk = %s)';
1300 $types = array("integer");
1301 $values = array($resourceLink->getRecordId());
1302 $ok = $ilDB->manipulateF($query, $types, $values);
1303 }
1304
1305 // Update any resource links for which this is the primary resource link
1306 if ($ok) {
1307 $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
1308 'SET primary_resource_link_pk = NULL ' .
1309 'WHERE (primary_resource_link_pk = %s)';
1310 $types = array("integer");
1311 $values = array($resourceLink->getRecordId());
1312 $ok = $ilDB->manipulateF($query, $types, $values);
1313 }
1314
1315 // Delete resource link
1316 if ($ok) {
1317 $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
1318 'WHERE (resource_link_pk = %s)';
1319 $types = array("integer");
1320 $values = array($resourceLink->getRecordId());
1321 $ok = (bool) $ilDB->manipulateF($query, $types, $values);
1322 }
1323
1324 if ($ok) {
1325 $resourceLink->initialize();
1326 }
1327
1328 return $ok;
1329 }
1330
1341 ResourceLink $resourceLink,
1342 bool $localOnly,
1343 int $idScope
1344 ): array {
1345 $ilDB = $this->database;
1346
1347 $users = array();
1348
1349 // if ($localOnly) {
1350 // $query = 'SELECT u.user_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
1351 // "FROM {$this->dbTableNamePrefix}" . Tool\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' AS u ' .
1352 // "INNER JOIN {$this->dbTableNamePrefix}" . Tool\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' AS rl ' .
1353 // 'ON u.resource_link_pk = rl.resource_link_pk ' .
1354 // "WHERE (rl.resource_link_pk = %d) AND (rl.primary_resource_link_pk IS NULL)",
1355 // $resourceLink->getRecordId());
1356 // } else {
1357 // $query = 'SELECT u.user_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
1358 // "FROM {$this->dbTableNamePrefix}" . Tool\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' AS u ' .
1359 // "INNER JOIN {$this->dbTableNamePrefix}" . Tool\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' AS rl ' .
1360 // 'ON u.resource_link_pk = rl.resource_link_pk ' .
1361 // 'WHERE ((rl.resource_link_pk = %d) AND (rl.primary_resource_link_pk IS NULL)) OR ' .
1362 // '((rl.primary_resource_link_pk = %d) AND (share_approved = 1))',
1363 // $resourceLink->getRecordId(), $resourceLink->getRecordId());
1364 // }
1365 // $rsUser = mysql_query($sql);
1366 // if ($rsUser) {
1367 // while ($row = $ilDB->fetchObject($rsUser)) {
1368 // $user = Tool\User::fromResourceLink($resourceLink, $row->lti_user_id);
1369 // $user->setRecordId(intval($row->user_pk));
1370 // $user->ltiResultSourcedId = $row->lti_result_sourcedid;
1371 // $user->created = strtotime($row->created);
1372 // $user->updated = strtotime($row->updated);
1373 // if (is_null($idScope)) {
1374 // $users[] = $user;
1375 // } else {
1376 // $users[$user->getId($idScope)] = $user;
1377 // }
1378 // }
1379 // }
1380
1381 return $users;
1382 }
1383
1384 // /**
1385 // * Get array of shares defined for this resource link.
1386 // * @param ResourceLink $resourceLink Resource_Link object
1387 // * @return array Array of ResourceLinkShare objects
1388 // */
1389 // public function getSharesResourceLink(\ILIAS\LTI\Tool\ResourceLink $resourceLink) : array
1390 // {
1391 // global $DIC;
1392 // $ilDB = $DIC->database();
1393 //
1394 // $shares = array();
1395 //
1396 // $query = 'SELECT consumer_pk, resource_link_pk, share_approved ' .
1397 // "FROM {$this->dbTableNamePrefix}" . Tool\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
1398 // 'WHERE (primary_resource_link_pk = %s) ' .
1399 // 'ORDER BY consumer_pk';
1400 // $types = array("integer");
1401 // $values = array($resourceLink->getRecordId());
1402 // $rsShare = $ilDB->queryF($query, $types, $values);
1403 // if ($rsShare) {
1404 // while ($row = $ilDB->fetchObject($rsShare)) {
1405 // $share = new Tool\ResourceLinkShare();
1406 // $share->resourceLinkId = intval($row->resource_link_pk);
1407 // $share->approved = (intval($row->share_approved) === 1);
1408 // $shares[] = $share;
1409 // }
1410 // }
1411 //
1412 // return $shares;
1413 // }
1414
1415
1416 ###
1417 ### PlatformNonce methods
1418 ###
1419
1425 public function loadPlatformNonce(\ILIAS\LTI\ToolProvider\PlatformNonce $nonce): bool
1426 {
1427 $ilDB = $this->database;
1428
1429 $ok = true;
1430
1431 // Delete any expired nonce values
1432 $now = date("{$this->dateFormat} {$this->timeFormat}", time());//PRÜFEN UK
1433 $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::NONCE_TABLE_NAME . " WHERE expires <= %s";
1434 $types = array("timestamp");
1435 $values = array($now);
1436 $ilDB->manipulateF($query, $types, $values);
1437 // Load the nonce
1438 $query = "SELECT value AS T FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::NONCE_TABLE_NAME . ' WHERE (consumer_pk = %s) AND (value = %s)';
1439 $types = array("integer", "text");
1440 $values = array($nonce->getPlatform()->getRecordId(), $nonce->getValue());
1441 $rs_nonce = $ilDB->queryF($query, $types, $values);
1442 if ($rs_nonce) {
1443 $row = $ilDB->fetchObject($rs_nonce);
1444 if (!$row) {
1445 $ok = false;
1446 }
1447 }
1448
1449 return $ok;
1450 }
1451
1457 public function savePlatformNonce(\ILIAS\LTI\ToolProvider\PlatformNonce $nonce): bool
1458 {
1459 $ilDB = $this->database;
1460
1461 $expires = date("{$this->dateFormat} {$this->timeFormat}", $nonce->expires);
1462 $query = "INSERT INTO {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::NONCE_TABLE_NAME . " (consumer_pk, value, expires) VALUES (%s, %s, %s)";
1463 $types = array("integer", "text", "timestamp");
1464 $values = array($nonce->getPlatform()->getRecordId(), $nonce->getValue(), $expires);
1465 $ok = (bool) $ilDB->manipulateF($query, $types, $values);
1466
1467 return $ok;
1468 }
1469
1470
1471 ###
1472 ### ResourceLinkShareKey methods
1473 ###
1474
1480 // public function loadResourceLinkShareKey(\ILIAS\LTI\Tool\ResourceLinkShareKey $shareKey) : bool
1481 public function loadResourceLinkShareKey(ResourceLinkShareKey $shareKey): bool
1482 {
1483 $ilDB = $this->database;
1484
1485 $ok = false;
1486
1487 // Clear expired share keys
1488 $now = date("{$this->dateFormat} {$this->timeFormat}", time());
1489 $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . " WHERE expires <= '%s'";
1490 $types = array("timestamp");
1491 $values = array($now);
1492 $ilDB->manipulateF($query, $types, $values);
1493
1494 // Load share key
1495 // $id = mysql_real_escape_string($shareKey->getId());//ACHTUNG UK utf8
1496 $id = $shareKey->getId();
1497 $query = 'SELECT resource_link_pk, auto_approve, expires ' .
1498 "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' ' .
1499 "WHERE share_key_id = %s";
1500 $types = array("text");
1501 $values = array($id);
1502 $rsShareKey = $ilDB->queryF($query, $types, $values);
1503 if ($rsShareKey) {
1504 $row = $ilDB->fetchObject($rsShareKey);
1505 if ($row && (intval($row->resource_link_pk) === $shareKey->resourceLinkId)) {
1506 $shareKey->autoApprove = (intval($row->auto_approve) === 1);
1507 $shareKey->expires = strtotime($row->expires);
1508 $ok = true;
1509 }
1510 }
1511
1512 return $ok;
1513 }
1514
1520 // public function saveResourceLinkShareKey(\ILIAS\LTI\Tool\ResourceLinkShareKey $shareKey) : bool
1521 public function saveResourceLinkShareKey(ResourceLinkShareKey $shareKey): bool
1522 {
1523 $ilDB = $this->database;
1524
1525 if ($shareKey->autoApprove) {
1526 $approve = 1;
1527 } else {
1528 $approve = 0;
1529 }
1530 $expires = date("{$this->dateFormat} {$this->timeFormat}", $shareKey->expires);
1531 $query = "INSERT INTO {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' ' .
1532 '(share_key_id, resource_link_pk, auto_approve, expires) ' .
1533 "VALUES (%s, %s, %s, %s)";
1534 $types = array("text", "integer", "integer", "timestamp");
1535 $values = array($shareKey->getId(), $shareKey->resourceLinkId, $approve, $expires);
1536 $ok = (bool) $ilDB->manipulateF($query, $types, $values);
1537
1538 return $ok;
1539 }
1540
1546 public function deleteResourceLinkShareKey(ResourceLinkShareKey $shareKey): bool
1547 {
1548 $ilDB = $this->database;
1549
1550 $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . " WHERE share_key_id = %s";
1551 $types = array("text");
1552 $values = array($shareKey->getId());
1553 $ok = (bool) $ilDB->manipulateF($query, $types, $values);
1554
1555 if ($ok) {
1556 $shareKey->initialize();
1557 }
1558
1559 return $ok;
1560 }
1561
1562
1563 ###
1564 ### User methods
1565 ###
1566
1572 public function loadUserResult(\ILIAS\LTI\ToolProvider\User $userresult): bool
1573 {
1574 $ilDB = $this->database;
1575 $id = $userresult->getRecordId();
1576 if (!is_null($id)) {
1577 $query = 'SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
1578 'FROM ' . $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1579 'WHERE user_pk = ' . $ilDB->quote($id, 'integer');
1580 } else {
1581 $rid = $userresult->getResourceLink()->getRecordId();
1582 $uid = $userresult->getId(ToolProvider\Tool::ID_SCOPE_ID_ONLY);
1583
1584 $query = 'SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
1585 'FROM ' . $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1586 'WHERE resource_link_pk = ' . $ilDB->quote($rid, 'integer') . ' ' .
1587 'AND lti_user_id = ' . $ilDB->quote($uid, 'text');
1588 }
1589
1590 $this->logger->debug('Loading user with query: ' . $query);
1591
1592 $ok = false;
1593 try {
1594 $res = $ilDB->query($query);
1595 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1596 $userresult->setRecordId((int) $row->user_pk);
1597 $userresult->setResourceLinkId((int) $row->resource_link_pk);
1598 $userresult->ltiUserId = (string) $row->lti_user_id;
1599 $userresult->ltiResultSourcedId = (string) $row->lti_result_sourcedid;
1600 $userresult->created = strtotime($row->created);
1601 $userresult->updated = strtotime($row->updated);
1602 $ok = true;
1603 }
1604 } catch (ilDatabaseException $e) {
1605 $this->logger->error((string) $e);
1606 }
1607 return $ok;
1608 }
1609
1615 public function saveUserResult(\ILIAS\LTI\ToolProvider\User $userresult): bool
1616 {
1617 $ilDB = $this->database;
1618
1619 $this->logger->info('Save user called with ' . $userresult->created);
1620
1621 $time = time();
1622 $now = date($this->dateFormat . ' ' . $this->timeFormat, $time);
1623 if (is_null($userresult->created)) {
1624 // if (is_null($user->getRecordId())) {
1625 $userresult->setRecordId($ilDB->nextId($this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME));
1626 $userresult->created = $time;
1627 $rid = $userresult->getResourceLink()->getRecordId();
1628 $uid = $userresult->getId(ToolProvider\Tool::ID_SCOPE_ID_ONLY);
1629 $query = 'INSERT INTO ' . $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1630 '(user_pk,resource_link_pk,lti_user_id, lti_result_sourcedid, created, updated) ' .
1631 'VALUES( ' .
1632 $ilDB->quote($userresult->getRecordId(), 'integer') . ', ' .
1633 $ilDB->quote($rid, 'integer') . ', ' .
1634 $ilDB->quote($uid, 'text') . ', ' .
1635 $ilDB->quote($userresult->ltiResultSourcedId, 'text') . ', ' .
1636 $ilDB->quote($now, 'text') . ', ' .
1637 $ilDB->quote($now, 'text') .
1638 ')';
1639 } else {
1640 $query = 'UPDATE ' . $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1641 'SET lti_result_sourcedid = ' . $ilDB->quote($userresult->ltiResultSourcedId, 'text') . ', ' .
1642 'updated = ' . $ilDB->quote($now, 'text') . ' ' .
1643 'WHERE user_pk = ' . $ilDB->quote($userresult->getRecordId(), 'integer');
1644 }
1645
1646 $this->logger->debug('Saving user data with query: ' . $query);
1647
1648 $ok = false;
1649 try {
1650 $ilDB->manipulate($query);
1651 $userresult->updated = $time;
1652 $ok = true;
1653 } catch (ilDatabaseException $e) {
1654 $this->logger->error($e->getMessage());
1655 }
1656
1657 return $ok;
1658 }
1659
1665 public function deleteUser(\ILIAS\LTI\ToolProvider\User $user): bool
1666 {
1667 $ilDB = $this->database;
1668
1669 $query = 'DELETE from ' . $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1670 'WHERE user_pk = ' . $ilDB->quote($user->getRecordId(), 'integer');
1671
1672 $ok = false;
1673 try {
1674 $ilDB->manipulate($query);
1675 $user->initialize();
1676 $ok = true;
1677 } catch (ilDatabaseException $e) {
1678 $this->logger->error((string) $e);
1679 }
1680 return $ok;
1681 }
1682
1692 int $a_ref_id,
1693 string $a_lti_user,
1694 int $a_ext_consumer,
1695 ilDateTime $since = null
1696 ): array {
1697 $db = $this->database;
1698
1699 $logger = ilLoggerFactory::getLogger('ltis');
1700
1701 $query = 'select rl.resource_link_pk ' .
1702 'from lti2_user_result ur join lti2_resource_link rl on rl.resource_link_pk = ur.resource_link_pk ' .
1703 'join lti2_consumer c on rl.consumer_pk = c.consumer_pk ' .
1704 'join lti_ext_consumer ec on c.ext_consumer_id = ec.id ' .
1705 'where c.enabled = ' . $db->quote(1, 'integer') . ' ' .
1706 'and ref_id = ' . $db->quote($a_ref_id, 'integer') . ' ' .
1707 'and ur.lti_user_id = ' . $db->quote($a_lti_user, 'text') . ' ' .
1708 'and ec.id = ' . $db->quote($a_ext_consumer, 'integer');
1709 $logger->debug($query);
1710 $resource_links = [];
1711 try {
1712 $res = $db->query($query);
1713 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1714 $resource_links[] = $row->resource_link_pk;
1715 }
1716 } catch (ilDatabaseException $e) {
1717 $logger->error('Query execution failed with message: ' . $e->getMessage());
1718 }
1719 return $resource_links;
1720 }
1721
1727 {
1728 $db = $this->database;
1729 $logger = ilLoggerFactory::getLogger('ltis');
1730
1731 $query = 'select lti_user_id, rl.resource_link_pk, ec.id, ref_id ' .
1732 'from lti2_resource_link rl join lti2_user_result ur on rl.resource_link_pk = ur.resource_link_pk ' .
1733 'join lti2_consumer c on rl.consumer_pk = c.consumer_pk ' .
1734 'join lti_ext_consumer ec on ext_consumer_id = ec.id ' .
1735 'where c.enabled = ' . $db->quote(1, 'integer') . ' ' .
1736 'and rl.updated > ' . $db->quote($since->get(IL_CAL_DATETIME), 'timestamp');
1737 $res = $db->query($query);
1738
1739 $results = [];
1740 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1741 $results[$row->id . '__' . $row->lti_user_id][] = $row->resource_link_pk . '__' . $row->ref_id;
1742 }
1743 return $results;
1744 }
1745
1746 public static function getDataConnector(object $db = null, string $dbTableNamePrefix = '', string $type = ''): ilLTIDataConnector
1747 {
1749 return $dataConnector;
1750 }
1751}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class to represent an HTTP message.
Definition: AccessToken.php:33
Class to represent a platform context.
Definition: Context.php:34
Class to provide a connection to a persistent store for LTI objects.
Class to represent a platform nonce.
Class to represent a platform.
Definition: Platform.php:36
Class to represent a platform resource link share key.
initialize()
Initialise the resource link share key.
Class to represent a platform resource link share.
Class to represent an LTI Tool.
Definition: Tool.php:39
Class to represent a platform user.
Definition: UserResult.php:31
Class to represent a platform user.
Definition: User.php:31
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@classDescription Date and time handling
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
deleteResourceLinkShareKey(ResourceLinkShareKey $shareKey)
Delete resource link share key object.
lookupRecordIdByGlobalSettingsAndRefId(ilLTIPlatform $platform)
Lookup record id for global settings and ref_id.
lookupResourcesForAllUsersSinceDate(ilDateTime $since)
savePlatformNonce(\ILIAS\LTI\ToolProvider\PlatformNonce $nonce)
Save nonce object.
loadContext(Context $context)
Load context object.
static getDataConnector(object $db=null, string $dbTableNamePrefix='', string $type='')
deleteUser(\ILIAS\LTI\ToolProvider\User $user)
Delete user object.
lookupResourcesForUserObjectRelation(int $a_ref_id, string $a_lti_user, int $a_ext_consumer, ilDateTime $since=null)
Lookup resources for user object relation.
saveUserResult(\ILIAS\LTI\ToolProvider\User $userresult)
Save user object.
loadPlatformNonce(\ILIAS\LTI\ToolProvider\PlatformNonce $nonce)
Load nonce object.
loadGlobalToolConsumerSettings(ilLTIPlatform $platform)
Load global tool consumer settings in consumer.
saveResourceLinkShareKey(ResourceLinkShareKey $shareKey)
Save resource link share key object.
loadPlatform(\ILIAS\LTI\ToolProvider\Platform $platform)
Load platform object.
loadResourceLink(ResourceLink $resourceLink)
Load resource link object.
deleteContext(Context $context)
Delete context object.
loadResourceLinkShareKey(ResourceLinkShareKey $shareKey)
Load resource link share key object.
saveGlobalToolConsumerSettings(ilLTIPlatform $platform)
Save lti_ext_consumer.
deleteToolConsumer(\ILIAS\LTI\ToolProvider\Platform $platform)
Delete tool consumer object.
getUserResultSourcedIDsResourceLink(ResourceLink $resourceLink, bool $localOnly, int $idScope)
Get array of user objects.
loadUserResult(\ILIAS\LTI\ToolProvider\User $userresult)
Load user object.
getGlobalToolConsumerSettings()
Get global consumer settings.
saveContext(Context $context)
Save context object.
__construct()
ilLTIDataConnector constructor.
saveResourceLink(ResourceLink $resourceLink)
Save resource link object.
deleteGlobalToolConsumerSettings(ilLTIPlatform $platform)
Delete global tool consumer settings.
saveToolConsumerILIAS(ilLTIPlatform $platform)
Save extended tool consumer object with ILIAS extensions.
deleteResourceLink(ResourceLink $resourceLink)
Delete resource link object.
LTI provider for LTI launch.
initialize()
Initialise the platform.
setDescription(string $description)
setTitle(string $title)
setActive(bool $value)
setLanguage(string $lang)
setPrefix(string $prefix)
setExtConsumerId(int $a_id)
setRole(int $role_id)
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
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 $key
Consumer key/client ID value.
Definition: System.php:193
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
Class ChatMainBarProvider \MainMenu\Provider.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$query
$type
$results
$context
Definition: webdav.php:29