ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 

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.

References $GLOBALS.

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  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

Member Function Documentation

◆ executeCommand()

ilLTIProviderObjectSettingGUI::executeCommand ( )

Ctrl execute command.

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

109  {
110  $cmd = $this->ctrl->getCmd('settings');
111  $next_class = $this->ctrl->getNextClass($this);
112 
113  switch ($next_class) {
114  default:
115  $this->$cmd();
116  break;
117  }
118  }

◆ getRoleSelection()

ilLTIProviderObjectSettingGUI::getRoleSelection ( )
protected

Get role selection.

Returns
array

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

References $options, $title, ilObjRole\_getTranslation(), and ilObject\_lookupTitle().

Referenced by initObjectSettingsForm().

288  {
289  $options = [];
290  $options[0] = $this->lng->txt('select_one');
291  foreach ($this->custom_roles as $role_id) {
293  $options[$role_id] = $title;
294  }
295  return $options;
296  }
static _lookupTitle($a_id)
lookup object title
static _getTranslation($a_role_title)
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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.

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

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  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static lookupLTISettingsRefId()
Lookup ref_id.
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

◆ initObjectSettingsForm()

ilLTIProviderObjectSettingGUI::initObjectSettingsForm ( )
protected

Init object settings form.

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

References $form, $GLOBALS, $key, $ref_id, $secret, $section, $url, ilObject\_lookupType(), ilLTIToolConsumer\fromGlobalSettingsAndRefId(), getRoleSelection(), ilFormPropertyGUI\setInfo(), and ilSelectInputGUI\setOptions().

Referenced by settings(), and updateSettings().

137  {
138  $form = new ilPropertyFormGUI();
139  $form->setFormAction($this->ctrl->getFormAction($this));
140  $form->setTitle($this->lng->txt('lti_object_release_settings_form'));
141 
142  foreach (ilObjLTIAdministration::getEnabledConsumersForType(ilObject::_lookupType($this->ref_id, true)) as $global_consumer) {
143  $object_info = new ilLTIProviderObjectSetting($this->ref_id, $global_consumer->getExtConsumerId());
144 
145  $this->logger->debug($object_info->getAdminRole());
146 
147 
148  // meta data for external consumers
150  $section->setTitle($global_consumer->getTitle());
151  $section->setInfo($global_consumer->getDescription());
152  $form->addItem($section);
153 
154  $connector = new ilLTIDataConnector();
155 
157  $global_consumer->getExtConsumerId(),
159  $connector
160  );
161 
162  $active = new ilCheckboxInputGUI($GLOBALS['lng']->txt('lti_obj_active'), 'lti_active_' . $global_consumer->getExtConsumerId());
163  $active->setInfo($GLOBALS['lng']->txt('lti_obj_active_info'));
164  $active->setValue(1);
165  $form->addItem($active);
166 
167  if ($active_consumer->getEnabled()) { // and enabled
168  $active->setChecked(true);
169 
170  $url = new ilNonEditableValueGUI($this->lng->txt('lti_launch_url'), 'url');
171  $url->setValue(ILIAS_HTTP_PATH . '/lti.php?client_id=' . CLIENT_ID);
172  $active->addSubItem($url);
173 
174  $key = new ilNonEditableValueGUI($this->lng->txt('lti_consumer_key'), 'key');
175  $key->setValue($active_consumer->getKey());
176  $active->addSubItem($key);
177 
178  $secret = new ilNonEditableValueGUI($this->lng->txt('lti_consumer_secret'), 'secret');
179  $secret->setValue($active_consumer->getSecret());
180  $active->addSubItem($secret);
181  }
182 
183  if ($this->custom_roles) {
184  $admin = new ilSelectInputGUI(
185  $this->lng->txt('lti_admin'),
186  'lti_admin_' . $global_consumer->getExtConsumerId()
187  );
188  $admin->setOptions($this->getRoleSelection());
189  $admin->setValue($object_info->getAdminRole() ? $object_info->getAdminRole() : 0);
190  $active->addSubItem($admin);
191 
192  $tutor = new ilSelectInputGUI(
193  $this->lng->txt('lti_tutor'),
194  'lti_tutor_' . $global_consumer->getExtConsumerId()
195  );
196  $tutor->setOptions($this->getRoleSelection());
197  $tutor->setValue($object_info->getTutorRole() ? $object_info->getTutorRole() : 0);
198  $active->addSubItem($tutor);
199 
200  $member = new ilSelectInputGUI(
201  $this->lng->txt('lti_member'),
202  'lti_member_' . $global_consumer->getExtConsumerId()
203  );
204  $member->setOptions($this->getRoleSelection());
205  $member->setValue($object_info->getMemberRole() ? $object_info->getMemberRole() : 0);
206  $active->addSubItem($member);
207  }
208  }
209 
210  $form->addCommandButton('updateSettings', $this->lng->txt('save'));
211  return $form;
212  }
This class represents a selection list property in a property form.
This class represents a property form user interface.
$secret
Definition: demo.php:27
Class to represent an LTI Data Connector for ILIAS.
This class represents a section header in a property form.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
This class represents a checkbox property in a property form.
static fromGlobalSettingsAndRefId($a_ext_consumer_id, $a_ref_id, ilLTIDataConnector $a_data_connector)
Load consumer from global settings and ref_id.
setInfo($a_info)
Set Information Text.
$section
Definition: Utf8Test.php:83
if(isset($_POST['submit'])) $form
setOptions($a_options)
Set Options.
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a non editable value in a property form.
$url
$key
Definition: croninfo.php:18
+ 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 99 of file class.ilLTIProviderObjectSettingGUI.php.

100  {
101  $this->use_lti_roles = $a_stat;
102  }

◆ saveRoleSelection()

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

Save role selection for consumer.

Parameters
ilPropertyFormGUI$form
type$global_consumer_id

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

References ilPropertyFormGUI\getInput().

Referenced by updateSettings().

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

Referenced by ilObjSAHSLearningModuleGUI\executeCommand(), ilObjGroupGUI\executeCommand(), ilObjSurveyGUI\executeCommand(), ilObjContentObjectGUI\executeCommand(), ilObjTestGUI\executeCommand(), and ilObjCourseGUI\executeCommand().

91  {
92  $this->custom_roles = $a_roles;
93  }
+ Here is the caller graph for this function:

◆ settings()

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

Show settings.

Parameters
ilPropertyFormGUI$form

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

References $form, and initObjectSettingsForm().

Referenced by updateSettings().

125  {
126  if (!$form instanceof ilPropertyFormGUI) {
127  $form = $this->initObjectSettingsForm();
128  }
129  $this->tpl->setContent($form->getHTML());
130  }
This class represents a property form user interface.
+ 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 217 of file class.ilLTIProviderObjectSettingGUI.php.

References $consumer, $form, $ref_id, ilObject\_lookupType(), ilLTIToolConsumer\fromGlobalSettingsAndRefId(), initObjectSettingsForm(), saveRoleSelection(), ilUtil\sendSuccess(), and settings().

218  {
219  $form = $this->initObjectSettingsForm();
220  if (!$form->checkInput()) {
221  $form->setValuesByPost();
222  $this->settings($form);
223  return;
224  }
225 
226  $connector = new ilLTIDataConnector();
227  foreach (ilObjLTIAdministration::getEnabledConsumersForType(ilObject::_lookupType($this->ref_id, true)) as $global_consumer) {
228  $this->saveRoleSelection($form, $global_consumer->getExtConsumerId());
229 
231  $global_consumer->getExtConsumerId(),
233  $connector
234  );
235  if (!$form->getInput('lti_active_' . $global_consumer->getExtConsumerId())) {
236  // not active anymore => delete consumer
237  if ($consumer->getEnabled()) {
238  $this->logger->info('Deleting lti consumer for object reference: ' . $this->ref_id);
239  $consumer->delete();
240  }
241  } else {
242  // new activation
243  if (!$consumer->getEnabled()) {
244  $this->logger->info('Created new lti release for: ' . $this->ref_id);
245  $consumer->setExtConsumerId($global_consumer->getExtConsumerId());
246  $consumer->createSecret();
247  $consumer->setRefId($this->ref_id);
248  $consumer->setEnabled(true);
249  $consumer->saveLTI($connector);
250  }
251  }
252  }
253 
254  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
255  $this->ctrl->redirect($this, 'settings');
256  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
saveRoleSelection(ilPropertyFormGUI $form, $global_consumer_id)
Save role selection for consumer.
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.
if(isset($_POST['submit'])) $form
settings(ilPropertyFormGUI $form=null)
Show settings.
$consumer
Definition: demo.php:30
static _lookupType($a_id, $a_reference=false)
lookup object type
+ 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

◆ $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: