ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilCASSettingsGUI Class Reference
+ Collaboration diagram for ilCASSettingsGUI:

Public Member Functions

 __construct ($a_auth_ref_id)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 settings ()
 Show settings. More...
 
 save ()
 Save. More...
 

Data Fields

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

Protected Member Functions

 getSettings ()
 
 initFormSettings ()
 Init cas settings. More...
 

Private Member Functions

 prepareRoleSelection ()
 

Private Attributes

 $settings
 
 $ref_id
 

Detailed Description

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

ilCASSettingsGUI:

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

Constructor & Destructor Documentation

◆ __construct()

ilCASSettingsGUI::__construct (   $a_auth_ref_id)

Constructor.

public

Parameters
intobject auth ref_id

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

References $ilCtrl, $lng, $tpl, ilCASSettings\getInstance(), and settings().

33  {
34  global $lng,$ilCtrl,$tpl,$ilTabs;
35 
36  $this->ctrl = $ilCtrl;
37  $this->tabs_gui = $ilTabs;
38  $this->lng = $lng;
39  $this->lng->loadLanguageModule('registration');
40  $this->lng->loadLanguageModule('auth');
41 
42  $this->tpl = $tpl;
43  $this->ref_id = $a_auth_ref_id;
44 
46  }
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
settings()
Show settings.
global $lng
Definition: privfeed.php:17
static getInstance()
Get singleton instance.
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilCASSettingsGUI::executeCommand ( )

Execute command.

public

Parameters

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

References $cmd, $ilCtrl, $ilErr, and ilUtil\sendFailure().

65  {
66  global $ilAccess,$ilErr,$ilCtrl;
67 
68  $next_class = $this->ctrl->getNextClass($this);
69  $cmd = $this->ctrl->getCmd("settings");
70 
71  if(!$ilAccess->checkAccess('read','',$this->ref_id))
72  {
73  $ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$ilErr->WARNING);
74  }
75 
76  if(!$ilAccess->checkAccess('write','',$this->ref_id) && $cmd != "settings")
77  {
78  ilUtil::sendFailure($this->lng->txt('msg_no_perm_write'), true);
79  $ilCtrl->redirect($this, "settings");
80  }
81 
82 
83  switch($next_class)
84  {
85  default:
86  if(!$cmd)
87  {
88  $cmd = "settings";
89  }
90  $this->$cmd();
91  break;
92  }
93  return true;
94 
95  }
global $ilErr
Definition: raiseError.php:16
$cmd
Definition: sahs_server.php:35
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ getSettings()

ilCASSettingsGUI::getSettings ( )
protected
Returns
ilCASSettings

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

References $settings.

Referenced by initFormSettings(), and save().

53  {
54  return $this->settings;
55  }
+ Here is the caller graph for this function:

◆ initFormSettings()

ilCASSettingsGUI::initFormSettings ( )
protected

Init cas settings.

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

References $options, $text, AUTH_CAS, ilLDAPServer\getAvailableDataSources(), ilLDAPServer\getDataSource(), getSettings(), ilLDAPServer\isDataSourceActive(), prepareRoleSelection(), ilCheckboxInputGUI\setChecked(), ilTextAreaInputGUI\setCols(), ilRadioOption\setInfo(), ilFormPropertyGUI\setInfo(), ilSelectInputGUI\setOptions(), ilFormPropertyGUI\setRequired(), ilNumberInputGUI\setValue(), ilCASSettings\SYNC_CAS, ilCASSettings\SYNC_DISABLED, and ilCASSettings\SYNC_LDAP.

Referenced by save(), and settings().

102  {
103  $this->lng->loadLanguageModule('auth');
104  $this->lng->loadLanguageModule('radius');
105 
106  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
107  $form = new ilPropertyFormGUI();
108  $form->setFormAction($this->ctrl->getFormAction($this));
109 
110  $form->setTitle($this->lng->txt('auth_cas_auth'));
111  $form->setDescription($this->lng->txt("auth_cas_auth_desc"));
112 
113  // Form checkbox
114  $check = new ilCheckboxInputGUI($this->lng->txt("active"),'active');
115  $check->setChecked($this->getSettings()->isActive() ? true : false);
116  $check->setValue(1);
117  $form->addItem($check);
118 
119  $text = new ilTextInputGUI($this->lng->txt('server'),'server');
120  $text->setValue($this->getSettings()->getServer());
121  $text->setRequired(true);
122  $text->setInfo($this->lng->txt('auth_cas_server_desc'));
123  $text->setSize(64);
124  $text->setMaxLength(255);
125  $form->addItem($text);
126 
127  $port = new ilNumberInputGUI($this->lng->txt("port"), 'port');
128  $port->setValue($this->getSettings()->getPort());
129  $port->setRequired(true);
130  $port->setMinValue(0);
131  $port->setMaxValue(65535);
132  $port->setSize(5);
133  $port->setMaxLength(5);
134  $port->setInfo($this->lng->txt('auth_cas_port_desc'));
135  $form->addItem($port);
136 
137  $text = new ilTextInputGUI($this->lng->txt('uri'), 'uri');
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->setRequired(true);
151  #$sync->setInfo($this->lng->txt('auth_radius_sync_info'));
152  $form->addItem($sync);
153 
154  // Disabled
155  $dis = new ilRadioOption(
156  $this->lng->txt('disabled'),
157  self::SYNC_DISABLED,
158  ''
159  );
160  #$dis->setInfo($this->lng->txt('auth_radius_sync_disabled_info'));
161  $sync->addOption($dis);
162 
163  // CAS
164  $rad = new ilRadioOption(
165  $this->lng->txt('auth_sync_cas'),
166  self::SYNC_CAS,
167  ''
168  );
169  $rad->setInfo($this->lng->txt('auth_sync_cas_info'));
170  $sync->addOption($rad);
171 
172  $select = new ilSelectInputGUI($this->lng->txt('auth_user_default_role'),'role');
173  $select->setOptions($this->prepareRoleSelection());
174  $select->setValue($this->getSettings()->getDefaultRole());
175  $rad->addSubItem($select);
176 
177 
178 
179  // LDAP
180  include_once './Services/LDAP/classes/class.ilLDAPServer.php';
182 
183  if(count($server_ids))
184  {
185  $ldap = new ilRadioOption(
186  $this->lng->txt('auth_radius_ldap'),
188  ''
189  );
190  $ldap->setInfo($this->lng->txt('auth_radius_ldap_info'));
191  $sync->addOption($ldap);
192 
193  $ldap_server_select = new ilSelectInputGUI($this->lng->txt('auth_ldap_server_ds'), 'ldap_sid');
194  $options[0] = $this->lng->txt('select_one');
195  foreach($server_ids as $ldap_sid)
196  {
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  {
210  $sync->setValue(ilCASSettings::SYNC_LDAP);
211  }
212  else
213  {
214  $sync->setValue(
215  $this->getSettings()->isUserCreationEnabled() ?
218  );
219  }
220 
221  $instruction = new ilTextAreaInputGUI($this->lng->txt('auth_login_instructions'), 'instruction');
222  $instruction->setCols(80);
223  $instruction->setRows(6);
224  $instruction->setValue($this->getSettings()->getLoginInstruction());
225  $form->addItem($instruction);
226 
227  $create = new ilCheckboxInputGUI($this->lng->txt('auth_allow_local'), 'local');
228  $create->setInfo($this->lng->txt('auth_cas_allow_local_desc'));
229  $create->setChecked($this->getSettings()->isLocalAuthenticationEnabled() ? true : false);
230  $create->setValue(1);
231  $form->addItem($create);
232 
233  $form->addCommandButton('save',$this->lng->txt('save'));
234 
235  return $form;
236  }
This class represents an option in a radio group.
setValue($a_value)
Set Value.
This class represents a selection list property in a property form.
This class represents a property form user interface.
const AUTH_CAS
static getAvailableDataSources($a_auth_mode)
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Info.
setInfo($a_info)
Set Information Text.
setChecked($a_checked)
Set Checked.
This class represents a property in a property form.
static isDataSourceActive($a_auth_mode)
Check if a data source is active for a specific auth mode ilDB $ilDB.
if(!is_array($argv)) $options
This class represents a number property in a property form.
This class represents a text property in a property form.
static getDataSource($a_auth_mode)
setOptions($a_options)
Set Options.
This class represents a text area property in a property form.
$text
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareRoleSelection()

ilCASSettingsGUI::prepareRoleSelection ( )
private

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

References ilObject\_lookupTitle(), and ilUtil\_sortIds().

Referenced by initFormSettings().

308  {
309  global $rbacreview,$ilObjDataCache;
310 
311  $global_roles = ilUtil::_sortIds($rbacreview->getGlobalRoles(),
312  'object_data',
313  'title',
314  'obj_id');
315 
316  $select[0] = $this->lng->txt('links_select_one');
317  foreach($global_roles as $role_id)
318  {
319  $select[$role_id] = ilObject::_lookupTitle($role_id);
320  }
321 
322  return $select;
323  }
static _lookupTitle($a_id)
lookup object title
static _sortIds($a_ids, $a_table, $a_field, $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 ( )

Save.

public

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

References AUTH_CAS, ilLDAPServer\disableDataSourceForAuthMode(), getSettings(), initFormSettings(), ilUtil\sendFailure(), ilUtil\sendSuccess(), settings(), ilCASSettings\SYNC_CAS, ilCASSettings\SYNC_DISABLED, ilCASSettings\SYNC_LDAP, and ilLDAPServer\toggleDataSource().

259  {
260  $form = $this->initFormSettings();
261  if($form->checkInput())
262  {
263  $this->getSettings()->setActive($form->getInput('active'));
264  $this->getSettings()->setServer($form->getInput('server'));
265  $this->getSettings()->setPort($form->getInput('port'));
266  $this->getSettings()->setUri($form->getInput('uri'));
267  $this->getSettings()->setDefaultRole($form->getInput('role'));
268  $this->getSettings()->enableLocalAuthentication($form->getInput('local'));
269  $this->getSettings()->setLoginInstruction($form->getInput('instruction'));
270  $this->getSettings()->enableUserCreation($form->getInput('sync') == ilCASSettings::SYNC_CAS ? true : false);
271  $this->getSettings()->save();
272 
273  include_once './Services/LDAP/classes/class.ilLDAPServer.php';
274  switch((int) $form->getInput('sync'))
275  {
278  break;
279 
282  break;
283 
285  if(!(int) $_REQUEST['ldap_sid'])
286  {
287  ilUtil::sendFailure($this->lng->txt('err_check_input'));
288  $this->settings();
289  return false;
290  }
291 
292  ilLDAPServer::toggleDataSource((int) $_REQUEST['ldap_sid'], AUTH_CAS,true);
293  break;
294  }
295 
296  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
297  $this->ctrl->redirect($this,'settings');
298  }
299 
300  $form->setValuesByPost();
301  ilUtil::sendFailure($this->lng->txt('err_ceck_input'));
302  $this->tpl->setContent($form->getHTML());
303  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
const AUTH_CAS
static disableDataSourceForAuthMode($a_authmode)
Disable data source.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
settings()
Show settings.
initFormSettings()
Init cas settings.
static toggleDataSource($a_ldap_server_id, $a_auth_mode, $a_status)
Toggle Data Source.
+ Here is the call graph for this function:

◆ settings()

ilCASSettingsGUI::settings ( )

Show settings.

public

Parameters

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

References initFormSettings().

Referenced by __construct(), and save().

246  {
247  $form = $this->initFormSettings();
248  $this->tpl->setContent($form->getHTML());
249  return;
250  }
initFormSettings()
Init cas settings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ref_id

ilCASSettingsGUI::$ref_id
private

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

◆ $settings

ilCASSettingsGUI::$settings
private

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

Referenced by getSettings().

◆ SYNC_CAS

const ilCASSettingsGUI::SYNC_CAS = 1

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

◆ SYNC_DISABLED

const ilCASSettingsGUI::SYNC_DISABLED = 0

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

◆ SYNC_LDAP

const ilCASSettingsGUI::SYNC_LDAP = 2

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


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