3 declare(strict_types=1);
76 $this->ref_id = $a_ref_id;
78 $this->
ctrl = $DIC->ctrl();
79 $this->tpl = $DIC[
'tpl'];
80 $this->rbacSystem = $DIC->rbac()->system();
81 $this->rbacReview = $DIC->rbac()->review();
82 $this->rbacAdmin = $DIC->rbac()->admin();
84 $this->
lng = $DIC->language();
85 $this->
lng->loadLanguageModule(
'lti');
98 return $this->rbacSystem->checkAccess(
110 if (empty($a_roles)) {
112 $a_roles = $this->rbacReview->getLocalRoles($this->ref_id);
114 $this->custom_roles = $a_roles;
122 $this->use_lti_roles = $a_stat;
131 $cmd = $this->
ctrl->getCmd(
'settings');
132 $next_class = $this->
ctrl->getNextClass($this);
150 $this->tpl->setContent($form->getHTML());
160 $form->setFormAction($this->
ctrl->getFormAction($this));
161 $form->setTitle($this->
lng->txt(
'lti_object_release_settings_form'));
163 foreach (ilObjLTIAdministration::getEnabledConsumersForType(
ilObject::_lookupType($this->ref_id,
true)) as $global_consumer) {
166 $this->
logger->debug((
string) $object_info->getAdminRole());
171 $section->setTitle($global_consumer->getTitle());
172 $section->setInfo($global_consumer->getDescription());
173 $form->addItem($section);
178 $global_consumer->getExtConsumerId(),
182 $active =
new ilCheckboxInputGUI($this->
lng->txt(
'lti_obj_active'),
'lti_active_' . $global_consumer->getExtConsumerId());
183 $active->
setInfo($this->
lng->txt(
'lti_obj_active_info'));
184 $active->setValue(
"1");
185 if ($active_consumer->getEnabled()) {
186 $active->setChecked(
true);
188 if ($this->custom_roles) {
190 $this->
lng->txt(
'lti_admin'),
191 'lti_admin_' . $global_consumer->getExtConsumerId()
194 $admin->setValue($object_info->getAdminRole() ? $object_info->getAdminRole() : 0);
195 $active->addSubItem($admin);
198 $this->
lng->txt(
'lti_tutor'),
199 'lti_tutor_' . $global_consumer->getExtConsumerId()
202 $tutor->setValue($object_info->getTutorRole() ? $object_info->getTutorRole() : 0);
203 $active->addSubItem($tutor);
206 $this->
lng->txt(
'lti_member'),
207 'lti_member_' . $global_consumer->getExtConsumerId()
210 $member->setValue($object_info->getMemberRole() ? $object_info->getMemberRole() : 0);
211 $active->addSubItem($member);
213 $form->addItem($active);
217 if (!is_null($active_consumer->ltiVersion)) {
218 $version->setValue($active_consumer->ltiVersion);
223 $sh->
setValue($this->
lng->txt(
"lti_13_step1_info"));
224 $op1->addSubItem($sh);
226 $url->setValue(ILIAS_HTTP_PATH .
'/lti.php?client_id=' .
CLIENT_ID);
227 $op1->addSubItem(
$url);
229 $url->setValue(ILIAS_HTTP_PATH .
'/Modules/LTIConsumer/lticerts.php');
231 $op1->addSubItem(
$url);
240 $sh->
setValue($this->
lng->txt(
"lti_13_step2_info"));
241 $op1->addSubItem($sh);
242 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_platform_id'),
'platform_id_' . $global_consumer->getExtConsumerId());
243 $tf->setValue($active_consumer->platformId);
244 $op1->addSubItem($tf);
245 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_client_id'),
'client_id_' . $global_consumer->getExtConsumerId());
246 $tf->setValue($active_consumer->clientId);
247 $op1->addSubItem($tf);
248 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_deployment_id'),
'deployment_id_' . $global_consumer->getExtConsumerId());
249 $tf->setValue($active_consumer->deploymentId);
250 $op1->addSubItem($tf);
251 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_keyset_url'),
'keyset_url_' . $global_consumer->getExtConsumerId());
252 $tf->setValue($active_consumer->jku);
253 $op1->addSubItem($tf);
254 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_token_url'),
'token_url_' . $global_consumer->getExtConsumerId());
255 $tf->setValue($active_consumer->accessTokenUrl);
256 $op1->addSubItem($tf);
257 $tf =
new ilTextInputGUI($this->
lng->txt(
'lti_13_authentication_url'),
'authentication_url_' . $global_consumer->getExtConsumerId());
258 $tf->setValue($active_consumer->authenticationUrl);
259 $op1->addSubItem($tf);
264 $url->
setValue(ILIAS_HTTP_PATH .
'/lti.php?client_id=' . CLIENT_ID);
265 $op0->addSubItem($url);
267 if (is_null($active_consumer->getKey())) {
268 $active_consumer->setKey(\
ILIAS\
LTI\ToolProvider\Util::getRandomString(10));
270 $key->setValue($active_consumer->getKey());
271 $op0->addSubItem(
$key);
273 if (is_null($active_consumer->getSecret())) {
274 $active_consumer->createSecret();
276 $secret->setValue($active_consumer->getSecret());
283 $form->addCommandButton(
'updateSettings', $this->
lng->txt(
'save'));
293 if (!$form->checkInput()) {
294 $form->setValuesByPost();
300 foreach (ilObjLTIAdministration::getEnabledConsumersForType(
ilObject::_lookupType($this->ref_id,
true)) as $global_consumer) {
304 $global_consumer->getExtConsumerId(),
308 if (!$form->getInput(
'lti_active_' . $global_consumer->getExtConsumerId())) {
310 if ($consumer->getEnabled()) {
311 $this->
logger->info(
'Deleting lti consumer for object reference: ' . $this->ref_id);
312 $consumer->setEnabled(
false);
313 $consumer->saveLTI($connector);
316 $consumer->ltiVersion = $form->getInput(
'version_' . $global_consumer->getExtConsumerId());
317 $this->
logger->info(
'Created new lti release for: ' . $this->ref_id);
318 $consumer->setExtConsumerId($global_consumer->getExtConsumerId());
319 $consumer->setKey((
string) $form->getInput(
'key_' . $global_consumer->getExtConsumerId()));
320 $consumer->setSecret((
string) $form->getInput(
'secret_' . $global_consumer->getExtConsumerId()));
321 $consumer->setRefId($this->ref_id);
322 $consumer->setEnabled(
true);
323 if ($form->getInput(
'platform_id_' . $global_consumer->getExtConsumerId())) {
324 $consumer->platformId = (string) $form->getInput(
'platform_id_' . $global_consumer->getExtConsumerId());
326 $consumer->platformId = null;
328 if ($form->getInput(
'client_id_' . $global_consumer->getExtConsumerId())) {
329 $consumer->clientId = $form->getInput(
'client_id_' . $global_consumer->getExtConsumerId());
331 $consumer->clientId = null;
333 if ($form->getInput(
'deployment_id_' . $global_consumer->getExtConsumerId())) {
334 $consumer->deploymentId = $form->getInput(
'deployment_id_' . $global_consumer->getExtConsumerId());
336 $consumer->deploymentId = null;
338 if ($form->getInput(
'keyset_url_' . $global_consumer->getExtConsumerId())) {
339 $consumer->jku = $form->getInput(
'keyset_url_' . $global_consumer->getExtConsumerId());
343 if ($form->getInput(
'token_url_' . $global_consumer->getExtConsumerId())) {
344 $consumer->accessTokenUrl = $form->getInput(
'token_url_' . $global_consumer->getExtConsumerId());
346 $consumer->accessTokenUrl =
'';
348 if ($form->getInput(
'authentication_url_' . $global_consumer->getExtConsumerId())) {
349 $consumer->authenticationUrl = $form->getInput(
'authentication_url_' . $global_consumer->getExtConsumerId());
351 $consumer->authenticationUrl =
'';
353 $consumer->saveLTI($connector);
357 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
358 $this->
ctrl->redirect($this,
'settings');
370 $admin_role = (
int) $form->
getInput(
'lti_admin_' . $global_consumer_id);
371 if ($admin_role > 0) {
372 $object_info->setAdminRole($admin_role);
374 $tutor_role = (
int) $form->
getInput(
'lti_tutor_' . $global_consumer_id);
375 if ($tutor_role > 0) {
376 $object_info->setTutorRole($tutor_role);
378 $member_role = (
int) $form->
getInput(
'lti_member_' . $global_consumer_id);
379 if ($member_role > 0) {
380 $object_info->setMemberRole($member_role);
382 $object_info->save();
392 $options[0] = $this->
lng->txt(
'select_one');
393 foreach ($this->custom_roles as $role_id) {
395 $options[$role_id] = $title;
406 if (is_array($a_global_role) && !empty($a_global_role)) {
407 if (count($this->rbacReview->getRolesOfObject($this->ref_id,
false)) == 0) {
411 $role->setTitle(
"il_lti_learner");
414 $rbacadmin->assignRoleToFolder($role->getId(),
$this->ref_id,
'y');
419 $role->setTitle(
"il_lti_instructor");
422 $rbacadmin->assignRoleToFolder($role->getId(),
$this->ref_id,
'y');
424 if (
$type ==
"svy") {
427 if (
$type ==
"tst") {
431 $rbacadmin->grantPermission($role->getId(), $ops,
$this->ref_id);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $a_ref_id)
getRoleSelection()
Get role selection.
static getLogger(string $a_component_id)
Get component logger.
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getOperationIdsByName(array $operations)
get ops_id's by name.
saveRoleSelection(ilPropertyFormGUI $form, string $global_consumer_id)
Save role selection for consumer.
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
settings(ilPropertyFormGUI $form=null)
Show settings.
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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