LTI Integration Library 5.3.1
PHP class library for building LTI integrations
Loading...
Searching...
No Matches

Class to provide a connection to a persistent store for LTI objects. More...

Inheritance diagram for DataConnector:

Public Member Functions

bool loadPlatform (Platform $platform)
 Load platform object.
bool savePlatform (Platform $platform)
 Save platform object.
bool deletePlatform (Platform $platform)
 Delete platform object.
Platform[] getPlatforms ()
 Load platform objects.
bool loadContext (Context $context)
 Load context object.
bool saveContext (Context $context)
 Save context object.
bool deleteContext (Context $context)
 Delete context object.
bool loadResourceLink (ResourceLink $resourceLink)
 Load resource link object.
bool saveResourceLink (ResourceLink $resourceLink)
 Save resource link object.
bool deleteResourceLink (ResourceLink $resourceLink)
 Delete resource link object.
UserResult[] getUserResultSourcedIDsResourceLink (ResourceLink $resourceLink, bool $localOnly, ?IdScope $idScope)
 Get array of user objects.
ResourceLinkShare[] getSharesResourceLink (ResourceLink $resourceLink)
 Get array of shares defined for this resource link.
bool loadPlatformNonce (PlatformNonce $nonce)
 Load nonce object.
bool savePlatformNonce (PlatformNonce $nonce)
 Save nonce object.
bool deletePlatformNonce (PlatformNonce $nonce)
 Delete nonce object.
bool loadAccessToken (AccessToken $accessToken)
 Load access token object.
bool saveAccessToken (AccessToken $accessToken)
 Save access token object.
bool loadResourceLinkShareKey (ResourceLinkShareKey $shareKey)
 Load resource link share key object.
bool saveResourceLinkShareKey (ResourceLinkShareKey $shareKey)
 Save resource link share key object.
bool deleteResourceLinkShareKey (ResourceLinkShareKey $shareKey)
 Delete resource link share key object.
bool loadUserResult (UserResult $userResult)
 Load user object.
bool saveUserResult (UserResult $userResult)
 Save user object.
bool deleteUserResult (UserResult $userResult)
 Delete user object.
bool loadTool (Tool $tool)
 Load tool object.
bool saveTool (Tool $tool)
 Save tool object.
bool deleteTool (Tool $tool)
 Delete tool object.
Tool[] getTools ()
 Load tool objects.

Static Public Member Functions

static bool useMemcache (?string $host=null, int $port=-1)
 Set/check whether memcached should be used when available.
static DataConnector getDataConnector (mixed $db=null, string $dbTableNamePrefix="", string $type="")
 Create data connector object.

Public Attributes

const PLATFORM_TABLE_NAME = 'lti2_consumer'
 Default name for database table used to store platforms.
const CONTEXT_TABLE_NAME = 'lti2_context'
 Default name for database table used to store contexts.
const RESOURCE_LINK_TABLE_NAME = 'lti2_resource_link'
 Default name for database table used to store resource links.
const USER_RESULT_TABLE_NAME = 'lti2_user_result'
 Default name for database table used to store users.
const RESOURCE_LINK_SHARE_KEY_TABLE_NAME = 'lti2_share_key'
 Default name for database table used to store resource link share keys.
const NONCE_TABLE_NAME = 'lti2_nonce'
 Default name for database table used to store nonce values.
const ACCESS_TOKEN_TABLE_NAME = 'lti2_access_token'
 Default name for database table used to store access token values.
const TOOL_TABLE_NAME = 'lti2_tool'
 Default name for database table used to store tools.

Static Public Attributes

static int $maximumSecretLength = 1024
 Maximum length for a platform/tool shared secret field (default = 1024).

Protected Member Functions

 __construct (mixed $db, string $dbTableNamePrefix="")
 Class constructor.
void fixPlatformSettings (Platform $platform, bool $isSave)
 Adjust the settings for any platform properties being stored as a setting value.
void fixToolSettings (Tool $tool, bool $isSave)
 Adjust the settings for any tool properties being stored as a setting value.
string dbTableName (string $table)
 Add the prefix to the name for a database table.

Protected Attributes

mixed $db = null
 Database connection.
string $dbTableNamePrefix = ''
 Prefix for database table names.
string $dateFormat = 'Y-m-d'
 SQL date format (default = 'Y-m-d').
string $timeFormat = 'H:i:s'
 SQL time format (default = 'H:i:s').

Detailed Description

Class to provide a connection to a persistent store for LTI objects.

This class assumes no data persistence - it should be extended for specific database connections.

Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com
Licence: http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3

Constructor & Destructor Documentation

◆ __construct()

__construct ( mixed $db,
string $dbTableNamePrefix = "" )
protected

Class constructor.

Parameters
object | resource$dbDatabase connection object
string$dbTableNamePrefixPrefix for database table names (optional, default is none)

Reimplemented in DataConnector_oci8.

Member Function Documentation

◆ dbTableName()

string dbTableName ( string $table)
protected

Add the prefix to the name for a database table.

Parameters
string$tableName of table without prefix
Returns
string The fullname of the database table

Referenced by DataConnector_oci8\__construct(), DataConnector_mysqli\deleteContext(), DataConnector_pdo\deleteContext(), DataConnector_pgsql\deleteContext(), DataConnector_sql\deleteContext(), DataConnector_mysqli\deletePlatform(), DataConnector_oci8\deletePlatform(), DataConnector_pdo\deletePlatform(), DataConnector_pgsql\deletePlatform(), DataConnector_sql\deletePlatform(), DataConnector_oci8\deleteResourceLinkShareKey(), DataConnector_pdo\deleteResourceLinkShareKey(), DataConnector_mysqli\deleteUserResult(), DataConnector_oci8\deleteUserResult(), DataConnector_pgsql\deleteUserResult(), DataConnector_sql\deleteUserResult(), DataConnector_mysqli\getSharesResourceLink(), DataConnector_oci8\getSharesResourceLink(), DataConnector_pdo\getSharesResourceLink(), DataConnector_pgsql\getSharesResourceLink(), DataConnector_sql\getSharesResourceLink(), DataConnector_mysqli\getUserResultSourcedIDsResourceLink(), DataConnector_oci8\getUserResultSourcedIDsResourceLink(), DataConnector_pdo\getUserResultSourcedIDsResourceLink(), DataConnector_pdo_pgsql\getUserResultSourcedIDsResourceLink(), DataConnector_pgsql\getUserResultSourcedIDsResourceLink(), DataConnector_sql\getUserResultSourcedIDsResourceLink(), DataConnector_pgsql\loadPlatform(), DataConnector_sql\loadPlatform(), DataConnector_oci8\loadPlatformNonce(), DataConnector_pdo\loadPlatformNonce(), DataConnector_pgsql\loadPlatformNonce(), DataConnector_sql\loadPlatformNonce(), DataConnector_pgsql\loadResourceLinkShareKey(), DataConnector_sql\loadResourceLinkShareKey(), DataConnector_mysqli\loadUserResult(), DataConnector_oci8\loadUserResult(), DataConnector_pdo\loadUserResult(), DataConnector_pgsql\loadUserResult(), DataConnector_sql\loadUserResult(), DataConnector_mysqli\saveAccessToken(), DataConnector_oci8\saveAccessToken(), DataConnector_pdo\saveAccessToken(), DataConnector_pgsql\saveAccessToken(), DataConnector_sql\saveAccessToken(), DataConnector_mysqli\saveContext(), DataConnector_mysqli\savePlatformNonce(), DataConnector_pgsql\savePlatformNonce(), DataConnector_sql\savePlatformNonce(), DataConnector_mysqli\saveResourceLink(), DataConnector_pdo\saveResourceLink(), DataConnector_sql\saveResourceLink(), DataConnector_mysqli\saveResourceLinkShareKey(), DataConnector_pdo\saveResourceLinkShareKey(), DataConnector_pgsql\saveResourceLinkShareKey(), DataConnector_sql\saveResourceLinkShareKey(), DataConnector_sql\saveTool(), DataConnector_mysqli\saveUserResult(), DataConnector_oci8\saveUserResult(), DataConnector_pdo\saveUserResult(), DataConnector_pgsql\saveUserResult(), and DataConnector_sql\saveUserResult().

◆ deleteContext()

bool deleteContext ( Context $context)

Delete context object.

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

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References deleteResourceLink(), and ResourceLink\initialize().

Referenced by getPlatforms().

◆ deletePlatform()

bool deletePlatform ( Platform $platform)

Delete platform object.

Parameters
Platform$platformPlatform object
Returns
bool True if the platform object was successfully deleted

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

◆ deletePlatformNonce()

bool deletePlatformNonce ( PlatformNonce $nonce)

Delete nonce object.

Parameters
PlatformNonce$nonceNonce object
Returns
bool True if the nonce object was successfully deleted

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

◆ deleteResourceLink()

bool deleteResourceLink ( ResourceLink $resourceLink)

Delete resource link object.

Parameters
ResourceLink$resourceLinkResourceLink object
Returns
bool True if the resource link object was successfully deleted

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References PlatformNonce\getPlatform(), System\getRecordId(), PlatformNonce\getValue(), and loadPlatformNonce().

Referenced by deleteContext().

◆ deleteResourceLinkShareKey()

bool deleteResourceLinkShareKey ( ResourceLinkShareKey $shareKey)

Delete resource link share key object.

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

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References deleteUserResult(), and UserResult\initialize().

◆ deleteTool()

bool deleteTool ( Tool $tool)

Delete tool object.

Parameters
Tool$toolTool object
Returns
bool True if the tool object was successfully deleted

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References $db.

Referenced by deleteUserResult().

◆ deleteUserResult()

bool deleteUserResult ( UserResult $userResult)

Delete user object.

Parameters
UserResult$userResultUserResult object
Returns
bool True if the user object was successfully deleted

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References deleteTool(), and Tool\initialize().

Referenced by deleteResourceLinkShareKey().

◆ fixPlatformSettings()

void fixPlatformSettings ( Platform $platform,
bool $isSave )
protected

Adjust the settings for any platform properties being stored as a setting value.

Parameters
Platform$platformPlatform object
bool$isSaveTrue if the settings are being saved

References Util\$logLevel.

◆ fixToolSettings()

void fixToolSettings ( Tool $tool,
bool $isSave )
protected

Adjust the settings for any tool properties being stored as a setting value.

Parameters
Tool$toolTool object
bool$isSaveTrue if the settings are being saved

◆ getDataConnector()

DataConnector getDataConnector ( mixed $db = null,
string $dbTableNamePrefix = "",
string $type = "" )
static

Create data connector object.

A data connector provides access to persistent storage for the different objects.

Names of tables may be given a prefix to allow multiple versions to share the same schema. A separate sub-class is defined for each different database connection - the class to use is determined by inspecting the database object passed, but this can be overridden (for example, to use a bespoke connector) by specifying a type. If no database is passed then this class is used which acts as a dummy connector with no persistence.

Parameters
object | resource$dbA database connection object or string (optional, default is no persistence)
string$dbTableNamePrefixPrefix for database table names (optional, default is none)
string$typeThe type of data connector (optional, default is based on $db parameter)
Returns
DataConnector Data connector object

References Util\$logLevel.

Referenced by saveTool().

◆ getPlatforms()

Platform[] getPlatforms ( )

Load platform objects.

Returns
Platform[] Array of all defined Platform objects

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References deleteContext(), and Context\initialize().

◆ getSharesResourceLink()

ResourceLinkShare[] getSharesResourceLink ( ResourceLink $resourceLink)

Get array of shares defined for this resource link.

Parameters
ResourceLink$resourceLinkResourceLink object
Returns
ResourceLinkShare[] Array of ResourceLinkShare objects

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

◆ getTools()

Tool[] getTools ( )

Load tool objects.

Returns
Tool[] Array of all defined Tool objects

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References $db, and $dbTableNamePrefix.

◆ getUserResultSourcedIDsResourceLink()

UserResult[] getUserResultSourcedIDsResourceLink ( ResourceLink $resourceLink,
bool $localOnly,
?IdScope $idScope )

Get array of user objects.

Obtain an array of UserResult 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
bool$localOnlyTrue if only users within the resource link are to be returned (excluding users sharing this resource link)
IdScope | null$idScopeScope value to use for user IDs
Returns
UserResult[] Array of UserResult objects

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pdo_pgsql, DataConnector_pgsql, and DataConnector_sql.

References PlatformNonce\getPlatform(), System\getRecordId(), PlatformNonce\getValue(), and savePlatformNonce().

Referenced by loadResourceLink().

◆ loadAccessToken()

bool loadAccessToken ( AccessToken $accessToken)

Load access token object.

Parameters
AccessToken$accessTokenAccess token object
Returns
bool True if the nonce object was successfully loaded

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

Referenced by savePlatformNonce().

◆ loadContext()

bool loadContext ( Context $context)

Load context object.

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

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References loadResourceLink().

◆ loadPlatform()

bool loadPlatform ( Platform $platform)

Load platform object.

Parameters
Platform$platformPlatform object
Returns
bool True if the platform object was successfully loaded

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

Referenced by useMemcache().

◆ loadPlatformNonce()

bool loadPlatformNonce ( PlatformNonce $nonce)

Load nonce object.

Parameters
PlatformNonce$nonceNonce object
Returns
bool True if the nonce object was successfully loaded

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

Referenced by deleteResourceLink().

◆ loadResourceLink()

bool loadResourceLink ( ResourceLink $resourceLink)

Load resource link object.

Parameters
ResourceLink$resourceLinkResourceLink object
Returns
bool True if the resource link object was successfully loaded

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References getUserResultSourcedIDsResourceLink().

Referenced by loadContext().

◆ loadResourceLinkShareKey()

bool loadResourceLinkShareKey ( ResourceLinkShareKey $shareKey)

Load resource link share key object.

Parameters
ResourceLinkShareKey$shareKeyResourceLink share key object
Returns
bool True if the resource link share key object was successfully loaded

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

◆ loadTool()

bool loadTool ( Tool $tool)

Load tool object.

Parameters
Tool$toolTool object
Returns
bool True if the tool object was successfully loaded

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

Referenced by loadUserResult().

◆ loadUserResult()

bool loadUserResult ( UserResult $userResult)

Load user object.

Parameters
UserResult$userResultUserResult object
Returns
bool True if the user object was successfully loaded

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References loadTool().

◆ saveAccessToken()

bool saveAccessToken ( AccessToken $accessToken)

Save access token object.

Parameters
AccessToken$accessTokenAccess token object
Returns
bool True if the access token object was successfully saved

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References saveResourceLinkShareKey().

◆ saveContext()

bool saveContext ( Context $context)

Save context object.

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

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References saveResourceLink().

◆ savePlatform()

bool savePlatform ( Platform $platform)

Save platform object.

Parameters
Platform$platformPlatform object
Returns
bool True if the platform object was successfully saved

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

◆ savePlatformNonce()

bool savePlatformNonce ( PlatformNonce $nonce)

Save nonce object.

Parameters
PlatformNonce$nonceNonce object
Returns
bool True if the nonce object was successfully saved

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References AccessToken\get(), AccessToken\getPlatform(), System\getRecordId(), and loadAccessToken().

Referenced by getUserResultSourcedIDsResourceLink().

◆ saveResourceLink()

bool saveResourceLink ( ResourceLink $resourceLink)

Save resource link object.

Parameters
ResourceLink$resourceLinkResourceLink object
Returns
bool True if the resource link object was successfully saved

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

Referenced by saveContext().

◆ saveResourceLinkShareKey()

bool saveResourceLinkShareKey ( ResourceLinkShareKey $shareKey)

Save resource link share key object.

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

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pdo_pgsql, DataConnector_pgsql, and DataConnector_sql.

Referenced by saveAccessToken().

◆ saveTool()

bool saveTool ( Tool $tool)

Save tool object.

Parameters
Tool$toolTool object
Returns
bool True if the tool object was successfully saved

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References $db, $dbTableNamePrefix, and getDataConnector().

Referenced by saveUserResult().

◆ saveUserResult()

bool saveUserResult ( UserResult $userResult)

Save user object.

Parameters
UserResult$userResultUserResult object
Returns
bool True if the user object was successfully saved

Reimplemented in DataConnector_mysqli, DataConnector_oci8, DataConnector_pdo, DataConnector_pgsql, and DataConnector_sql.

References saveTool().

◆ useMemcache()

bool useMemcache ( ?string $host = null,
int $port = -1 )
static

Set/check whether memcached should be used when available.

Parameters
string$hostName or IP address of host running memcache server (use an empty string to disable)
int$portPort number used by memcache server (use -1 for default)
Returns
bool True if memcache is enabled

References loadPlatform().