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

Services/WebServices/ECS/classes/class.ilECSSettingsGUI.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 ilECSSettingsGUI
00034 {
00035         protected $tpl;
00036         protected $lng;
00037         protected $ctrl;
00038         
00039 
00045         public function __construct()
00046         {
00047                 global $lng,$tpl,$ilCtrl;
00048                 
00049                 $this->tpl = $tpl;
00050                 $this->lng = $lng;
00051                 $this->ctrl = $ilCtrl;
00052                 
00053                 $this->initSettings();
00054         }
00055         
00063         public function executeCommand()
00064         {
00065                 $next_class = $this->ctrl->getNextClass($this);
00066                 $cmd = $this->ctrl->getCmd();
00067 
00068                 switch($next_class)
00069                 {
00070                         default:
00071                                 if(!$cmd)
00072                                 {
00073                                         $cmd = "settings";
00074                                 }
00075                                 $this->$cmd();
00076                                 break;
00077                 }
00078                 return true;
00079         }
00080         
00086         protected function settings()
00087         {
00088                 $this->initSettingsForm();
00089                 
00090                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.ecs_settings.html','Services/WebServices/ECS');
00091                 $this->tpl->setVariable('SETTINGS_TABLE',$this->form->getHTML());
00092                 
00093                 include_once('Services/WebServices/ECS/classes/class.ilECSConnector.php');
00094                 include_once('Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
00095                 
00096                 try
00097                 {
00098                         $connector = new ilECSConnector();
00099                         $res = $connector->getResources();
00100                         #var_dump("<pre>",$res->getResult(),"</pre>");
00101                         
00102                         #$connector = new ilECSConnector();
00103                         #$res = $connector->addResource(json_encode($res->getResult()));
00104                         #var_dump("<pre>",$res->getResult(),"</pre>");
00105                         
00106                         #$connector = new ilECSConnector();
00107                         #$res = $connector->deleteResource(4);
00108                         #var_dump("<pre>",$res->getResult(),"</pre>");
00109                         
00110                         $json_arr = $res->getResult();
00111                         $json_arr[0]->lecturer[] = 'Stefan Meyer';
00112                         $json_arr[0]->credits = 99;
00113                         
00114                         $connector = new ilECSConnector();
00115                         $res = $connector->updateResource($json_arr[0]->eid,json_encode($json_arr[0]));
00116                         
00117                         var_dump("<pre>",$res->getResult(),$res->getPlainResultString(),"</pre>");
00118                         
00119                 }
00120                 catch(ilECSConnectorException $exc)
00121                 {
00122                         var_dump("<pre>",$exc->getMessage(),"</pre>");
00123                 }               
00124                 
00125         }
00126         
00132         protected function initSettingsForm()
00133         {
00134                 if(is_object($this->form))
00135                 {
00136                         return true;
00137                 }
00138                 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
00139                 
00140                 $this->form = new ilPropertyFormGUI();
00141                 $this->form->setFormAction($this->ctrl->getFormAction($this,'settings'));
00142                 $this->form->setTitle($this->lng->txt('ecs_settings'));
00143                 
00144                 $ena = new ilCheckboxInputGUI($this->lng->txt('ecs_active'),'active');
00145                 $ena->setChecked($this->settings->isEnabled());
00146                 $ena->setValue(1);
00147                 $this->form->addItem($ena);
00148                 
00149                 $ser = new ilTextInputGUI($this->lng->txt('ecs_server'),'server');
00150                 $ser->setValue($this->settings->getServer());
00151                 $ser->setRequired(true);
00152                 $this->form->addItem($ser);
00153                 
00154                 $pro = new ilSelectInputGUI($this->lng->txt('ecs_protocol'),'protocol');
00155                 // fixed to https
00156                 #$pro->setOptions(array(ilECSSettings::PROTOCOL_HTTP => $this->lng->txt('http'),
00157                 #               ilECSSettings::PROTOCOL_HTTPS => $this->lng->txt('https')));
00158                 $pro->setOptions(array(ilECSSettings::PROTOCOL_HTTPS => 'HTTPS'));
00159                 $pro->setValue($this->settings->getProtocol());
00160                 $pro->setRequired(true);
00161                 $this->form->addItem($pro);
00162                 
00163                 $por = new ilTextInputGUI($this->lng->txt('ecs_port'),'port');
00164                 $por->setSize(5);
00165                 $por->setMaxLength(5);
00166                 $por->setValue($this->settings->getPort());
00167                 $por->setRequired(true);
00168                 $this->form->addItem($por);
00169                 
00170                 $cer = new ilTextInputGUI($this->lng->txt('ecs_client_cert'),'client_cert');
00171                 $cer->setValue($this->settings->getClientCertPath());
00172                 $cer->setRequired(true);
00173                 $this->form->addItem($cer);
00174                 
00175                 $cer = new ilTextInputGUI($this->lng->txt('ecs_ca_cert'),'ca_cert');
00176                 $cer->setValue($this->settings->getCACertPath());
00177                 $cer->setRequired(true);
00178                 $this->form->addItem($cer);
00179 
00180                 $cer = new ilTextInputGUI($this->lng->txt('ecs_cert_key'),'key_path');
00181                 $cer->setValue($this->settings->getKeyPath());
00182                 $cer->setRequired(true);
00183                 $this->form->addItem($cer);
00184                 
00185                 $cer = new ilTextInputGUI($this->lng->txt('ecs_key_password'),'key_password');
00186                 $cer->setValue($this->settings->getKeyPassword());
00187                 $cer->setInputType('password');
00188                 $cer->setRequired(true);
00189                 $this->form->addItem($cer);
00190 
00191                 $loc = new ilFormSectionHeaderGUI();
00192                 $loc->setTitle($this->lng->txt('ecs_local_settings'));
00193                 $this->form->addItem($loc);
00194                 
00195                 $pol = new ilDurationInputGUI($this->lng->txt('ecs_polling'),'polling');
00196                 $pol->setShowDays(false);
00197                 $pol->setShowHours(false);
00198                 $pol->setShowMinutes(true);
00199                 $pol->setShowSeconds(true);
00200                 $pol->setSeconds($this->settings->getPollingTimeSeconds());
00201                 $pol->setMinutes($this->settings->getPollingTimeMinutes());
00202                 $pol->setRequired(true);
00203                 $this->form->addItem($pol);
00204                 
00205                 $imp = new ilTextInputGUI($this->lng->txt('import_id'),'import_id');
00206                 $imp->setSize(5);
00207                 $imp->setMaxLength(6);
00208                 $imp->setValue($this->settings->getImportId() ? $this->settings->getImportId() : '');
00209                 $this->form->addItem($imp);
00210                 
00211                 $this->form->addCommandButton('saveSettings',$this->lng->txt('save'));
00212                 $this->form->addCommandButton('settings',$this->lng->txt('cancel'));
00213         }
00214         
00220         protected function saveSettings()
00221         {
00222                 $this->settings->setEnabledStatus((int) $_POST['active']);
00223                 $this->settings->setServer(ilUtil::stripSlashes($_POST['server']));
00224                 $this->settings->setPort(ilUtil::stripSlashes($_POST['port']));
00225                 $this->settings->setProtocol(ilUtil::stripSlashes($_POST['protocol']));
00226                 $this->settings->setClientCertPath(ilUtil::stripSlashes($_POST['client_cert']));
00227                 $this->settings->setCACertPath(ilUtil::stripSlashes($_POST['ca_cert']));
00228                 $this->settings->setKeyPath(ilUtil::stripSlashes($_POST['key_path']));
00229                 $this->settings->setKeyPassword(ilUtil::stripSlashes($_POST['key_password']));
00230                 $this->settings->setImportId(ilUtil::stripSlashes($_POST['import_id']));
00231                 $this->settings->setPollingTimeMS((int) $_POST['polling']['mm'],(int) $_POST['polling']['ss']);
00232                 $this->settings->setServer(ilUtil::stripSlashes($_POST['server']));
00233                 
00234                 if($this->settings->validate())
00235                 {
00236                         $this->settings->save();
00237                         ilUtil::sendInfo($this->lng->txt('settings_saved'));
00238                 }
00239                 else
00240                 {
00241                         ilUtil::sendInfo($this->lng->txt('fill_out_all_required_fields'));
00242                 }
00243                 $this->settings();
00244                 return true;
00245         }
00246 
00247 
00253         protected function initSettings()
00254         {       
00255                 include_once('Services/WebServices/ECS/classes/class.ilECSSettings.php');
00256                 $this->settings = ilECSSettings::_getInstance();
00257         }
00258 }
00259 
00260 ?>

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