19 declare(strict_types=1);
79 $this->ref_id = $a_ref_id;
81 $this->
ctrl = $DIC->ctrl();
82 $this->tpl = $DIC[
'tpl'];
83 $this->rbacSystem = $DIC->rbac()->system();
84 $this->rbacReview = $DIC->rbac()->review();
85 $this->rbacAdmin = $DIC->rbac()->admin();
87 $this->
lng = $DIC->language();
88 $this->
lng->loadLanguageModule(
'lti');
101 return $this->rbacSystem->checkAccess(
113 if (empty($a_roles)) {
115 $a_roles = $this->rbacReview->getLocalRoles($this->ref_id);
117 $this->custom_roles = $a_roles;
125 $this->use_lti_roles = $a_stat;
134 $cmd = $this->
ctrl->getCmd(
'settings');
135 $next_class = $this->
ctrl->getNextClass($this);
153 $this->tpl->setContent($form->getHTML());
163 $form->setFormAction($this->
ctrl->getFormAction($this));
164 $form->setTitle($this->
lng->txt(
'lti_object_release_settings_form'));
166 foreach (ilObjLTIAdministration::getEnabledConsumersForType(
ilObject::_lookupType($this->ref_id,
true)) as $global_consumer) {
169 $this->
logger->debug((
string) $object_info->getAdminRole());
174 $section->setTitle($global_consumer->getTitle());
175 $section->setInfo($global_consumer->getDescription());
176 $form->addItem($section);
181 $global_consumer->getExtConsumerId(),
185 $active =
new ilCheckboxInputGUI($this->
lng->txt(
'lti_obj_active'),
'lti_active_' . $global_consumer->getExtConsumerId());
186 $active->setInfo($this->
lng->txt(
'lti_obj_active_info'));
187 $active->setValue(
"1");
188 if ($active_consumer->getEnabled()) {
189 $active->setChecked(
true);
191 if ($this->custom_roles) {
193 $this->
lng->txt(
'lti_admin'),
194 'lti_admin_' . $global_consumer->getExtConsumerId()
197 $admin->setValue($object_info->getAdminRole() ? $object_info->getAdminRole() : 0);
198 $active->addSubItem($admin);
201 $this->
lng->txt(
'lti_tutor'),
202 'lti_tutor_' . $global_consumer->getExtConsumerId()
205 $tutor->setValue($object_info->getTutorRole() ? $object_info->getTutorRole() : 0);
206 $active->addSubItem($tutor);
209 $this->
lng->txt(
'lti_member'),
210 'lti_member_' . $global_consumer->getExtConsumerId()
213 $member->setValue($object_info->getMemberRole() ? $object_info->getMemberRole() : 0);
214 $active->addSubItem($member);
216 $form->addItem($active);
220 if (!is_null($active_consumer->ltiVersion)) {
221 $version->setValue($active_consumer->ltiVersion->value);
224 $op1 =
new ilRadioOption($this->
lng->txt(
"lti_obj_version_13"), LtiVersion::V1P3->value);
226 $sh->
setValue($this->
lng->txt(
"lti_13_step1_info"));
227 $op1->addSubItem($sh);
229 $url->setValue(ILIAS_HTTP_PATH .
'/lti.php?client_id=' .
CLIENT_ID);
230 $op1->addSubItem(
$url);
238 $sh->
setValue($this->
lng->txt(
"lti_13_step2_info"));
239 $op1->addSubItem($sh);
240 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_platform_id'),
'platform_id_' . $global_consumer->getExtConsumerId());
241 $tf->setValue($active_consumer->platformId);
242 $op1->addSubItem($tf);
243 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_client_id'),
'client_id_' . $global_consumer->getExtConsumerId());
244 $tf->setValue($active_consumer->clientId);
245 $op1->addSubItem($tf);
246 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_deployment_id'),
'deployment_id_' . $global_consumer->getExtConsumerId());
247 $tf->setValue($active_consumer->deploymentId);
248 $op1->addSubItem($tf);
249 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_keyset_url'),
'keyset_url_' . $global_consumer->getExtConsumerId());
250 $tf->setValue($active_consumer->jku);
251 $op1->addSubItem($tf);
252 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_token_url'),
'token_url_' . $global_consumer->getExtConsumerId());
253 $tf->setValue($active_consumer->accessTokenUrl);
254 $op1->addSubItem($tf);
255 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_authentication_url'),
'authentication_url_' . $global_consumer->getExtConsumerId());
256 $tf->setValue($active_consumer->authenticationUrl);
257 $op1->addSubItem($tf);
260 $op0 =
new ilRadioOption($this->
lng->txt(
"lti_obj_version_11"), LtiVersion::V1->value);
262 $url->
setValue(ILIAS_HTTP_PATH .
'/lti.php?client_id=' . CLIENT_ID);
263 $op0->addSubItem($url);
264 $key =
new ilNonEditableValueGUI($this->
lng->txt(
'lti_consumer_key'),
'key_' . $global_consumer->getExtConsumerId());
265 if (is_null($active_consumer->getKey())) {
266 $active_consumer->setKey(Util::getRandomString(10));
268 $key->setValue($active_consumer->getKey());
269 $op0->addSubItem($key);
270 $secret =
new ilNonEditableValueGUI($this->
lng->txt(
'lti_consumer_secret'),
'secret_' . $global_consumer->getExtConsumerId());
271 if (is_null($active_consumer->getSecret())) {
272 $active_consumer->createSecret();
274 $secret->setValue($active_consumer->getSecret());
275 $op0->addSubItem($secret);
281 $form->addCommandButton(
'updateSettings', $this->
lng->txt(
'save'));
291 if (!$form->checkInput()) {
292 $form->setValuesByPost();
298 foreach (ilObjLTIAdministration::getEnabledConsumersForType(
ilObject::_lookupType($this->ref_id,
true)) as $global_consumer) {
302 $global_consumer->getExtConsumerId(),
306 if (!$form->getInput(
'lti_active_' . $global_consumer->getExtConsumerId())) {
308 if ($consumer->getEnabled()) {
309 $this->
logger->info(
'Deleting lti consumer for object reference: ' . $this->ref_id);
310 $consumer->setEnabled(
false);
311 $consumer->saveLTI($connector);
314 $consumer->ltiVersion =
LtiVersion::from($form->getInput(
'version_' . $global_consumer->getExtConsumerId()));
315 $this->
logger->info(
'Created new lti release for: ' . $this->ref_id);
316 $consumer->setExtConsumerId($global_consumer->getExtConsumerId());
317 $consumer->setKey((
string) $form->getInput(
'key_' . $global_consumer->getExtConsumerId()));
318 $consumer->setSecret((
string) $form->getInput(
'secret_' . $global_consumer->getExtConsumerId()));
319 $consumer->setRefId($this->ref_id);
320 $consumer->setEnabled(
true);
321 if ($form->getInput(
'platform_id_' . $global_consumer->getExtConsumerId())) {
322 $consumer->platformId = (string) $form->getInput(
'platform_id_' . $global_consumer->getExtConsumerId());
324 $consumer->platformId =
null;
326 if ($form->getInput(
'client_id_' . $global_consumer->getExtConsumerId())) {
327 $consumer->clientId = $form->getInput(
'client_id_' . $global_consumer->getExtConsumerId());
329 $consumer->clientId =
null;
331 if ($form->getInput(
'deployment_id_' . $global_consumer->getExtConsumerId())) {
332 $consumer->deploymentId = $form->getInput(
'deployment_id_' . $global_consumer->getExtConsumerId());
334 $consumer->deploymentId =
null;
336 if ($form->getInput(
'keyset_url_' . $global_consumer->getExtConsumerId())) {
337 $consumer->jku = $form->getInput(
'keyset_url_' . $global_consumer->getExtConsumerId());
341 if ($form->getInput(
'token_url_' . $global_consumer->getExtConsumerId())) {
342 $consumer->accessTokenUrl = $form->getInput(
'token_url_' . $global_consumer->getExtConsumerId());
344 $consumer->accessTokenUrl =
'';
346 if ($form->getInput(
'authentication_url_' . $global_consumer->getExtConsumerId())) {
347 $consumer->authenticationUrl = $form->getInput(
'authentication_url_' . $global_consumer->getExtConsumerId());
349 $consumer->authenticationUrl =
'';
351 $consumer->saveLTI($connector);
355 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
356 $this->
ctrl->redirect($this,
'settings');
368 $admin_role = (
int) $form->
getInput(
'lti_admin_' . $global_consumer_id);
369 if ($admin_role > 0) {
370 $object_info->setAdminRole($admin_role);
372 $tutor_role = (
int) $form->
getInput(
'lti_tutor_' . $global_consumer_id);
373 if ($tutor_role > 0) {
374 $object_info->setTutorRole($tutor_role);
376 $member_role = (
int) $form->
getInput(
'lti_member_' . $global_consumer_id);
377 if ($member_role > 0) {
378 $object_info->setMemberRole($member_role);
380 $object_info->save();
390 $options[0] = $this->
lng->txt(
'select_one');
391 foreach ($this->custom_roles as $role_id) {
393 $options[$role_id] = $title;
404 if (is_array($a_global_role) && !empty($a_global_role)) {
405 if (count($this->rbacReview->getRolesOfObject($this->ref_id,
false)) == 0) {
409 $role->setTitle(
"il_lti_learner");
412 $rbacadmin->assignRoleToFolder($role->getId(),
$this->ref_id,
'y');
415 if ($type ==
"sahs" || $type ==
"lm" || $type ==
"svy" || $type ==
"tst") {
417 $role->setTitle(
"il_lti_instructor");
420 $rbacadmin->assignRoleToFolder($role->getId(),
$this->ref_id,
'y');
422 if ($type ==
"svy") {
425 if ($type ==
"tst") {
428 $rbacadmin->grantPermission($role->getId(), $ops,
$this->ref_id);
This class represents an option in a radio group.
__construct(int $a_ref_id)
getRoleSelection()
Get role selection.
static getLogger(string $a_component_id)
Get component logger.
static _getOperationIdsByName(array $operations)
get ops_id's by name.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
settings(?ilPropertyFormGUI $form=null)
Show settings.
saveRoleSelection(ilPropertyFormGUI $form, string $global_consumer_id)
Save role selection for consumer.
static _lookupTitle(int $obj_id)
GUI class for LTI provider object settings.
static lookupLTISettingsRefId()
Lookup ref_id.
hasSettingsAccess()
Check if user has access to lti settings.
static _getTranslation(string $a_role_title)
setValue(string $a_value)
static _lookupObjectId(int $ref_id)
initObjectSettingsForm()
Init object settings form.
setCustomRolesForSelection(array $a_roles)
Set custom roles for mapping to LTI roles.
static _getIdsForTitle(string $title, string $type='', bool $partial_match=false)
executeCommand()
Ctrl execute command.
offerLTIRolesForSelection(bool $a_stat)
Offer LTI roles for mapping.
updateSettings()
Update settings (activate deactivate lti access)
checkLocalRole()
check for local roles for lti objects which are not grp or crs
Class ilRbacAdmin Core functions for role based access control.
static _lookupType(int $id, bool $reference=false)
ilGlobalPageTemplate $tpl