Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

(no description)

File Size: 608 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: DataConnector  - X-Ref

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.

__construct($db, $dbTableNamePrefix = '')   X-Ref
Class constructor

param: object $db                 Database connection object
param: string $dbTableNamePrefix  Prefix for database table names (optional, default is none)

loadToolConsumer($consumer)   X-Ref
Load tool consumer object.

param: ToolConsumer $consumer ToolConsumer object
return: boolean True if the tool consumer object was successfully loaded

saveToolConsumer($consumer)   X-Ref
Save tool consumer object.

param: ToolConsumer $consumer Consumer object
return: boolean True if the tool consumer object was successfully saved

deleteToolConsumer($consumer)   X-Ref
Delete tool consumer object.

param: ToolConsumer $consumer Consumer object
return: boolean True if the tool consumer object was successfully deleted

getToolConsumers()   X-Ref
Load tool consumer objects.

return: array Array of all defined ToolConsumer objects

loadToolProxy($toolProxy)   X-Ref
Load tool proxy object.

param: ToolProxy $toolProxy ToolProxy object
return: boolean True if the tool proxy object was successfully loaded

saveToolProxy($toolProxy)   X-Ref
Save tool proxy object.

param: ToolProxy $toolProxy ToolProxy object
return: boolean True if the tool proxy object was successfully saved

deleteToolProxy($toolProxy)   X-Ref
Delete tool proxy object.

param: ToolProxy $toolProxy ToolProxy object
return: boolean True if the tool proxy object was successfully deleted

loadContext($context)   X-Ref
Load context object.

param: Context $context Context object
return: boolean True if the context object was successfully loaded

saveContext($context)   X-Ref
Save context object.

param: Context $context Context object
return: boolean True if the context object was successfully saved

deleteContext($context)   X-Ref
Delete context object.

param: Context $context Context object
return: boolean True if the Context object was successfully deleted

loadResourceLink($resourceLink)   X-Ref
Load resource link object.

param: ResourceLink $resourceLink Resource_Link object
return: boolean True if the resource link object was successfully loaded

saveResourceLink($resourceLink)   X-Ref
Save resource link object.

param: ResourceLink $resourceLink Resource_Link object
return: boolean True if the resource link object was successfully saved

deleteResourceLink($resourceLink)   X-Ref
Delete resource link object.

param: ResourceLink $resourceLink Resource_Link object
return: boolean True if the resource link object was successfully deleted

getUserResultSourcedIDsResourceLink($resourceLink, $localOnly, $idScope)   X-Ref
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.

param: ResourceLink $resourceLink      Resource link object
param: boolean     $localOnly True if only users within the resource link are to be returned (excluding users sharing this resource link)
param: int         $idScope     Scope value to use for user IDs
return: array Array of User objects

getSharesResourceLink($resourceLink)   X-Ref
Get array of shares defined for this resource link.

param: ResourceLink $resourceLink Resource_Link object
return: array Array of ResourceLinkShare objects

loadConsumerNonce($nonce)   X-Ref
Load nonce object.

param: ConsumerNonce $nonce Nonce object
return: boolean True if the nonce object was successfully loaded

saveConsumerNonce($nonce)   X-Ref
Save nonce object.

param: ConsumerNonce $nonce Nonce object
return: boolean True if the nonce object was successfully saved

loadResourceLinkShareKey($shareKey)   X-Ref
Load resource link share key object.

param: ResourceLinkShareKey $shareKey Resource_Link share key object
return: boolean True if the resource link share key object was successfully loaded

saveResourceLinkShareKey($shareKey)   X-Ref
Save resource link share key object.

param: ResourceLinkShareKey $shareKey Resource link share key object
return: boolean True if the resource link share key object was successfully saved

deleteResourceLinkShareKey($shareKey)   X-Ref
Delete resource link share key object.

param: ResourceLinkShareKey $shareKey Resource link share key object
return: boolean True if the resource link share key object was successfully deleted

loadUser($user)   X-Ref
Load user object.

param: User $user User object
return: boolean True if the user object was successfully loaded

saveUser($user)   X-Ref
Save user object.

param: User $user User object
return: boolean True if the user object was successfully saved

deleteUser($user)   X-Ref
Delete user object.

param: User $user User object
return: boolean True if the user object was successfully deleted

getConsumerKey($key)   X-Ref
Return a hash of a consumer key for values longer than 255 characters.

param: string $key
return: string

getDataConnector($dbTableNamePrefix = '', $db = null, $type = '')   X-Ref
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.

param: string  $dbTableNamePrefix  Prefix for database table names (optional, default is none)
param: object  $db                 A database connection object or string (optional, default is no persistence)
param: string  $type               The type of data connector (optional, default is based on $db parameter)
return: DataConnector Data connector object

getRandomString($length = 8)   X-Ref
Generate a random string.

The generated string will only comprise letters (upper- and lower-case) and digits.

param: int $length Length of string to be generated (optional, default is 8 characters)
return: string Random string

quoted($value, $addQuotes = true)   X-Ref
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.

param: string $value Value to be quoted
param: bool $addQuotes If true the returned string will be enclosed in single quotes (optional, default is true)
return: string The quoted string.