ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilLTIConsumerLaunch Class Reference
+ Collaboration diagram for ilLTIConsumerLaunch:

Public Member Functions

 __construct (int $a_ref_id)
 ilObjLTIConsumerLaunch constructor. More...
 
 getContext ($a_valid_types=array('crs', 'grp', 'cat', 'root'))
 get info about the context in which the link is used More...
 

Static Public Member Functions

static getLTIContextType ($a_type)
 
static signOAuth ($a_params)
 sign request data with OAuth More...
 

Protected Attributes

 $ref_id
 

Static Private Attributes

static $last_oauth_base_string = ""
 

Detailed Description

Definition at line 14 of file class.ilLTIConsumerLaunch.php.

Constructor & Destructor Documentation

◆ __construct()

ilLTIConsumerLaunch::__construct ( int  $a_ref_id)

ilObjLTIConsumerLaunch constructor.

Parameters
int$a_id
bool$a_reference

Definition at line 25 of file class.ilLTIConsumerLaunch.php.

26 {
27 $this->ref_id = $a_ref_id;
28 }

Member Function Documentation

◆ getContext()

ilLTIConsumerLaunch::getContext (   $a_valid_types = array('crs', 'grp', 'cat', 'root'))

get info about the context in which the link is used

The most outer matching course or group is used If not found the most inner category or root node is used

Parameters
arraylist of valid types
Returns
array context array ("ref_id", "title", "type")

Definition at line 39 of file class.ilLTIConsumerLaunch.php.

40 {
41 global $DIC; /* @var \ILIAS\DI\Container $DIC */
42 $tree = $DIC->repositoryTree();
43
44 if (!isset($this->context)) {
45 $this->context = array();
46
47 // check fromm inner to outer
48 $path = array_reverse($tree->getPathFull($this->ref_id));
49 foreach ($path as $key => $row) {
50 if (in_array($row['type'], $a_valid_types)) {
51 // take an existing inner context outside a course
52 if (in_array($row['type'], array('cat', 'root')) && !empty($this->context)) {
53 break;
54 }
55
56 $this->context['id'] = $row['child'];
57 $this->context['title'] = $row['title'];
58 $this->context['type'] = $row['type'];
59
60 // don't break to get the most outer course or group
61 }
62 }
63 }
64 return $this->context;
65 }
$context
Definition: webdav.php:26
$DIC
Definition: xapitoken.php:46

References $context, and $DIC.

◆ getLTIContextType()

static ilLTIConsumerLaunch::getLTIContextType (   $a_type)
static

Definition at line 70 of file class.ilLTIConsumerLaunch.php.

71 {
72 switch ($a_type) {
73 case "crs":
74 return "CourseOffering";
75 break;
76 case "grp":
77 return "Group";
78 break;
79 case "root":
80 return "urn:lti:context-type:ilias/RootNode";
81 break;
82 case "cat":
83 default:
84 return "urn:lti:context-type:ilias/Category";
85 break;
86 }
87 }
$a_type
Definition: workflow.php:92

References $a_type.

Referenced by ilLTIConsumerEmbeddedContentGUI\getLaunchParameters().

+ Here is the caller graph for this function:

◆ signOAuth()

static ilLTIConsumerLaunch::signOAuth (   $a_params)
static

sign request data with OAuth

Parameters
array( "method => signature methos "key" => consumer key "secret" => shared secret "token" => request token "url" => request url data => array (key => value) )
Returns
array signed data

Definition at line 104 of file class.ilLTIConsumerLaunch.php.

105 {
106 require_once('./Modules/LTIConsumer/lib/OAuth.php');
107 switch ($a_params['sign_method']) {
108 case "HMAC_SHA1":
109 $method = new OAuthSignatureMethod_HMAC_SHA1();
110 break;
111 case "PLAINTEXT":
112 $method = new OAuthSignatureMethod_PLAINTEXT();
113 break;
114 case "RSA_SHA1":
115 $method = new OAuthSignatureMethod_RSA_SHA1();
116 break;
117
118 default:
119 return "ERROR: unsupported signature method!";
120 }
121
122 $consumer = new OAuthConsumer($a_params["key"], $a_params["secret"], $a_params["callback"]);
123 $request = OAuthRequest::from_consumer_and_token($consumer, $a_params["token"], $a_params["http_method"], $a_params["url"], $a_params["data"]);
124 $request->sign_request($method, $consumer, $a_params["token"]);
125
126 // Pass this back up "out of band" for debugging
127 self::$last_oauth_base_string = $request->get_signature_base_string();
128 // die(self::$last_oauth_base_string);
129
130 return $request->get_parameters();
131 }
static from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=null)
pretty much a helper function to set up the request
Definition: OAuth.php:284

References OAuthRequest\from_consumer_and_token().

Referenced by ilObjLTIConsumer\buildLaunchParameters().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $last_oauth_base_string

ilLTIConsumerLaunch::$last_oauth_base_string = ""
staticprivate

Definition at line 16 of file class.ilLTIConsumerLaunch.php.

◆ $ref_id

ilLTIConsumerLaunch::$ref_id
protected

Definition at line 18 of file class.ilLTIConsumerLaunch.php.


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