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

classes/class.ilObjExternalToolsSettingsGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 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 
00034 require_once "class.ilObjectGUI.php";
00035 
00036 class ilObjExternalToolsSettingsGUI extends ilObjectGUI
00037 {
00042         function ilObjExternalToolsSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
00043         {
00044                 $this->type = "extt";
00045                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
00046                 
00047                 define ("ILINC_DEFAULT_HTTP_PORT",80);
00048                 define ("ILINC_DEFAULT_SSL_PORT",443);
00049                 define ("ILINC_DEFAULT_TIMEOUT",30);
00050         }
00051         
00057         function viewObject()
00058         {
00059                 global $rbacsystem;
00060                 
00061                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00062                 {
00063                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00064                 }
00065                 
00066                 $this->getTemplateFile("general");
00067                 
00068                 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."&cmd=gateway");
00069                 $this->tpl->setVariable("TXT_EXTT_TITLE", $this->lng->txt("extt_title_configure"));
00070 
00071                 $this->tpl->setVariable("TXT_EXTT_NAME", $this->lng->txt("extt_name"));
00072                 $this->tpl->setVariable("TXT_EXTT_ACTIVE", $this->lng->txt("active")."?");
00073                 $this->tpl->setVariable("TXT_EXTT_DESC", $this->lng->txt("description"));
00074 
00075                 $this->tpl->setVariable("TXT_CONFIGURE", $this->lng->txt("extt_configure"));
00076                 $this->tpl->setVariable("TXT_EXTT_REMARK", $this->lng->txt("extt_remark"));
00077 
00078                 // ilinc
00079                 $this->tpl->setVariable("TXT_EXTT_ILINC_NAME", $this->lng->txt("extt_ilinc"));
00080                 $this->tpl->setVariable("TXT_EXTT_ILINC_DESC", $this->lng->txt("extt_ilinc_desc"));
00081 
00082         
00083                 // icon handlers
00084                 $icon_ok = "<img src=\"".ilUtil::getImagePath("icon_ok.gif")."\" alt=\"".$this->lng->txt("enabled")."\" title=\"".$this->lng->txt("enabled")."\" border=\"0\" vspace=\"0\"/>";
00085                 $icon_not_ok = "<img src=\"".ilUtil::getImagePath("icon_not_ok.gif")."\" alt=\"".$this->lng->txt("disabled")."\" title=\"".$this->lng->txt("disabled")."\" border=\"0\" vspace=\"0\"/>";
00086 
00087                 $this->tpl->setVariable("EXTT_ILINC_ACTIVE", $this->ilias->getSetting('ilinc_active') ? $icon_ok : $icon_not_ok);
00088         }
00089         
00095         function getTabs(&$tabs_gui)
00096         {
00097                 // tabs are defined manually here. The autogeneration via objects.xml will be deprecated in future
00098                 // for usage examples see ilObjGroupGUI or ilObjSystemFolderGUI
00099         }
00100         
00106         function editiLincObject()
00107         {
00108                 global $rbacsystem, $rbacreview;
00109                 
00110                 if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
00111                 {
00112                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00113                 }
00114                 
00115                 if ($_SESSION["error_post_vars"])
00116                 {
00117                         if ($_SESSION["error_post_vars"]["ilinc"]["active"] == "1")
00118                         {
00119                                 $this->tpl->setVariable("CHK_ILINC_ACTIVE", "checked=\"checked\"");
00120                         }
00121                         
00122                         $this->tpl->setVariable("ILINC_SERVER", $_SESSION["error_post_vars"]["ilinc"]["server"]);
00123                         $this->tpl->setVariable("ILINC_REGISTRAR_LOGIN", $_SESSION["error_post_vars"]["ilinc"]["registrar_login"]);
00124                         $this->tpl->setVariable("ILINC_REGISTRAR_PASSWD", $_SESSION["error_post_vars"]["ilinc"]["registrar_passwd"]);
00125                         $this->tpl->setVariable("ILINC_CUSTOMER_ID", $_SESSION["error_post_vars"]["ilinc"]["customer_id"]);
00126                 }
00127                 else
00128                 {
00129                         // set already saved data or default value for port
00130                         $settings = $this->ilias->getAllSettings();
00131 
00132                         if ($settings["ilinc_active"] == "1")
00133                         {
00134                                 $this->tpl->setVariable("CHK_ILINC_ACTIVE", "checked=\"checked\"");
00135                         }
00136 
00137                         $this->tpl->setVariable("ILINC_SERVER", $settings["ilinc_server"].$settings["ilinc_path"]);
00138                         $this->tpl->setVariable("ILINC_REGISTRAR_LOGIN", $settings["ilinc_registrar_login"]);
00139                         $this->tpl->setVariable("ILINC_REGISTRAR_PASSWD", $settings["ilinc_registrar_passwd"]);
00140                         $this->tpl->setVariable("ILINC_CUSTOMER_ID", $settings["ilinc_customer_id"]);
00141                         
00142                         if (empty($settings["ilinc_port"]))
00143                         {
00144                                 $this->tpl->setVariable("ILINC_PORT", ILINC_DEFAULT_HTTP_PORT);
00145                         }
00146                         else
00147                         {
00148                                 $this->tpl->setVariable("ILINC_PORT", $settings["ilinc_port"]);                 
00149                         }
00150 
00151                         if ($settings["ilinc_protocol"] == "https")
00152                         {
00153                                 $this->tpl->setVariable("ILINC_PROTOCOL_SSL_SEL", "selected=\"selected\"");
00154                         }
00155                         else
00156                         {
00157                                 $this->tpl->setVariable("ILINC_PROTOCOL_HTTP_SEL", "selected=\"selected\"");            
00158                         }
00159                         
00160                         if (empty($settings["ilinc_timeout"]))
00161                         {
00162                                 $this->tpl->setVariable("ILINC_TIMEOUT", ILINC_DEFAULT_TIMEOUT);
00163                         }
00164                         else
00165                         {
00166                                 $this->tpl->setVariable("ILINC_TIMEOUT", $settings["ilinc_timeout"]);                   
00167                         }               
00168                 }
00169 
00170                 $this->getTemplateFile("ilinc");
00171                 
00172                 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."&cmd=gateway");
00173                 $this->tpl->setVariable("TXT_ILINC_TITLE", $this->lng->txt("extt_ilinc_configure"));
00174                 $this->tpl->setVariable("TXT_ILINC_ACTIVE", $this->lng->txt("extt_ilinc_enable"));
00175                 $this->tpl->setVariable("TXT_OPTIONS", $this->lng->txt("options"));
00176                 $this->tpl->setVariable("TXT_ILINC_SERVER", $this->lng->txt("extt_ilinc_server"));
00177                 $this->tpl->setVariable("TXT_ILINC_PROTOCOL_PORT", $this->lng->txt("extt_ilinc_protocol_port"));
00178                 $this->tpl->setVariable("TXT_ILINC_TIMEOUT", $this->lng->txt("extt_ilinc_timeout"));
00179                 $this->tpl->setVariable("ILINC_DEFAULT_HTTP_PORT", ILINC_DEFAULT_HTTP_PORT);
00180                 $this->tpl->setVariable("ILINC_DEFAULT_SSL_PORT", ILINC_DEFAULT_SSL_PORT);
00181                 $this->tpl->setVariable("TXT_HTTP", $this->lng->txt('http'));
00182                 $this->tpl->setVariable("TXT_SSL", $this->lng->txt('ssl'));
00183                 
00184                 $this->tpl->setVariable("TXT_SECONDS", $this->lng->txt("seconds"));
00185                 $this->tpl->setVariable("TXT_ILINC_REGISTRAR_LOGIN", $this->lng->txt("extt_ilinc_registrar_login"));
00186                 $this->tpl->setVariable("TXT_ILINC_REGISTRAR_PASSWD", $this->lng->txt("extt_ilinc_registrar_passwd"));
00187                 $this->tpl->setVariable("TXT_ILINC_CUSTOMER_ID", $this->lng->txt("extt_ilinc_customer_id"));
00188 
00189                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00190                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00191                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00192                 $this->tpl->setVariable("CMD_SUBMIT", "saveiLinc");
00193         }
00194 
00200         function saveiLincObject()
00201         {
00202          global $ilUser;
00203 
00204         // validate required data 
00205                 if (!$_POST["ilinc"]["server"] or !$_POST["ilinc"]["port"] or !$_POST["ilinc"]["registrar_login"] or !$_POST["ilinc"]["registrar_passwd"] or !$_POST["ilinc"]["customer_id"])
00206                 {
00207                         $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
00208                 }
00209                 
00210                 // validate port
00211                 if ((preg_match("/^[0-9]{0,5}$/",$_POST["ilinc"]["port"])) == false)
00212                 {
00213                         $this->ilias->raiseError($this->lng->txt("err_invalid_port"),$this->ilias->error_obj->MESSAGE);
00214                 }
00215                 
00216                 if (substr($_POST["ilinc"]["server"],0,8) != "https://" and substr($_POST["ilinc"]["server"],0,7) != "http://")
00217                 {
00218                         $_POST["ilinc"]["server"] = $_POST["ilinc"]["protocol"]."://".$_POST["ilinc"]["server"];
00219                 }
00220                 
00221                 $url = parse_url($_POST["ilinc"]["server"]);
00222                 
00223                 if (!ilUtil::isIPv4($url["host"]) and !ilUtil::isDN($url["host"]))
00224                 {
00225                         $this->ilias->raiseError($this->lng->txt("err_invalid_server"),$this->ilias->error_obj->MESSAGE);
00226                 }
00227                 
00228                 if (is_numeric($_POST["ilinc"]["timeout"]))
00229                 {
00230                         $this->ilias->setSetting("ilinc_timeout", $_POST["ilinc"]["timeout"]);
00231                 }
00232 
00233                 // all ok. save settings
00234                 $this->ilias->setSetting("ilinc_server", $url["host"]);
00235                 $this->ilias->setSetting("ilinc_path", $url["path"]);
00236                 $this->ilias->setSetting("ilinc_protocol", $_POST["ilinc"]["protocol"]);
00237                 $this->ilias->setSetting("ilinc_port", $_POST["ilinc"]["port"]);
00238                 $this->ilias->setSetting("ilinc_active", $_POST["ilinc"]["active"]);
00239                 $this->ilias->setSetting("ilinc_registrar_login", $_POST["ilinc"]["registrar_login"]);
00240                 $this->ilias->setSetting("ilinc_registrar_passwd", $_POST["ilinc"]["registrar_passwd"]);
00241                 $this->ilias->setSetting("ilinc_customer_id", $_POST["ilinc"]["customer_id"]);
00242 
00243                 sendInfo($this->lng->txt("extt_ilinc_settings_saved"),true);
00244                 ilUtil::redirect($this->getReturnLocation("view",$this->ctrl->getLinkTarget($this,"")));
00245         }
00246         
00247 } // END class.ilObjExternalToolsSettingsGUI
00248 ?>

Generated on Fri Dec 13 2013 10:18:27 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1