ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilLTIProviderObjectSettingGUI Class Reference

GUI class for LTI provider object settings. More...

+ Collaboration diagram for ilLTIProviderObjectSettingGUI:

Public Member Functions

 __construct ($a_ref_id)
 
 hasSettingsAccess ()
 Check if user has access to lti settings. More...
 
 setCustomRolesForSelection ($a_roles)
 Set custom roles for mapping to LTI roles. More...
 
 offerLTIRolesForSelection ($a_stat)
 Offer LTI roles for mapping. More...
 
 executeCommand ()
 Ctrl execute command. More...
 

Data Fields

const ROLE_ADMIN = 'admin'
 
const ROLE_TUTOR = 'tutor'
 
const ROLE_MEMBER = 'member'
 

Protected Member Functions

 settings (ilPropertyFormGUI $form=null)
 Show settings. More...
 
 initObjectSettingsForm ()
 Init object settings form. More...
 
 updateSettings ()
 Update settings (activate deactivate lti access) More...
 
 saveRoleSelection (ilPropertyFormGUI $form, $global_consumer_id)
 Save role selection for consumer. More...
 
 getRoleSelection ()
 Get role selection. More...
 
 checkLocalRole ()
 check for local roles for lti objects which are not grp or crs More...
 

Protected Attributes

 $ctrl = null
 
 $logger = null
 
 $lng = null
 
 $tpl = null
 
 $ref_id = null
 
 $custom_roles = []
 
 $use_lti_roles = true
 

Detailed Description

GUI class for LTI provider object settings.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 11 of file class.ilLTIProviderObjectSettingGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilLTIProviderObjectSettingGUI::__construct (   $a_ref_id)
Parameters
intref_id

Definition at line 57 of file class.ilLTIProviderObjectSettingGUI.php.

58 {
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();
63
64 $this->lng = $GLOBALS['DIC']->language();
65 $this->lng->loadLanguageModule('lti');
66 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64

References $GLOBALS.

Member Function Documentation

◆ checkLocalRole()

ilLTIProviderObjectSettingGUI::checkLocalRole ( )
protected

check for local roles for lti objects which are not grp or crs

Definition at line 305 of file class.ilLTIProviderObjectSettingGUI.php.

306 {
307 global $DIC;
308 $a_global_role = ilObject::_getIdsForTitle("il_lti_global_role", "role", false);
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'];
313 $type = ilObject::_lookupType($this->ref_id, true);
314 $role = new ilObjRole();
315 $role->setTitle("il_lti_learner");
316 $role->setDescription("LTI Learner of " . $type . " obj_no." . ilObject::_lookupObjectId($this->ref_id));
317 $role->create();
318 $rbacadmin->assignRoleToFolder($role->getId(), $this->ref_id, 'y');
319 $rbacadmin->grantPermission($role->getId(), ilRbacReview::_getOperationIdsByName(array('visible','read')), $this->ref_id);
320 // $rbacadmin->setRolePermission($role->getId(), ilObject::_lookupType($this->ref_id, true), [2,3], $this->ref_id);
321 if ($type == "sahs" || $type == "lm" || $type == "svy" || $type == "tst") {
322 $role = new ilObjRole();
323 $role->setTitle("il_lti_instructor");
324 $role->setDescription("LTI Instructor of " . $type . " obj_no." . ilObject::_lookupObjectId($this->ref_id));
325 $role->create();
326 $rbacadmin->assignRoleToFolder($role->getId(), $this->ref_id, 'y');
327 $ops = ilRbacReview::_getOperationIdsByName(array('visible','read','read_learning_progress'));
328 if ($type == "svy") {
329 $ops[] = ilRbacReview::_getOperationIdsByName(array('read_results'))[0];
330 }
331 if ($type == "tst") {
332 $ops[] = ilRbacReview::_getOperationIdsByName(array('tst_results'))[0];
333 $ops[] = ilRbacReview::_getOperationIdsByName(array('tst_statistics'))[0];
334 }
335 $rbacadmin->grantPermission($role->getId(), $ops, $this->ref_id);
336 }
337 }
338 }
339 }
Class ilObjRole.
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.
$type
$DIC
Definition: xapitoken.php:46

References $DIC, $type, ilObject\_getIdsForTitle(), ilRbacReview\_getOperationIdsByName(), ilObject\_lookupObjectId(), and ilObject\_lookupType().

Referenced by setCustomRolesForSelection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilLTIProviderObjectSettingGUI::executeCommand ( )

Ctrl execute command.

Definition at line 112 of file class.ilLTIProviderObjectSettingGUI.php.

113 {
114 $cmd = $this->ctrl->getCmd('settings');
115 $next_class = $this->ctrl->getNextClass($this);
116
117 switch ($next_class) {
118 default:
119 $this->$cmd();
120 break;
121 }
122 }

◆ getRoleSelection()

ilLTIProviderObjectSettingGUI::getRoleSelection ( )
protected

Get role selection.

Returns
array

Definition at line 291 of file class.ilLTIProviderObjectSettingGUI.php.

292 {
293 $options = [];
294 $options[0] = $this->lng->txt('select_one');
295 foreach ($this->custom_roles as $role_id) {
297 $options[$role_id] = $title;
298 }
299 return $options;
300 }
static _getTranslation($a_role_title)
static _lookupTitle($a_id)
lookup object title

References ilObjRole\_getTranslation(), and ilObject\_lookupTitle().

Referenced by initObjectSettingsForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasSettingsAccess()

ilLTIProviderObjectSettingGUI::hasSettingsAccess ( )

Check if user has access to lti settings.

Parameters
intref_id
intuser_id

Definition at line 73 of file class.ilLTIProviderObjectSettingGUI.php.

74 {
75 if (!ilObjLTIAdministration::isEnabledForType(ilObject::_lookupType($this->ref_id, true))) {
76 $this->logger->debug('No LTI consumers activated for object type: ' . ilObject::_lookupType($this->ref_id, true));
77 return false;
78 }
79 $access = $GLOBALS['DIC']->rbac()->system();
80 return $access->checkAccess(
81 'release_objects',
83 );
84 }
static lookupLTISettingsRefId()
Lookup ref_id.

References $GLOBALS, ilObject\_lookupType(), and ilObjLTIAdministration\lookupLTISettingsRefId().

+ Here is the call graph for this function:

◆ initObjectSettingsForm()

ilLTIProviderObjectSettingGUI::initObjectSettingsForm ( )
protected

Init object settings form.

Definition at line 140 of file class.ilLTIProviderObjectSettingGUI.php.

141 {
142 $form = new ilPropertyFormGUI();
143 $form->setFormAction($this->ctrl->getFormAction($this));
144 $form->setTitle($this->lng->txt('lti_object_release_settings_form'));
145
146 foreach (ilObjLTIAdministration::getEnabledConsumersForType(ilObject::_lookupType($this->ref_id, true)) as $global_consumer) {
147 $object_info = new ilLTIProviderObjectSetting($this->ref_id, $global_consumer->getExtConsumerId());
148
149 $this->logger->debug($object_info->getAdminRole());
150
151
152 // meta data for external consumers
154 $section->setTitle($global_consumer->getTitle());
155 $section->setInfo($global_consumer->getDescription());
156 $form->addItem($section);
157
158 $connector = new ilLTIDataConnector();
159
161 $global_consumer->getExtConsumerId(),
162 $this->ref_id,
163 $connector
164 );
165
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);
170
171 if ($active_consumer->getEnabled()) { // and enabled
172 $active->setChecked(true);
173
174 $url = new ilNonEditableValueGUI($this->lng->txt('lti_launch_url'), 'url');
175 $url->setValue(ILIAS_HTTP_PATH . '/lti.php?client_id=' . CLIENT_ID);
176 $active->addSubItem($url);
177
178 $key = new ilNonEditableValueGUI($this->lng->txt('lti_consumer_key'), 'key');
179 $key->setValue($active_consumer->getKey());
180 $active->addSubItem($key);
181
182 $secret = new ilNonEditableValueGUI($this->lng->txt('lti_consumer_secret'), 'secret');
183 $secret->setValue($active_consumer->getSecret());
184 $active->addSubItem($secret);
185 }
186
187 if ($this->custom_roles) {
188 $admin = new ilSelectInputGUI(
189 $this->lng->txt('lti_admin'),
190 'lti_admin_' . $global_consumer->getExtConsumerId()
191 );
192 $admin->setOptions($this->getRoleSelection());
193 $admin->setValue($object_info->getAdminRole() ? $object_info->getAdminRole() : 0);
194 $active->addSubItem($admin);
195
196 $tutor = new ilSelectInputGUI(
197 $this->lng->txt('lti_tutor'),
198 'lti_tutor_' . $global_consumer->getExtConsumerId()
199 );
200 $tutor->setOptions($this->getRoleSelection());
201 $tutor->setValue($object_info->getTutorRole() ? $object_info->getTutorRole() : 0);
202 $active->addSubItem($tutor);
203
204 $member = new ilSelectInputGUI(
205 $this->lng->txt('lti_member'),
206 'lti_member_' . $global_consumer->getExtConsumerId()
207 );
208 $member->setOptions($this->getRoleSelection());
209 $member->setValue($object_info->getMemberRole() ? $object_info->getMemberRole() : 0);
210 $active->addSubItem($member);
211 }
212 }
213
214 $form->addCommandButton('updateSettings', $this->lng->txt('save'));
215 return $form;
216 }
$section
Definition: Utf8Test.php:83
This class represents a checkbox property in a property form.
This class represents a section header in a property form.
Class to represent an LTI Data Connector for ILIAS.
static fromGlobalSettingsAndRefId($a_ext_consumer_id, $a_ref_id, ilLTIDataConnector $a_data_connector)
Load consumer from global settings and ref_id.
This class represents a non editable value in a property form.
This class represents a property form user interface.
This class represents a selection list property in a property form.
$url

References $GLOBALS, $section, $url, ilObject\_lookupType(), ilLTIToolConsumer\fromGlobalSettingsAndRefId(), getRoleSelection(), and ILIAS_HTTP_PATH.

Referenced by settings(), and updateSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ offerLTIRolesForSelection()

ilLTIProviderObjectSettingGUI::offerLTIRolesForSelection (   $a_stat)

Offer LTI roles for mapping.

Parameters
bool$a_stat

Definition at line 103 of file class.ilLTIProviderObjectSettingGUI.php.

104 {
105 $this->use_lti_roles = $a_stat;
106 }

◆ saveRoleSelection()

ilLTIProviderObjectSettingGUI::saveRoleSelection ( ilPropertyFormGUI  $form,
  $global_consumer_id 
)
protected

Save role selection for consumer.

Parameters
ilPropertyFormGUI$form
type$global_consumer_id

Definition at line 267 of file class.ilLTIProviderObjectSettingGUI.php.

268 {
269 $object_info = new ilLTIProviderObjectSetting($this->ref_id, $global_consumer_id);
270
271 $admin_role = $form->getInput('lti_admin_' . $global_consumer_id);
272 if ($admin_role > 0) {
273 $object_info->setAdminRole($admin_role);
274 }
275 $tutor_role = $form->getInput('lti_tutor_' . $global_consumer_id);
276 if ($tutor_role > 0) {
277 $object_info->setTutorRole($tutor_role);
278 }
279 $member_role = $form->getInput('lti_member_' . $global_consumer_id);
280 if ($member_role > 0) {
281 $object_info->setMemberRole($member_role);
282 }
283 $object_info->save();
284 }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.

References ilPropertyFormGUI\getInput().

Referenced by updateSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCustomRolesForSelection()

ilLTIProviderObjectSettingGUI::setCustomRolesForSelection (   $a_roles)

Set custom roles for mapping to LTI roles.

Parameters
type$a_roles

Definition at line 90 of file class.ilLTIProviderObjectSettingGUI.php.

91 {
92 if (empty($a_roles)) {
93 $this->checkLocalRole();
94 $a_roles = $GLOBALS['DIC']->rbac()->review()->getLocalRoles($this->ref_id);
95 }
96 $this->custom_roles = $a_roles;
97 }
checkLocalRole()
check for local roles for lti objects which are not grp or crs

References $GLOBALS, and checkLocalRole().

+ Here is the call graph for this function:

◆ settings()

ilLTIProviderObjectSettingGUI::settings ( ilPropertyFormGUI  $form = null)
protected

Show settings.

Parameters
ilPropertyFormGUI$form

Definition at line 128 of file class.ilLTIProviderObjectSettingGUI.php.

129 {
130 if (!$form instanceof ilPropertyFormGUI) {
131 $form = $this->initObjectSettingsForm();
132 }
133 $this->tpl->setContent($form->getHTML());
134 }

References initObjectSettingsForm().

Referenced by updateSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateSettings()

ilLTIProviderObjectSettingGUI::updateSettings ( )
protected

Update settings (activate deactivate lti access)

Definition at line 221 of file class.ilLTIProviderObjectSettingGUI.php.

222 {
223 $form = $this->initObjectSettingsForm();
224 if (!$form->checkInput()) {
225 $form->setValuesByPost();
226 $this->settings($form);
227 return;
228 }
229
230 $connector = new ilLTIDataConnector();
231 foreach (ilObjLTIAdministration::getEnabledConsumersForType(ilObject::_lookupType($this->ref_id, true)) as $global_consumer) {
232 $this->saveRoleSelection($form, $global_consumer->getExtConsumerId());
233
235 $global_consumer->getExtConsumerId(),
236 $this->ref_id,
237 $connector
238 );
239 if (!$form->getInput('lti_active_' . $global_consumer->getExtConsumerId())) {
240 // not active anymore => delete consumer
241 if ($consumer->getEnabled()) {
242 $this->logger->info('Deleting lti consumer for object reference: ' . $this->ref_id);
243 $consumer->delete();
244 }
245 } else {
246 // new activation
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);
254 }
255 }
256 }
257
258 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
259 $this->ctrl->redirect($this, 'settings');
260 }
saveRoleSelection(ilPropertyFormGUI $form, $global_consumer_id)
Save role selection for consumer.
settings(ilPropertyFormGUI $form=null)
Show settings.

References ilObject\_lookupType(), ilLTIToolConsumer\fromGlobalSettingsAndRefId(), initObjectSettingsForm(), saveRoleSelection(), and settings().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilLTIProviderObjectSettingGUI::$ctrl = null
protected

Definition at line 21 of file class.ilLTIProviderObjectSettingGUI.php.

◆ $custom_roles

ilLTIProviderObjectSettingGUI::$custom_roles = []
protected

Definition at line 47 of file class.ilLTIProviderObjectSettingGUI.php.

◆ $lng

ilLTIProviderObjectSettingGUI::$lng = null
protected

Definition at line 31 of file class.ilLTIProviderObjectSettingGUI.php.

◆ $logger

ilLTIProviderObjectSettingGUI::$logger = null
protected

Definition at line 26 of file class.ilLTIProviderObjectSettingGUI.php.

◆ $ref_id

ilLTIProviderObjectSettingGUI::$ref_id = null
protected

Definition at line 41 of file class.ilLTIProviderObjectSettingGUI.php.

◆ $tpl

ilLTIProviderObjectSettingGUI::$tpl = null
protected

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

◆ $use_lti_roles

ilLTIProviderObjectSettingGUI::$use_lti_roles = true
protected

Definition at line 52 of file class.ilLTIProviderObjectSettingGUI.php.

◆ ROLE_ADMIN

const ilLTIProviderObjectSettingGUI::ROLE_ADMIN = 'admin'

Definition at line 13 of file class.ilLTIProviderObjectSettingGUI.php.

◆ ROLE_MEMBER

const ilLTIProviderObjectSettingGUI::ROLE_MEMBER = 'member'

Definition at line 15 of file class.ilLTIProviderObjectSettingGUI.php.

◆ ROLE_TUTOR

const ilLTIProviderObjectSettingGUI::ROLE_TUTOR = 'tutor'

Definition at line 14 of file class.ilLTIProviderObjectSettingGUI.php.


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