ILIAS  release_8 Revision v8.24
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
 

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 41 of file class.ilCASSettingsGUI.php.

42 {
43 global $DIC;
44 $this->tpl = $DIC->ui()->mainTemplate();
45
46 $this->ctrl = $DIC->ctrl();
47 $this->rbacSystem = $DIC->rbac()->system();
48 $this->rbacReview = $DIC->rbac()->review();
49 $this->ilErr = $DIC['ilErr'];
50 $this->lng = $DIC->language();
51 $this->lng->loadLanguageModule('registration');
52 $this->lng->loadLanguageModule('auth');
53
54 $this->renderer = $DIC->ui()->renderer();
55 $this->factory = $DIC->ui()->factory();
56
57 $this->ref_id = $a_auth_ref_id;
58
60 }
static getInstance()
Get singleton instance.
global $DIC
Definition: feed.php:28

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

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilCASSettingsGUI::executeCommand ( )

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

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

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

+ Here is the call graph for this function:

◆ getSettings()

ilCASSettingsGUI::getSettings ( )
protected

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

References $settings.

Referenced by initFormSettings(), and save().

+ Here is the caller graph for this function:

◆ initFormSettings()

ilCASSettingsGUI::initFormSettings ( )
protected

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

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

References $check, ilAuthUtils\AUTH_CAS, ILIAS\Repository\ctrl(), ilLDAPServer\getAvailableDataSources(), ilLDAPServer\getDataSource(), getSettings(), ilLDAPServer\isDataSourceActive(), ILIAS\Repository\lng(), prepareRoleSelection(), ilCASSettings\SYNC_CAS, ilCASSettings\SYNC_DISABLED, and ilCASSettings\SYNC_LDAP.

Referenced by save(), and settings().

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

◆ prepareRoleSelection()

ilCASSettingsGUI::prepareRoleSelection ( )
private

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

270 : array
271 {
272 $global_roles = ilUtil::_sortIds(
273 $this->rbacReview->getGlobalRoles(),
274 'object_data',
275 'title',
276 'obj_id'
277 );
278
279 $select[0] = $this->lng->txt('links_select_one');
280 foreach ($global_roles as $role_id) {
281 $select[$role_id] = ilObject::_lookupTitle((int) $role_id);
282 }
283
284 return $select;
285 }
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,...

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

Referenced by initFormSettings().

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

◆ save()

ilCASSettingsGUI::save ( )

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

229 : void
230 {
231 $form = $this->initFormSettings();
232 if ($form->checkInput()) {
233 $this->getSettings()->setActive((bool) $form->getInput('active'));
234 $this->getSettings()->setServer($form->getInput('server'));
235 $this->getSettings()->setPort((int) $form->getInput('port'));
236 $this->getSettings()->setUri($form->getInput('uri'));
237 $this->getSettings()->setDefaultRole((int) $form->getInput('role'));
238 $this->getSettings()->enableLocalAuthentication((bool) $form->getInput('local'));
239 $this->getSettings()->setLoginInstruction($form->getInput('instruction'));
240 $this->getSettings()->enableUserCreation((int) $form->getInput('sync') === ilCASSettings::SYNC_CAS);
241 $this->getSettings()->save();
242
243 switch ((int) $form->getInput('sync')) {
247 break;
248
250 if (!(int) $form->getInput('ldap_sid')) {
251 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
252 $this->settings();
253 //TODO do we need return false?
254 return;
255 }
256
257 ilLDAPServer::toggleDataSource((int) $form->getInput('ldap_sid'), ilAuthUtils::AUTH_CAS, 1);
258 break;
259 }
260
261 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
262 $this->ctrl->redirect($this, 'settings');
263 }
264
265 $form->setValuesByPost();
266 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_ceck_input'));
267 $this->tpl->setContent($form->getHTML());
268 }
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.

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().

+ Here is the call graph for this function:

◆ settings()

ilCASSettingsGUI::settings ( )

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

223 : void
224 {
225 $form = $this->initFormSettings();
226 $this->tpl->setContent($form->getHTML());
227 }

References initFormSettings().

Referenced by __construct(), and save().

+ 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.

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

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