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

chat/classes/class.ilObjChatServerGUI.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 
00024 
00037 require_once "classes/class.ilObjectGUI.php";
00038 
00039 class ilObjChatServerGUI extends ilObjectGUI
00040 {
00045         function ilObjChatServerGUI($a_data,$a_id,$a_call_by_reference = true, $a_prepare_output = true)
00046         {
00047 
00048                 #define("ILIAS_MODULE","chat");
00049                 $this->type = "chac";
00050                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output);
00051 
00052                 $this->lng->loadLanguageModule("chat");
00053         }
00054 
00055         function &executeCommand()
00056         {
00057                 $next_class = $this->ctrl->getNextClass($this);
00058                 $cmd = $this->ctrl->getCmd();
00059                 $this->prepareOutput();
00060 
00061                 switch($next_class)
00062                 {
00063                         case 'ilpermissiongui':
00064                                 include_once("./classes/class.ilPermissionGUI.php");
00065                                 $perm_gui =& new ilPermissionGUI($this);
00066                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00067                                 break;
00068 
00069                         default:
00070                                 if(!$cmd)
00071                                 {
00072                                         $cmd = "view";
00073                                 }
00074                                 $cmd .= "Object";
00075                                 $this->$cmd();
00076 
00077                                 break;
00078                 }
00079                 return true;
00080         }
00081 
00082         function editObject()
00083         {
00084                 global $rbacsystem;
00085 
00086                 $this->tabs_gui->setTabActive('edit_properties');
00087 
00088                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00089                 {
00090                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00091                 }
00092                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chac_edit.html",'chat');
00093 
00094         $internal_ip = $_SESSION["error_post_vars"]["chat_internal_ip"] ? 
00095             $_SESSION["error_post_vars"]["chat_internal_ip"] :
00096             $this->object->server_conf->getInternalIp();
00097 
00098         $external_ip = $_SESSION["error_post_vars"]["chat_external_ip"] ? 
00099             $_SESSION["error_post_vars"]["chat_external_ip"] :
00100             $this->object->server_conf->getExternalIp();
00101 
00102                 $port = $_SESSION["error_post_vars"]["chat_port"] ? 
00103                         $_SESSION["error_post_vars"]["chat_port"] :
00104                         $this->object->server_conf->getPort();
00105 
00106                 $moderator = $_SESSION["error_post_vars"]["chat_moderator"] ? 
00107                         $_SESSION["error_post_vars"]["chat_moderator"] :
00108                         $this->object->server_conf->getModeratorPassword();
00109 
00110                 $logfile = $_SESSION["error_post_vars"]["chat_logfile"] ? 
00111                         $_SESSION["error_post_vars"]["chat_logfile"] :
00112                         $this->object->server_conf->getLogfile();
00113 
00114                 $loglevel = $_SESSION["error_post_vars"]["chat_loglevel"] ? 
00115                         $_SESSION["error_post_vars"]["chat_loglevel"] :
00116                         $this->object->server_conf->getLogLevel();
00117 
00118         $allowed = $_SESSION["error_post_vars"]["chat_allowed"] ? 
00119             $_SESSION["error_post_vars"]["chat_internal_ip"] :
00120             $this->object->server_conf->getAllowedHosts();
00121 
00122                 $active = $_SESSION["error_post_vars"]["chat_active"] ?
00123                         $_SESSION["error_post_vars"]["chat_active"] :
00124                         $this->object->server_conf->getActiveStatus();
00125 
00126                 
00127                 if($this->object->server_conf->isAlive() or $this->object->server_conf->getActiveStatus())
00128                 {
00129                         $this->tpl->setCurrentBlock("chat_active");
00130                         $this->tpl->setVariable("TXT_ACT_CHAT",$this->lng->txt("chat_ilias"));
00131                         $this->tpl->setVariable("TXT_ACT_STATUS",$this->lng->txt("chat_status"));
00132                         $this->tpl->setVariable("TXT_ACT_SUBMIT",$this->lng->txt("change"));
00133                         $this->tpl->setVariable("SELECT_ACT_STATUS",$this->__getStatusSelect($active));
00134                 }
00135                         
00136 
00137 
00138                 // SET TEXT VARIABLES
00139                 $this->tpl->setVariable("FORMACTION",
00140                                                                 $this->ctrl->getFormAction($this));
00141                                                                 #$this->getFormAction("gateway","adm_object.php?ref_id=".$this->ref_id."&cmd=gateway"));
00142                 $this->tpl->setVariable("TXT_CHAT_SERVER_SETTINGS",$this->lng->txt("chat_server_settings"));
00143         $this->tpl->setVariable("TXT_CHAT_SERVER_INTERNAL_IP",$this->lng->txt("chat_server_internal_ip"));
00144         $this->tpl->setVariable("TXT_CHAT_SERVER_EXTERNAL_IP",$this->lng->txt("chat_server_external_ip"));
00145                 $this->tpl->setVariable("TXT_CHAT_SERVER_MODERATOR",$this->lng->txt("chat_moderator_password"));
00146                 $this->tpl->setVariable("TXT_CHAT_SERVER_PORT",$this->lng->txt("chat_server_port"));
00147                 $this->tpl->setVariable("TXT_CHAT_SERVER_LOGFILE",$this->lng->txt("chat_server_logfile"));
00148                 $this->tpl->setVariable("TXT_CHAT_SERVER_LEVEL",$this->lng->txt("chat_server_loglevel"));
00149                 $this->tpl->setVariable("TXT_CHAT_SERVER_ALLOWED",$this->lng->txt("chat_server_allowed"));
00150                 $this->tpl->setVariable("TXT_CHAT_SERVER_ALLOWED_B",$this->lng->txt("chat_server_allowed_b"));
00151                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00152                 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
00153                 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("save"));
00154 
00155                 // SET SETTING VARS
00156         $this->tpl->setVariable("CHAT_SERVER_INTERNAL",$internal_ip);
00157         $this->tpl->setVariable("CHAT_SERVER_EXTERNAL",$external_ip);
00158                 $this->tpl->setVariable("CHAT_PORT",$port);
00159                 $this->tpl->setVariable("CHAT_MODERATOR",$moderator);
00160                 $this->tpl->setVariable("CHAT_LOGFILE",$logfile);
00161                 $this->tpl->setVariable("CHAT_ALLOWED",$allowed);
00162                 $this->tpl->setVariable("SELECT_LEVEL",$this->__getLogLevelSelect($loglevel));
00163                 $this->tpl->parseCurrentBlock();
00164                 
00165                 return true;
00166         }
00167 
00168         function updateObject()
00169         {
00170                 global $rbacsystem;
00171 
00172                 if (!$rbacsystem->checkAccess("write", $this->ref_id))
00173                 {
00174                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00175                 }
00176 
00177         $this->object->server_conf->setInternalIp($_POST["chat_internal_ip"]);
00178         $this->object->server_conf->setExternalIp($_POST["chat_external_ip"]);
00179                 $this->object->server_conf->setPort($_POST["chat_port"]);
00180                 $this->object->server_conf->setModeratorPassword($_POST["chat_moderator"]);
00181                 $this->object->server_conf->setLogfile($_POST["chat_logfile"]);
00182                 $this->object->server_conf->setLogLevel($_POST["chat_loglevel"]);
00183                 $this->object->server_conf->setAllowedHosts($_POST["chat_allowed"]);
00184 
00185                 if(!$this->object->server_conf->validate())
00186                 {
00187                         $this->ilias->raiseError($this->object->server_conf->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
00188                 }
00189                 else
00190                 {
00191                         if(!$this->object->server_conf->update())
00192                         {
00193                                 $this->ilias->raiseError($this->object->server_conf->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
00194                         }
00195                 }
00196                 sendInfo($this->lng->txt("chat_settings_saved"),true);
00197                 $this->editObject();
00198         }
00199 
00200         function activateObject()
00201         {
00202                 $this->object->server_conf->setActiveStatus((bool) $_POST["chat_active"]);
00203                 $this->object->server_conf->updateStatus();
00204 
00205                 sendInfo($this->lng->txt("chat_status_saved"));
00206                 $this->editObject();
00207         }
00208 
00209         // PRIVATE
00210         function __getLogLevelSelect($a_level)
00211         {
00212                 $levels = array(1 => $this->lng->txt("chat_level_fatal"),
00213                                                 2 => $this->lng->txt("chat_level_error"),
00214                                                 3 => $this->lng->txt("chat_level_info"),
00215                                                 5 => $this->lng->txt("chat_level_debug"),
00216                                                 6 => $this->lng->txt("chat_level_all"));
00217 
00218                 return ilUtil::formSelect($a_level,"chat_loglevel",$levels,false,true);
00219         }
00220         function __getStatusSelect($a_status)
00221         {
00222                 $stati = array(1 => $this->lng->txt("chat_active"),
00223                                            0 => $this->lng->txt("chat_inactive"));
00224 
00225                 return ilUtil::formSelect($a_status,"chat_active",$stati,false,true);
00226         }
00227 
00233         function getAdminTabs(&$tabs_gui)
00234         {
00235                 global $rbacsystem,$rbacreview;
00236 
00237                 $this->ctrl->setParameter($this,"ref_id",$this->object->getRefId());
00238 
00239                 if($rbacsystem->checkAccess('read',$this->object->getRefId()))
00240                 {
00241                         $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "view")
00242                                 ? true
00243                                 : false;
00244                         $tabs_gui->addTarget("chat_rooms",
00245                                 $this->ctrl->getLinkTarget($this, "view"), array("view", ""), get_class($this),
00246                                 "", $force_active);
00247                 }
00248                 if($rbacsystem->checkAccess('write',$this->object->getRefId()))
00249                 {
00250                         $force_active = ($_GET["cmd"] == "edit")
00251                                 ? true
00252                                 : false;
00253                         $tabs_gui->addTarget("edit_properties",
00254                                 $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this),
00255                                 "", $force_active);
00256                 }
00257                 if($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00258                 {
00259                         $tabs_gui->addTarget("perm_settings",
00260                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00261                 }
00262         }
00263 
00264 
00265         
00266 
00267 
00268 } // END class.ilObjChatServerGUI
00269 
00270 ?>

Generated on Fri Dec 13 2013 11:57:53 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1