00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00036 require_once "class.ilObjectGUI.php";
00037
00038 class ilObjExternalToolsSettingsGUI extends ilObjectGUI
00039 {
00044 function ilObjExternalToolsSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
00045 {
00046 $this->type = "extt";
00047 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
00048
00049 define ("ILINC_DEFAULT_HTTP_PORT",80);
00050 define ("ILINC_DEFAULT_SSL_PORT",443);
00051 define ("ILINC_DEFAULT_TIMEOUT",30);
00052 }
00053
00059 function viewObject()
00060 {
00061 global $rbacsystem;
00062
00063 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00064 {
00065 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00066 }
00067
00068 $this->__initSubTabs("view");
00069
00070 $this->getTemplateFile("general");
00071
00072 $this->tpl->setVariable("FORMACTION",
00073 $this->ctrl->getFormAction($this));
00074 $this->tpl->setVariable("TXT_EXTT_TITLE", $this->lng->txt("extt_title_configure"));
00075
00076 $this->tpl->setVariable("TXT_EXTT_NAME", $this->lng->txt("extt_name"));
00077 $this->tpl->setVariable("TXT_EXTT_ACTIVE", $this->lng->txt("active")."?");
00078 $this->tpl->setVariable("TXT_EXTT_DESC", $this->lng->txt("description"));
00079
00080 $this->tpl->setVariable("TXT_CONFIGURE", $this->lng->txt("extt_configure"));
00081 $this->tpl->setVariable("TXT_EXTT_REMARK", $this->lng->txt("extt_remark"));
00082
00083
00084 $this->tpl->setVariable("TXT_EXTT_ILINC_NAME", $this->lng->txt("extt_ilinc"));
00085 $this->tpl->setVariable("TXT_EXTT_ILINC_DESC", $this->lng->txt("extt_ilinc_desc"));
00086
00087
00088
00089 $icon_ok = "<img src=\"".ilUtil::getImagePath("icon_ok.gif")."\" alt=\"".$this->lng->txt("enabled")."\" title=\"".$this->lng->txt("enabled")."\" border=\"0\" vspace=\"0\"/>";
00090 $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\"/>";
00091
00092 $this->tpl->setVariable("EXTT_ILINC_ACTIVE", $this->ilias->getSetting('ilinc_active') ? $icon_ok : $icon_not_ok);
00093 }
00094
00095 function cancelObject()
00096 {
00097 sendInfo($this->lng->txt("msg_cancel"),true);
00098 $this->ctrl->redirect($this, "view");
00099 }
00100
00101 function getAdminTabs(&$tabs_gui)
00102 {
00103 $this->getTabs($tabs_gui);
00104 }
00105
00111 function getTabs(&$tabs_gui)
00112 {
00113 global $rbacsystem;
00114
00115 $this->ctrl->setParameter($this,"ref_id",$this->object->getRefId());
00116
00117 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00118 {
00119 $tabs_gui->addTarget("settings",
00120 $this->ctrl->getLinkTarget($this, "view"), array("view","editiLinc",""), "", "");
00121 }
00122
00123 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00124 {
00125 $tabs_gui->addTarget("perm_settings",
00126 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00127 }
00128 }
00129
00135 function editiLincObject()
00136 {
00137 global $rbacsystem, $rbacreview;
00138
00139 if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
00140 {
00141 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00142 }
00143
00144 $this->__initSubTabs("editiLinc");
00145
00146 if ($_SESSION["error_post_vars"])
00147 {
00148 if ($_SESSION["error_post_vars"]["ilinc"]["active"] == "1")
00149 {
00150 $this->tpl->setVariable("CHK_ILINC_ACTIVE", "checked=\"checked\"");
00151 }
00152
00153 $this->tpl->setVariable("ILINC_SERVER", $_SESSION["error_post_vars"]["ilinc"]["server"]);
00154 $this->tpl->setVariable("ILINC_REGISTRAR_LOGIN", $_SESSION["error_post_vars"]["ilinc"]["registrar_login"]);
00155 $this->tpl->setVariable("ILINC_REGISTRAR_PASSWD", $_SESSION["error_post_vars"]["ilinc"]["registrar_passwd"]);
00156 $this->tpl->setVariable("ILINC_CUSTOMER_ID", $_SESSION["error_post_vars"]["ilinc"]["customer_id"]);
00157 }
00158 else
00159 {
00160
00161 $settings = $this->ilias->getAllSettings();
00162
00163 if ($settings["ilinc_active"] == "1")
00164 {
00165 $this->tpl->setVariable("CHK_ILINC_ACTIVE", "checked=\"checked\"");
00166 }
00167
00168 $this->tpl->setVariable("ILINC_SERVER", $settings["ilinc_server"].$settings["ilinc_path"]);
00169 $this->tpl->setVariable("ILINC_REGISTRAR_LOGIN", $settings["ilinc_registrar_login"]);
00170 $this->tpl->setVariable("ILINC_REGISTRAR_PASSWD", $settings["ilinc_registrar_passwd"]);
00171 $this->tpl->setVariable("ILINC_CUSTOMER_ID", $settings["ilinc_customer_id"]);
00172
00173 if (empty($settings["ilinc_port"]))
00174 {
00175 $this->tpl->setVariable("ILINC_PORT", ILINC_DEFAULT_HTTP_PORT);
00176 }
00177 else
00178 {
00179 $this->tpl->setVariable("ILINC_PORT", $settings["ilinc_port"]);
00180 }
00181
00182 if ($settings["ilinc_protocol"] == "https")
00183 {
00184 $this->tpl->setVariable("ILINC_PROTOCOL_SSL_SEL", "selected=\"selected\"");
00185 }
00186 else
00187 {
00188 $this->tpl->setVariable("ILINC_PROTOCOL_HTTP_SEL", "selected=\"selected\"");
00189 }
00190
00191 if (empty($settings["ilinc_timeout"]))
00192 {
00193 $this->tpl->setVariable("ILINC_TIMEOUT", ILINC_DEFAULT_TIMEOUT);
00194 }
00195 else
00196 {
00197 $this->tpl->setVariable("ILINC_TIMEOUT", $settings["ilinc_timeout"]);
00198 }
00199 }
00200
00201 $this->getTemplateFile("ilinc");
00202
00203 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00204 $this->tpl->setVariable("TXT_ILINC_TITLE", $this->lng->txt("extt_ilinc_configure"));
00205 $this->tpl->setVariable("TXT_ILINC_ACTIVE", $this->lng->txt("extt_ilinc_enable"));
00206 $this->tpl->setVariable("TXT_OPTIONS", $this->lng->txt("options"));
00207 $this->tpl->setVariable("TXT_ILINC_SERVER", $this->lng->txt("extt_ilinc_server"));
00208 $this->tpl->setVariable("TXT_ILINC_PROTOCOL_PORT", $this->lng->txt("extt_ilinc_protocol_port"));
00209 $this->tpl->setVariable("TXT_ILINC_TIMEOUT", $this->lng->txt("extt_ilinc_timeout"));
00210 $this->tpl->setVariable("ILINC_DEFAULT_HTTP_PORT", ILINC_DEFAULT_HTTP_PORT);
00211 $this->tpl->setVariable("ILINC_DEFAULT_SSL_PORT", ILINC_DEFAULT_SSL_PORT);
00212 $this->tpl->setVariable("TXT_HTTP", $this->lng->txt('http'));
00213 $this->tpl->setVariable("TXT_SSL", $this->lng->txt('ssl'));
00214
00215 $this->tpl->setVariable("TXT_SECONDS", $this->lng->txt("seconds"));
00216 $this->tpl->setVariable("TXT_ILINC_REGISTRAR_LOGIN", $this->lng->txt("extt_ilinc_registrar_login"));
00217 $this->tpl->setVariable("TXT_ILINC_REGISTRAR_PASSWD", $this->lng->txt("extt_ilinc_registrar_passwd"));
00218 $this->tpl->setVariable("TXT_ILINC_CUSTOMER_ID", $this->lng->txt("extt_ilinc_customer_id"));
00219
00220 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00221 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00222 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00223 $this->tpl->setVariable("CMD_SUBMIT", "saveiLinc");
00224 }
00225
00231 function saveiLincObject()
00232 {
00233 global $ilUser;
00234
00235
00236 if (!$_POST["ilinc"]["server"] or !$_POST["ilinc"]["port"] or !$_POST["ilinc"]["registrar_login"] or !$_POST["ilinc"]["registrar_passwd"] or !$_POST["ilinc"]["customer_id"])
00237 {
00238 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
00239 }
00240
00241
00242 if ((preg_match("/^[0-9]{0,5}$/",$_POST["ilinc"]["port"])) == false)
00243 {
00244 $this->ilias->raiseError($this->lng->txt("err_invalid_port"),$this->ilias->error_obj->MESSAGE);
00245 }
00246
00247 if (substr($_POST["ilinc"]["server"],0,8) != "https://" and substr($_POST["ilinc"]["server"],0,7) != "http://")
00248 {
00249 $_POST["ilinc"]["server"] = $_POST["ilinc"]["protocol"]."://".$_POST["ilinc"]["server"];
00250 }
00251
00252 $url = parse_url($_POST["ilinc"]["server"]);
00253
00254 if (!ilUtil::isIPv4($url["host"]) and !ilUtil::isDN($url["host"]))
00255 {
00256 $this->ilias->raiseError($this->lng->txt("err_invalid_server"),$this->ilias->error_obj->MESSAGE);
00257 }
00258
00259 if (is_numeric($_POST["ilinc"]["timeout"]))
00260 {
00261 $this->ilias->setSetting("ilinc_timeout", $_POST["ilinc"]["timeout"]);
00262 }
00263
00264
00265 $this->ilias->setSetting("ilinc_server", $url["host"]);
00266 $this->ilias->setSetting("ilinc_path", $url["path"]);
00267 $this->ilias->setSetting("ilinc_protocol", $_POST["ilinc"]["protocol"]);
00268 $this->ilias->setSetting("ilinc_port", $_POST["ilinc"]["port"]);
00269 $this->ilias->setSetting("ilinc_active", $_POST["ilinc"]["active"]);
00270 $this->ilias->setSetting("ilinc_registrar_login", $_POST["ilinc"]["registrar_login"]);
00271 $this->ilias->setSetting("ilinc_registrar_passwd", $_POST["ilinc"]["registrar_passwd"]);
00272 $this->ilias->setSetting("ilinc_customer_id", $_POST["ilinc"]["customer_id"]);
00273
00274 sendInfo($this->lng->txt("extt_ilinc_settings_saved"),true);
00275 $this->ctrl->redirect($this,'editiLinc');
00276 }
00277
00278
00279 function __initSubTabs($a_cmd)
00280 {
00281 $ilinc = ($a_cmd == 'editiLinc') ? true : false;
00282 $overview = ($a_cmd == 'view' or $a_cmd == '') ? true : false;
00283
00284 $this->tabs_gui->addSubTabTarget("overview", $this->ctrl->getLinkTarget($this, "view"),
00285 "", "", "", $overview);
00286 $this->tabs_gui->addSubTabTarget("extt_ilinc", $this->ctrl->getLinkTarget($this, "editiLinc"),
00287 "", "", "", $ilinc);
00288 }
00289
00290 function &executeCommand()
00291 {
00292 $next_class = $this->ctrl->getNextClass($this);
00293 $cmd = $this->ctrl->getCmd();
00294 $this->prepareOutput();
00295
00296 switch($next_class)
00297 {
00298 case 'ilpermissiongui':
00299 include_once("./classes/class.ilPermissionGUI.php");
00300 $perm_gui =& new ilPermissionGUI($this);
00301 $ret =& $this->ctrl->forwardCommand($perm_gui);
00302 break;
00303
00304 default:
00305 if(!$cmd)
00306 {
00307 $cmd = "view";
00308 }
00309 $cmd .= "Object";
00310 $this->$cmd();
00311
00312 break;
00313 }
00314 return true;
00315 }
00316
00317 }
00318 ?>