ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilLTIPlatform Class Reference

The platforms of the administration that launch ILIAS: what lti_ext_consumer keeps of them, and their LTI Advantage registration in lti2_consumer, the table of celtic/lti, which ilLTIDataConnector reads at a launch. More...

+ Collaboration diagram for ilLTIPlatform:

Static Public Member Functions

static lookupVersion (int $platform_id)
 The LTI version of a platform of the administration: LTI Advantage when it has an LTI Advantage registration, for the whole platform or, in older installations, for one of its objects. More...
 
static saveRegistration (int $platform_id, string $name, bool $enabled, array $registration, array $settings=[])
 Stores the LTI Advantage registration of a platform of the administration, once for the whole platform (ref_id 0). More...
 
static lookupIdByRegistration (string $issuer, string $client_id, string $deployment_id)
 The platform of the administration an LTI Advantage registration belongs to, 0 when none has it. More...
 
static lookupAdministrationRow (int $platform_id)
 The platform of the administration as stored in lti_ext_consumer, empty when it does not exist. More...
 
static lookupNamesRoles (int $platform_id)
 Whether ILIAS reads the members of the contexts of the platform when an instructor launches (LTI Advantage NRPS). More...
 
static lookupObjectTypes (int $platform_id)
 The types of the objects that can be released to a platform of the administration. More...
 
static lookupRegistrationSettings (int $platform_id)
 The settings of celtic/lti the LTI Advantage registration of a platform of the administration has. More...
 

Detailed Description

The platforms of the administration that launch ILIAS: what lti_ext_consumer keeps of them, and their LTI Advantage registration in lti2_consumer, the table of celtic/lti, which ilLTIDataConnector reads at a launch.

Author
Saúl Díaz sdiaz.nosp@m.@sur.nosp@m.labs..nosp@m.com

Definition at line 30 of file class.ilLTIPlatform.php.

Member Function Documentation

◆ lookupAdministrationRow()

static ilLTIPlatform::lookupAdministrationRow ( int  $platform_id)
static

The platform of the administration as stored in lti_ext_consumer, empty when it does not exist.

Definition at line 129 of file class.ilLTIPlatform.php.

129 : array
130 {
131 global $DIC;
132
133 $db = $DIC->database();
134
135 return $db->fetchAssoc($db->query(
136 'SELECT * FROM lti_ext_consumer WHERE id = ' . $db->quote($platform_id, 'integer')
137 )) ?? [];
138 }
global $DIC
Definition: shib_login.php:26

References $DIC.

Referenced by ilLTIAdvantageToolRegistration\acceptToken(), ilLTIAdvantageToolRegistration\getPlatformToRegister(), ilAuthProviderLTI\lookupConsumer(), and ilLTIAdministrationPlatformForm\read().

+ Here is the caller graph for this function:

◆ lookupIdByRegistration()

static ilLTIPlatform::lookupIdByRegistration ( string  $issuer,
string  $client_id,
string  $deployment_id 
)
static

The platform of the administration an LTI Advantage registration belongs to, 0 when none has it.

A launch names the platform by these three ids, so no two platforms may share them.

Definition at line 110 of file class.ilLTIPlatform.php.

110 : int
111 {
112 global $DIC;
113
114 $db = $DIC->database();
115 $db->setLimit(1);
116 $row = $db->fetchAssoc($db->queryF(
117 'SELECT ext_consumer_id FROM lti2_consumer WHERE platform_id = %s AND client_id = %s AND deployment_id = %s'
118 . ' AND lti_version = %s ORDER BY ref_id, consumer_pk',
119 ['text', 'text', 'text', 'text'],
120 [$issuer, $client_id, $deployment_id, LtiVersion::V1P3->value]
121 ));
122
123 return (int) ($row['ext_consumer_id'] ?? 0);
124 }
$client_id
Definition: ltiresult.php:32

References $client_id, and $DIC.

Referenced by ilLTIAdministrationPlatformForm\getForm(), and ilLTIAdvantageToolRegistration\getPlatformToRegister().

+ Here is the caller graph for this function:

◆ lookupNamesRoles()

static ilLTIPlatform::lookupNamesRoles ( int  $platform_id)
static

Whether ILIAS reads the members of the contexts of the platform when an instructor launches (LTI Advantage NRPS).

Definition at line 143 of file class.ilLTIPlatform.php.

143 : bool
144 {
145 return (bool) (self::lookupAdministrationRow($platform_id)['names_roles'] ?? false);
146 }
static lookupAdministrationRow(int $platform_id)
The platform of the administration as stored in lti_ext_consumer, empty when it does not exist.

Referenced by ilAuthProviderLTI\syncMembers().

+ Here is the caller graph for this function:

◆ lookupObjectTypes()

static ilLTIPlatform::lookupObjectTypes ( int  $platform_id)
static

The types of the objects that can be released to a platform of the administration.

Returns
string[]

Definition at line 153 of file class.ilLTIPlatform.php.

153 : array
154 {
155 global $DIC;
156
157 $db = $DIC->database();
158 $result = $db->queryF(
159 'SELECT object_type FROM lti_ext_consumer_otype WHERE consumer_id = %s',
160 ['integer'],
161 [$platform_id]
162 );
163 $types = [];
164 while ($row = $db->fetchAssoc($result)) {
165 $types[] = (string) $row['object_type'];
166 }
167
168 return $types;
169 }

References $DIC.

Referenced by ilLTIAdministrationPlatformTable\getObjectTypes(), and ilLTIAdministrationPlatformForm\read().

+ Here is the caller graph for this function:

◆ lookupRegistrationSettings()

static ilLTIPlatform::lookupRegistrationSettings ( int  $platform_id)
static

The settings of celtic/lti the LTI Advantage registration of a platform of the administration has.

Definition at line 174 of file class.ilLTIPlatform.php.

174 : array
175 {
176 global $DIC;
177
178 $db = $DIC->database();
179 $row = $db->fetchAssoc($db->query(
180 'SELECT settings FROM lti2_consumer WHERE ref_id = 0 AND ext_consumer_id = ' . $db->quote($platform_id, 'integer')
181 ));
182 $settings = json_decode((string) ($row['settings'] ?? ''), true);
183
184 return is_array($settings) ? $settings : [];
185 }
$settings
Definition: index.php:44

References $DIC, and $settings.

Referenced by ilLTIAdvantageToolRegistration\acceptToken(), and ilLTIAdministrationPlatformForm\save().

+ Here is the caller graph for this function:

◆ lookupVersion()

static ilLTIPlatform::lookupVersion ( int  $platform_id)
static

The LTI version of a platform of the administration: LTI Advantage when it has an LTI Advantage registration, for the whole platform or, in older installations, for one of its objects.

Definition at line 36 of file class.ilLTIPlatform.php.

36 : string
37 {
38 global $DIC;
39
40 $db = $DIC->database();
41 $db->setLimit(1);
42 $row = $db->fetchAssoc($db->queryF(
43 'SELECT consumer_pk FROM lti2_consumer WHERE lti_version = %s AND ext_consumer_id = %s',
44 ['text', 'integer'],
45 [ilLTITool::VERSION_ADVANTAGE, $platform_id]
46 ));
47
49 }
const string VERSION_ADVANTAGE
const string VERSION_1P1

References $DIC, ilLTITool\VERSION_1P1, and ilLTITool\VERSION_ADVANTAGE.

Referenced by ilLTIAdvantageToolRegistration\acceptToken(), ilObjLTIAdministrationGUI\getPlatformForm(), and ilLTIProviderObjectSettingGUI\isAdvantage().

+ Here is the caller graph for this function:

◆ saveRegistration()

static ilLTIPlatform::saveRegistration ( int  $platform_id,
string  $name,
bool  $enabled,
array  $registration,
array  $settings = [] 
)
static

Stores the LTI Advantage registration of a platform of the administration, once for the whole platform (ref_id 0).

The URLs go to the settings of celtic/lti. An empty registration still marks the platform as an LTI Advantage one, until it registers through Dynamic Registration.

Parameters
int$platform_idthe platform in lti_ext_consumer
array$registrationplatform_id, client_id, deployment_id, keyset_url, token_url and authentication_url
array$settingsfurther settings of celtic/lti to store

Definition at line 60 of file class.ilLTIPlatform.php.

66 : void {
67 global $DIC;
68
69 $db = $DIC->database();
70 $now = date('Y-m-d H:i:s');
71 $fields = [
72 'name' => ['text', ilStr::subStr($name, 0, 50)],
73 'lti_version' => ['text', LtiVersion::V1P3->value],
74 'signature_method' => ['text', 'RS256'],
75 'enabled' => ['integer', (int) $enabled],
76 'platform_id' => ['text', $registration['platform_id']],
77 'client_id' => ['text', $registration['client_id']],
78 'deployment_id' => ['text', $registration['deployment_id']],
79 'settings' => ['text', json_encode([
80 '_jku' => $registration['keyset_url'],
81 '_oauth2_access_token_url' => $registration['token_url'],
82 '_authentication_request_url' => $registration['authentication_url'],
83 ] + $settings, JSON_UNESCAPED_SLASHES)],
84 // the key celtic/lti fetched from the key set is a cache: it is fetched again from the saved URL
85 'public_key' => ['clob', null],
86 'updated' => ['timestamp', $now],
87 ];
88
89 $row = $db->fetchAssoc($db->query(
90 'SELECT consumer_pk FROM lti2_consumer WHERE ref_id = 0 AND ext_consumer_id = ' . $db->quote($platform_id, 'integer')
91 ));
92 if ($row !== null) {
93 $db->update('lti2_consumer', $fields, ['consumer_pk' => ['integer', (int) $row['consumer_pk']]]);
94 return;
95 }
96 $db->insert('lti2_consumer', $fields + [
97 'consumer_pk' => ['integer', $db->nextId('lti2_consumer')],
98 'secret' => ['text', ''],
99 'protected' => ['integer', 0],
100 'created' => ['timestamp', $now],
101 'ext_consumer_id' => ['integer', $platform_id],
102 'ref_id' => ['integer', 0],
103 ]);
104 }
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:21

Referenced by ilLTIAdvantageToolRegistration\getPlatformToRegister(), and ilLTIAdministrationPlatformForm\save().

+ Here is the caller graph for this function:

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