ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilLTIDataConnector Class Reference

Class to represent an LTI Data Connector for ILIAS. More...

+ Inheritance diagram for ilLTIDataConnector:
+ Collaboration diagram for ilLTIDataConnector:

Public Member Functions

 __construct ()
 ilLTIDataConnector constructor. More...
 
 loadToolConsumer ($consumer)
 Load tool consumer object. More...
 
 loadObjectToolConsumerSettings (ilLTIToolConsumer $consumer)
 Load tool consumer settings. More...
 
 loadGlobalToolConsumerSettings (ilLTIToolConsumer $consumer)
 Load global tool consumer settings in consumer. More...
 
 loadToolConsumerILIAS (ilLTIToolConsumer $consumer)
 Load extended tool consumer object with ILIAS extension. More...
 
 lookupRecordIdByGlobalSettingsAndRefId (ilLTIToolConsumer $consumer)
 Lookup record id for global settings and ref_id. More...
 
 saveToolConsumer ($consumer)
 Save tool consumer object. More...
 
 saveGlobalToolConsumerSettings (ilLTIToolConsumer $consumer)
 Save lti_ext_consumer type $DIC. More...
 
 saveToolConsumerILIAS (ilLTIToolConsumer $consumer)
 Save extended tool consumer object with ILIAS extensions. More...
 
 deleteGlobalToolConsumerSettings (ilLTIToolConsumer $consumer)
 Delete global tool consumer settings. More...
 
 deleteToolConsumer ($consumer)
 Delete tool consumer object. More...
 
 getGlobalToolConsumerSettings ()
 Get global consumer settings type $DIC. More...
 
 getToolConsumers ()
 
 loadToolProxy ($toolProxy)
 
 saveToolProxy ($toolProxy)
 
 deleteToolProxy ($toolProxy)
 
 loadContext ($context)
 Load context object. More...
 
 saveContext ($context)
 Save context object. More...
 
 deleteContext ($context)
 Delete context object. More...
 
 loadResourceLink ($resourceLink)
 Load resource link object. More...
 
 saveResourceLink ($resourceLink)
 Save resource link object. More...
 
 deleteResourceLink ($resourceLink)
 Delete resource link object. More...
 
 getUserResultSourcedIDsResourceLink ($resourceLink, $localOnly, $idScope)
 Get array of user objects. More...
 
 getSharesResourceLink ($resourceLink)
 Get array of shares defined for this resource link. More...
 
 loadConsumerNonce ($nonce)
 Load nonce object. More...
 
 saveConsumerNonce ($nonce)
 Save nonce object. More...
 
 loadResourceLinkShareKey ($shareKey)
 Load resource link share key object. More...
 
 saveResourceLinkShareKey ($shareKey)
 Save resource link share key object. More...
 
 deleteResourceLinkShareKey ($shareKey)
 Delete resource link share key object. More...
 
 loadUser ($user)
 Load user object. More...
 
 saveUser ($user)
 Save user object. More...
 
 deleteUser ($user)
 Delete user object. More...
 
 lookupResourcesForUserObjectRelation ($a_ref_id, $a_lti_user, $a_ext_consumer, ilDateTime $since=null)
 Lookup resources for user object relation. More...
 
 lookupResourcesForAllUsersSinceDate (ilDateTime $since)
 

Private Attributes

 $logger = null
 

Detailed Description

Class to represent an LTI Data Connector for ILIAS.

Author
Uwe Kohnle based on Stephen P Vickers svick.nosp@m.ers@.nosp@m.imsgl.nosp@m.obal.nosp@m..org
Date
2016
Version
3.0.0 http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0

Definition at line 26 of file class.ilLTIDataConnector.php.

Constructor & Destructor Documentation

◆ __construct()

ilLTIDataConnector::__construct ( )

ilLTIDataConnector constructor.

Definition at line 37 of file class.ilLTIDataConnector.php.

References $DIC.

38  {
39  global $DIC;
40 
41  $this->logger = $DIC->logger()->lti();
42  $this->db = "";
43  $this->dbTableNamePrefix = "";
44  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ deleteContext()

ilLTIDataConnector::deleteContext (   $context)

Delete context object.

Parameters
Context$contextContext object
Returns
boolean True if the Context object was successfully deleted

Definition at line 875 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, $query, and array.

876  {
877  global $DIC;
878  $ilDB = $DIC['ilDB'];
879 
880  // Delete any outstanding share keys for resource links for this context
881  $query = 'DELETE sk ' .
882  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' sk ' .
883  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON sk.resource_link_pk = rl.resource_link_pk ' .
884  'WHERE rl.context_pk = %s';
885  $types = array("integer");
886  $values = array($context->getRecordId());
887  $ilDB->manipulateF($query, $types, $values);
888 
889  // Delete any users in resource links for this context
890  $query = 'DELETE u ' .
891  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' u ' .
892  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON u.resource_link_pk = rl.resource_link_pk ' .
893  'WHERE rl.context_pk = %s';
894  $types = array("integer");
895  $values = array($context->getRecordId());
896  $ilDB->manipulateF($query, $types, $values);
897 
898  // Update any resource links for which this consumer is acting as a primary resource link
899  $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' prl ' .
900  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON prl.primary_resource_link_pk = rl.resource_link_pk ' .
901  'SET prl.primary_resource_link_pk = null, prl.share_approved = null ' .
902  'WHERE rl.context_pk = %s';
903  $types = array("integer");
904  $values = array($context->getRecordId());
905  $ilDB->manipulateF($query, $types, $values);
906 
907  // Delete any resource links for this consumer
908  $query = 'DELETE rl ' .
909  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ' .
910  'WHERE rl.context_pk = %s';
911  $types = array("integer");
912  $values = array($context->getRecordId());
913  $ilDB->manipulateF($query, $types, $values);
914 
915  // Delete context
916  $query = 'DELETE c ' .
917  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ' .
918  'WHERE c.context_pk = %s';
919  $types = array("integer");
920  $values = array($context->getRecordId());
921  $ok = $ilDB->manipulateF($query, $types, $values);
922  if ($ok) {
923  $context->initialize();
924  }
925 
926  return $ok;
927  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
global $ilDB

◆ deleteGlobalToolConsumerSettings()

ilLTIDataConnector::deleteGlobalToolConsumerSettings ( ilLTIToolConsumer  $consumer)

Delete global tool consumer settings.

Definition at line 504 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $query, array, ilLTIToolConsumer\getExtConsumerId(), and IMSGlobal\LTI\ToolProvider\ToolConsumer\initialize().

Referenced by ilLTIToolConsumer\deleteGlobalToolConsumerSettings().

505  {
506  global $DIC;
507  $ilDB = $DIC['ilDB'];
508 
509  $query = 'DELETE FROM lti_ext_consumer WHERE id = %s';
510  $types = array("integer");
511  $values = array($consumer->getExtConsumerId());
512  $ilDB->manipulateF($query, $types, $values);
513 
514  $query = 'DELETE FROM lti_ext_consumer_otype WHERE consumer_id = %s';
515  $types = array("integer");
516  $values = array($consumer->getExtConsumerId());
517  $ilDB->manipulateF($query, $types, $values);
518 
519 
520  // delete all assigned lti consumers
521  $consumer->initialize();
522  return true;
523  }
global $DIC
Definition: saml.php:7
initialize()
Initialise the tool consumer.
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteResourceLink()

ilLTIDataConnector::deleteResourceLink (   $resourceLink)

Delete resource link object.

Parameters
ResourceLink$resourceLinkResource_Link object
Returns
boolean True if the resource link object was successfully deleted

Definition at line 1088 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, $query, and array.

1089  {
1090  global $DIC;
1091  $ilDB = $DIC['ilDB'];
1092 
1093  // Delete any outstanding share keys for resource links for this consumer
1094  $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' ' .
1095  'WHERE (resource_link_pk = %s)';
1096  $types = array("integer");
1097  $values = array($resourceLink->getRecordId());
1098  $ok = $ilDB->manipulateF($query, $types, $values);
1099 
1100  // Delete users
1101  if ($ok) {
1102  $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1103  'WHERE (resource_link_pk = %s)';
1104  $types = array("integer");
1105  $values = array($resourceLink->getRecordId());
1106  $ok = $ilDB->manipulateF($query, $types, $values);
1107  }
1108 
1109  // Update any resource links for which this is the primary resource link
1110  if ($ok) {
1111  $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
1112  'SET primary_resource_link_pk = NULL ' .
1113  'WHERE (primary_resource_link_pk = %s)';
1114  $types = array("integer");
1115  $values = array($resourceLink->getRecordId());
1116  $ok = $ilDB->manipulateF($query, $types, $values);
1117  }
1118 
1119  // Delete resource link
1120  if ($ok) {
1121  $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
1122  'WHERE (resource_link_pk = %s)';
1123  $types = array("integer");
1124  $values = array($resourceLink->getRecordId());
1125  $ok = $ilDB->manipulateF($query, $types, $values);
1126  }
1127 
1128  if ($ok) {
1129  $resourceLink->initialize();
1130  }
1131 
1132  return $ok;
1133  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
global $ilDB

◆ deleteResourceLinkShareKey()

ilLTIDataConnector::deleteResourceLinkShareKey (   $shareKey)

Delete resource link share key object.

Parameters
ResourceLinkShareKey$shareKeyResource link share key object
Returns
boolean True if the resource link share key object was successfully deleted

Definition at line 1365 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, $query, and array.

1366  {
1367  global $DIC;
1368  $ilDB = $DIC['ilDB'];
1369 
1370  $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . " WHERE share_key_id = %s";
1371  $types = array("text");
1372  $values = array($shareKey->getId());
1373  $ok = $ilDB->manipulateF($query, $types, $values);
1374 
1375  if ($ok) {
1376  $shareKey->initialize();
1377  }
1378 
1379  return $ok;
1380  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
global $ilDB

◆ deleteToolConsumer()

ilLTIDataConnector::deleteToolConsumer (   $consumer)

Delete tool consumer object.

Parameters
ToolConsumer$consumerConsumer object
Returns
boolean True if the tool consumer object was successfully deleted

Definition at line 532 of file class.ilLTIDataConnector.php.

References $consumer, $DIC, $ilDB, $ok, $query, and array.

533  {
534  global $DIC;
535  $ilDB = $DIC['ilDB'];
536 
537 
538  // Delete any nonce values for this consumer
539  $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::NONCE_TABLE_NAME . ' WHERE consumer_pk = %s';
540  $types = array("integer");
541  $values = array($consumer->getRecordId());
542  $ilDB->manipulateF($query, $types, $values);
543 
544  // Delete any outstanding share keys for resource links for this consumer
545  $query = 'DELETE sk ' .
546  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' sk ' .
547  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON sk.resource_link_pk = rl.resource_link_pk ' .
548  'WHERE rl.consumer_pk = %s';
549  $types = array("integer");
550  $values = array($consumer->getRecordId());
551  $ilDB->manipulateF($query, $types, $values);
552 
553  // Delete any outstanding share keys for resource links for contexts in this consumer
554  $query = 'DELETE sk ' .
555  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' sk ' .
556  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON sk.resource_link_pk = rl.resource_link_pk ' .
557  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ON rl.context_pk = c.context_pk ' .
558  'WHERE c.consumer_pk = %s';
559  $types = array("integer");
560  $values = array($consumer->getRecordId());
561  $ilDB->manipulateF($query, $types, $values);
562 
563  // Delete any users in resource links for this consumer
564  $query = 'DELETE u ' .
565  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' u ' .
566  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON u.resource_link_pk = rl.resource_link_pk ' .
567  'WHERE rl.consumer_pk = %s';
568  $types = array("integer");
569  $values = array($consumer->getRecordId());
570  $ilDB->manipulateF($query, $types, $values);
571 
572  // Delete any users in resource links for contexts in this consumer
573  $query = 'DELETE u ' .
574  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' u ' .
575  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON u.resource_link_pk = rl.resource_link_pk ' .
576  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ON rl.context_pk = c.context_pk ' .
577  'WHERE c.consumer_pk = %s';
578  $types = array("integer");
579  $values = array($consumer->getRecordId());
580  $ilDB->manipulateF($query, $types, $values);
581 
582  // Update any resource links for which this consumer is acting as a primary resource link
583  $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' prl ' .
584  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON prl.primary_resource_link_pk = rl.resource_link_pk ' .
585  'SET prl.primary_resource_link_pk = NULL, prl.share_approved = NULL ' .
586  'WHERE rl.consumer_pk = %s';
587  $types = array("integer");
588  $values = array($consumer->getRecordId());
589  $ilDB->manipulateF($query, $types, $values);
590 
591  // Update any resource links for contexts in which this consumer is acting as a primary resource link
592  $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' prl ' .
593  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ON prl.primary_resource_link_pk = rl.resource_link_pk ' .
594  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ON rl.context_pk = c.context_pk ' .
595  'SET prl.primary_resource_link_pk = NULL, prl.share_approved = NULL ' .
596  'WHERE c.consumer_pk = %s';
597  $types = array("integer");
598  $values = array($consumer->getRecordId());
599  $ilDB->manipulateF($query, $types, $values);
600 
601  // Delete any resource links for this consumer
602  $query = 'DELETE rl ' .
603  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ' .
604  'WHERE rl.consumer_pk = %s';
605  $types = array("integer");
606  $values = array($consumer->getRecordId());
607  $ilDB->manipulateF($query, $types, $values);
608 
609  // Delete any resource links for contexts in this consumer
610  $query = 'DELETE rl ' .
611  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' rl ' .
612  "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ON rl.context_pk = c.context_pk ' .
613  'WHERE c.consumer_pk = %s';
614  $types = array("integer");
615  $values = array($consumer->getRecordId());
616  $ilDB->manipulateF($query, $types, $values);
617 
618  // Delete any contexts for this consumer
619  $query = 'DELETE c ' .
620  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ' .
621  'WHERE c.consumer_pk = %s';
622  $types = array("integer");
623  $values = array($consumer->getRecordId());
624  $ilDB->manipulateF($query, $types, $values);
625 
626  // Delete consumer
627  $query = 'DELETE c ' .
628  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONSUMER_TABLE_NAME . ' c ' .
629  'WHERE c.consumer_pk = %s';
630  $types = array("integer");
631  $values = array($consumer->getRecordId());
632  $ilDB->manipulateF($query, $types, $values);
633 
634  if ($ok) {
635  $consumer->initialize();
636  }
637 
638  return $ok;
639  }
global $DIC
Definition: saml.php:7
$query
$consumer
Definition: demo.php:30
Create styles array
The data for the language used.
global $ilDB

◆ deleteToolProxy()

ilLTIDataConnector::deleteToolProxy (   $toolProxy)

Definition at line 769 of file class.ilLTIDataConnector.php.

770  {
771  return false;
772  }

◆ deleteUser()

ilLTIDataConnector::deleteUser (   $user)

Delete user object.

Parameters
User$userUser object
Returns
boolean True if the user object was successfully deleted

Definition at line 1544 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, and $query.

1545  {
1546  global $DIC;
1547  $ilDB = $DIC->database();
1548 
1549  $query = 'DELETE from ' . $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1550  'WHERE user_pk = ' . $ilDB->quote($user->getRecordId(), 'integer');
1551 
1552  $ok = false;
1553  try {
1554  $ilDB->manipulate($query);
1555  $user->initialize();
1556  $ok = true;
1557  } catch (ilDatabaseException $e) {
1558  $this->logger->error($e);
1559  }
1560  return $ok;
1561 
1562  // $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1563  // 'WHERE (user_pk = %d)',
1564  // $user->getRecordId());
1565  // $ok = mysql_query($sql);
1566 
1567  // if ($ok) {
1568  // $user->initialize();
1569  // }
1570 
1571  // return $ok;
1572  }
global $DIC
Definition: saml.php:7
Class ilDatabaseException.
$query
global $ilDB

◆ getGlobalToolConsumerSettings()

ilLTIDataConnector::getGlobalToolConsumerSettings ( )

Get global consumer settings type $DIC.

Returns
[]

Definition at line 646 of file class.ilLTIDataConnector.php.

References $consumer, $DIC, $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

647  {
648  global $DIC;
649  $ilDB = $DIC['ilDB'];
650 
651  $consumers = array();
652  $query = 'SELECT * from lti_ext_consumer ';
653  $res = $ilDB->query($query);
654  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
655  $consumer = new ilLTIToolConsumer(null, $this);
656  $consumer->setExtConsumerId($row->id);
657  $consumer->setTitle($row->title);
658  $consumer->setDescription($row->description);
659  $consumer->setPrefix($row->prefix);
660  $consumer->setLanguage($row->user_language);
661  $consumer->setRole($row->role);
662  $consumer->setActive($row->active);
663  $consumers[] = $consumer;
664  }
665  return $consumers;
666  }
global $DIC
Definition: saml.php:7
LTI provider for LTI launch.
foreach($_POST as $key=> $value) $res
$query
$consumer
Definition: demo.php:30
Create styles array
The data for the language used.
global $ilDB

◆ getSharesResourceLink()

ilLTIDataConnector::getSharesResourceLink (   $resourceLink)

Get array of shares defined for this resource link.

Parameters
ResourceLink$resourceLinkResource_Link object
Returns
array Array of ResourceLinkShare objects

Definition at line 1196 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $query, $row, and array.

1197  {
1198  global $DIC;
1199  $ilDB = $DIC['ilDB'];
1200 
1201  $shares = array();
1202 
1203  $query = 'SELECT consumer_pk, resource_link_pk, share_approved ' .
1204  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
1205  'WHERE (primary_resource_link_pk = %s) ' .
1206  'ORDER BY consumer_pk';
1207  $types = array("integer");
1208  $values = array($resourceLink->getRecordId());
1209  $rsShare = $ilDB->queryF($query, $types, $values);
1210  if ($rsShare) {
1211  while ($row = $ilDB->fetchObject($rsShare)) {
1212  $share = new ToolProvider\ResourceLinkShare();
1213  $share->resourceLinkId = intval($row->resource_link_pk);
1214  $share->approved = (intval($row->share_approved) === 1);
1215  $shares[] = $share;
1216  }
1217  }
1218 
1219  return $shares;
1220  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
global $ilDB

◆ getToolConsumers()

ilLTIDataConnector::getToolConsumers ( )

Definition at line 673 of file class.ilLTIDataConnector.php.

References $consumer, $DIC, $ilDB, $query, $res, $row, and array.

674  {
675  global $DIC;
676  $ilDB = $DIC['ilDB'];
677  require_once 'Services/LTI/classes/InternalProvider/class.ilLTIToolConsumer.php';
678  $consumers = array();
679  $query = 'SELECT consumer_pk, name, consumer_key256, consumer_key, secret, lti_version, ' .
680  'consumer_name, consumer_version, consumer_guid, ' .
681  'profile, tool_proxy, settings, protected, enabled, ' .
682  'enable_from, enable_until, last_access, created, updated, ' .
683  'title, description, prefix, user_language, role, local_role_always_member, default_skin ' .
684  'FROM lti2_consumer, lti_ext_consumer ' .
685  'WHERE lti_ext_consumer.id = consumer_pk';
686 
687  // $sql = 'SELECT consumer_pk, consumer_key, consumer_key, name, secret, lti_version, consumer_name, consumer_version, consumer_guid, ' .
688  // 'profile, tool_proxy, settings, ' .
689  // 'protected, enabled, enable_from, enable_until, last_access, created, updated ' .
690  // "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONSUMER_TABLE_NAME . ' ' .
691  // 'ORDER BY name';
692  // $rsConsumers = mysql_query($sql);
693  // if ($rsConsumers) {
694  // while ($row = mysql_fetch_object($rsConsumers)) {
695  $res = $ilDB->query($query);
696  // if ($rsConsumer) {
697  while ($row = $ilDB->fetchObject($res)) {
698  // $consumer = new ToolProvider\ToolConsumer($row->consumer_key, $this); //ACHTUNG: FEHLER IN BIBLIOTHEK; $row->consumer_key ist i.d.R. null
699  $consumer = new ilLTIToolConsumer(null, $this);
700  $consumer->setRecordId(intval($row->consumer_pk));
701  $consumer->name = $row->name;
702  $consumer->secret = $row->secret;
703  $consumer->ltiVersion = $row->lti_version;
704  $consumer->consumerName = $row->consumer_name;
705  $consumer->consumerVersion = $row->consumer_version;
706  $consumer->consumerGuid = $row->consumer_guid;
707  $consumer->profile = json_decode($row->profile);
708  $consumer->toolProxy = $row->tool_proxy;
709  $settings = unserialize($row->settings);
710  if (!is_array($settings)) {
711  $settings = array();
712  }
713  $consumer->setSettings($settings);
714  $consumer->protected = (intval($row->protected) === 1);
715  $consumer->enabled = (intval($row->enabled) === 1);
716  $consumer->enableFrom = null;
717  if (!is_null($row->enable_from)) {
718  $consumer->enableFrom = strtotime($row->enable_from);
719  }
720  $consumer->enableUntil = null;
721  if (!is_null($row->enable_until)) {
722  $consumer->enableUntil = strtotime($row->enable_until);
723  }
724  $consumer->lastAccess = null;
725  if (!is_null($row->last_access)) {
726  $consumer->lastAccess = strtotime($row->last_access);
727  }
728  $consumer->created = strtotime($row->created);
729  $consumer->updated = strtotime($row->updated);
730  //ILIAS specific
731  $consumer->setTitle($row->title);
732  $consumer->setDescription($row->description);
733  $consumer->setPrefix($row->prefix);
734  $consumer->setLanguage($row->user_language);
735  $consumer->setRole($row->role);
736  // local_role_always_member
737  // default_skin
738  $consumer->setKey($row->consumer_key256);//ACHTUNG: hier müsste evtl. consumer_key sein
739  $consumers[] = $consumer;
740  }
741  // mysql_free_result($rsConsumers);
742  // }
743 
744  return $consumers;
745  }
global $DIC
Definition: saml.php:7
LTI provider for LTI launch.
foreach($_POST as $key=> $value) $res
$query
$consumer
Definition: demo.php:30
Create styles array
The data for the language used.
global $ilDB

◆ getUserResultSourcedIDsResourceLink()

ilLTIDataConnector::getUserResultSourcedIDsResourceLink (   $resourceLink,
  $localOnly,
  $idScope 
)

Get array of user objects.

Obtain an array of User objects for users with a result sourcedId. The array may include users from other resource links which are sharing this resource link. It may also be optionally indexed by the user ID of a specified scope.

Parameters
ResourceLink$resourceLinkResource link object
boolean$localOnlyTrue if only users within the resource link are to be returned (excluding users sharing this resource link)
int$idScopeScope value to use for user IDs
Returns
array Array of User objects

Definition at line 1147 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $users, and array.

1148  {
1149  global $DIC;
1150  $ilDB = $DIC['ilDB'];
1151 
1152  $users = array();
1153 
1154  // if ($localOnly) {
1155  // $query = 'SELECT u.user_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
1156  // "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' AS u ' .
1157  // "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' AS rl ' .
1158  // 'ON u.resource_link_pk = rl.resource_link_pk ' .
1159  // "WHERE (rl.resource_link_pk = %d) AND (rl.primary_resource_link_pk IS NULL)",
1160  // $resourceLink->getRecordId());
1161  // } else {
1162  // $query = 'SELECT u.user_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
1163  // "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' AS u ' .
1164  // "INNER JOIN {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' AS rl ' .
1165  // 'ON u.resource_link_pk = rl.resource_link_pk ' .
1166  // 'WHERE ((rl.resource_link_pk = %d) AND (rl.primary_resource_link_pk IS NULL)) OR ' .
1167  // '((rl.primary_resource_link_pk = %d) AND (share_approved = 1))',
1168  // $resourceLink->getRecordId(), $resourceLink->getRecordId());
1169  // }
1170  // $rsUser = mysql_query($sql);
1171  // if ($rsUser) {
1172  // while ($row = $ilDB->fetchObject($rsUser)) {
1173  // $user = ToolProvider\User::fromResourceLink($resourceLink, $row->lti_user_id);
1174  // $user->setRecordId(intval($row->user_pk));
1175  // $user->ltiResultSourcedId = $row->lti_result_sourcedid;
1176  // $user->created = strtotime($row->created);
1177  // $user->updated = strtotime($row->updated);
1178  // if (is_null($idScope)) {
1179  // $users[] = $user;
1180  // } else {
1181  // $users[$user->getId($idScope)] = $user;
1182  // }
1183  // }
1184  // }
1185 
1186  return $users;
1187  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
global $ilDB

◆ loadConsumerNonce()

ilLTIDataConnector::loadConsumerNonce (   $nonce)

Load nonce object.

Parameters
ConsumerNonce$nonceNonce object
Returns
boolean True if the nonce object was successfully loaded

Definition at line 1234 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, $query, $row, array, date, and time.

1235  {
1236  global $DIC;
1237  $ilDB = $DIC['ilDB'];
1238 
1239  $ok = true;
1240 
1241  // Delete any expired nonce values
1242  $now = date("{$this->dateFormat} {$this->timeFormat}", time());//PRÃœFEN UK
1243  $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::NONCE_TABLE_NAME . " WHERE expires <= %s";
1244  $types = array("timestamp");
1245  $values = array($now);
1246  $ilDB->manipulateF($query, $types, $values);
1247  // Load the nonce
1248  $query = "SELECT value AS T FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::NONCE_TABLE_NAME . ' WHERE (consumer_pk = %s) AND (value = %s)';
1249  $types = array("integer","text");
1250  $values = array($nonce->getConsumer()->getRecordId(), $nonce->getValue());
1251  $rs_nonce = $ilDB->queryF($query, $types, $values);
1252  if ($rs_nonce) {
1253  $row = $ilDB->fetchObject($rs_nonce);
1254  if (!$row) {
1255  $ok = false;
1256  }
1257  }
1258 
1259  return $ok;
1260  }
global $DIC
Definition: saml.php:7
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$query
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ loadContext()

ilLTIDataConnector::loadContext (   $context)

Load context object.

Parameters
Context$contextContext object
Returns
boolean True if the context object was successfully loaded

Definition at line 785 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, $query, $row, and array.

786  {
787  global $DIC;
788  $ilDB = $DIC['ilDB'];
789 
790  $ok = false;
791  if (!empty($context->getRecordId())) {
792  $query = 'SELECT context_pk, consumer_pk, lti_context_id, settings, created, updated ' .
793  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' ' .
794  'WHERE (context_pk = %s)';
795  $types = array("integer");
796  $values = array($context->getRecordId());
797  } else {
798  $query = 'SELECT context_pk, consumer_pk, lti_context_id, settings, created, updated ' .
799  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' ' .
800  'WHERE (consumer_pk = %s) AND (lti_context_id = %s)';
801  $types = array("integer","text");
802  $values = array($context->getConsumer()->getRecordId(), $context->ltiContextId);
803  }
804  $rs_context = $ilDB->queryF($query, $types, $values);
805  if ($rs_context) {
806  $row = $ilDB->fetchObject($rs_context);
807  if ($row) {
808  $context->setRecordId(intval($row->context_pk));
809  $context->setConsumerId(intval($row->consumer_pk));
810  $context->ltiContextId = $row->lti_context_id;
811  $settings = unserialize($row->settings);
812  if (!is_array($settings)) {
813  $settings = array();
814  }
815  $context->setSettings($settings);
816  $context->created = strtotime($row->created);
817  $context->updated = strtotime($row->updated);
818  $ok = true;
819  }
820  }
821 
822  return $ok;
823  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
global $ilDB

◆ loadGlobalToolConsumerSettings()

ilLTIDataConnector::loadGlobalToolConsumerSettings ( ilLTIToolConsumer  $consumer)

Load global tool consumer settings in consumer.

Parameters
ilLTIToolConsumer$consumer

Definition at line 166 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, ilLTIToolConsumer\getExtConsumerId(), ilLTIToolConsumer\setActive(), ilLTIToolConsumer\setDescription(), ilLTIToolConsumer\setLanguage(), ilLTIToolConsumer\setPrefix(), ilLTIToolConsumer\setRole(), and ilLTIToolConsumer\setTitle().

Referenced by loadObjectToolConsumerSettings(), and loadToolConsumerILIAS().

167  {
168  global $DIC;
169  $ilDB = $DIC['ilDB'];
170 
171  $query = 'SELECT * from lti_ext_consumer where id = ' . $ilDB->quote($consumer->getExtConsumerId(), 'integer');
172  $res = $ilDB->query($query);
173  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
174  $consumer->setTitle($row->title);
175  $consumer->setDescription($row->description);
176  $consumer->setPrefix($row->prefix);
177  $consumer->setLanguage($row->user_language);
178  $consumer->setRole($row->role);
179  $consumer->setActive($row->active);
180  return true;
181  }
182  return false;
183  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadObjectToolConsumerSettings()

ilLTIDataConnector::loadObjectToolConsumerSettings ( ilLTIToolConsumer  $consumer)

Load tool consumer settings.

Parameters
ilLTIToolConsumer$consumer

Definition at line 141 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, ilLTIToolConsumer\getExtConsumerId(), loadGlobalToolConsumerSettings(), ilLTIToolConsumer\setActive(), ilLTIToolConsumer\setDescription(), ilLTIToolConsumer\setLanguage(), ilLTIToolConsumer\setPrefix(), ilLTIToolConsumer\setRole(), and ilLTIToolConsumer\setTitle().

142  {
143  $this->loadGlobalToolConsumerSettings($consumer);
144 
145  global $DIC;
146  $ilDB = $DIC['ilDB'];
147 
148  $query = 'SELECT * from lti2_consumer where id = ' . $ilDB->quote($consumer->getExtConsumerId(), 'integer');
149  $res = $ilDB->query($query);
150  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
151  $consumer->setTitle($row->title);
152  $consumer->setDescription($row->description);
153  $consumer->setPrefix($row->prefix);
154  $consumer->setLanguage($row->user_language);
155  $consumer->setRole($row->role);
156  $consumer->setActive($row->active);
157  return true;
158  }
159  return false;
160  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
loadGlobalToolConsumerSettings(ilLTIToolConsumer $consumer)
Load global tool consumer settings in consumer.
+ Here is the call graph for this function:

◆ loadResourceLink()

ilLTIDataConnector::loadResourceLink (   $resourceLink)

Load resource link object.

Parameters
ResourceLink$resourceLinkResource_Link object
Returns
boolean True if the resource link object was successfully loaded

Definition at line 940 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, $query, $row, and array.

941  {
942  global $DIC;
943  $ilDB = $DIC['ilDB'];
944 
945  $ok = false;
946  if (!empty($resourceLink->getRecordId())) {
947  $query = 'SELECT resource_link_pk, context_pk, consumer_pk, lti_resource_link_id, settings, primary_resource_link_pk, share_approved, created, updated ' .
948  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
949  'WHERE (resource_link_pk = %s)';
950  $types = array("integer");
951  $values = array($resourceLink->getRecordId());
952  } elseif (!empty($resourceLink->getContext())) {
953  $query = 'SELECT resource_link_pk, context_pk, consumer_pk, lti_resource_link_id, settings, primary_resource_link_pk, share_approved, created, updated ' .
954  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
955  'WHERE (context_pk = %s) AND (lti_resource_link_id = %s)';
956  $types = array("integer","text");
957  $values = array($resourceLink->getContext()->getRecordId(), $resourceLink->getId());
958  } else {
959  $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 ' .
960  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' r LEFT OUTER JOIN ' .
961  $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' c ON r.context_pk = c.context_pk ' .
962  ' WHERE ((r.consumer_pk = %s) OR (c.consumer_pk = %s)) AND (lti_resource_link_id = %s)';
963  $types = array("integer","integer","text");
964  $values = array($resourceLink->getConsumer()->getRecordId(), $resourceLink->getConsumer()->getRecordId(), $resourceLink->getId());
965  }
966  $rsContext = $ilDB->queryF($query, $types, $values);
967  if ($rsContext) {
968  $row = $ilDB->fetchObject($rsContext);
969  if ($row) {
970  $resourceLink->setRecordId(intval($row->resource_link_pk));
971  if (!is_null($row->context_pk)) {
972  $resourceLink->setContextId(intval($row->context_pk));
973  } else {
974  $resourceLink->setContextId(null);
975  }
976  if (!is_null($row->consumer_pk)) {
977  $resourceLink->setConsumerId(intval($row->consumer_pk));
978  } else {
979  $resourceLink->setConsumerId(null);
980  }
981  $resourceLink->ltiResourceLinkId = $row->lti_resource_link_id;
982  $settings = unserialize($row->settings);
983  if (!is_array($settings)) {
984  $settings = array();
985  }
986  $resourceLink->setSettings($settings);
987  if (!is_null($row->primary_resource_link_pk)) {
988  $resourceLink->primaryResourceLinkId = intval($row->primary_resource_link_pk);
989  } else {
990  $resourceLink->primaryResourceLinkId = null;
991  }
992  $resourceLink->shareApproved = (is_null($row->share_approved)) ? null : (intval($row->share_approved) === 1);
993  $resourceLink->created = strtotime($row->created);
994  $resourceLink->updated = strtotime($row->updated);
995  $ok = true;
996  }
997  }
998 
999  return $ok;
1000  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
global $ilDB

◆ loadResourceLinkShareKey()

ilLTIDataConnector::loadResourceLinkShareKey (   $shareKey)

Load resource link share key object.

Parameters
ResourceLinkShareKey$shareKeyResource_Link share key object
Returns
boolean True if the resource link share key object was successfully loaded

Definition at line 1295 of file class.ilLTIDataConnector.php.

References $DIC, $id, $ilDB, $ok, $query, $row, array, date, and time.

1296  {
1297  global $DIC;
1298  $ilDB = $DIC['ilDB'];
1299 
1300  $ok = false;
1301 
1302  // Clear expired share keys
1303  $now = date("{$this->dateFormat} {$this->timeFormat}", time());
1304  $query = "DELETE FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . " WHERE expires <= '%s'";
1305  $types = array("timestamp");
1306  $values = array($now);
1307  $ilDB->manipulateF($query, $types, $values);
1308 
1309  // Load share key
1310  // $id = mysql_real_escape_string($shareKey->getId());//ACHTUNG UK utf8
1311  $id = $shareKey->getId();
1312  $query = 'SELECT resource_link_pk, auto_approve, expires ' .
1313  "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' ' .
1314  "WHERE share_key_id = %s";
1315  $types = array("text");
1316  $values = array($id);
1317  $rsShareKey = $ilDB->queryF($query, $types, $values);
1318  if ($rsShareKey) {
1319  $row = $ilDB->fetchObject($rsShareKey);
1320  if ($row && (intval($row->resource_link_pk) === $shareKey->resourceLinkId)) {
1321  $shareKey->autoApprove = (intval($row->auto_approve) === 1);
1322  $shareKey->expires = strtotime($row->expires);
1323  $ok = true;
1324  }
1325  }
1326 
1327  return $ok;
1328  }
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$query
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ loadToolConsumer()

ilLTIDataConnector::loadToolConsumer (   $consumer)

Load tool consumer object.

Parameters
ToolConsumer$consumerToolConsumer object
Returns
boolean True if the tool consumer object was successfully loaded

Definition at line 56 of file class.ilLTIDataConnector.php.

References $consumer, $DIC, $ilDB, $ok, $query, $res, $row, and array.

57  {
58  global $DIC;
59  $ilDB = $DIC['ilDB'];
60 
61  $ok = false;
62  $query = 'SELECT consumer_pk, name, consumer_key256, consumer_key, secret, lti_version, ' .
63  'consumer_name, consumer_version, consumer_guid, ' .
64  'profile, tool_proxy, settings, protected, enabled, ' .
65  'enable_from, enable_until, last_access, created, updated ' .
66  // 'enable_from, enable_until, last_access, created, updated, ' .
67  // 'title, description, prefix, user_language, role, local_role_always_member, default_skin ' .
68  'FROM lti2_consumer WHERE ';
69  // 'FROM lti2_consumer, lti_ext_consumer ' .
70  // 'WHERE lti_ext_consumer.id = consumer_pk AND ';
71  if (!empty($consumer->getRecordId())) {
72  $query .= 'consumer_pk = %s';
73  $types = array('integer');
74  $values = array($consumer->getRecordId());
75  } else {
76  $query .= 'consumer_key256 = %s';
77  $types = array('text');
78  $key256 = ToolProvider\DataConnector\DataConnector::getConsumerKey($consumer->getKey());
79  $values = array($key256);
80  }
81  // $rsConsumer = mysql_query($sql);
82  $res = $ilDB->queryF($query, $types, $values);
83  // if ($rsConsumer) {
84  while ($row = $ilDB->fetchObject($res)) {
85  // while ($row = mysql_fetch_object($rsConsumer)) {
86  if (empty($key256) || empty($row->consumer_key) || ($consumer->getKey() === $row->consumer_key)) {
87  $consumer->setRecordId(intval($row->consumer_pk));
88  $consumer->name = $row->name;
89  $consumer->setkey(empty($row->consumer_key) ? $row->consumer_key256 : $row->consumer_key);
90  $consumer->secret = $row->secret;
91  $consumer->ltiVersion = $row->lti_version;
92  $consumer->consumerName = $row->consumer_name;
93  $consumer->consumerVersion = $row->consumer_version;
94  $consumer->consumerGuid = $row->consumer_guid;
95  $consumer->profile = json_decode($row->profile);
96  $consumer->toolProxy = $row->tool_proxy;
97  $settings = unserialize($row->settings);
98  if (!is_array($settings)) {
99  $settings = array();
100  }
101  $consumer->setSettings($settings);
102  $consumer->protected = (intval($row->protected) === 1);
103  $consumer->enabled = (intval($row->enabled) === 1);
104  $consumer->enableFrom = null;
105  if (!is_null($row->enable_from)) {
106  $consumer->enableFrom = strtotime($row->enable_from);
107  }
108  $consumer->enableUntil = null;
109  if (!is_null($row->enable_until)) {
110  $consumer->enableUntil = strtotime($row->enable_until);
111  }
112  $consumer->lastAccess = null;
113  if (!is_null($row->last_access)) {
114  $consumer->lastAccess = strtotime($row->last_access);
115  }
116  $consumer->created = strtotime($row->created);
117  $consumer->updated = strtotime($row->updated);
118  //ILIAS specific
119  // if ($consumer->setTitle) $consumer->setTitle($row->title);
120  // if ($consumer->setDescription) $consumer->setDescription($row->description);
121  // if ($consumer->setPrefix) $consumer->setPrefix($row->prefix);
122  // if ($consumer->setPrefix) $consumer->setLanguage($row->user_language);
123  // if ($consumer->setPrefix) $consumer->setRole($row->role);
124  // local_role_always_member
125  // default_skin
126 
127  $ok = true;
128  break;
129  }
130  // }
131  // mysql_free_result($rsConsumer);
132  }
133 
134  return $ok;
135  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$consumer
Definition: demo.php:30
Create styles array
The data for the language used.
global $ilDB

◆ loadToolConsumerILIAS()

ilLTIDataConnector::loadToolConsumerILIAS ( ilLTIToolConsumer  $consumer)

Load extended tool consumer object with ILIAS extension.

Parameters
ToolConsumer$consumerToolConsumer object
Returns
boolean True if the tool consumer object was successfully loaded

Definition at line 192 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, $query, $res, $row, array, IMSGlobal\LTI\ToolProvider\ToolConsumer\getKey(), IMSGlobal\LTI\ToolProvider\ToolConsumer\getRecordId(), loadGlobalToolConsumerSettings(), ilLTIToolConsumer\setExtConsumerId(), IMSGlobal\LTI\ToolProvider\ToolConsumer\setRecordId(), ilLTIToolConsumer\setRefId(), and IMSGlobal\LTI\ToolProvider\ToolConsumer\setSettings().

193  {
194  global $DIC;
195  $ilDB = $DIC['ilDB'];
196 
197  $ok = false;
198  $query = 'SELECT consumer_pk, name, consumer_key256, consumer_key, secret, lti_version, ' .
199  'consumer_name, consumer_version, consumer_guid, ' .
200  'profile, tool_proxy, settings, protected, enabled, ' .
201  'enable_from, enable_until, last_access, created, updated, ' .
202  'ext_consumer_id, ref_id ' .
203  #'title, description, prefix, user_language, role, local_role_always_member, default_skin ' .
204  'FROM lti2_consumer ' .
205  #'FROM lti2_consumer, lti_ext_consumer ' .
206  'WHERE ';
207  #'WHERE lti_ext_consumer.id = consumer_pk AND ';
208  if (!empty($consumer->getRecordId())) {
209  $query .= 'consumer_pk = %s';
210  $types = array('integer');
211  $values = array($consumer->getRecordId());
212  } else {
213  $query .= 'consumer_key256 = %s';
214  $types = array('text');
215  $key256 = ToolProvider\DataConnector\DataConnector::getConsumerKey($consumer->getKey());
216  $values = array($key256);
217  }
218  // $rsConsumer = mysql_query($sql);
219  $res = $ilDB->queryF($query, $types, $values);
220  // if ($rsConsumer) {
221  while ($row = $ilDB->fetchObject($res)) {
222  // while ($row = mysql_fetch_object($rsConsumer)) {
223  if (empty($key256) || empty($row->consumer_key) || ($consumer->getKey() === $row->consumer_key)) {
224  $consumer->setRecordId(intval($row->consumer_pk));
225  $consumer->name = $row->name;
226  $consumer->setkey(empty($row->consumer_key) ? $row->consumer_key256 : $row->consumer_key);
227  $consumer->secret = $row->secret;
228  $consumer->ltiVersion = $row->lti_version;
229  $consumer->consumerName = $row->consumer_name;
230  $consumer->consumerVersion = $row->consumer_version;
231  $consumer->consumerGuid = $row->consumer_guid;
232  $consumer->profile = json_decode($row->profile);
233  $consumer->toolProxy = $row->tool_proxy;
234  $settings = unserialize($row->settings);
235  if (!is_array($settings)) {
236  $settings = array();
237  }
238  $consumer->setSettings($settings);
239  $consumer->protected = (intval($row->protected) === 1);
240  $consumer->enabled = (intval($row->enabled) === 1);
241  $consumer->enableFrom = null;
242  if (!is_null($row->enable_from)) {
243  $consumer->enableFrom = strtotime($row->enable_from);
244  }
245  $consumer->enableUntil = null;
246  if (!is_null($row->enable_until)) {
247  $consumer->enableUntil = strtotime($row->enable_until);
248  }
249  $consumer->lastAccess = null;
250  if (!is_null($row->last_access)) {
251  $consumer->lastAccess = strtotime($row->last_access);
252  }
253  $consumer->created = strtotime($row->created);
254  $consumer->updated = strtotime($row->updated);
255 
256  //ILIAS specific
257  $consumer->setExtConsumerId($row->ext_consumer_id);
258  $consumer->setRefId($row->ref_id);
259  #$consumer->setTitle($row->title);
260  #$consumer->setDescription($row->description);
261  #$consumer->setPrefix($row->prefix);
262  #$consumer->setLanguage($row->user_language);
263  #$consumer->setRole($row->role);
264  // local_role_always_member
265  // default_skin
266 
267  $ok = true;
268  break;
269  }
270  // }
271  // mysql_free_result($rsConsumer);
272  }
273 
274  $this->loadGlobalToolConsumerSettings($consumer);
275  return $ok;
276  }
setSettings($settings)
Set an array of all setting values.
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
setRecordId($id)
Sets the tool consumer record ID.
getRecordId()
Get the tool consumer record ID.
global $ilDB
loadGlobalToolConsumerSettings(ilLTIToolConsumer $consumer)
Load global tool consumer settings in consumer.
getKey()
Get the tool consumer key.
+ Here is the call graph for this function:

◆ loadToolProxy()

ilLTIDataConnector::loadToolProxy (   $toolProxy)

Definition at line 753 of file class.ilLTIDataConnector.php.

754  {
755  return false;
756  }

◆ loadUser()

ilLTIDataConnector::loadUser (   $user)

Load user object.

Parameters
User$userUser object
Returns
boolean True if the user object was successfully loaded

Definition at line 1394 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

1395  {
1396  global $DIC;
1397  $ilDB = $DIC->database();
1398 
1399  $ok = false;
1400  if ($user->getRecordId()) {
1401  $query = 'SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
1402  'FROM ' . $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1403  'WHERE user_pk = ' . $ilDB->quote($user->getRecordId(), 'integer');
1404  } else {
1405  $query = 'SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
1406  'FROM ' . $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1407  'WHERE resource_link_pk = ' . $ilDB->quote($user->getResourceLink()->getRecordId(), 'integer') . ' ' .
1408  'AND lti_user_id = ' . $ilDB->quote($user->getId(ToolProvider\ToolProvider::ID_SCOPE_ID_ONLY), 'text');
1409  }
1410 
1411  $this->logger->debug('Loading user with query: ' . $query);
1412 
1413  $ok = false;
1414  try {
1415  $res = $ilDB->query($query);
1416  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1417  $user->setRecordId($row->user_pk);
1418  $user->setResourceLinkId($row->resource_link_pk);
1419  $user->ltiUserId = $row->lti_user_id;
1420  $user->ltiResultSourcedId = $row->lti_result_sourcedid;
1421  $user->created = strtotime($row->created);
1422  $user->updated = strtotime($row->updated);
1423  $ok = true;
1424  }
1425  } catch (ilDatabaseException $e) {
1426  $this->logger->error($e);
1427  }
1428  return $ok;
1429 
1430  // if (!empty($user->getRecordId())) {
1431  // $query = 'SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
1432  // "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1433  // 'WHERE (user_pk = %d)',
1434  // $user->getRecordId());
1435  // } else {
1436  // $query = 'SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
1437  // "FROM {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1438  // 'WHERE (resource_link_pk = %d) AND (lti_user_id = %s)',
1439  // $user->getResourceLink()->getRecordId(),
1440  // ToolProvider\DataConnector\DataConnector::quoted($user->getId(ToolProvider\ToolProvider::ID_SCOPE_ID_ONLY)));
1441  // }
1442  // $rsUser = mysql_query($sql);
1443  // if ($rsUser) {
1444  // $row = $ilDB->fetchObject($rsUser);
1445  // if ($row) {
1446  // $user->setRecordId(intval($row->user_pk));
1447  // $user->setResourceLinkId(intval($row->resource_link_pk));
1448  // $user->ltiUserId = $row->lti_user_id;
1449  // $user->ltiResultSourcedId = $row->lti_result_sourcedid;
1450  // $user->created = strtotime($row->created);
1451  // $user->updated = strtotime($row->updated);
1452  // $ok = true;
1453  // }
1454  // }
1455  }
global $DIC
Definition: saml.php:7
Class to represent an LTI Tool Provider.
Class ilDatabaseException.
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ lookupRecordIdByGlobalSettingsAndRefId()

ilLTIDataConnector::lookupRecordIdByGlobalSettingsAndRefId ( ilLTIToolConsumer  $consumer)

Lookup record id for global settings and ref_id.

Parameters
ilLTIToolConsumer$consumer
Returns
type

Definition at line 284 of file class.ilLTIDataConnector.php.

References $GLOBALS, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, ilLTIToolConsumer\getExtConsumerId(), and ilLTIToolConsumer\getRefId().

Referenced by ilLTIToolConsumer\fromGlobalSettingsAndRefId().

285  {
286  $db = $GLOBALS['DIC']->database();
287 
288  $query = 'SELECT consumer_pk from lti2_consumer ' .
289  'WHERE ext_consumer_id = ' . $db->quote($consumer->getExtConsumerId(), 'integer') . ' ' .
290  'AND ref_id = ' . $db->quote($consumer->getRefId(), 'integer');
291  $res = $db->query($query);
292  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
293  return $row->consumer_pk;
294  }
295  return null;
296  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
foreach($_POST as $key=> $value) $res
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupResourcesForAllUsersSinceDate()

ilLTIDataConnector::lookupResourcesForAllUsersSinceDate ( ilDateTime  $since)
Parameters
\ilDateTime$since

Definition at line 1616 of file class.ilLTIDataConnector.php.

References $DIC, $logger, $query, $res, $results, $row, ilDBConstants\FETCHMODE_OBJECT, ilDateTime\get(), and IL_CAL_DATETIME.

1617  {
1618  global $DIC;
1619 
1620  $db = $DIC->database();
1621  $logger = $DIC->logger()->lti();
1622 
1623  $query = 'select lti_user_id, rl.resource_link_pk, ec.id, ref_id ' .
1624  'from lti2_resource_link rl join lti2_user_result ur on rl.resource_link_pk = ur.resource_link_pk ' .
1625  'join lti2_consumer c on rl.consumer_pk = c.consumer_pk ' .
1626  'join lti_ext_consumer ec on ext_consumer_id = ec.id ' .
1627  'where c.enabled = ' . $db->quote(1, 'integer') . ' ' .
1628  'and rl.updated > ' . $db->quote($since->get(IL_CAL_DATETIME), 'timestamp');
1629  $res = $db->query($query);
1630 
1631  $results = [];
1632  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1633  $results[$row->id . '__' . $row->lti_user_id][] = $row->resource_link_pk . '__' . $row->ref_id;
1634  }
1635  return $results;
1636  }
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
get($a_format, $a_format_str='', $a_tz='')
get formatted date
$results
Definition: svg-scanner.php:47
+ Here is the call graph for this function:

◆ lookupResourcesForUserObjectRelation()

ilLTIDataConnector::lookupResourcesForUserObjectRelation (   $a_ref_id,
  $a_lti_user,
  $a_ext_consumer,
ilDateTime  $since = null 
)

Lookup resources for user object relation.

Parameters
$a_ref_id
$a_lti_user
$a_ext_consumer
ilDateTime$since
Returns
int[]

Definition at line 1585 of file class.ilLTIDataConnector.php.

References $DIC, $logger, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

1586  {
1587  global $DIC;
1588 
1589  $db = $DIC->database();
1590  $logger = $DIC->logger()->lti();
1591 
1592  $query = 'select rl.resource_link_pk ' .
1593  'from lti2_user_result ur join lti2_resource_link rl on rl.resource_link_pk = ur.resource_link_pk ' .
1594  'join lti2_consumer c on rl.consumer_pk = c.consumer_pk ' .
1595  'join lti_ext_consumer ec on c.ext_consumer_id = ec.id ' .
1596  'where c.enabled = ' . $db->quote(1, 'integer') . ' ' .
1597  'and ref_id = ' . $db->quote($a_ref_id, 'integer') . ' ' .
1598  'and ur.lti_user_id = ' . $db->quote($a_lti_user, 'text') . ' ' .
1599  'and ec.id = ' . $db->quote($a_ext_consumer, 'integer');
1600 
1601  $resource_links = [];
1602  try {
1603  $res = $db->query($query);
1604  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1605  $resource_links[] = $row->resource_link_pk;
1606  }
1607  } catch (ilDatabaseException $e) {
1608  $logger->error('Query execution failed with message: ' . $e->getMessage());
1609  }
1610  return $resource_links;
1611  }
global $DIC
Definition: saml.php:7
Class ilDatabaseException.
foreach($_POST as $key=> $value) $res
$query

◆ saveConsumerNonce()

ilLTIDataConnector::saveConsumerNonce (   $nonce)

Save nonce object.

Parameters
ConsumerNonce$nonceNonce object
Returns
boolean True if the nonce object was successfully saved

Definition at line 1269 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, $query, array, and date.

1270  {
1271  global $DIC;
1272  $ilDB = $DIC['ilDB'];
1273 
1274  $expires = date("{$this->dateFormat} {$this->timeFormat}", $nonce->expires);
1275  $query = "INSERT INTO {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::NONCE_TABLE_NAME . " (consumer_pk, value, expires) VALUES (%s, %s, %s)";
1276  $types = array("integer","text","timestamp");
1277  $values = array($nonce->getConsumer()->getRecordId(), $nonce->getValue(), $expires);
1278  $ok = $ilDB->manipulateF($query, $types, $values);
1279 
1280  return $ok;
1281  }
global $DIC
Definition: saml.php:7
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$query
Create styles array
The data for the language used.
global $ilDB

◆ saveContext()

ilLTIDataConnector::saveContext (   $context)

Save context object.

Parameters
Context$contextContext object
Returns
boolean True if the context object was successfully saved

Definition at line 832 of file class.ilLTIDataConnector.php.

References $DIC, $id, $ilDB, $ok, $query, $time, array, date, and time.

833  {
834  global $DIC;
835  $ilDB = $DIC['ilDB'];
836 
837  $time = time();
838  $now = date("{$this->dateFormat} {$this->timeFormat}", $time);
839  $settingsValue = serialize($context->getSettings());
840  $id = $context->getRecordId();
841  $consumer_pk = $context->getConsumer()->getRecordId();
842  if (empty($id)) {
843  $context->setRecordId($ilDB->nextId(ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME));
844  $id = $context->getRecordId();
845  $context->created = $time;
846 
847  $query = "INSERT INTO {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' (context_pk, consumer_pk, lti_context_id, ' .
848  'settings, created, updated) ' .
849  'VALUES (%s, %s, %s, %s, %s, %s)';
850  $types = array("integer","integer","text","text","timestamp","timestamp");
851  $values = array($id, $consumer_pk, $context->ltiContextId, $settingsValue, $now, $now);
852  } else {
853  $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' SET ' .
854  'lti_context_id = %s, settings = %s, ' .
855  'updated = %s' .
856  'WHERE (consumer_pk = %s) AND (context_pk = %s)';
857  $types = array("text","text","timestamp","integer","integer");
858  $values = array($context->ltiContextId, $settingsValue, $now, $consumer_pk, $id);
859  }
860  $ok = $ilDB->manipulateF($query, $types, $values);
861  if ($ok) {
862  $context->updated = $time;
863  }
864 
865  return $ok;
866  }
global $DIC
Definition: saml.php:7
Class to represent an LTI Tool Provider.
if(!array_key_exists('StateId', $_REQUEST)) $id
$time
Definition: cron.php:21
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$query
Class to provide a connection to a persistent store for LTI objects.
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ saveGlobalToolConsumerSettings()

ilLTIDataConnector::saveGlobalToolConsumerSettings ( ilLTIToolConsumer  $consumer)

Save lti_ext_consumer type $DIC.

Definition at line 381 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $query, ilLTIToolConsumer\getActive(), ilLTIToolConsumer\getDescription(), ilLTIToolConsumer\getExtConsumerId(), ilLTIToolConsumer\getLanguage(), ilLTIToolConsumer\getPrefix(), ilLTIToolConsumer\getRole(), ilLTIToolConsumer\getTitle(), and ilLTIToolConsumer\setExtConsumerId().

Referenced by ilLTIToolConsumer\saveGlobalToolConsumerSettings().

382  {
383  global $DIC;
384  $ilDB = $DIC['ilDB'];
385 
386  if (!$consumer->getExtConsumerId()) {
387  // create
388  $new_id = $ilDB->nextId('lti_ext_consumer');
389  $query = 'INSERT INTO lti_ext_consumer (title, description, prefix, user_language, role, id, active) ' .
390  'VALUES (%s, %s, %s, %s, %s, %s, %s)';
391  $types = ["text", "text", "text", "text", "integer", "integer", 'integer'];
392  $values = [
393  $consumer->getTitle(),
394  $consumer->getDescription(),
395  $consumer->getPrefix(),
396  $consumer->getLanguage(),
397  $consumer->getRole(),
398  $new_id,
399  (int) $consumer->getActive()
400  ];
401  $ilDB->manipulateF($query, $types, $values);
402  $consumer->setExtConsumerId($new_id);
403  return true;
404  } else {
405  // update
406  $query = 'update lti_ext_consumer set ' .
407  'title = ' . $ilDB->quote($consumer->getTitle(), 'text') . ', ' .
408  'description = ' . $ilDB->quote($consumer->getDescription(), 'text') . ', ' .
409  'prefix = ' . $ilDB->quote($consumer->getPrefix(), 'text') . ', ' .
410  'user_language = ' . $ilDB->quote($consumer->getLanguage(), 'text') . ', ' .
411  'role = ' . $ilDB->quote($consumer->getRole(), 'integer') . ', ' .
412  'active = ' . $ilDB->quote((int) $consumer->getActive(), 'integer') . ' ' .
413  'where id = ' . $ilDB->quote($consumer->getExtConsumerId(), 'integer');
414  $ilDB->manipulate($query);
415  return true;
416  }
417  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveResourceLink()

ilLTIDataConnector::saveResourceLink (   $resourceLink)

Save resource link object.

Parameters
ResourceLink$resourceLinkResource_Link object
Returns
boolean True if the resource link object was successfully saved

Definition at line 1009 of file class.ilLTIDataConnector.php.

References $DIC, $id, $ilDB, $ok, $query, $time, array, date, ilLogLevel\INFO, and time.

1010  {
1011  global $DIC;
1012  $ilDB = $DIC['ilDB'];
1013 
1014  if (is_null($resourceLink->shareApproved)) {
1015  $approved = 'NULL';
1016  } elseif ($resourceLink->shareApproved) {
1017  $approved = '1';
1018  } else {
1019  $approved = '0';
1020  }
1021  if (empty($resourceLink->primaryResourceLinkId)) {
1022  $primaryResourceLinkId = 'NULL';
1023  } else {
1024  $primaryResourceLinkId = strval($resourceLink->primaryResourceLinkId);
1025  }
1026  $time = time();
1027  $now = date("{$this->dateFormat} {$this->timeFormat}", $time);
1028  $settingsValue = serialize($resourceLink->getSettings());
1029  if (!empty($resourceLink->getContext())) {
1030  //$consumerId = 'NULL';
1031  $consumerId = strval($resourceLink->getConsumer()->getRecordId());
1032  $contextId = strval($resourceLink->getContext()->getRecordId());
1033  } elseif (!empty($resourceLink->getContextId())) {
1034  //$consumerId = 'NULL';
1035  $consumerId = strval($resourceLink->getConsumer()->getRecordId());
1036  $contextId = strval($resourceLink->getContextId());
1037  } else {
1038  $consumerId = strval($resourceLink->getConsumer()->getRecordId());
1039  $contextId = 'NULL';
1040  }
1041  $id = $resourceLink->getRecordId();
1042  if (empty($id)) {
1043  $resourceLink->setRecordId($ilDB->nextId(ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME));
1044  $id = $resourceLink->getRecordId();
1045  $resourceLink->created = $time;
1046  $query = "INSERT INTO {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' (resource_link_pk, consumer_pk, context_pk, ' .
1047  'lti_resource_link_id, settings, primary_resource_link_pk, share_approved, created, updated) ' .
1048  'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)';
1049  $types = array("integer","integer","integer","text","text","integer","integer","timestamp","timestamp");
1050  $values = array($id, $consumerId, $contextId, $resourceLink->getId(), $settingsValue, $primaryResourceLinkId, $approved, $now, $now);
1051  } elseif ($contextId !== 'NULL') {
1052  $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' SET ' .
1053  'consumer_pk = %s, lti_resource_link_id = %s, settings = %s, ' .
1054  'primary_resource_link_pk = %s, share_approved = %s, updated = %s ' .
1055  'WHERE (context_pk = %s) AND (resource_link_pk = %s)';
1056  $types = array("integer","text","text","integer","integer","timestamp","integer","integer");
1057  $values = array($consumerId, $resourceLink->getId(), $settingsValue, $primaryResourceLinkId, $approved, $now, $contextId, $id);
1058  } else {
1059  $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' SET ' .
1060  'context_pk = %s, lti_resource_link_id = %s, settings = %s, ' .
1061  'primary_resource_link_pk = %s, share_approved = %s, updated = %s ' .
1062  'WHERE (consumer_pk = %s) AND (resource_link_pk = %s)';
1063  $types = array("integer","text","text","integer","integer","timestamp","integer","integer");
1064  $values = array($contextId, $resourceLink->getId(), $settingsValue, $primaryResourceLinkId, $approved, $now, $consumerId, $id);
1065  }
1066  $ok =$ilDB->manipulateF($query, $types, $values);
1067 
1068  $this->logger->info('Update resource link with query: ' . $query);
1069  $this->logger->logStack();
1070  $this->logger->dump($values, ilLogLevel::INFO);
1071 
1072  $this->logger->dump($ok);
1073 
1074  if ($ok) {
1075  $resourceLink->updated = $time;
1076  }
1077 
1078  return $ok;
1079  }
global $DIC
Definition: saml.php:7
Class to represent an LTI Tool Provider.
if(!array_key_exists('StateId', $_REQUEST)) $id
$time
Definition: cron.php:21
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$query
Class to provide a connection to a persistent store for LTI objects.
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ saveResourceLinkShareKey()

ilLTIDataConnector::saveResourceLinkShareKey (   $shareKey)

Save resource link share key object.

Parameters
ResourceLinkShareKey$shareKeyResource link share key object
Returns
boolean True if the resource link share key object was successfully saved

Definition at line 1337 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, $query, array, and date.

1338  {
1339  global $DIC;
1340  $ilDB = $DIC['ilDB'];
1341 
1342  if ($shareKey->autoApprove) {
1343  $approve = 1;
1344  } else {
1345  $approve = 0;
1346  }
1347  $expires = date("{$this->dateFormat} {$this->timeFormat}", $shareKey->expires);
1348  $query = "INSERT INTO {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' ' .
1349  '(share_key_id, resource_link_pk, auto_approve, expires) ' .
1350  "VALUES (%s, %s, %s, %s)";
1351  $types = array("text","integer","integer","timestamp");
1352  $values = array($shareKey->getId(), $shareKey->resourceLinkId, $approve, $expires);
1353  $ok = $ilDB->manipulateF($query, $types, $values);
1354 
1355  return $ok;
1356  }
global $DIC
Definition: saml.php:7
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$query
Create styles array
The data for the language used.
global $ilDB

◆ saveToolConsumer()

ilLTIDataConnector::saveToolConsumer (   $consumer)

Save tool consumer object.

Parameters
ToolConsumer$consumerConsumer object
Returns
boolean True if the tool consumer object was successfully saved

Definition at line 305 of file class.ilLTIDataConnector.php.

References $consumer, $DIC, $from, $id, $ilDB, $key, $query, $time, array, date, and time.

306  {
307  global $DIC;
308  $ilDB = $DIC['ilDB'];
309 
310  $id = $consumer->getRecordId();
311  $key = $consumer->getKey();
312  $key256 = ToolProvider\DataConnector\DataConnector::getConsumerKey($key);
313  // $key256 = $this->getConsumerKey($key);
314  if ($key === $key256) {
315  $key = null;
316  }
317  $protected = ($consumer->protected) ? 1 : 0;
318  $enabled = ($consumer->enabled)? 1 : 0;
319  $profile = (!empty($consumer->profile)) ? json_encode($consumer->profile) : null;
320  $settingsValue = serialize($consumer->getSettings());
321  $time = time();
322  $now = date("{$this->dateFormat} {$this->timeFormat}", $time);
323  $from = null;
324  if (!is_null($consumer->enableFrom)) {
325  $from = date("{$this->dateFormat} {$this->timeFormat}", $consumer->enableFrom);
326  }
327  $until = null;
328  if (!is_null($consumer->enableUntil)) {
329  $until = date("{$this->dateFormat} {$this->timeFormat}", $consumer->enableUntil);
330  }
331  $last = null;
332  if (!is_null($consumer->lastAccess)) {
333  $last = date($this->dateFormat, $consumer->lastAccess);
334  }
335 
336  if (empty($id)) {
337  $consumer->setRecordId($ilDB->nextId('lti_ext_consumer'));
338  $id = $consumer->getRecordId();
339  $consumer->created = $time;
340  $consumer->updated = $time;
341  if ($key256 == null) {
342  $key256 = $id . ToolProvider\DataConnector\DataConnector::getRandomString(10);
343  }
344 
345  // $query = "INSERT INTO {$this->dbTableNamePrefix}" . $this->CONSUMER_TABLE_NAME . ' (consumer_key256, consumer_key, name, ' .
346  $query = 'INSERT INTO lti2_consumer (consumer_key256, consumer_key, name, ' .
347  'secret, lti_version, consumer_name, consumer_version, consumer_guid, profile, tool_proxy, settings, protected, enabled, ' .
348  'enable_from, enable_until, last_access, created, updated, consumer_pk) ' .
349  'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)';
350  $types = array("text", "text", "text",
351  "text", "text", "text", "text", "text", "text", "text", "text", "integer", "integer",
352  "timestamp", "timestamp", "timestamp", "timestamp", "timestamp", "integer");
353  $values = array($key256, $key, $consumer->name,
354  $consumer->secret, $consumer->ltiVersion, $consumer->consumerName, $consumer->consumerVersion, $consumer->consumerGuid, $profile, $consumer->toolProxy, $settingsValue, $protected, $enabled,
355  $from, $until, $last, $now, $now, $id);
356  $ilDB->manipulateF($query, $types, $values);
357  } else {
358  $consumer->updated = $time;
359 
360  $query = 'UPDATE lti2_consumer SET ' .
361  'consumer_key256 = %s, consumer_key = %s, name = %s, ' .
362  'secret= %s, lti_version = %s, consumer_name = %s, consumer_version = %s, consumer_guid = %s, ' .
363  'profile = %s, tool_proxy = %s, settings = %s, protected = %s, enabled = %s, ' .
364  'enable_from = %s, enable_until = %s, last_access = %s, updated = %s ' .
365  'WHERE consumer_pk = %s';
366  $types = array("text", "text", "text",
367  "text", "text", "text", "text", "text", "text", "text", "text", "integer", "integer",
368  "timestamp", "timestamp", "timestamp", "timestamp", "integer");
369  $values = array($key256, $key, $consumer->name,
370  $consumer->secret, $consumer->ltiVersion, $consumer->consumerName, $consumer->consumerVersion, $consumer->consumerGuid, $profile, $consumer->toolProxy, $settingsValue, $protected, $enabled,
371  $from, $until, $last, $now, $id);
372  $ilDB->manipulateF($query, $types, $values);
373  }
374  return $true;
375  }
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
$from
$time
Definition: cron.php:21
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$query
$consumer
Definition: demo.php:30
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
$key
Definition: croninfo.php:18

◆ saveToolConsumerILIAS()

ilLTIDataConnector::saveToolConsumerILIAS ( ilLTIToolConsumer  $consumer)

Save extended tool consumer object with ILIAS extensions.

Parameters
ToolConsumer$consumerConsumer object
Returns
boolean True if the tool consumer object was successfully saved

Definition at line 427 of file class.ilLTIDataConnector.php.

References $DIC, $from, $id, $ilDB, $key, $query, $time, array, date, ilLTIToolConsumer\getExtConsumerId(), IMSGlobal\LTI\ToolProvider\ToolConsumer\getKey(), IMSGlobal\LTI\ToolProvider\ToolConsumer\getRecordId(), ilLTIToolConsumer\getRefId(), IMSGlobal\LTI\ToolProvider\ToolConsumer\getSettings(), ilLTIToolConsumer\getTitle(), IMSGlobal\LTI\ToolProvider\ToolConsumer\setRecordId(), and time.

428  {
429  global $DIC;
430  $ilDB = $DIC['ilDB'];
431 
432  $id = $consumer->getRecordId();
433  $key = $consumer->getKey();
434  $key256 = ToolProvider\DataConnector\DataConnector::getConsumerKey($key);
435  // $key256 = $this->getConsumerKey($key);
436  if ($key === $key256) {
437  $key = null;
438  }
439  $protected = ($consumer->protected) ? 1 : 0;
440  $enabled = ($consumer->enabled)? 1 : 0;
441  $profile = (!empty($consumer->profile)) ? json_encode($consumer->profile) : null;
442  $settingsValue = serialize($consumer->getSettings());
443  $time = time();
444  $now = date("{$this->dateFormat} {$this->timeFormat}", $time);
445  $from = null;
446  if (!is_null($consumer->enableFrom)) {
447  $from = date("{$this->dateFormat} {$this->timeFormat}", $consumer->enableFrom);
448  }
449  $until = null;
450  if (!is_null($consumer->enableUntil)) {
451  $until = date("{$this->dateFormat} {$this->timeFormat}", $consumer->enableUntil);
452  }
453  $last = null;
454  if (!is_null($consumer->lastAccess)) {
455  $last = date($this->dateFormat, $consumer->lastAccess);
456  }
457 
458  $consumer->name = $consumer->getTitle();//50UK
459  if (empty($id)) {
460  $consumer->setRecordId($ilDB->nextId('lti2_consumer'));
461  $id = $consumer->getRecordId();
462  $consumer->created = $time;
463  $consumer->updated = $time;
464  if ($key256 == null) {
465  $key256 = $id . ToolProvider\DataConnector\DataConnector::getRandomString(10);
466  }
467 
468  // $query = "INSERT INTO {$this->dbTableNamePrefix}" . $this->CONSUMER_TABLE_NAME . ' (consumer_key256, consumer_key, name, ' .
469  $query = 'INSERT INTO lti2_consumer (consumer_key256, consumer_key, name, ' .
470  'secret, lti_version, consumer_name, consumer_version, consumer_guid, profile, tool_proxy, settings, protected, enabled, ' .
471  'enable_from, enable_until, last_access, created, updated, consumer_pk,ext_consumer_id,ref_id) ' .
472  'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)';
473  $types = array("text", "text", "text",
474  "text", "text", "text", "text", "text", "text", "text", "text", "integer", "integer",
475  "timestamp", "timestamp", "timestamp", "timestamp", "timestamp", "integer", 'integer', 'integer');
476  $values = array($key256, $key, $consumer->name,
477  $consumer->secret, $consumer->ltiVersion, $consumer->consumerName, $consumer->consumerVersion, $consumer->consumerGuid, $profile, $consumer->toolProxy, $settingsValue, $protected, $enabled,
478  $from, $until, $last, $now, $now, $id, $consumer->getExtConsumerId(), $consumer->getRefId());
479  $ilDB->manipulateF($query, $types, $values);
480  } else {
481  $consumer->updated = $time;
482 
483  $query = 'UPDATE lti2_consumer SET ' .
484  'consumer_key256 = %s, consumer_key = %s, name = %s, ' .
485  'secret= %s, lti_version = %s, consumer_name = %s, consumer_version = %s, consumer_guid = %s, ' .
486  'profile = %s, tool_proxy = %s, settings = %s, protected = %s, enabled = %s, ' .
487  'enable_from = %s, enable_until = %s, last_access = %s, updated = %s ' .
488  'WHERE consumer_pk = %s';
489  $types = array("text", "text", "text",
490  "text", "text", "text", "text", "text", "text", "text", "text", "integer", "integer",
491  "timestamp", "timestamp", "timestamp", "timestamp", "integer");
492  $values = array($key256, $key, $consumer->name,
493  $consumer->secret, $consumer->ltiVersion, $consumer->consumerName, $consumer->consumerVersion, $consumer->consumerGuid, $profile, $consumer->toolProxy, $settingsValue, $protected, $enabled,
494  $from, $until, $last, $now, $id);
495  $ilDB->manipulateF($query, $types, $values);
496  }
497 
498  return true;
499  }
getSettings()
Get an array of all setting values.
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
$from
$time
Definition: cron.php:21
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$query
Create styles array
The data for the language used.
setRecordId($id)
Sets the tool consumer record ID.
getRecordId()
Get the tool consumer record ID.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
getKey()
Get the tool consumer key.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ saveToolProxy()

ilLTIDataConnector::saveToolProxy (   $toolProxy)

Definition at line 761 of file class.ilLTIDataConnector.php.

762  {
763  return false;
764  }

◆ saveUser()

ilLTIDataConnector::saveUser (   $user)

Save user object.

Parameters
User$userUser object
Returns
boolean True if the user object was successfully saved

Definition at line 1464 of file class.ilLTIDataConnector.php.

References $DIC, $ilDB, $ok, $query, $time, date, and time.

1465  {
1466  global $DIC;
1467  $ilDB = $DIC->database();
1468 
1469  $this->logger->info('Save user called');
1470 
1471  $time = time();
1472  $now = date($this->dateFormat . ' ' . $this->timeFormat, $time);
1473  if (is_null($user->created)) {
1474  $user->setRecordId($ilDB->nextId($this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME));
1475  $user->created = $time;
1476  $query = 'INSERT INTO ' . $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1477  '(user_pk,resource_link_pk,lti_user_id, lti_result_sourcedid, created, updated) ' .
1478  'VALUES( ' .
1479  $ilDB->quote($user->getRecordId(), 'integer') . ', ' .
1480  $ilDB->quote($user->getResourceLink()->getRecordId(), 'integer') . ', ' .
1481  $ilDB->quote($user->getId(ToolProvider\ToolProvider::ID_SCOPE_ID_ONLY), 'text') . ', ' .
1482  $ilDB->quote($user->ltiResultSourcedId, 'text') . ', ' .
1483  $ilDB->quote($now, 'text') . ', ' .
1484  $ilDB->quote($now, 'text') .
1485  ')';
1486  } else {
1487  $user->updated = $time;
1488  $query = 'UPDATE ' . $this->dbTableNamePrefix . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1489  'SET lti_result_sourcedid = ' . $ilDB->quote($user->ltiResultSourcedId, 'text') . ', ' .
1490  'updated = ' . $ilDB->quote($now, 'text') . ' ' .
1491  'WHERE user_pk = ' . $ilDB->quote($user->getRecordId(), 'integer');
1492  }
1493 
1494  $this->logger->debug('Saving user data with query: ' . $query);
1495 
1496  $ok = false;
1497  try {
1498  $ilDB->manipulate($query);
1499  $ok = true;
1500  } catch (ilDatabaseException $e) {
1501  $this->logger->error($e->getMessage());
1502  }
1503 
1504  return $ok;
1505 
1506 
1507 
1508  // $time = time();
1509  // $now = date("{$this->dateFormat} {$this->timeFormat}", $time);
1510  // if (is_null($user->created)) {
1511  // $query = "INSERT INTO {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' (resource_link_pk, ' .
1512  // 'lti_user_id, lti_result_sourcedid, created, updated) ' .
1513  // 'VALUES (%d, %s, %s, %s, %s)',
1514  // $user->getResourceLink()->getRecordId(),
1515  // ToolProvider\DataConnector\DataConnector::quoted($user->getId(ToolProvider\ToolProvider::ID_SCOPE_ID_ONLY)), ToolProvider\DataConnector\DataConnector::quoted($user->ltiResultSourcedId),
1516  // ToolProvider\DataConnector\DataConnector::quoted($now), ToolProvider\DataConnector\DataConnector::quoted($now));
1517  // } else {
1518  // $query = "UPDATE {$this->dbTableNamePrefix}" . ToolProvider\DataConnector\DataConnector::USER_RESULT_TABLE_NAME . ' ' .
1519  // 'SET lti_result_sourcedid = %s, updated = %s ' .
1520  // 'WHERE (user_pk = %d)',
1521  // ToolProvider\DataConnector\DataConnector::quoted($user->ltiResultSourcedId),
1522  // ToolProvider\DataConnector\DataConnector::quoted($now),
1523  // $user->getRecordId());
1524  // }
1525  // $ok = mysql_query($sql);
1526  // if ($ok) {
1527  // if (is_null($user->created)) {
1528  // $user->setRecordId(mysql_insert_id());
1529  // $user->created = $time;
1530  // }
1531  // $user->updated = $time;
1532  // }
1533 
1534  // return $ok;
1535  }
global $DIC
Definition: saml.php:7
Class to represent an LTI Tool Provider.
Class ilDatabaseException.
$time
Definition: cron.php:21
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$query
Class to provide a connection to a persistent store for LTI objects.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

Field Documentation

◆ $logger

ilLTIDataConnector::$logger = null
private

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