59 $this->ref_id = $a_ref_id;
60 $this->logger =
$GLOBALS[
'DIC']->logger()->lti();
61 $this->ctrl =
$GLOBALS[
'DIC']->ctrl();
62 $this->tpl =
$GLOBALS[
'DIC']->ui()->mainTemplate();
64 $this->lng =
$GLOBALS[
'DIC']->language();
65 $this->lng->loadLanguageModule(
'lti');
76 $this->logger->debug(
'No LTI consumers activated for object type: ' .
ilObject::_lookupType($this->ref_id,
true));
79 $access =
$GLOBALS[
'DIC']->rbac()->system();
80 return $access->checkAccess(
92 if (empty($a_roles)) {
94 $a_roles =
$GLOBALS[
'DIC']->rbac()->review()->getLocalRoles($this->ref_id);
96 $this->custom_roles = $a_roles;
105 $this->use_lti_roles = $a_stat;
114 $cmd = $this->ctrl->getCmd(
'settings');
115 $next_class = $this->ctrl->getNextClass($this);
117 switch ($next_class) {
133 $this->tpl->setContent($form->getHTML());
143 $form->setFormAction($this->ctrl->getFormAction($this));
144 $form->setTitle($this->lng->txt(
'lti_object_release_settings_form'));
146 foreach (ilObjLTIAdministration::getEnabledConsumersForType(
ilObject::_lookupType($this->ref_id,
true)) as $global_consumer) {
149 $this->logger->debug($object_info->getAdminRole());
154 $section->setTitle($global_consumer->getTitle());
155 $section->setInfo($global_consumer->getDescription());
161 $global_consumer->getExtConsumerId(),
166 $active =
new ilCheckboxInputGUI(
$GLOBALS[
'lng']->txt(
'lti_obj_active'),
'lti_active_' . $global_consumer->getExtConsumerId());
167 $active->setInfo(
$GLOBALS[
'lng']->txt(
'lti_obj_active_info'));
168 $active->setValue(1);
169 $form->addItem($active);
171 if ($active_consumer->getEnabled()) {
172 $active->setChecked(
true);
176 $active->addSubItem(
$url);
179 $key->setValue($active_consumer->getKey());
180 $active->addSubItem($key);
183 $secret->setValue($active_consumer->getSecret());
184 $active->addSubItem($secret);
187 if ($this->custom_roles) {
189 $this->lng->txt(
'lti_admin'),
190 'lti_admin_' . $global_consumer->getExtConsumerId()
193 $admin->setValue($object_info->getAdminRole() ? $object_info->getAdminRole() : 0);
194 $active->addSubItem($admin);
197 $this->lng->txt(
'lti_tutor'),
198 'lti_tutor_' . $global_consumer->getExtConsumerId()
201 $tutor->setValue($object_info->getTutorRole() ? $object_info->getTutorRole() : 0);
202 $active->addSubItem($tutor);
205 $this->lng->txt(
'lti_member'),
206 'lti_member_' . $global_consumer->getExtConsumerId()
209 $member->setValue($object_info->getMemberRole() ? $object_info->getMemberRole() : 0);
210 $active->addSubItem($member);
214 $form->addCommandButton(
'updateSettings', $this->lng->txt(
'save'));
224 if (!$form->checkInput()) {
225 $form->setValuesByPost();
231 foreach (ilObjLTIAdministration::getEnabledConsumersForType(
ilObject::_lookupType($this->ref_id,
true)) as $global_consumer) {
235 $global_consumer->getExtConsumerId(),
239 if (!$form->getInput(
'lti_active_' . $global_consumer->getExtConsumerId())) {
241 if ($consumer->getEnabled()) {
242 $this->logger->info(
'Deleting lti consumer for object reference: ' . $this->ref_id);
247 if (!$consumer->getEnabled()) {
248 $this->logger->info(
'Created new lti release for: ' . $this->ref_id);
249 $consumer->setExtConsumerId($global_consumer->getExtConsumerId());
250 $consumer->createSecret();
251 $consumer->setRefId($this->ref_id);
252 $consumer->setEnabled(
true);
253 $consumer->saveLTI($connector);
258 ilUtil::sendSuccess($this->lng->txt(
'settings_saved'),
true);
259 $this->ctrl->redirect($this,
'settings');
271 $admin_role = $form->
getInput(
'lti_admin_' . $global_consumer_id);
272 if ($admin_role > 0) {
273 $object_info->setAdminRole($admin_role);
275 $tutor_role = $form->
getInput(
'lti_tutor_' . $global_consumer_id);
276 if ($tutor_role > 0) {
277 $object_info->setTutorRole($tutor_role);
279 $member_role = $form->
getInput(
'lti_member_' . $global_consumer_id);
280 if ($member_role > 0) {
281 $object_info->setMemberRole($member_role);
283 $object_info->save();
294 $options[0] = $this->lng->txt(
'select_one');
295 foreach ($this->custom_roles as $role_id) {
297 $options[$role_id] = $title;
309 if (is_array($a_global_role) && !empty($a_global_role)) {
310 $rbacreview =
$DIC[
'rbacreview'];
311 if (count($rbacreview->getRolesOfObject($this->ref_id,
false)) == 0) {
312 $rbacadmin =
$DIC[
'rbacadmin'];
315 $role->setTitle(
"il_lti_learner");
318 $rbacadmin->assignRoleToFolder($role->getId(), $this->ref_id,
'y');
323 $role->setTitle(
"il_lti_instructor");
326 $rbacadmin->assignRoleToFolder($role->getId(), $this->ref_id,
'y');
328 if (
$type ==
"svy") {
331 if (
$type ==
"tst") {
335 $rbacadmin->grantPermission($role->getId(), $ops, $this->ref_id);
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
Class to represent an LTI Data Connector for ILIAS.
GUI class for LTI provider object settings.
initObjectSettingsForm()
Init object settings form.
saveRoleSelection(ilPropertyFormGUI $form, $global_consumer_id)
Save role selection for consumer.
executeCommand()
Ctrl execute command.
updateSettings()
Update settings (activate deactivate lti access)
setCustomRolesForSelection($a_roles)
Set custom roles for mapping to LTI roles.
hasSettingsAccess()
Check if user has access to lti settings.
offerLTIRolesForSelection($a_stat)
Offer LTI roles for mapping.
settings(ilPropertyFormGUI $form=null)
Show settings.
checkLocalRole()
check for local roles for lti objects which are not grp or crs
getRoleSelection()
Get role selection.
This class represents a non editable value in a property form.
static lookupLTISettingsRefId()
Lookup ref_id.
static _getTranslation($a_role_title)
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getIdsForTitle($title, $type='', $partialmatch=false)
static _getOperationIdsByName($operations)
get ops_id's by name.