ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
IMSGlobal\LTI\ToolProvider\ToolConsumer Class Reference

Class to represent a tool consumer. More...

+ Inheritance diagram for IMSGlobal\LTI\ToolProvider\ToolConsumer:
+ Collaboration diagram for IMSGlobal\LTI\ToolProvider\ToolConsumer:

Public Member Functions

 __construct ($key=null, $dataConnector=null, $autoEnable=false)
 Class constructor. More...
 
 initialize ()
 Initialise the tool consumer. More...
 
 initialise ()
 Initialise the tool consumer. More...
 
 save ()
 Save the tool consumer to the database. More...
 
 delete ()
 Delete the tool consumer from the database. More...
 
 getRecordId ()
 Get the tool consumer record ID. More...
 
 setRecordId ($id)
 Sets the tool consumer record ID. More...
 
 getKey ()
 Get the tool consumer key. More...
 
 setKey ($key)
 Set the tool consumer key. More...
 
 getDataConnector ()
 Get the data connector. More...
 
 getIsAvailable ()
 Is the consumer key available to accept launch requests? More...
 
 getSetting ($name, $default='')
 Get a setting value. More...
 
 setSetting ($name, $value=null)
 Set a setting value. More...
 
 getSettings ()
 Get an array of all setting values. More...
 
 setSettings ($settings)
 Set an array of all setting values. More...
 
 saveSettings ()
 Save setting values. More...
 
 hasToolSettingsService ()
 Check if the Tool Settings service is supported. More...
 
 getToolSettings ($simple=true)
 Get Tool Settings. More...
 
 setToolSettings ($settings=array())
 Perform a Tool Settings service request. More...
 
 signParameters ($url, $type, $version, $params)
 Add the OAuth signature to an LTI message. More...
 
 doServiceRequest ($service, $method, $format, $data)
 Perform a service request. More...
 

Static Public Member Functions

static addSignature ($endpoint, $consumerKey, $consumerSecret, $data, $method='POST', $type=null)
 Add the OAuth signature to an array of message parameters or to a header string. More...
 
static fromRecordId ($id, $dataConnector)
 Load the tool consumer from the database by its record ID. More...
 

Data Fields

 $name = null
 Local name of tool consumer. More...
 
 $secret = null
 Shared secret. More...
 
 $ltiVersion = null
 LTI version (as reported by last tool consumer connection). More...
 
 $consumerName = null
 Name of tool consumer (as reported by last tool consumer connection). More...
 
 $consumerVersion = null
 Tool consumer version (as reported by last tool consumer connection). More...
 
 $consumerGuid = null
 Tool consumer GUID (as reported by first tool consumer connection). More...
 
 $cssPath = null
 Optional CSS path (as reported by last tool consumer connection). More...
 
 $protected = false
 Whether the tool consumer instance is protected by matching the consumer_guid value in incoming requests. More...
 
 $enabled = false
 Whether the tool consumer instance is enabled to accept incoming connection requests. More...
 
 $enableFrom = null
 Date/time from which the the tool consumer instance is enabled to accept incoming connection requests. More...
 
 $enableUntil = null
 Date/time until which the tool consumer instance is enabled to accept incoming connection requests. More...
 
 $lastAccess = null
 Date of last connection from this tool consumer. More...
 
 $idScope = ToolProvider::ID_SCOPE_ID_ONLY
 Default scope to use when generating an Id value for a user. More...
 
 $defaultEmail = ''
 Default email address (or email domain) to use when no email address is provided for a user. More...
 
 $settings = null
 Setting values (LTI parameters, custom parameters and local parameters). More...
 
 $created = null
 Date/time when the object was created. More...
 
 $updated = null
 Date/time when the object was last updated. More...
 

Private Member Functions

 load ($key, $autoEnable=false)
 Load the tool consumer from the database. More...
 

Private Attributes

 $id = null
 Consumer ID value. More...
 
 $key = null
 Consumer key value. More...
 
 $settingsChanged = false
 Whether the settings value have changed since last saved. More...
 
 $dataConnector = null
 Data connector object or string. More...
 

Detailed Description

Class to represent a tool consumer.

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

Definition at line 19 of file ToolConsumer.php.

Constructor & Destructor Documentation

◆ __construct()

IMSGlobal\LTI\ToolProvider\ToolConsumer::__construct (   $key = null,
  $dataConnector = null,
  $autoEnable = false 
)

Class constructor.

Parameters
string$keyConsumer key
DataConnector$dataConnectorA data connector object
boolean$autoEnabletrue if the tool consumers is to be enabled automatically (optional, default is false)

Definition at line 157 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$dataConnector, IMSGlobal\LTI\ToolProvider\ToolConsumer\$key, IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector\getDataConnector(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector\getRandomString(), IMSGlobal\LTI\ToolProvider\ToolConsumer\initialize(), and IMSGlobal\LTI\ToolProvider\ToolConsumer\load().

158  {
159 
160  $this->initialize();
161  if (empty($dataConnector)) {
163  }
164  $this->dataConnector = $dataConnector;
165  if (!empty($key)) {
166  $this->load($key, $autoEnable);
167  } else {
168  $this->secret = DataConnector::getRandomString(32);
169  }
170 
171  }
static getDataConnector($dbTableNamePrefix='', $db=null, $type='')
Create data connector object.
$dataConnector
Data connector object or string.
initialize()
Initialise the tool consumer.
load($key, $autoEnable=false)
Load the tool consumer from the database.
static getRandomString($length=8)
Generate a random string.
+ Here is the call graph for this function:

Member Function Documentation

◆ addSignature()

static IMSGlobal\LTI\ToolProvider\ToolConsumer::addSignature (   $endpoint,
  $consumerKey,
  $consumerSecret,
  $data,
  $method = 'POST',
  $type = null 
)
static

Add the OAuth signature to an array of message parameters or to a header string.

Returns
mixed Array of signed message parameters or header string

Definition at line 513 of file ToolConsumer.php.

References $data, $endpoint, $header, IMSGlobal\LTI\ToolProvider\ToolConsumer\$name, PHPMailer\PHPMailer\$params, $type, and IMSGlobal\LTI\OAuth\OAuthRequest\from_consumer_and_token().

Referenced by IMSGlobal\LTI\ToolProvider\ToolConsumer\doServiceRequest(), and IMSGlobal\LTI\ToolProvider\Service\Service\send().

514  {
515 
516  $params = array();
517  if (is_array($data)) {
518  $params = $data;
519  }
520 // Check for query parameters which need to be included in the signature
521  $queryParams = array();
522  $queryString = parse_url($endpoint, PHP_URL_QUERY);
523  if (!is_null($queryString)) {
524  $queryItems = explode('&', $queryString);
525  foreach ($queryItems as $item) {
526  if (strpos($item, '=') !== false) {
527  list($name, $value) = explode('=', $item);
528  $queryParams[urldecode($name)] = urldecode($value);
529  } else {
530  $queryParams[urldecode($item)] = '';
531  }
532  }
533  $params = $params + $queryParams;
534  }
535 
536  if (!is_array($data)) {
537 // Calculate body hash
538  $hash = base64_encode(sha1($data, true));
539  $params['oauth_body_hash'] = $hash;
540  }
541 
542 // Add OAuth signature
543  $hmacMethod = new OAuth\OAuthSignatureMethod_HMAC_SHA1();
544  $oauthConsumer = new OAuth\OAuthConsumer($consumerKey, $consumerSecret, null);
545  $oauthReq = OAuth\OAuthRequest::from_consumer_and_token($oauthConsumer, null, $method, $endpoint, $params);
546  $oauthReq->sign_request($hmacMethod, $oauthConsumer, null);
547  $params = $oauthReq->get_parameters();
548 // Remove parameters being passed on the query string
549  foreach (array_keys($queryParams) as $name) {
550  unset($params[$name]);
551  }
552 
553  if (!is_array($data)) {
554  $header = $oauthReq->to_header();
555  if (empty($data)) {
556  if (!empty($type)) {
557  $header .= "\nAccept: {$type}";
558  }
559  } else if (isset($type)) {
560  $header .= "\nContent-Type: {$type}";
561  $header .= "\nContent-Length: " . strlen($data);
562  }
563  return $header;
564  } else {
565  return $params;
566  }
567 
568  }
$type
$endpoint
static from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=null)
pretty much a helper function to set up the request
$name
Local name of tool consumer.
$data
Definition: bench.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

IMSGlobal\LTI\ToolProvider\ToolConsumer::delete ( )

Delete the tool consumer from the database.

Returns
boolean True if the object was successfully deleted

Definition at line 236 of file ToolConsumer.php.

237  {
238 
239  return $this->dataConnector->deleteToolConsumer($this);
240 
241  }

◆ doServiceRequest()

IMSGlobal\LTI\ToolProvider\ToolConsumer::doServiceRequest (   $service,
  $method,
  $format,
  $data 
)

Perform a service request.

Parameters
object$serviceService object to be executed
string$methodHTTP action
string$formatMedia type
mixed$dataArray of parameters or body string
Returns
HTTPMessage HTTP object containing request and response details

Definition at line 580 of file ToolConsumer.php.

References $data, $format, $header, $http, IMSGlobal\LTI\ToolProvider\ToolConsumer\$secret, and IMSGlobal\LTI\ToolProvider\ToolConsumer\addSignature().

581  {
582 
583  $header = ToolConsumer::addSignature($service->endpoint, $this->getKey(), $this->secret, $data, $method, $format);
584 
585 // Connect to tool consumer
586  $http = new HTTPMessage($service->endpoint, $method, $data, $header);
587 // Parse JSON response
588  if ($http->send() && !empty($http->response)) {
589  $http->responseJson = json_decode($http->response);
590  $http->ok = !is_null($http->responseJson);
591  }
592 
593  return $http;
594 
595  }
$format
Definition: metadata.php:141
static addSignature($endpoint, $consumerKey, $consumerSecret, $data, $method='POST', $type=null)
Add the OAuth signature to an array of message parameters or to a header string.
$http
Definition: raiseError.php:7
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ fromRecordId()

static IMSGlobal\LTI\ToolProvider\ToolConsumer::fromRecordId (   $id,
  $dataConnector 
)
static

Load the tool consumer from the database by its record ID.

Parameters
string$idThe consumer key record ID
DataConnector$dataConnectorDatabase connection object
Returns
object ToolConsumer The tool consumer object

Definition at line 605 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$dataConnector, and IMSGlobal\LTI\ToolProvider\ToolConsumer\$id.

Referenced by IMSGlobal\LTI\ToolProvider\ToolProxy\getConsumer(), IMSGlobal\LTI\ToolProvider\Context\getConsumer(), and IMSGlobal\LTI\ToolProvider\ResourceLink\getConsumer().

606  {
607 
608  $toolConsumer = new ToolConsumer(null, $dataConnector);
609 
610  $toolConsumer->initialize();
611  $toolConsumer->setRecordId($id);
612  if (!$dataConnector->loadToolConsumer($toolConsumer)) {
613  $toolConsumer->initialize();
614  }
615 
616  return $toolConsumer;
617 
618  }
$dataConnector
Data connector object or string.
+ Here is the caller graph for this function:

◆ getDataConnector()

IMSGlobal\LTI\ToolProvider\ToolConsumer::getDataConnector ( )

Get the data connector.

Returns
mixed Data connector object or string

Definition at line 296 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$dataConnector.

297  {
298 
299  return $this->dataConnector;
300 
301  }
$dataConnector
Data connector object or string.

◆ getIsAvailable()

IMSGlobal\LTI\ToolProvider\ToolConsumer::getIsAvailable ( )

Is the consumer key available to accept launch requests?

Returns
boolean True if the consumer key is enabled and within any date constraints

Definition at line 308 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$enabled, and $ok.

309  {
310 
312 
313  $now = time();
314  if ($ok && !is_null($this->enableFrom)) {
315  $ok = $this->enableFrom <= $now;
316  }
317  if ($ok && !is_null($this->enableUntil)) {
318  $ok = $this->enableUntil > $now;
319  }
320 
321  return $ok;
322 
323  }
$enabled
Whether the tool consumer instance is enabled to accept incoming connection requests.

◆ getKey()

IMSGlobal\LTI\ToolProvider\ToolConsumer::getKey ( )

Get the tool consumer key.

Returns
string Consumer key value

Definition at line 272 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$key.

Referenced by ilLTIDataConnector\loadToolConsumerILIAS(), ilLTIDataConnector\saveToolConsumerILIAS(), and IMSGlobal\LTI\ToolProvider\ToolConsumer\signParameters().

273  {
274 
275  return $this->key;
276 
277  }
+ Here is the caller graph for this function:

◆ getRecordId()

IMSGlobal\LTI\ToolProvider\ToolConsumer::getRecordId ( )

Get the tool consumer record ID.

Returns
int Consumer record ID value

Definition at line 248 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$id.

Referenced by ilLTIToolConsumer\getId(), ilLTIDataConnector\loadToolConsumerILIAS(), and ilLTIDataConnector\saveToolConsumerILIAS().

249  {
250 
251  return $this->id;
252 
253  }
+ Here is the caller graph for this function:

◆ getSetting()

IMSGlobal\LTI\ToolProvider\ToolConsumer::getSetting (   $name,
  $default = '' 
)

Get a setting value.

Parameters
string$nameName of setting
string$defaultValue to return if the setting does not exist (optional, default is an empty string)
Returns
string Setting value

Definition at line 333 of file ToolConsumer.php.

References $default, IMSGlobal\LTI\ToolProvider\ToolConsumer\$name, and settings().

Referenced by IMSGlobal\LTI\ToolProvider\ToolConsumer\getToolSettings(), IMSGlobal\LTI\ToolProvider\ToolConsumer\hasToolSettingsService(), IMSGlobal\LTI\ToolProvider\ToolConsumer\setSetting(), and IMSGlobal\LTI\ToolProvider\ToolConsumer\setToolSettings().

334  {
335 
336  if (array_key_exists($name, $this->settings)) {
337  $value = $this->settings[$name];
338  } else {
339  $value = $default;
340  }
341 
342  return $value;
343 
344  }
settings()
Definition: settings.php:2
$default
Definition: build.php:20
$name
Local name of tool consumer.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSettings()

IMSGlobal\LTI\ToolProvider\ToolConsumer::getSettings ( )

Get an array of all setting values.

Returns
array Associative array of setting values

Definition at line 372 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$settings.

Referenced by ilLTIDataConnector\saveToolConsumerILIAS().

373  {
374 
375  return $this->settings;
376 
377  }
$settings
Setting values (LTI parameters, custom parameters and local parameters).
+ Here is the caller graph for this function:

◆ getToolSettings()

IMSGlobal\LTI\ToolProvider\ToolConsumer::getToolSettings (   $simple = true)

Get Tool Settings.

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

Definition at line 430 of file ToolConsumer.php.

References $response, $url, and IMSGlobal\LTI\ToolProvider\ToolConsumer\getSetting().

431  {
432 
433  $url = $this->getSetting('custom_system_setting_url');
434  $service = new Service\ToolSettings($this, $url, $simple);
435  $response = $service->get();
436 
437  return $response;
438 
439  }
getSetting($name, $default='')
Get a setting value.
$url
$response
+ Here is the call graph for this function:

◆ hasToolSettingsService()

IMSGlobal\LTI\ToolProvider\ToolConsumer::hasToolSettingsService ( )

Check if the Tool Settings service is supported.

Returns
boolean True if this tool consumer supports the Tool Settings service

Definition at line 414 of file ToolConsumer.php.

References $url, and IMSGlobal\LTI\ToolProvider\ToolConsumer\getSetting().

415  {
416 
417  $url = $this->getSetting('custom_system_setting_url');
418 
419  return !empty($url);
420 
421  }
getSetting($name, $default='')
Get a setting value.
$url
+ Here is the call graph for this function:

◆ initialise()

IMSGlobal\LTI\ToolProvider\ToolConsumer::initialise ( )

Initialise the tool consumer.

Pseudonym for initialize().

Definition at line 207 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\initialize().

208  {
209 
210  $this->initialize();
211 
212  }
initialize()
Initialise the tool consumer.
+ Here is the call graph for this function:

◆ initialize()

IMSGlobal\LTI\ToolProvider\ToolConsumer::initialize ( )

Initialise the tool consumer.

Definition at line 176 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolProvider\ID_SCOPE_ID_ONLY, and settings().

Referenced by IMSGlobal\LTI\ToolProvider\ToolConsumer\__construct(), ilLTIDataConnector\deleteGlobalToolConsumerSettings(), and IMSGlobal\LTI\ToolProvider\ToolConsumer\initialise().

177  {
178 
179  $this->id = null;
180  $this->key = null;
181  $this->name = null;
182  $this->secret = null;
183  $this->ltiVersion = null;
184  $this->consumerName = null;
185  $this->consumerVersion = null;
186  $this->consumerGuid = null;
187  $this->profile = null;
188  $this->toolProxy = null;
189  $this->settings = array();
190  $this->protected = false;
191  $this->enabled = false;
192  $this->enableFrom = null;
193  $this->enableUntil = null;
194  $this->lastAccess = null;
195  $this->idScope = ToolProvider::ID_SCOPE_ID_ONLY;
196  $this->defaultEmail = '';
197  $this->created = null;
198  $this->updated = null;
199 
200  }
settings()
Definition: settings.php:2
const ID_SCOPE_ID_ONLY
Use ID value only.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

IMSGlobal\LTI\ToolProvider\ToolConsumer::load (   $key,
  $autoEnable = false 
)
private

Load the tool consumer from the database.

Parameters
string$keyThe consumer key value
boolean$autoEnableTrue if the consumer should be enabled (optional, default if false)
Returns
boolean True if the consumer was successfully loaded

Definition at line 633 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$key, and $ok.

Referenced by IMSGlobal\LTI\ToolProvider\ToolConsumer\__construct().

634  {
635 
636  $this->key = $key;
637  $ok = $this->dataConnector->loadToolConsumer($this);
638  if (!$ok) {
639  $this->enabled = $autoEnable;
640  }
641 
642  return $ok;
643 
644  }
+ Here is the caller graph for this function:

◆ save()

IMSGlobal\LTI\ToolProvider\ToolConsumer::save ( )

Save the tool consumer to the database.

Returns
boolean True if the object was successfully saved

Definition at line 219 of file ToolConsumer.php.

References $ok.

Referenced by IMSGlobal\LTI\ToolProvider\ToolConsumer\saveSettings().

220  {
221 
222  $ok = $this->dataConnector->saveToolConsumer($this);
223  if ($ok) {
224  $this->settingsChanged = false;
225  }
226 
227  return $ok;
228 
229  }
+ Here is the caller graph for this function:

◆ saveSettings()

IMSGlobal\LTI\ToolProvider\ToolConsumer::saveSettings ( )

Save setting values.

Returns
boolean True if the settings were successfully saved

Definition at line 396 of file ToolConsumer.php.

References $ok, and IMSGlobal\LTI\ToolProvider\ToolConsumer\save().

397  {
398 
399  if ($this->settingsChanged) {
400  $ok = $this->save();
401  } else {
402  $ok = true;
403  }
404 
405  return $ok;
406 
407  }
save()
Save the tool consumer to the database.
+ Here is the call graph for this function:

◆ setKey()

IMSGlobal\LTI\ToolProvider\ToolConsumer::setKey (   $key)

Set the tool consumer key.

Parameters
string$keyConsumer key value

Definition at line 284 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$key.

285  {
286 
287  $this->key = $key;
288 
289  }

◆ setRecordId()

IMSGlobal\LTI\ToolProvider\ToolConsumer::setRecordId (   $id)

Sets the tool consumer record ID.

Parameters
int$idConsumer record ID value

Definition at line 260 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$id.

Referenced by ilLTIDataConnector\loadToolConsumerILIAS(), and ilLTIDataConnector\saveToolConsumerILIAS().

261  {
262 
263  $this->id = $id;
264 
265  }
+ Here is the caller graph for this function:

◆ setSetting()

IMSGlobal\LTI\ToolProvider\ToolConsumer::setSetting (   $name,
  $value = null 
)

Set a setting value.

Parameters
string$nameName of setting
string$valueValue to set, use an empty value to delete a setting (optional, default is null)

Definition at line 352 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$name, IMSGlobal\LTI\ToolProvider\ToolConsumer\getSetting(), and settings().

353  {
354 
355  $old_value = $this->getSetting($name);
356  if ($value !== $old_value) {
357  if (!empty($value)) {
358  $this->settings[$name] = $value;
359  } else {
360  unset($this->settings[$name]);
361  }
362  $this->settingsChanged = true;
363  }
364 
365  }
settings()
Definition: settings.php:2
getSetting($name, $default='')
Get a setting value.
$name
Local name of tool consumer.
+ Here is the call graph for this function:

◆ setSettings()

IMSGlobal\LTI\ToolProvider\ToolConsumer::setSettings (   $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

Definition at line 384 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$settings, and settings().

Referenced by ilLTIDataConnector\loadToolConsumerILIAS().

385  {
386 
387  $this->settings = $settings;
388 
389  }
settings()
Definition: settings.php:2
$settings
Setting values (LTI parameters, custom parameters and local parameters).
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setToolSettings()

IMSGlobal\LTI\ToolProvider\ToolConsumer::setToolSettings (   $settings = array())

Perform a Tool Settings service request.

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

Definition at line 448 of file ToolConsumer.php.

References $response, IMSGlobal\LTI\ToolProvider\ToolConsumer\$settings, $url, and IMSGlobal\LTI\ToolProvider\ToolConsumer\getSetting().

449  {
450 
451  $url = $this->getSetting('custom_system_setting_url');
452  $service = new Service\ToolSettings($this, $url);
453  $response = $service->set($settings);
454 
455  return $response;
456 
457  }
$settings
Setting values (LTI parameters, custom parameters and local parameters).
getSetting($name, $default='')
Get a setting value.
$url
$response
+ Here is the call graph for this function:

◆ signParameters()

IMSGlobal\LTI\ToolProvider\ToolConsumer::signParameters (   $url,
  $type,
  $version,
  $params 
)

Add the OAuth signature to an LTI message.

Parameters
string$urlURL for message request
string$typeLTI message type
string$versionLTI version
array$paramsMessage parameters
Returns
array Array of signed message parameters

Definition at line 469 of file ToolConsumer.php.

References IMSGlobal\LTI\ToolProvider\ToolConsumer\$name, PHPMailer\PHPMailer\$params, $req, $type, $url, $version, IMSGlobal\LTI\OAuth\OAuthRequest\from_consumer_and_token(), and IMSGlobal\LTI\ToolProvider\ToolConsumer\getKey().

470  {
471 
472  if (!empty($url)) {
473 // Check for query parameters which need to be included in the signature
474  $queryParams = array();
475  $queryString = parse_url($url, PHP_URL_QUERY);
476  if (!is_null($queryString)) {
477  $queryItems = explode('&', $queryString);
478  foreach ($queryItems as $item) {
479  if (strpos($item, '=') !== false) {
480  list($name, $value) = explode('=', $item);
481  $queryParams[urldecode($name)] = urldecode($value);
482  } else {
483  $queryParams[urldecode($item)] = '';
484  }
485  }
486  }
487  $params = $params + $queryParams;
488 // Add standard parameters
489  $params['lti_version'] = $version;
490  $params['lti_message_type'] = $type;
491  $params['oauth_callback'] = 'about:blank';
492 // Add OAuth signature
493  $hmacMethod = new OAuth\OAuthSignatureMethod_HMAC_SHA1();
494  $consumer = new OAuth\OAuthConsumer($this->getKey(), $this->secret, null);
495  $req = OAuth\OAuthRequest::from_consumer_and_token($consumer, null, 'POST', $url, $params);
496  $req->sign_request($hmacMethod, $consumer, null);
497  $params = $req->get_parameters();
498 // Remove parameters being passed on the query string
499  foreach (array_keys($queryParams) as $name) {
500  unset($params[$name]);
501  }
502  }
503 
504  return $params;
505 
506  }
$type
$req
Definition: getUserInfo.php:20
static from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=null)
pretty much a helper function to set up the request
$version
Definition: build.php:27
$name
Local name of tool consumer.
$url
getKey()
Get the tool consumer key.
+ Here is the call graph for this function:

Field Documentation

◆ $consumerGuid

string IMSGlobal\LTI\ToolProvider\ToolConsumer::$consumerGuid = null

Tool consumer GUID (as reported by first tool consumer connection).

Definition at line 57 of file ToolConsumer.php.

◆ $consumerName

string IMSGlobal\LTI\ToolProvider\ToolConsumer::$consumerName = null

Name of tool consumer (as reported by last tool consumer connection).

Definition at line 45 of file ToolConsumer.php.

◆ $consumerVersion

string IMSGlobal\LTI\ToolProvider\ToolConsumer::$consumerVersion = null

Tool consumer version (as reported by last tool consumer connection).

Definition at line 51 of file ToolConsumer.php.

◆ $created

int IMSGlobal\LTI\ToolProvider\ToolConsumer::$created = null

Date/time when the object was created.

Definition at line 117 of file ToolConsumer.php.

◆ $cssPath

string IMSGlobal\LTI\ToolProvider\ToolConsumer::$cssPath = null

Optional CSS path (as reported by last tool consumer connection).

Definition at line 63 of file ToolConsumer.php.

◆ $dataConnector

◆ $defaultEmail

string IMSGlobal\LTI\ToolProvider\ToolConsumer::$defaultEmail = ''

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

Definition at line 105 of file ToolConsumer.php.

◆ $enabled

boolean IMSGlobal\LTI\ToolProvider\ToolConsumer::$enabled = false

Whether the tool consumer instance is enabled to accept incoming connection requests.

Definition at line 75 of file ToolConsumer.php.

Referenced by ilLTIToolConsumer\getEnabled(), and IMSGlobal\LTI\ToolProvider\ToolConsumer\getIsAvailable().

◆ $enableFrom

int IMSGlobal\LTI\ToolProvider\ToolConsumer::$enableFrom = null

Date/time from which the the tool consumer instance is enabled to accept incoming connection requests.

Definition at line 81 of file ToolConsumer.php.

◆ $enableUntil

int IMSGlobal\LTI\ToolProvider\ToolConsumer::$enableUntil = null

Date/time until which the tool consumer instance is enabled to accept incoming connection requests.

Definition at line 87 of file ToolConsumer.php.

◆ $id

◆ $idScope

int IMSGlobal\LTI\ToolProvider\ToolConsumer::$idScope = ToolProvider::ID_SCOPE_ID_ONLY

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

Definition at line 99 of file ToolConsumer.php.

◆ $key

string IMSGlobal\LTI\ToolProvider\ToolConsumer::$key = null
private

◆ $lastAccess

int IMSGlobal\LTI\ToolProvider\ToolConsumer::$lastAccess = null

Date of last connection from this tool consumer.

Definition at line 93 of file ToolConsumer.php.

◆ $ltiVersion

string IMSGlobal\LTI\ToolProvider\ToolConsumer::$ltiVersion = null

LTI version (as reported by last tool consumer connection).

Definition at line 39 of file ToolConsumer.php.

◆ $name

◆ $protected

boolean IMSGlobal\LTI\ToolProvider\ToolConsumer::$protected = false

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

Definition at line 69 of file ToolConsumer.php.

◆ $secret

string IMSGlobal\LTI\ToolProvider\ToolConsumer::$secret = null

◆ $settings

array IMSGlobal\LTI\ToolProvider\ToolConsumer::$settings = null

Setting values (LTI parameters, custom parameters and local parameters).

Definition at line 111 of file ToolConsumer.php.

Referenced by IMSGlobal\LTI\ToolProvider\ToolConsumer\getSettings(), IMSGlobal\LTI\ToolProvider\ToolConsumer\setSettings(), and IMSGlobal\LTI\ToolProvider\ToolConsumer\setToolSettings().

◆ $settingsChanged

boolean IMSGlobal\LTI\ToolProvider\ToolConsumer::$settingsChanged = false
private

Whether the settings value have changed since last saved.

Definition at line 142 of file ToolConsumer.php.

◆ $updated

int IMSGlobal\LTI\ToolProvider\ToolConsumer::$updated = null

Date/time when the object was last updated.

Definition at line 123 of file ToolConsumer.php.


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