19declare(strict_types=1);
21use ceLTIc\LTI\OAuth\OAuthConsumer;
22use ceLTIc\LTI\OAuth\OAuthRequest;
23use ceLTIc\LTI\OAuth\OAuthSignatureMethod_HMAC_SHA1;
43 $this->ref_id = $a_ref_id;
54 public function getContext(?array $a_valid_types = array(
'crs',
'grp',
'cat',
'root')): ?array
57 $tree =
$DIC->repositoryTree();
59 if (!isset($this->context)) {
60 $this->context = array();
63 $path = array_reverse($tree->getPathFull($this->ref_id));
64 foreach (
$path as $row) {
65 if (in_array($row[
'type'], $a_valid_types)) {
67 if (in_array($row[
'type'], array(
'cat',
'root')) && !empty($this->context)) {
71 $this->context[
'id'] = $row[
'child'];
72 $this->context[
'title'] = $row[
'title'];
73 $this->context[
'type'] = $row[
'type'];
89 return "http://purl.imsglobal.org/vocab/lis/v2/course#CourseOffering";
91 return "http://purl.imsglobal.org/vocab/lis/v2/course#Group";
93 return "http://purl.imsglobal.org/vocab/lis/v2/course#CourseOffering";
96 return "http://purl.imsglobal.org/vocab/lis/v2/course#CourseOffering";
115 public static function signOAuth(array $a_params): array
117 switch ($a_params[
'sign_method']) {
119 $method =
new OAuthSignatureMethod_HMAC_SHA1();
122 throw new Exception(
"Unknown signature method: " . $a_params[
'sign_method']);
125 $consumer =
new OAuthConsumer($a_params[
"key"], $a_params[
"secret"], $a_params[
"callback"]);
126 $request = OAuthRequest::from_consumer_and_token($consumer, $a_params[
"token"], $a_params[
"http_method"], $a_params[
"url"], $a_params[
"data"]);
127 $request->sign_request($method, $consumer, $a_params[
"token"]);
133 return $request->get_parameters();
static getLTIContextType(string $a_type)
static signOAuth(array $a_params)
sign request data with OAuth
getContext(?array $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 ...
__construct(int $a_ref_id)
ilObjLTIConsumerLaunch constructor.