• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Radius/classes/class.ilRadiusSettingsGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00033 class ilRadiusSettingsGUI
00034 {
00035         private $ref_id;
00036         
00044         public function __construct($a_auth_ref_id)
00045         {
00046                 global $lng,$ilCtrl,$tpl,$ilTabs;
00047                 
00048                 $this->ctrl = $ilCtrl;
00049                 $this->tabs_gui = $ilTabs;
00050                 $this->lng = $lng;
00051                 $this->lng->loadLanguageModule('registration');
00052                 $this->lng->loadLanguageModule('auth');
00053                 
00054                 $this->tpl = $tpl;
00055                 $this->ref_id = $a_auth_ref_id;
00056 
00057                 $this->initSettings();
00058         }
00059         
00067         public function executeCommand()
00068         {
00069                 global $ilAccess,$ilErr;
00070                 
00071                 if(!$ilAccess->checkAccess('write','',$this->ref_id))
00072                 {
00073                         $ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$ilErr->WARNING);
00074                 }
00075                 
00076                 $next_class = $this->ctrl->getNextClass($this);
00077                 $cmd = $this->ctrl->getCmd();
00078 
00079                 switch($next_class)
00080                 {
00081                         default:
00082                                 if(!$cmd)
00083                                 {
00084                                         $cmd = "settings";
00085                                 }
00086                                 $this->$cmd();
00087                                 break;
00088                 }
00089                 return true;
00090                 
00091         }
00092         
00100         public function settings()
00101         {
00102                 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
00103                 
00104                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.settings.html','Services/Radius');
00105                 
00106                 $form = new ilPropertyFormGUI();
00107                 $form->setFormAction($this->ctrl->getFormAction($this));
00108                 $form->setTitle($this->lng->txt('auth_radius_configure'));
00109                 
00110                 // Form checkbox
00111                 $check = new ilCheckboxInputGUI($this->lng->txt('auth_radius_enable'),'active');
00112                 $check->setChecked($this->settings->isActive() ? 1 : 0);
00113                 $check->setValue(1);
00114                 $form->addItem($check);
00115                 
00116                 $text = new ilTextInputGUI($this->lng->txt('auth_radius_name'),'name');
00117                 $text->setRequired(true);
00118                 $text->setInfo($this->lng->txt('auth_radius_name_desc'));
00119                 $text->setValue($this->settings->getName());
00120                 $text->setSize(32);
00121                 $text->setMaxLength(64);
00122                 $form->addItem($text);
00123                 
00124                 $text = new ilTextInputGUI($this->lng->txt('auth_radius_server'),'servers');
00125                 $text->setRequired(true);
00126                 $text->setInfo($this->lng->txt('auth_radius_server_desc'));
00127                 $text->setValue($this->settings->getServersAsString());
00128                 $text->setSize(64);
00129                 $text->setMaxLength(255);
00130                 $form->addItem($text);
00131                 
00132                         
00133                 $text = new ilTextInputGUI($this->lng->txt('auth_radius_port'),'port');
00134                 $text->setRequired(true);
00135                 $text->setValue($this->settings->getPort());
00136                 $text->setSize(5);
00137                 $text->setMaxLength(5);
00138                 $form->addItem($text);
00139 
00140                 $text = new ilTextInputGUI($this->lng->txt('auth_radius_shared_secret'),'secret');
00141                 $text->setRequired(true);
00142                 $text->setValue($this->settings->getSecret());
00143                 $text->setSize(16);
00144                 $text->setMaxLength(32);
00145                 $form->addItem($text);
00146                 
00147                 $encoding = new ilSelectInputGUI($this->lng->txt('auth_radius_charset'),'charset');
00148                 $encoding->setRequired(true);
00149                 $encoding->setOptions($this->prepareCharsetSelection());
00150                 $encoding->setValue($this->settings->getCharset());
00151                 $encoding->setInfo($this->lng->txt('auth_radius_charset_info'));
00152                 $form->addItem($encoding);
00153                 
00154                 
00155                 $check = new ilCheckboxInputGUI($this->lng->txt('auth_radius_sync'),'sync');
00156                 $check->setInfo($this->lng->txt('auth_radius_sync_info'));
00157                 $check->setChecked($this->settings->enabledCreation() ? 1 : 0);
00158                 $check->setValue(1);
00159                 
00160                 
00161                 $select = new ilSelectInputGUI($this->lng->txt('auth_radius_role_select'),'role');
00162                 $select->setOptions($this->prepareRoleSelection());
00163                 $select->setValue($this->settings->getDefaultRole());
00164                 $check->addSubItem($select);
00165 
00166                 $migr = new ilCheckboxInputGUI($this->lng->txt('auth_rad_migration'),'migration');
00167                 $migr->setInfo($this->lng->txt('auth_rad_migration_info'));
00168                 $migr->setChecked($this->settings->isAccountMigrationEnabled() ? 1 : 0);
00169                 $migr->setValue(1);
00170                 $check->addSubItem($migr);
00171                 $form->addItem($check);
00172                 
00173                 
00174 
00175                 $form->addCommandButton('save',$this->lng->txt('save'));
00176                 $form->addCommandButton('cancel',$this->lng->txt('cancel'));
00177                 $this->tpl->setVariable('SETTINGS_TABLE',$form->getHTML());
00178         }
00179         
00186         public function save()
00187         {
00188                 $this->settings->setActive((int) $_POST['active']);
00189                 $this->settings->setName(ilUtil::stripSlashes($_POST['name']));
00190                 $this->settings->setPort(ilUtil::stripSlashes($_POST['port']));
00191                 $this->settings->setSecret(ilUtil::stripSlashes($_POST['secret']));
00192                 $this->settings->setServerString(ilUtil::stripSlashes($_POST['servers']));
00193                 $this->settings->setDefaultRole((int) $_POST['role']);
00194                 $this->settings->enableCreation((int) $_POST['sync']);
00195                 $this->settings->enableAccountMigration((int) $_POST['migration']);
00196                 $this->settings->setCharset((int) $_POST['charset']);
00197                 
00198                 if(!$this->settings->validateRequired())
00199                 {
00200                         ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields"));
00201                         $this->settings();
00202                         return false;
00203                 }
00204                 if(!$this->settings->validatePort())
00205                 {
00206                         ilUtil::sendInfo($this->lng->txt("err_invalid_port"));
00207                         $this->settings();
00208                         return false;
00209                 }
00210                 if(!$this->settings->validateServers())
00211                 {
00212                         ilUtil::sendInfo($this->lng->txt("err_invalid_server"));
00213                         $this->settings();
00214                         return false;
00215                 }
00216                 $this->settings->save();
00217                 ilUtil::sendInfo($this->lng->txt('settings_saved'));
00218                 $this->settings();
00219                 return true;
00220         }
00221         
00222         
00229         private function initSettings()
00230         {
00231                 include_once('Services/Radius/classes/class.ilRadiusSettings.php');
00232                 $this->settings = ilRadiusSettings::_getInstance();
00233                 
00234                 
00235         }
00236         
00237         private function prepareRoleSelection()
00238         {
00239                 global $rbacreview,$ilObjDataCache;
00240                 
00241                 $global_roles = ilUtil::_sortIds($rbacreview->getGlobalRoles(),
00242                         'object_data',
00243                         'title',
00244                         'obj_id');
00245                 
00246                 $select[0] = $this->lng->txt('links_select_one');
00247                 foreach($global_roles as $role_id)
00248                 {
00249                         $select[$role_id] = ilObject::_lookupTitle($role_id);
00250                 }
00251                 
00252                 return $select;
00253         }
00254         
00261         private function prepareCharsetSelection()
00262         {
00263                 return $select = array(ilRadiusSettings::RADIUS_CHARSET_UTF8 => 'UTF-8',
00264                                 ilRadiusSettings::RADIUS_CHARSET_LATIN1 => 'ISO-8859-1');
00265         }
00266         
00267 }
00268 ?>

Generated on Fri Dec 13 2013 17:57:00 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1