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

Services/PrivacySecurity/classes/class.ilObjPrivacySecurityGUI.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 include_once("./classes/class.ilObjectGUI.php");
00024 include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
00025 include_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
00026 
00038 class ilObjPrivacySecurityGUI extends ilObjectGUI
00039 {
00040     private static $ERROR_MESSAGE;
00046         public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00047         {
00048                 $this->type = 'ps';
00049                 parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
00050 
00051                 $this->lng->loadLanguageModule('ps');
00052 
00053                 ilObjPrivacySecurityGUI::$ERROR_MESSAGE = array (
00054                    ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_AUTO_HTTPS => $this->lng->txt("ps_error_message_https_header_missing"),
00055                    ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_HTTPS_NOT_AVAILABLE => $this->lng->txt('https_not_possible'),
00056                ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_HTTP_NOT_AVAILABLE => $this->lng->txt('http_not_possible')
00057                 );
00058         }
00059 
00066         public function executeCommand()
00067         {
00068                 global $rbacsystem,$ilErr,$ilAccess;
00069 
00070                 $next_class = $this->ctrl->getNextClass($this);
00071                 $cmd = $this->ctrl->getCmd();
00072 
00073                 $this->prepareOutput();
00074 
00075                 if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
00076                 {
00077                         $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
00078                 }
00079 
00080                 switch($next_class)
00081                 {
00082                         case 'ilpermissiongui':
00083                                 $this->tabs_gui->setTabActive('perm_settings');
00084                                 include_once("./classes/class.ilPermissionGUI.php");
00085                                 $perm_gui =& new ilPermissionGUI($this);
00086                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00087                                 break;
00088 
00089                         default:
00090                                 if(!$cmd || $cmd == 'view')
00091                                 {
00092                                         $cmd = "showPrivacy";
00093                                 }
00094 
00095                                 $this->$cmd();
00096                                 break;
00097                 }
00098                 return true;
00099         }
00100 
00107         public function getAdminTabs()
00108         {
00109                 global $rbacsystem;
00110 
00111                 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00112                 {
00113                         $this->tabs_gui->addTarget("show_privacy",
00114                                 $this->ctrl->getLinkTarget($this, "showPrivacy"),
00115                                 'showPrivacy');
00116             $this->tabs_gui->addTarget("show_security",
00117                                 $this->ctrl->getLinkTarget($this, "showSecurity"),
00118                                 'showSecurity');
00119 
00120                 }
00121 
00122                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00123                 {
00124                         $this->tabs_gui->addTarget("perm_settings",
00125                                 $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
00126                                 array(),'ilpermissiongui');
00127                 }
00128         }
00129 
00135         public function showPrivacy()
00136         {
00137                 $privacy = ilPrivacySettings::_getInstance();
00138 
00139                 $this->tabs_gui->setTabActive('show_privacy');
00140                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.show_privacy.html','Services/PrivacySecurity');
00141 
00142                 include_once('Modules/Course/classes/class.ilCourseAgreement.php');
00143                 if(ilCourseAgreement::_hasAgreements())
00144                 {
00145                         $this->tpl->setCurrentBlock('warning_modify');
00146                         $this->tpl->setVariable('TXT_WARNING',$this->lng->txt('ps_warning_modify'));
00147                         $this->tpl->parseCurrentBlock();
00148                 }
00149 
00150                 $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
00151                 $this->tpl->setVariable('TXT_PRIVACY_PROTECTION',$this->lng->txt('ps_privacy_protection'));
00152                 $this->tpl->setVariable('TXT_PROFILE_EXPORT',$this->lng->txt('ps_profile_export'));
00153                 $this->tpl->setVariable('TXT_EXPORT_COURSE',$this->lng->txt('ps_export_course'));
00154                 $this->tpl->setVariable('TXT_EXPORT_CONFIRM',$this->lng->txt('ps_export_confirm'));
00155                 $this->tpl->setVariable('TXT_GRP_ACCESS',$this->lng->txt('ps_show_grp_access'));
00156 
00157                 // Check export
00158                 $this->tpl->setVariable('CHECK_EXPORT_COURSE',ilUtil::formCheckbox($privacy->enabledExport() ? 1 : 0,'export_course',1));
00159                 $this->tpl->setVariable('CHECK_EXPORT_CONFIRM',ilUtil::formCheckbox($privacy->confirmationRequired() ? 1 : 0,'export_confirm',1));
00160                 $this->tpl->setVariable('CHECK_GRP_ACCESS',ilUtil::formCheckbox($privacy->enabledAccessTimes() ? 1 : 0,'access_times',1));
00161 
00162                 // Fora statistics
00163                 $this->tpl->setVariable('TXT_STATISTICS',$this->lng->txt('enable_fora_statistics'));
00164                 $this->tpl->setVariable('TXT_FORA_STATISTICS',$this->lng->txt('enable_fora_statistics_desc'));
00165                 $this->tpl->setVariable('CHECK_FORA_STATISTICS',ilUtil::formCheckbox($privacy->enabledForaStatistics() ? 1 : 0,'fora_statistics',1));
00166                 
00167 
00168                 $this->tpl->setVariable('TXT_SAVE',$this->lng->txt('save'));
00169         }
00170 
00171 
00177         public function showSecurity()
00178         {
00179                 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
00180                 
00181                 $privacy = ilSecuritySettings::_getInstance();
00182                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.show_security.html','Services/PrivacySecurity');
00183 
00184                 $this->tabs_gui->setTabActive('show_security');
00185 
00186                 $form = new ilPropertyFormGUI();
00187                 $form->setFormAction($this->ctrl->getFormAction($this));
00188                 $form->setTitle($this->lng->txt('ps_security_protection'));
00189                 
00190                 // Form checkbox
00191                 $check = new ilCheckboxInputGUI($this->lng->txt('ps_auto_https'),'auto_https_detect_enabled');
00192                 $check->setOptionTitle($this->lng->txt('ps_auto_https_description'));
00193                 $check->setChecked($privacy->isAutomaticHTTPSEnabled() ? 1 : 0);
00194                 $check->setValue(1);
00195                 
00196                         $text = new ilTextInputGUI($this->lng->txt('ps_auto_https_header_name'),'auto_https_detect_header_name');
00197                         $text->setValue($privacy->getAutomaticHTTPSHeaderName());
00198                         $text->setSize(24);
00199                         $text->setMaxLength(64);
00200                 $check->addSubItem($text);
00201                         
00202                         $text = new ilTextInputGUI($this->lng->txt('ps_auto_https_header_value'),'auto_https_detect_header_value');
00203                         $text->setValue($privacy->getAutomaticHTTPSHeaderValue());
00204                         $text->setSize(24);
00205                         $text->setMaxLength(64);
00206                 
00207                 $check->addSubItem($text);
00208                 $form->addItem($check);
00209 
00210                 $check2 = new ilCheckboxInputGUI($this->lng->txt('activate_https'),'https_enabled');
00211                 $check2->setChecked($privacy->isHTTPSEnabled() ? 1 : 0);
00212                 $check2->setValue(1);
00213                 $form->addItem($check2);
00214 
00215                 $form->addCommandButton('save_security',$this->lng->txt('save'));
00216                 $this->tpl->setVariable('NEW_FORM',$form->getHTML());
00217         }
00218 
00225         public function save_privacy()
00226         {
00227                 global $ilErr,$ilAccess;
00228 
00229                 if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
00230                 {
00231                         $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
00232                 }
00233 
00234 
00235                 $privacy = ilPrivacySettings::_getInstance();
00236                 $privacy->enableExport((int) $_POST['export_course']);
00237                 $privacy->setConfirmationRequired((int) $_POST['export_confirm']);
00238                 $privacy->enableForaStatistics ((int) $_POST['fora_statistics']);
00239                 $privacy->showAccessTimes((int) $_POST['access_times']);
00240 
00241         // validate settings
00242         $code = $privacy->validate();
00243 
00244         // if error code != 0, display error and do not save
00245         if ($code != 0)
00246         {
00247             $msg = $this->getErrorMessage ($code);
00248             ilUtil::sendInfo($msg);
00249         } 
00250         else
00251         {
00252             $privacy->save();
00253                     include_once('Modules/Course/classes/class.ilCourseAgreement.php');
00254                     ilCourseAgreement::_reset();
00255                     ilUtil::sendInfo($this->lng->txt('settings_saved'));
00256         }
00257 
00258                 $this->showPrivacy();
00259         }
00260 
00267         public function save_security()
00268         {
00269                 global $ilErr,$ilAccess;
00270 
00271                 if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
00272                 {
00273                         $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
00274                 }
00275 
00276 
00280                 $security = ilSecuritySettings::_getInstance();
00281 
00282                 // auto https detection settings
00283         $security->setAutomaticHTTPSEnabled((int) $_POST["auto_https_detect_enabled"]);
00284         $security->setAutomaticHTTPSHeaderName($_POST["auto_https_detect_header_name"]);
00285         $security->setAutomaticHTTPSHeaderValue($_POST["auto_https_detect_header_value"]);
00286 
00287         $security->setHTTPSEnabled($_POST["https_enabled"]);
00288         // validate settings
00289         $code = $security->validate();
00290 
00291         // if error code != 0, display error and do not save
00292         if ($code != 0)
00293         {
00294             $msg = $this->getErrorMessage ($code);
00295             ilUtil::sendInfo($msg);
00296         } else
00297         {
00298             $security->save();
00299                     ilUtil::sendInfo($this->lng->txt('settings_saved'));
00300         }
00301 
00302 
00303                 $this->showSecurity();
00304         }
00305 
00306 
00314         private static function getErrorMessage ($code) {
00315         return ilObjPrivacySecurityGUI::$ERROR_MESSAGE[$code];
00316         }
00317 }
00318 ?>

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