ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilCASSettingsGUI Class Reference
+ Collaboration diagram for ilCASSettingsGUI:

Public Member Functions

 __construct (int $a_auth_ref_id)
 
 executeCommand ()
 
 settings ()
 
 save ()
 

Data Fields

const SYNC_DISABLED = 0
 
const SYNC_CAS = 1
 
const SYNC_LDAP = 2
 

Protected Member Functions

 getSettings ()
 
 initFormSettings ()
 

Private Member Functions

 prepareRoleSelection ()
 

Private Attributes

ilCASSettings $settings
 
int $ref_id
 
ilGlobalTemplateInterface $tpl
 
ilCtrl $ctrl
 
ilLanguage $lng
 
ilRbacSystem $rbacSystem
 
ilRbacReview $rbacReview
 
ilErrorHandling $ilErr
 
ILIAS UI Renderer $renderer
 
ILIAS UI Factory $factory
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 24 of file class.ilCASSettingsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilCASSettingsGUI::__construct ( int  $a_auth_ref_id)

Definition at line 43 of file class.ilCASSettingsGUI.php.

References $DIC, ILIAS\Repository\ctrl(), ilCASSettings\getInstance(), ILIAS\Repository\lng(), and settings().

44  {
45  global $DIC;
46  $this->tpl = $DIC->ui()->mainTemplate();
47 
48  $this->ctrl = $DIC->ctrl();
49  $this->rbacSystem = $DIC->rbac()->system();
50  $this->rbacReview = $DIC->rbac()->review();
51  $this->ilErr = $DIC['ilErr'];
52  $this->lng = $DIC->language();
53  $this->lng->loadLanguageModule('registration');
54  $this->lng->loadLanguageModule('auth');
55 
56  $this->renderer = $DIC->ui()->renderer();
57  $this->factory = $DIC->ui()->factory();
58 
59  $this->ref_id = $a_auth_ref_id;
60 
62  }
global $DIC
Definition: shib_login.php:25
static getInstance()
Get singleton instance.
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilCASSettingsGUI::executeCommand ( )

Definition at line 69 of file class.ilCASSettingsGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

69  : bool
70  {
71  $next_class = $this->ctrl->getNextClass($this);
72  $cmd = $this->ctrl->getCmd("settings");
73 
74  if (!$this->rbacSystem->checkAccess("visible,read", $this->ref_id)) {
75  $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilErr->WARNING);
76  }
77 
78  switch ($next_class) {
79  default:
80  if (!$cmd) {
81  $cmd = "settings";
82  }
83  $this->$cmd();
84  break;
85  }
86  return true;
87  }
+ Here is the call graph for this function:

◆ getSettings()

ilCASSettingsGUI::getSettings ( )
protected

Definition at line 64 of file class.ilCASSettingsGUI.php.

References $settings.

Referenced by initFormSettings(), and save().

65  {
66  return $this->settings;
67  }
+ Here is the caller graph for this function:

◆ initFormSettings()

ilCASSettingsGUI::initFormSettings ( )
protected

Definition at line 89 of file class.ilCASSettingsGUI.php.

References $check, $text, ilAuthUtils\AUTH_CAS, ILIAS\Repository\ctrl(), ilLDAPServer\getAvailableDataSources(), ilLDAPServer\getDataSource(), getSettings(), ilLDAPServer\isDataSourceActive(), ILIAS\Repository\lng(), prepareRoleSelection(), ilTextAreaInputGUI\setCols(), ilFormPropertyGUI\setDisabled(), ilSelectInputGUI\setOptions(), ilCASSettings\SYNC_CAS, ilCASSettings\SYNC_DISABLED, and ilCASSettings\SYNC_LDAP.

Referenced by save(), and settings().

90  {
91  $this->lng->loadLanguageModule('auth');
92 
93  $form = new ilPropertyFormGUI();
94  $form->setFormAction($this->ctrl->getFormAction($this));
95 
96  $form->setTitle($this->lng->txt('auth_cas_auth'));
97 
98  $has_write_permissions = $this->rbacSystem->checkAccess('write', $this->ref_id);
99 
100  $drop_in_replacements_url = 'https://github.com/ILIAS-eLearning/ILIAS/tree/trunk/components/ILIAS/HTTP#dropinreplacements';
101  $drop_in_replacements_link = $this->factory->link()->standard(
102  $this->lng->txt("auth_cas_auth_desc"),
103  $drop_in_replacements_url
104  );
105  $form->setDescription($this->renderer->render(
106  $drop_in_replacements_link
107  ));
108 
109  // Form checkbox
110  $check = new ilCheckboxInputGUI($this->lng->txt("active"), 'active');
111  $check->setDisabled(!$has_write_permissions);
112  $check->setChecked($this->getSettings()->isActive());
113  $check->setValue("1");
114  $form->addItem($check);
115 
116  $text = new ilTextInputGUI($this->lng->txt('server'), 'server');
117  $text->setDisabled(!$has_write_permissions);
118  $text->setValue($this->getSettings()->getServer());
119  $text->setRequired(true);
120  $text->setInfo($this->lng->txt('auth_cas_server_desc'));
121  $text->setSize(64);
122  $text->setMaxLength(255);
123  $form->addItem($text);
124 
125  $port = new ilNumberInputGUI($this->lng->txt("port"), 'port');
126  $port->setDisabled(!$has_write_permissions);
127  $port->setValue((string) $this->getSettings()->getPort());
128  $port->setRequired(true);
129  $port->setMinValue(0);
130  $port->setMaxValue(65535);
131  $port->setSize(5);
132  $port->setMaxLength(5);
133  $port->setInfo($this->lng->txt('auth_cas_port_desc'));
134  $form->addItem($port);
135 
136  $text = new ilTextInputGUI($this->lng->txt('uri'), 'uri');
137  $text->setDisabled(!$has_write_permissions);
138  $text->setValue($this->getSettings()->getUri());
139  $text->setRequired(true);
140  $text->setInfo($this->lng->txt('auth_cas_uri_desc'));
141  $text->setSize(64);
142  $text->setMaxLength(255);
143  $form->addItem($text);
144 
145  // User synchronization
146  // 0: Disabled
147  // 1: CAS
148  // 2: LDAP
149  $sync = new ilRadioGroupInputGUI($this->lng->txt('auth_sync'), 'sync');
150  $sync->setDisabled(!$has_write_permissions);
151  $sync->setRequired(true);
152  $form->addItem($sync);
153 
154  // Disabled
155  $dis = new ilRadioOption(
156  $this->lng->txt('disabled'),
157  (string) self::SYNC_DISABLED,
158  ''
159  );
160  $dis->setDisabled(!$has_write_permissions);
161  $sync->addOption($dis);
162 
163  // CAS
164  $rad = new ilRadioOption(
165  $this->lng->txt('auth_sync_cas'),
166  (string) self::SYNC_CAS,
167  ''
168  );
169  $rad->setDisabled(!$has_write_permissions);
170  $rad->setInfo($this->lng->txt('auth_sync_cas_info'));
171  $sync->addOption($rad);
172 
173  $select = new ilSelectInputGUI($this->lng->txt('auth_user_default_role'), 'role');
174  $select->setOptions($this->prepareRoleSelection());
175  $select->setValue($this->getSettings()->getDefaultRole());
176  $select->setDisabled(!$has_write_permissions);
177  $rad->addSubItem($select);
178 
179 
180  // LDAP
182 
183  if (count($server_ids)) {
184  $ldap = new ilRadioOption(
185  $this->lng->txt('auth_css_ldap'),
186  (string) ilCASSettings::SYNC_LDAP,
187  ''
188  );
189  $ldap->setDisabled(!$has_write_permissions);
190  $ldap->setInfo($this->lng->txt('auth_cas_ldap_info'));
191  $sync->addOption($ldap);
192 
193  $ldap_server_select = new ilSelectInputGUI($this->lng->txt('auth_ldap_server_ds'), 'ldap_sid');
194  $ldap_server_select->setDisabled(!$has_write_permissions);
195  $options[0] = $this->lng->txt('select_one');
196  foreach ($server_ids as $ldap_sid) {
197  $ldap_server = new ilLDAPServer($ldap_sid);
198  $options[$ldap_sid] = $ldap_server->getName();
199  }
200  $ldap_server_select->setOptions($options);
201  $ldap_server_select->setRequired(true);
203  $ldap_server_select->setValue($ds);
204 
205  $ldap->addSubItem($ldap_server_select);
206  }
207 
209  $sync->setValue((string) ilCASSettings::SYNC_LDAP);
210  } else {
211  $sync->setValue(
212  $this->getSettings()->isUserCreationEnabled() ?
213  (string) ilCASSettings::SYNC_CAS :
215  );
216  }
217 
218  $instruction = new ilTextAreaInputGUI($this->lng->txt('auth_login_instructions'), 'instruction');
219  $instruction->setCols(80);
220  $instruction->setRows(6);
221  $instruction->setDisabled(!$has_write_permissions);
222  $instruction->setValue($this->getSettings()->getLoginInstruction());
223  $form->addItem($instruction);
224 
225  $create = new ilCheckboxInputGUI($this->lng->txt('auth_allow_local'), 'local');
226  $create->setInfo($this->lng->txt('auth_cas_allow_local_desc'));
227  $create->setChecked($this->getSettings()->isLocalAuthenticationEnabled());
228  $create->setValue("1");
229  $create->setDisabled(!$has_write_permissions);
230  $form->addItem($create);
231 
232  if ($this->rbacSystem->checkAccess('write', $this->ref_id)) {
233  $form->addCommandButton('save', $this->lng->txt('save'));
234  }
235 
236  return $form;
237  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getDataSource(int $a_auth_mode)
static getAvailableDataSources(int $a_auth_mode)
This class represents a selection list property in a property form.
setOptions(array $a_options)
static isDataSourceActive(int $a_auth_mode)
Check if a data source is active for a specific auth mode.
This class represents a property in a property form.
$text
Definition: xapiexit.php:21
This class represents a text area property in a property form.
$check
Definition: buildRTE.php:81
setDisabled(bool $a_disabled)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareRoleSelection()

ilCASSettingsGUI::prepareRoleSelection ( )
private

Definition at line 290 of file class.ilCASSettingsGUI.php.

References ilObject\_lookupTitle(), ilUtil\_sortIds(), and ILIAS\Repository\lng().

Referenced by initFormSettings().

290  : array
291  {
292  $global_roles = ilUtil::_sortIds(
293  $this->rbacReview->getGlobalRoles(),
294  'object_data',
295  'title',
296  'obj_id'
297  );
298 
299  $select[0] = $this->lng->txt('links_select_one');
300  foreach ($global_roles as $role_id) {
301  $select[$role_id] = ilObject::_lookupTitle((int) $role_id);
302  }
303 
304  return $select;
305  }
static _lookupTitle(int $obj_id)
static _sortIds(array $a_ids, string $a_table, string $a_field, string $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,7),'usr_data','lastname','usr_id') => sorts by lastname.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilCASSettingsGUI::save ( )

Definition at line 245 of file class.ilCASSettingsGUI.php.

References ilAuthUtils\AUTH_CAS, ILIAS\Repository\ctrl(), ilLDAPServer\disableDataSourceForAuthMode(), getSettings(), initFormSettings(), ILIAS\Repository\lng(), settings(), ilCASSettings\SYNC_CAS, ilCASSettings\SYNC_DISABLED, ilCASSettings\SYNC_LDAP, and ilLDAPServer\toggleDataSource().

245  : void
246  {
247  if (!$this->rbacSystem->checkAccess('write', $this->ref_id)) {
248  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->WARNING);
249  }
250 
251  $form = $this->initFormSettings();
252  if ($form->checkInput()) {
253  $this->getSettings()->setActive((bool) $form->getInput('active'));
254  $this->getSettings()->setServer($form->getInput('server'));
255  $this->getSettings()->setPort((int) $form->getInput('port'));
256  $this->getSettings()->setUri($form->getInput('uri'));
257  $this->getSettings()->setDefaultRole((int) $form->getInput('role'));
258  $this->getSettings()->enableLocalAuthentication((bool) $form->getInput('local'));
259  $this->getSettings()->setLoginInstruction($form->getInput('instruction'));
260  $this->getSettings()->enableUserCreation((int) $form->getInput('sync') === ilCASSettings::SYNC_CAS);
261  $this->getSettings()->save();
262 
263  switch ((int) $form->getInput('sync')) {
267  break;
268 
270  if (!(int) $form->getInput('ldap_sid')) {
271  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
272  $this->settings();
273  //TODO do we need return false?
274  return;
275  }
276 
277  ilLDAPServer::toggleDataSource((int) $form->getInput('ldap_sid'), ilAuthUtils::AUTH_CAS, 1);
278  break;
279  }
280 
281  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
282  $this->ctrl->redirect($this, 'settings');
283  }
284 
285  $form->setValuesByPost();
286  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_ceck_input'));
287  $this->tpl->setContent($form->getHTML());
288  }
static disableDataSourceForAuthMode(int $a_authmode)
Disable data source.
static toggleDataSource(int $a_ldap_server_id, int $a_auth_mode, int $a_status)
Toggle Data Source.
+ Here is the call graph for this function:

◆ settings()

ilCASSettingsGUI::settings ( )

Definition at line 239 of file class.ilCASSettingsGUI.php.

References initFormSettings().

Referenced by __construct(), and save().

239  : void
240  {
241  $form = $this->initFormSettings();
242  $this->tpl->setContent($form->getHTML());
243  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilCASSettingsGUI::$ctrl
private

Definition at line 35 of file class.ilCASSettingsGUI.php.

◆ $factory

ILIAS UI Factory ilCASSettingsGUI::$factory
private

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

◆ $ilErr

ilErrorHandling ilCASSettingsGUI::$ilErr
private

Definition at line 39 of file class.ilCASSettingsGUI.php.

◆ $lng

ilLanguage ilCASSettingsGUI::$lng
private

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

◆ $rbacReview

ilRbacReview ilCASSettingsGUI::$rbacReview
private

Definition at line 38 of file class.ilCASSettingsGUI.php.

◆ $rbacSystem

ilRbacSystem ilCASSettingsGUI::$rbacSystem
private

Definition at line 37 of file class.ilCASSettingsGUI.php.

◆ $ref_id

int ilCASSettingsGUI::$ref_id
private

Definition at line 32 of file class.ilCASSettingsGUI.php.

◆ $renderer

ILIAS UI Renderer ilCASSettingsGUI::$renderer
private

Definition at line 40 of file class.ilCASSettingsGUI.php.

◆ $settings

ilCASSettings ilCASSettingsGUI::$settings
private

Definition at line 30 of file class.ilCASSettingsGUI.php.

Referenced by getSettings().

◆ $tpl

ilGlobalTemplateInterface ilCASSettingsGUI::$tpl
private

Definition at line 34 of file class.ilCASSettingsGUI.php.

◆ SYNC_CAS

const ilCASSettingsGUI::SYNC_CAS = 1

Definition at line 27 of file class.ilCASSettingsGUI.php.

◆ SYNC_DISABLED

const ilCASSettingsGUI::SYNC_DISABLED = 0

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

◆ SYNC_LDAP

const ilCASSettingsGUI::SYNC_LDAP = 2

Definition at line 28 of file class.ilCASSettingsGUI.php.


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