Class to provide a connection to a persistent store for LTI objects. More...
Public Member Functions | |
| bool | loadToolConsumer ($consumer) |
| Load tool consumer object. | |
| bool | saveToolConsumer ($consumer) |
| Save tool consumer object. | |
| bool | deleteToolConsumer ($consumer) |
| Delete tool consumer object. | |
| ToolConsumer[] | getToolConsumers () |
| Load tool consumer objects. | |
| bool | loadPlatform ($platform) |
| Load platform object. | |
| bool | savePlatform ($platform) |
| Save platform object. | |
| bool | deletePlatform ($platform) |
| Delete platform object. | |
| Platform[] | getPlatforms () |
| Load platform objects. | |
| bool | loadContext ($context) |
| Load context object. | |
| bool | saveContext ($context) |
| Save context object. | |
| bool | deleteContext ($context) |
| Delete context object. | |
| bool | loadResourceLink ($resourceLink) |
| Load resource link object. | |
| bool | saveResourceLink ($resourceLink) |
| Save resource link object. | |
| bool | deleteResourceLink ($resourceLink) |
| Delete resource link object. | |
| UserResult[] | getUserResultSourcedIDsResourceLink ($resourceLink, $localOnly, $idScope) |
| Get array of user objects. | |
| ResourceLinkShare[] | getSharesResourceLink ($resourceLink) |
| Get array of shares defined for this resource link. | |
| bool | loadConsumerNonce ($nonce) |
| Load nonce object. | |
| bool | saveConsumerNonce ($nonce) |
| Save nonce object. | |
| bool | deleteConsumerNonce ($nonce) |
| Delete nonce object. | |
| bool | loadPlatformNonce ($nonce) |
| Load nonce object. | |
| bool | savePlatformNonce ($nonce) |
| Save nonce object. | |
| bool | deletePlatformNonce ($nonce) |
| Delete nonce object. | |
| bool | loadAccessToken ($accessToken) |
| Load access token object. | |
| bool | saveAccessToken ($accessToken) |
| Save access token object. | |
| bool | loadResourceLinkShareKey ($shareKey) |
| Load resource link share key object. | |
| bool | saveResourceLinkShareKey ($shareKey) |
| Save resource link share key object. | |
| bool | deleteResourceLinkShareKey ($shareKey) |
| Delete resource link share key object. | |
| bool | loadUserResult ($userresult) |
| Load user object. | |
| bool | saveUserResult ($userresult) |
| Save user object. | |
| bool | deleteUserResult ($userresult) |
| Delete user object. | |
| bool | loadTool ($tool) |
| Load tool object. | |
| bool | saveTool ($tool) |
| Save tool object. | |
| bool | deleteTool ($tool) |
| Delete tool object. | |
| Tool[] | getTools () |
| Load platform objects. | |
| string | escape ($value, $addQuotes=true) |
| Escape a string for use in a database query. | |
Static Public Member Functions | |
| static bool | useMemcache ($host=null, $port=-1) |
| Set/check whether memcached should be used when available. | |
| static DataConnector | getDataConnector ($db=null, $dbTableNamePrefix='', $type='') |
| Create data connector object. | |
| static string | getRandomString ($length=8) |
| Generate a random string. | |
| static string | quoted ($value, $addQuotes=true) |
| Quote a string for use in a database query. | |
Public Attributes | |
| const | PLATFORM_TABLE_NAME = 'lti2_consumer' |
| Default name for database table used to store platforms. | |
| const | CONSUMER_TABLE_NAME = self::PLATFORM_TABLE_NAME |
| 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. | |
Protected Member Functions | |
| __construct ($db, $dbTableNamePrefix='') | |
| Class constructor. | |
| fixPlatformSettings ($platform, $isSave) | |
| Adjust the settings for any platform properties being stored as a setting value. | |
| fixToolSettings ($tool, $isSave) | |
| Adjust the settings for any tool properties being stored as a setting value. | |
Protected Attributes | |
| object resource | $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') | |
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.
|
protected |
Class constructor.
| object | resource | $db | Database connection object |
| string | $dbTableNamePrefix | Prefix for database table names (optional, default is none) |
Reimplemented in DataConnector_mysql, DataConnector_oci, and DataConnector_pdo_oci.
| bool deleteConsumerNonce | ( | $nonce | ) |
Delete nonce object.
| ConsumerNonce | $nonce | Nonce object |
| bool deleteContext | ( | $context | ) |
Delete context object.
| Context | $context | Context object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool deletePlatform | ( | $platform | ) |
Delete platform object.
| Platform | $platform | Platform object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool deletePlatformNonce | ( | $nonce | ) |
Delete nonce object.
| PlatformNonce | $nonce | Nonce object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool deleteResourceLink | ( | $resourceLink | ) |
Delete resource link object.
| ResourceLink | $resourceLink | ResourceLink object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool deleteResourceLinkShareKey | ( | $shareKey | ) |
Delete resource link share key object.
| ResourceLinkShareKey | $shareKey | Resource link share key object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool deleteTool | ( | $tool | ) |
Delete tool object.
| Tool | $tool | Tool object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool deleteToolConsumer | ( | $consumer | ) |
Delete tool consumer object.
| ToolConsumer | $consumer | Tool consumer object |
| bool deleteUserResult | ( | $userresult | ) |
Delete user object.
| UserResult | $userresult | UserResult object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| string escape | ( | $value, | |
$addQuotes = true |
|||
| ) |
Escape a string for use in a database query.
Any single quotes in the value passed will be replaced with two single quotes. If a null value is passed, a string of 'null' is returned (which will never be enclosed in quotes irrespective of the value of the $addQuotes parameter.
| string | $value | Value to be escaped |
| bool | $addQuotes | If true the returned string will be enclosed in single quotes (optional, default is true) |
Reimplemented in DataConnector_mysql, DataConnector_pg, and DataConnector_sqlsrv.
|
protected |
Adjust the settings for any platform properties being stored as a setting value.
| Platform | $platform | Platform object |
| bool | $isSave | True if the settings are being saved |
Referenced by DataConnector_mysql\getPlatforms(), DataConnector_mysqli\getPlatforms(), DataConnector_oci\getPlatforms(), DataConnector_pdo\getPlatforms(), DataConnector_pg\getPlatforms(), DataConnector_sqlsrv\getPlatforms(), DataConnector_mysql\loadPlatform(), DataConnector_mysqli\loadPlatform(), DataConnector_oci\loadPlatform(), DataConnector_pdo\loadPlatform(), DataConnector_pg\loadPlatform(), DataConnector_sqlsrv\loadPlatform(), DataConnector_mysql\savePlatform(), DataConnector_mysqli\savePlatform(), DataConnector_oci\savePlatform(), DataConnector_pdo\savePlatform(), DataConnector_pg\savePlatform(), and DataConnector_sqlsrv\savePlatform().
|
protected |
Adjust the settings for any tool properties being stored as a setting value.
| Tool | $tool | Tool object |
| bool | $isSave | True if the settings are being saved |
Referenced by DataConnector_mysql\getTools(), DataConnector_mysqli\getTools(), DataConnector_oci\getTools(), DataConnector_pdo\getTools(), DataConnector_pg\getTools(), DataConnector_sqlsrv\getTools(), DataConnector_mysql\loadTool(), DataConnector_mysqli\loadTool(), DataConnector_oci\loadTool(), DataConnector_pdo\loadTool(), DataConnector_pg\loadTool(), DataConnector_sqlsrv\loadTool(), DataConnector_mysql\saveTool(), DataConnector_mysqli\saveTool(), DataConnector_oci\saveTool(), DataConnector_pdo\saveTool(), DataConnector_pg\saveTool(), and DataConnector_sqlsrv\saveTool().
|
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.
| object | resource | $db | A database connection object or string (optional, default is no persistence) |
| string | $dbTableNamePrefix | Prefix for database table names (optional, default is none) |
| string | $type | The type of data connector (optional, default is based on $db parameter) |
| Platform[] getPlatforms | ( | ) |
Load platform objects.
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
|
static |
Generate a random string.
The generated string will only comprise letters (upper- and lower-case) and digits.
| int | $length | Length of string to be generated (optional, default is 8 characters) |
| ResourceLinkShare[] getSharesResourceLink | ( | $resourceLink | ) |
Get array of shares defined for this resource link.
| ResourceLink | $resourceLink | ResourceLink object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| ToolConsumer[] getToolConsumers | ( | ) |
Load tool consumer objects.
| Tool[] getTools | ( | ) |
Load platform objects.
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| UserResult[] getUserResultSourcedIDsResourceLink | ( | $resourceLink, | |
| $localOnly, | |||
| $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.
| ResourceLink | $resourceLink | Resource link object |
| bool | $localOnly | True if only users within the resource link are to be returned (excluding users sharing this resource link) |
| int | $idScope | Scope value to use for user IDs |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pdo_pgsql, DataConnector_pg, and DataConnector_sqlsrv.
Referenced by ResourceLink\getLineItems().
| bool loadAccessToken | ( | $accessToken | ) |
Load access token object.
| AccessToken | $accessToken | Access token object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool loadConsumerNonce | ( | $nonce | ) |
Load nonce object.
| ConsumerNonce | $nonce | Nonce object |
| bool loadContext | ( | $context | ) |
Load context object.
| Context | $context | Context object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool loadPlatform | ( | $platform | ) |
Load platform object.
| Platform | $platform | Platform object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
Referenced by Platform\fromPlatformId().
| bool loadPlatformNonce | ( | $nonce | ) |
Load nonce object.
| PlatformNonce | $nonce | Nonce object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool loadResourceLink | ( | $resourceLink | ) |
Load resource link object.
| ResourceLink | $resourceLink | ResourceLink object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool loadResourceLinkShareKey | ( | $shareKey | ) |
Load resource link share key object.
| ResourceLinkShareKey | $shareKey | ResourceLink share key object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool loadTool | ( | $tool | ) |
Load tool object.
| Tool | $tool | Tool object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool loadToolConsumer | ( | $consumer | ) |
Load tool consumer object.
| ToolConsumer | $consumer | Tool consumer object |
| bool loadUserResult | ( | $userresult | ) |
Load user object.
| UserResult | $userresult | UserResult object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
|
static |
Quote a string for use in a database query.
Any single quotes in the value passed will be replaced with two single quotes. If a null value is passed, a string of 'null' is returned (which will never be enclosed in quotes irrespective of the value of the $addQuotes parameter.
| string | $value | Value to be quoted |
| bool | $addQuotes | If true the returned string will be enclosed in single quotes (optional, default is true) |
| bool saveAccessToken | ( | $accessToken | ) |
Save access token object.
| AccessToken | $accessToken | Access token object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool saveConsumerNonce | ( | $nonce | ) |
Save nonce object.
| ConsumerNonce | $nonce | Nonce object |
| bool saveContext | ( | $context | ) |
Save context object.
| Context | $context | Context object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool savePlatform | ( | $platform | ) |
Save platform object.
| Platform | $platform | Platform object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool savePlatformNonce | ( | $nonce | ) |
Save nonce object.
| PlatformNonce | $nonce | Nonce object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool saveResourceLink | ( | $resourceLink | ) |
Save resource link object.
| ResourceLink | $resourceLink | ResourceLink object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool saveResourceLinkShareKey | ( | $shareKey | ) |
Save resource link share key object.
| ResourceLinkShareKey | $shareKey | Resource link share key object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pdo_pgsql, DataConnector_pg, and DataConnector_sqlsrv.
| bool saveTool | ( | $tool | ) |
Save tool object.
| Tool | $tool | Tool object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
| bool saveToolConsumer | ( | $consumer | ) |
Save tool consumer object.
| ToolConsumer | $consumer | Tool consumer object |
| bool saveUserResult | ( | $userresult | ) |
Save user object.
| UserResult | $userresult | UserResult object |
Reimplemented in DataConnector_mysql, DataConnector_mysqli, DataConnector_oci, DataConnector_pdo, DataConnector_pg, and DataConnector_sqlsrv.
|
static |
Set/check whether memcached should be used when available.
| string | $host | Name or IP address of host running memcache server (use an empty string to disable) |
| int | $port | Port number used by memcache server (use -1 for default) |
|
protected |
SQL date format (default = 'Y-m-d')
$dateFormat
|
protected |
Database connection.
$db
Referenced by DataConnector_mysql\__construct(), and DataConnector_oci\__construct().
|
protected |
Prefix for database table names.
$dbTableNamePrefix
Referenced by DataConnector_mysql\__construct(), and DataConnector_oci\__construct().
|
protected |
SQL time format (default = 'H:i:s')
$timeFormat
| const CONSUMER_TABLE_NAME = self::PLATFORM_TABLE_NAME |
Default name for database table used to store platforms.