LTI Integration Library 4.10.3
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
Platform Class Reference

Class to represent a platform. More...

Inheritance diagram for Platform:
System ApiHook ToolConsumer

Public Member Functions

 __construct ($dataConnector=null)
 Class constructor.
 
 initialize ()
 Initialise the platform.
 
 initialise ()
 Initialise the platform.
 
 save ()
 Save the platform to the database.
 
 delete ()
 Delete the platform from the database.
 
 getId ()
 Get the platform ID.
 
 getFamilyCode ()
 Get platform family code (as reported by last platform connection).
 
 getDataConnector ()
 Get the data connector.
 
 getAccessToken ()
 Get the authorization access token.
 
 setAccessToken ($accessToken)
 Set the authorization access token.
 
 getIsAvailable ()
 Is the platform available to accept launch requests?
 
 hasToolSettingsService ()
 Check if the Tool Settings service is supported.
 
 getToolSettings ($simple=true)
 Get Tool Settings.
 
 setToolSettings ($settings=array())
 Set Tool Settings.
 
 getTools ()
 Get an array of defined tools.
 
 hasAccessTokenService ()
 Check if the Access Token service is supported.
 
 getMessageParameters ()
 Get the message parameters.
 
 handleRequest ()
 Process an incoming request.
 
- Public Member Functions inherited from System
 getRecordId ()
 Get the system record ID.
 
 setRecordId ($id)
 Sets the system record ID.
 
 getKey ()
 Get the consumer key.
 
 setKey ($key)
 Set the consumer key.
 
 getSetting ($name, $default='')
 Get a setting value.
 
 setSetting ($name, $value=null)
 Set a setting value.
 
 getSettings ()
 Get an array of all setting values.
 
 setSettings ($settings)
 Set an array of all setting values.
 
 saveSettings ()
 Save setting values.
 
 hasJwt ()
 Check whether a JWT exists.
 
 getJwt ()
 Get the JWT.
 
 getRawParameters ()
 Get the raw POST parameters.
 
 getMessageClaims ($fullyQualified=false)
 Get the message claims.
 
 signParameters ($url, $type, $version, $params)
 Add the signature to an LTI message.
 
 signMessage (&$url, $type, $version, $params, $loginHint=null, $ltiMessageHint=null)
 Add the signature to an LTI message.
 
 sendMessage ($url, $type, $messageParams, $target='', $userId=null, $hint=null)
 Generate a web page containing an auto-submitted form of LTI message parameters.
 
 signServiceRequest ($url, $method, $type, $data=null)
 Generates the headers for an LTI service request.
 
 doServiceRequest ($service, $method, $format, $data)
 Perform a service request.
 
 useOAuth1 ()
 Determine whether this consumer is using the OAuth 1 security model.
 
 addSignature ($endpoint, $data, $method='POST', $type=null, $nonce='', $hash=null, $timestamp=null)
 Add the signature to an array of message parameters or to a header string.
 
 checkMessage ()
 Verify the required properties of an LTI message.
 
 verifySignature ()
 Verify the signature of a message.
 

Static Public Member Functions

static fromConsumerKey ($key=null, $dataConnector=null, $autoEnable=false)
 Load the platform from the database by its consumer key.
 
static fromPlatformId ($platformId, $clientId, $deploymentId, $dataConnector=null, $autoEnable=false)
 Load the platform from the database by its platform, client and deployment IDs.
 
static fromRecordId ($id, $dataConnector)
 Load the platform from the database by its record ID.
 
static getStorageJS ()
 Get the JavaScript for handling storage postMessages from a tool.
 
- Static Public Member Functions inherited from System
static parseRoles ($roles, $ltiVersion=Util::LTI_VERSION1, $addPrincipalRole=false)
 Parse a set of roles to comply with a specified version of LTI.
 
- Static Public Member Functions inherited from ApiHook
static registerApiHook ($hookName, $familyCode, $className)
 Register the availability of an API hook.
 

Data Fields

 $name = null
 Local name of platform.
 
 $platformId = null
 Platform ID.
 
 $clientId = null
 Client ID.
 
 $deploymentId = null
 Deployment ID.
 
 $authorizationServerId = null
 Authorization server ID.
 
 $authenticationUrl = null
 Login authentication URL.
 
 $accessTokenUrl = null
 Access Token service URL.
 
 $consumerName = null
 Name of platform (as reported by last platform connection).
 
 $consumerVersion = null
 Platform version (as reported by last platform connection).
 
 $profile = null
 The platform profile data.
 
 $toolProxy = null
 The tool proxy.
 
 $consumerGuid = null
 Platform GUID (as reported by first platform connection).
 
 $cssPath = null
 Optional CSS path (as reported by last platform connection).
 
 $protected = false
 Whether the platform instance is protected by matching the consumer_guid value in incoming requests.
 
 $idScope = Tool::ID_SCOPE_ID_ONLY
 Default scope to use when generating an Id value for a user.
 
 $defaultEmail = ''
 Default email address (or email domain) to use when no email address is provided for a user.
 
 $lastServiceRequest = null
 HttpMessage object for last service request.
 
- Data Fields inherited from System
 $ok = true
 True if the last request was successful.
 
 $ltiVersion = null
 LTI version.
 
 $name = null
 Local name of platform/tool.
 
 $secret = null
 Shared secret.
 
 $signatureMethod = 'HMAC-SHA1'
 Method used for signing messages.
 
 $encryptionMethod = ''
 Algorithm used for encrypting messages.
 
 $dataConnector = null
 Data connector object.
 
 $rsaKey = null
 RSA key in PEM or JSON format.
 
 $requiredScopes = array()
 Scopes to request when obtaining an access token.
 
 $kid = null
 Key ID.
 
 $jku = null
 Endpoint for public key.
 
 $reason = null
 Error message for last request processed.
 
 $details = array()
 Details for error message relating to last request processed.
 
 $warnings = array()
 Warnings relating to last request processed.
 
 $debugMode = false
 Whether debug level messages are to be reported.
 
 $enabled = false
 Whether the system instance is enabled to accept connection requests.
 
 $enableFrom = null
 Timestamp from which the the system instance is enabled to accept connection requests.
 
 $enableUntil = null
 Timestamp until which the system instance is enabled to accept connection requests.
 
 $lastAccess = null
 Timestamp for date of last connection to this system.
 
 $created = null
 Timestamp for when the object was created.
 
 $updated = null
 Timestamp for when the object was last updated.
 

Static Public Attributes

static $MESSAGE_TYPES
 List of supported incoming message types.
 
static $browserStorageFrame = null
 Name of browser storage frame.
 
- Static Public Attributes inherited from ApiHook
static $USER_ID_HOOK = "UserId"
 User Id hook name.
 
static $CONTEXT_ID_HOOK = "ContextId"
 Context Id hook name.
 
static $GROUPS_SERVICE_HOOK = "Groups"
 Course Groups service hook name.
 
static $MEMBERSHIPS_SERVICE_HOOK = "Memberships"
 Memberships service hook name.
 
static $OUTCOMES_SERVICE_HOOK = "Outcomes"
 Outcomes service hook name.
 
static $TOOL_SETTINGS_SERVICE_HOOK = "ToolSettings"
 Tool Settings service hook name.
 
static $ACCESS_TOKEN_SERVICE_HOOK = "AccessToken"
 Access Token service hook name.
 

Protected Member Functions

 onInitiateLogin (&$url, &$loginHint, &$ltiMessageHint, $params)
 Save the hint and message parameters when sending an initiate login request.
 
 onAuthenticate ()
 Check the hint and recover the message parameters for an authentication request.
 
 onContentItem ()
 Process a valid content-item message.
 
 onLtiStartAssessment ()
 Process a valid start assessment message.
 
 onError ()
 Process a response to an invalid message.
 

Additional Inherited Members

- Protected Attributes inherited from System
 $jwt = null
 JWT ClientInterface object.
 
 $rawParameters = null
 Raw message parameters.
 
 $messageParameters = null
 LTI message parameters.
 

Detailed Description

Class to represent a platform.

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

Definition at line 17 of file Platform.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $dataConnector = null)

Class constructor.

Parameters
DataConnector | null$dataConnectorA data connector object

Definition at line 168 of file Platform.php.

References System\$dataConnector, Context\getDataConnector(), and Platform\initialize().

Member Function Documentation

◆ delete()

delete ( )

Delete the platform from the database.

Returns
bool True if the object was successfully deleted

Definition at line 237 of file Platform.php.

◆ fromConsumerKey()

static fromConsumerKey (   $key = null,
  $dataConnector = null,
  $autoEnable = false 
)
static

Load the platform from the database by its consumer key.

Parameters
string | null$keyConsumer key
DataConnector$dataConnectorA data connector object
bool$autoEnableTrue if the platform is to be enabled automatically (optional, default is false)
Returns
Platform The platform object

Definition at line 486 of file Platform.php.

References System\$dataConnector, and System\$ok.

Referenced by ToolConsumer\__construct(), and DataConnector_pdo\getPlatforms().

◆ fromPlatformId()

static fromPlatformId (   $platformId,
  $clientId,
  $deploymentId,
  $dataConnector = null,
  $autoEnable = false 
)
static

Load the platform from the database by its platform, client and deployment IDs.

Parameters
string$platformIdThe platform ID
string | null$clientIdThe client ID
string | null$deploymentIdThe deployment ID
DataConnector$dataConnectorA data connector object
bool$autoEnableTrue if the platform is to be enabled automatically (optional, default is false)
Returns
Platform The platform object

Definition at line 511 of file Platform.php.

References Platform\$clientId, System\$dataConnector, Platform\$deploymentId, and Platform\$platformId.

◆ fromRecordId()

static fromRecordId (   $id,
  $dataConnector 
)
static

Load the platform from the database by its record ID.

Parameters
int | string$idThe platform record ID
DataConnector$dataConnectorA data connector object
Returns
Platform The platform object

Definition at line 534 of file Platform.php.

References System\$dataConnector.

Referenced by Context\getPlatform(), and ResourceLink\getPlatform().

◆ getAccessToken()

getAccessToken ( )

Get the authorization access token.

Returns
AccessToken|null Access token

Definition at line 302 of file Platform.php.

◆ getDataConnector()

getDataConnector ( )

Get the data connector.

Returns
DataConnector|null Data connector object or string

Definition at line 292 of file Platform.php.

References System\$dataConnector.

◆ getFamilyCode()

getFamilyCode ( )

Get platform family code (as reported by last platform connection).

Returns
string Family code

Definition at line 273 of file Platform.php.

References Platform\$consumerVersion.

Referenced by Platform\getToolSettings(), Platform\hasAccessTokenService(), Platform\hasToolSettingsService(), and Platform\setToolSettings().

◆ getId()

getId ( )

Get the platform ID.

The ID will be the consumer key if one exists, otherwise a concatenation of the platform/client/deployment IDs

Returns
string|null Platform ID value

Definition at line 249 of file Platform.php.

References Platform\$clientId, Platform\$deploymentId, and Platform\$platformId.

◆ getIsAvailable()

getIsAvailable ( )

Is the platform available to accept launch requests?

Returns
bool True if the platform is enabled and within any date constraints

Definition at line 322 of file Platform.php.

References System\$enabled, and System\$ok.

◆ getMessageParameters()

getMessageParameters ( )

Get the message parameters.

Returns
array The message parameter array

Definition at line 432 of file Platform.php.

References System\$messageParameters.

Referenced by Platform\handleRequest().

◆ getStorageJS()

static getStorageJS ( )
static

Get the JavaScript for handling storage postMessages from a tool.

Returns
string The JavaScript to handle storage postMessages

Definition at line 548 of file Platform.php.

◆ getTools()

getTools ( )

Get an array of defined tools.

Returns
array Array of Tool objects

Definition at line 408 of file Platform.php.

◆ getToolSettings()

getToolSettings (   $simple = true)

Get Tool Settings.

Parameters
bool$simpleTrue if all the simple media type is to be used (optional, default is true)
Returns
array|bool The array of settings if successful, otherwise false

Definition at line 358 of file Platform.php.

References System\$ok, Platform\getFamilyCode(), and System\getSetting().

◆ handleRequest()

handleRequest ( )

◆ hasAccessTokenService()

hasAccessTokenService ( )

Check if the Access Token service is supported.

Returns
bool True if this platform supports the Access Token service

Definition at line 418 of file Platform.php.

References Platform\getFamilyCode(), and System\getSetting().

◆ hasToolSettingsService()

hasToolSettingsService ( )

Check if the Tool Settings service is supported.

Returns
bool True if this platform supports the Tool Settings service

Definition at line 342 of file Platform.php.

References Platform\getFamilyCode(), and System\getSetting().

◆ initialise()

initialise ( )

Initialise the platform.

Synonym for initialize().

Definition at line 217 of file Platform.php.

References Platform\initialize().

◆ initialize()

initialize ( )

Initialise the platform.

Definition at line 180 of file Platform.php.

References Tool\ID_SCOPE_ID_ONLY.

Referenced by Platform\__construct(), and Platform\initialise().

◆ onAuthenticate()

onAuthenticate ( )
protected

Check the hint and recover the message parameters for an authentication request.

Override this method if the data has been saved elsewhere.

Definition at line 728 of file Platform.php.

◆ onContentItem()

onContentItem ( )
protected

Process a valid content-item message.

Definition at line 755 of file Platform.php.

◆ onError()

onError ( )
protected

Process a response to an invalid message.

Definition at line 773 of file Platform.php.

Referenced by Platform\handleRequest().

◆ onInitiateLogin()

onInitiateLogin ( $url,
$loginHint,
$ltiMessageHint,
  $params 
)
protected

Save the hint and message parameters when sending an initiate login request.

Override this method to save the data elsewhere.

Parameters
string$urlThe message URL
string$loginHintThe ID of the user
string | null$ltiMessageHintThe message hint being sent to the tool
array$paramsAn associative array of message parameters

Definition at line 706 of file Platform.php.

◆ onLtiStartAssessment()

onLtiStartAssessment ( )
protected

Process a valid start assessment message.

Definition at line 764 of file Platform.php.

◆ save()

save ( )

Save the platform to the database.

Returns
bool True if the object was successfully saved

Definition at line 227 of file Platform.php.

◆ setAccessToken()

setAccessToken (   $accessToken)

Set the authorization access token.

Parameters
AccessToken$accessTokenAccess token

Definition at line 312 of file Platform.php.

◆ setToolSettings()

setToolSettings (   $settings = array())

Set Tool Settings.

Parameters
array$settingsAn associative array of settings (optional, default is none)
Returns
bool True if action was successful, otherwise false

Definition at line 385 of file Platform.php.

References System\$ok, Platform\getFamilyCode(), and System\getSetting().

Field Documentation

◆ $accessTokenUrl

string null $accessTokenUrl = null

Access Token service URL.

Definition at line 84 of file Platform.php.

◆ $authenticationUrl

string null $authenticationUrl = null

Login authentication URL.

Definition at line 77 of file Platform.php.

◆ $authorizationServerId

string null $authorizationServerId = null

Authorization server ID.

Definition at line 70 of file Platform.php.

◆ $browserStorageFrame

string null $browserStorageFrame = null
static

Name of browser storage frame.

Definition at line 35 of file Platform.php.

◆ $clientId

string null $clientId = null

Client ID.

Definition at line 56 of file Platform.php.

Referenced by Platform\fromPlatformId(), and Platform\getId().

◆ $consumerGuid

string null $consumerGuid = null

Platform GUID (as reported by first platform connection).

Definition at line 119 of file Platform.php.

◆ $consumerName

string null $consumerName = null

Name of platform (as reported by last platform connection).

Definition at line 91 of file Platform.php.

◆ $consumerVersion

string null $consumerVersion = null

Platform version (as reported by last platform connection).

Definition at line 98 of file Platform.php.

Referenced by Platform\getFamilyCode().

◆ $cssPath

string null $cssPath = null

Optional CSS path (as reported by last platform connection).

Definition at line 126 of file Platform.php.

◆ $defaultEmail

string $defaultEmail = ''

Default email address (or email domain) to use when no email address is provided for a user.

Definition at line 147 of file Platform.php.

◆ $deploymentId

string null $deploymentId = null

Deployment ID.

Definition at line 63 of file Platform.php.

Referenced by Platform\fromPlatformId(), and Platform\getId().

◆ $idScope

int $idScope = Tool::ID_SCOPE_ID_ONLY

Default scope to use when generating an Id value for a user.

Definition at line 140 of file Platform.php.

◆ $lastServiceRequest

HttpMessage null $lastServiceRequest = null

HttpMessage object for last service request.

Definition at line 154 of file Platform.php.

◆ $MESSAGE_TYPES

array $MESSAGE_TYPES
static
Initial value:
= array(
'ContentItemSelection',
'LtiStartAssessment'
)

List of supported incoming message types.

Definition at line 25 of file Platform.php.

◆ $name

string null $name = null

Local name of platform.

Definition at line 42 of file Platform.php.

◆ $platformId

string null $platformId = null

Platform ID.

Definition at line 49 of file Platform.php.

Referenced by Platform\fromPlatformId(), and Platform\getId().

◆ $profile

object null $profile = null

The platform profile data.

Definition at line 105 of file Platform.php.

◆ $protected

bool $protected = false

Whether the platform instance is protected by matching the consumer_guid value in incoming requests.

Definition at line 133 of file Platform.php.

◆ $toolProxy

object null $toolProxy = null

The tool proxy.

Definition at line 112 of file Platform.php.


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