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

chat/classes/class.ilObjChatGUI.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 
00035 require_once "classes/class.ilObjectGUI.php";
00036 
00037 class ilObjChatGUI extends ilObjectGUI
00038 {
00039         var $target_script = "adm_object.php";
00040         var $in_module = false;
00041 
00046         function ilObjChatGUI($a_data,$a_id,$a_call_by_reference = true, $a_prepare_output = true)
00047         {
00048                 define("ILIAS_MODULE","chat");
00049                 
00050                 $this->type = "chat";
00051                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output);
00052 
00053                 if(is_object($this->object->chat_user))
00054                 {
00055                         $this->object->chat_user->setUserId($_SESSION["AccountId"]);
00056                 }
00057         }
00058         function setTargetScript($a_script)
00059         {
00060                 $this->target_script = $a_script;
00061         }
00062         function getTargetScript($a_params)
00063         {
00064                 return $this->target_script."?".$a_params;
00065         }
00066         function setInModule($in_module)
00067         {
00068                 $this->in_module = $in_module;
00069         }
00070         function inModule()
00071         {
00072                 return $this->in_module;
00073         }
00074 
00075         function saveObject()
00076         {
00077                 $new_obj =& parent::saveObject();
00078 
00079                 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?ref_id=".$new_obj->getRefId()));
00080         }
00081 
00082         function cancelObject()
00083         {
00084                 unset($_SESSION["room_id_rename"]);
00085                 unset($_SESSION["room_id_delete"]);
00086                 parent::cancelObject();
00087         }
00088 
00089 
00090         function viewObject()
00091         {
00092 
00093                 global $rbacsystem;
00094 
00095                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00096                 {
00097                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00098                 }
00099                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chat_view.html",true);
00100 
00101                 // CHAT SERVER NOT ACTIVE
00102                 if(!$this->object->server_comm->isAlive() or !$this->ilias->getSetting("chat_active"))
00103                 {
00104                         sendInfo($this->lng->txt("chat_server_not_active"));
00105                 }
00106 
00107                 // DELETE ROOMS CONFIRM
00108                 $checked = array();
00109                 if($_SESSION["room_id_delete"])
00110                 {
00111                         $checked = $_SESSION["room_id_delete"];
00112                         sendInfo($this->lng->txt("chat_delete_sure"));
00113                         $this->tpl->setVariable("TXT_DELETE_CANCEL",$this->lng->txt("cancel"));
00114                         $this->tpl->setVariable("TXT_DELETE_CONFIRM",$this->lng->txt("delete"));
00115                 }
00116 
00117                 // SHOW ROOMS TABLE
00118                 $this->tpl->setVariable("FORMACTION",$this->getTargetScript("cmd=gateway&ref_id=".
00119                                                                                                                                         $this->ref_id));
00120                 $this->tpl->setVariable("TXT_CHATROOMS",$this->lng->txt("chat_chatrooms"));
00121 
00122                 $counter = 0;
00123                 $this->object->chat_room->setOwnerId($_SESSION["AccountId"]);
00124                 $rooms = $this->object->chat_room->getRoomsOfObject();
00125                 $script = $this->inModule() ? "./chat.php" : "./chat/chat.php";
00126 
00127                 // ADD PUBLIC ROOM
00128                 // CHAT SERVER  ACTIVE
00129                 if($this->object->server_comm->isAlive() and $this->ilias->getSetting("chat_active"))
00130                 {
00131                         $this->tpl->setCurrentBlock("active");
00132                         $this->tpl->setVariable("ROOM_LINK",$script."?ref_id=".$this->ref_id."&room_id=0");
00133                         $this->tpl->setVariable("ROOM_TARGET","_blank");
00134                         $this->tpl->setVariable("ROOM_TXT_LINK",$this->lng->txt("show"));
00135                         $this->tpl->parseCurrentBlock();
00136                 }
00137                 else
00138                 {
00139                         $this->tpl->touchBlock("not_active");
00140                 }
00141                 $this->tpl->setCurrentBlock("tbl_rooms_row");
00142                 $this->tpl->setVariable("ROWCOL",++$counter % 2 ? "tblrow1" : "tblrow2");
00143                 $this->tpl->setVariable("ROOM_CHECK",
00144                                                                 ilUtil::formCheckbox(in_array(0,$checked) ? 1 : 0,
00145                                                                                                          "del_id[]",
00146                                                                                                          0));
00147                 $this->tpl->setVariable("ROOM_NAME",$this->object->getTitle()." ".$this->lng->txt("chat_public_room"));
00148                 $this->tpl->parseCurrentBlock();
00149 
00150                 $script = $this->inModule() ? "./chat.php" : "./chat/chat.php";
00151 
00152 
00153 
00154                 foreach($rooms as $room)
00155                 {
00156                         // CHAT SERVER  ACTIVE
00157                         if($this->object->server_comm->isAlive() and $this->ilias->getSetting("chat_active"))
00158                         {
00159                                 $this->tpl->setCurrentBlock("active");
00160                                 $this->tpl->setVariable("ROOM_LINK",$script."?ref_id=".$this->ref_id."&room_id=".$room["room_id"]);
00161                                 $this->tpl->setVariable("ROOM_TARGET","_blank");
00162                                 $this->tpl->setVariable("ROOM_TXT_LINK",$this->lng->txt("show"));
00163                                 $this->tpl->parseCurrentBlock();
00164                         }
00165                         else
00166                         {
00167                                 $this->tpl->touchBlock("not_active");
00168                         }
00169                         $this->tpl->setCurrentBlock("tbl_rooms_row");
00170                         $this->tpl->setVariable("ROWCOL",++$counter % 2 ? "tblrow1" : "tblrow2");
00171                         $this->tpl->setVariable("ROOM_CHECK",
00172                                                                         ilUtil::formCheckbox(in_array($room["room_id"],$checked) ? 1 : 0,
00173                                                                         "del_id[]",
00174                                                                         $room["room_id"]));
00175 
00176                         $this->tpl->setVariable("ROOM_NAME",$room["title"]);
00177                         $this->tpl->parseCurrentBlock();
00178                 }
00179                 $this->tpl->setCurrentBlock("has_rooms");
00180                 $this->tpl->setVariable("TBL_FOOTER_IMG_SRC", ilUtil::getImagePath("arrow_downright.gif"));
00181                 $this->tpl->setVariable("TBL_FOOTER_SELECT",$this->__showAdminRoomSelect(count($rooms)));
00182                 $this->tpl->setVariable("FOOTER_HAS_ROOMS_OK",$this->lng->txt("ok"));
00183                 $this->tpl->parseCurrentBlock();
00184                 $this->tpl->setVariable("TBL_FOOTER_ADD_SELECT",$this->__showAdminAddRoomSelect());
00185                 $this->tpl->setVariable("FOOTER_OK",$this->lng->txt("add"));
00186         }
00187         function adminRoomsObject()
00188         {
00189                 global $rbacsystem;
00190 
00191                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00192                 {
00193                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00194                 }
00195                 
00196                 if(!isset($_POST["del_id"]))
00197                 {
00198                         $this->ilias->raiseError($this->lng->txt("chat_select_one_room"),$this->ilias->error_obj->MESSAGE);
00199                 }
00200 
00201                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chat_edit_room.html",true);
00202                 $this->tpl->setVariable("FORMACTION",$this->getTargetScript("cmd=gateway&ref_id=".$this->ref_id));
00203                 $this->tpl->setVariable("TXT_ROOM_NAME",$this->lng->txt("chat_room_name"));
00204                 $this->tpl->setVariable("ROOM_CANCEL",$this->lng->txt("cancel"));
00205         
00206                 switch($_POST["action"])
00207                 {
00208                         case "renameRoom":
00209                                 if(count($_POST["del_id"]) > 1)
00210                                 {
00211                                         $this->ilias->raiseError($this->lng->txt("chat_select_one_room"),$this->ilias->error_obj->MESSAGE);
00212                                 }
00213                                 if(in_array(0,$_POST["del_id"]))
00214                                 {
00215                                         $this->ilias->raiseError($this->lng->txt("chat_no_rename_public"),$this->ilias->error_obj->MESSAGE);
00216                                 }
00217 
00218                                 // STORE ID IN SESSION
00219                                 $_SESSION["room_id_rename"] = (int) $_POST["del_id"][0];
00220 
00221                                 $room =& new ilChatRoom($this->ref_id);
00222                                 $room->setRoomId($_SESSION["room_id_rename"]);
00223 
00224                                 $this->tpl->setVariable("TXT_EDIT_CHATROOMS",$this->lng->txt("chat_chatroom_rename"));
00225                                 $this->tpl->setVariable("ROOM_NAME",$room->getTitle());
00226                                 $this->tpl->setVariable("CMD","renameRoom");
00227                                 $this->tpl->setVariable("ROOM_EDIT",$this->lng->txt("rename"));
00228                                 break;
00229 
00230                         case "deleteRoom":
00231                                 if(in_array(0,$_POST["del_id"]))
00232                                 {
00233                                         $this->ilias->raiseError($this->lng->txt("chat_no_delete_public"),$this->ilias->error_obj->MESSAGE);
00234                                 }
00235                                 $_SESSION["room_id_delete"] = $_POST["del_id"];
00236                                 header("location: ".$this->getTargetScript("cmd=gateway&ref_id=".$this->ref_id));
00237                                 exit;
00238 
00239                         case "exportRoom":
00240                                 $this->__exportRooms();
00241                                 break;
00242 
00243                         case "refreshRoom":
00244                                 if(in_array(0,$_POST["del_id"]))
00245                                 {
00246                                         $this->ilias->raiseError($this->lng->txt("chat_no_refresh_public"),$this->ilias->error_obj->MESSAGE);
00247                                 }
00248                                 foreach($_POST["del_id"] as $room_id)
00249                                 {
00250                                         $this->object->chat_room->setRoomId($room_id);
00251                                         $this->object->server_comm->setType("delete");
00252                                         $this->object->server_comm->send();
00253                                         $this->object->chat_room->deleteAllMessages();
00254                                 }
00255                                 sendInfo($this->lng->txt("chat_messages_deleted"),true);
00256                                 header("location: ".$this->getTargetScript("cmd=gateway&ref_id=".$this->ref_id));
00257                                 exit;
00258                 }       
00259                 
00260         }
00261         function confirmedDeleteRoomObject()
00262         {
00263                 global $rbacsystem;
00264 
00265                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00266                 {
00267                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00268                 }
00269                 if(!$_SESSION["room_id_delete"])
00270                 {
00271                         $this->ilias->raiseError($this->lng->txt("chat_select_one_room"),$this->ilias->error_obj->MESSAGE);
00272                 }
00273                 $this->object->chat_room->setOwnerId($_SESSION["AccountId"]);
00274                 if(!$this->object->chat_room->deleteRooms($_SESSION["room_id_delete"]))
00275                 {
00276                         $this->ilias->raiseError($this->object->chat_room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
00277                 }
00278                 unset($_SESSION["room_id_delete"]);
00279                 sendInfo($this->lng->txt("chat_rooms_deleted"),true);
00280 
00281                 header("location: ".$this->getTargetScript("cmd=gateway&ref_id=".$this->ref_id));
00282                 exit;
00283         }
00284 
00285         function addRoomObject()
00286         {
00287                 global $rbacsystem;
00288 
00289                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00290                 {
00291                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00292                 }
00293                 $room =& new ilChatRoom($this->ref_id);
00294                 $room->setTitle(ilUtil::stripSlashes($_POST["room_name"]));
00295                 $room->setOwnerId($_SESSION["AccountId"]);
00296 
00297                 if(!$room->validate())
00298                 {
00299                         $this->ilias->raiseError($room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
00300                 }
00301                 $room->add();
00302 
00303                 sendInfo("chat_room_added");
00304                 header("location: ".$this->getTargetScript("cmd=gateway&ref_id=".$this->ref_id));
00305                 exit;
00306         }
00307 
00308         function renameRoomObject()
00309         {
00310                 global $rbacsystem;
00311 
00312                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00313                 {
00314                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00315                 }
00316                 
00317                 $room =& new ilChatRoom($this->ref_id);
00318                 $room->setRoomId($_SESSION["room_id_rename"]);
00319                 $room->setTitle(ilUtil::stripSlashes($_POST["room_name"]));
00320                 if(!$room->validate())
00321                 {
00322                         $this->ilias->raiseError($room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
00323                 }
00324                 $room->rename();
00325 
00326                 unset($_SESSION["room_id_rename"]);
00327                 sendInfo("chat_room_renamed");
00328                 header("location: ".$this->getTargetScript("cmd=gateway&ref_id=".$this->ref_id));
00329                 exit;
00330         }               
00331                 
00332 
00333 
00334         function adminAddRoomObject()
00335         {
00336                 global $rbacsystem;
00337 
00338                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00339                 {
00340                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00341                 }
00342                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chat_edit_room.html",true);
00343                 $this->tpl->setVariable("FORMACTION",$this->getTargetScript("cmd=gateway&ref_id=".$this->ref_id));
00344                 $this->tpl->setVariable("TXT_ROOM_NAME",$this->lng->txt("chat_room_name"));
00345                 $this->tpl->setVariable("ROOM_CANCEL",$this->lng->txt("cancel"));
00346         
00347                 $this->tpl->setVariable("TXT_EDIT_CHATROOMS",$this->lng->txt("chat_chatroom_rename"));
00348                 $this->tpl->setVariable("ROOM_NAME","");
00349                 $this->tpl->setVariable("CMD","addRoom");
00350                 $this->tpl->setVariable("ROOM_EDIT",$this->lng->txt("add"));
00351 
00352         }       
00353 
00354         function showFrames()
00355         {
00356                 global $rbacsystem;
00357 
00358                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00359                 {
00360                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00361                 }
00362 
00363                 // LOAD FRAMESET
00364                 $this->tpl = new ilTemplate("tpl.chat_start.html",false,false,true);
00365                 $this->tpl->setVariable("USER_TARGET","chat.php?cmd=showUserFrame&ref_id=".
00366                                                                 $this->object->getRefId()."&room_id=".
00367                                                                 $_REQUEST["room_id"]."&p_id=".$_GET["p_id"]);
00368                 $this->tpl->setVariable("TOP_TARGET","chat.php?cmd=showTopFrame&ref_id=".
00369                                                                 $this->object->getRefId()."&room_id=".
00370                                                                 $_REQUEST["room_id"]."&p_id=".$_GET["p_id"]);
00371                 $this->tpl->setVariable("SERVER_TARGET",$this->object->server_comm->getServerFrameSource());
00372                 $this->tpl->setVariable("INPUT_TARGET","chat.php?cmd=showInputFrame&ref_id=".
00373                                                                 $this->object->getRefId()."&room_id=".
00374                                                                 $_REQUEST["room_id"]."&p_id=".$_GET["p_id"]);
00375                 $this->tpl->setVariable("RIGHT_TARGET","chat.php?cmd=showRightFrame&ref_id=".
00376                                                                 $this->object->getRefId()."&room_id=".
00377                                                                 $_REQUEST["room_id"]."&p_id=".$_GET["p_id"]);
00378         }
00379         function showUserFrame()
00380         {
00381                 $this->object->chat_room->setUserId($_SESSION["AccountId"]);
00382                 $this->object->chat_room->updateLastVisit();
00383 
00384                 $this->__loadStylesheet(true);
00385                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_user_frame.html",true);
00386 
00387                 if($_REQUEST["room_id"])
00388                 {
00389                         $this->tpl->setVariable("TITLE",$this->object->chat_room->getTitle());
00390                 }
00391                 else
00392                 {
00393                         $this->tpl->setVariable("TITLE",$this->object->getTitle());
00394                 }
00395 
00396                 $this->__showRooms();
00397                 $this->__showActiveUsers();
00398                 if($this->object->chat_room->isOwner())
00399                 {
00400                         $this->__showOnlineUsers();
00401                 }
00402                 
00403         }
00404         function showTopFrame()
00405         {
00406                 $this->__loadStylesheet();
00407                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_top_frame.html",true);
00408         }
00409         function showInputFrame()
00410         {
00411                 $this->__loadStylesheet();
00412                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_input_frame.html",true);
00413 
00414                 if($this->error)
00415                 {
00416                         sendInfo($this->error);
00417                 }
00418                 if($_GET["p_id"])
00419                 {
00420                         $user_obj =& new ilObjUser((int) $_GET["p_id"]);
00421                         $message = $this->lng->txt("chat_private_message")." ";
00422                         $message .= $this->object->chat_user->getLogin()." -> ".$user_obj->getLogin();
00423                         sendInfo($message);
00424                 }
00425                 
00426                 $this->tpl->setVariable("FORMACTION","chat.php?cmd=gateway&ref_id=".
00427                                                                 $this->object->getRefId()."&room_id=".
00428                                                                 $_REQUEST["room_id"]."&p_id=".$_GET["p_id"]);
00429 
00430                 $this->tpl->setVariable("TXT_COLOR",$this->lng->txt("chat_color"));
00431                 $this->tpl->setVariable("TXT_TYPE",$this->lng->txt("chat_type"));
00432                 $this->tpl->setVariable("TXT_FACE",$this->lng->txt("chat_face"));
00433                 $this->tpl->setVariable("TXT_INPUT",$this->lng->txt("chat_input"));
00434 
00435                 if($_GET["p_id"])
00436                 {
00437                         $this->tpl->setCurrentBlock("whisper");
00438                         $this->tpl->setVariable("TXT_SUBMIT_CANCEL",$this->lng->txt("cancel"));
00439                         $this->tpl->parseCurrentBlock();
00440                         $this->tpl->setVariable("TXT_SUBMIT_OK",$this->lng->txt("ok"));
00441                 }
00442                 else
00443                 {
00444                         $this->tpl->setVariable("TXT_SUBMIT_OK",$this->lng->txt("ok"));
00445                 }
00446                 $this->tpl->setVariable("SELECT_COLOR",$this->__getColorSelect());
00447                 $this->tpl->setVariable("RADIO_TYPE",$this->__getFontType());
00448                 $this->tpl->setVariable("CHECK_FACE",$this->__getFontFace());
00449 
00450 
00451         }
00452         function showRightFrame()
00453         {
00454                 $this->__loadStylesheet();
00455                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_right_frame.html",true);
00456         }
00457 
00458         function cancel()
00459         {
00460                 unset($_GET["p_id"]);
00461 
00462                 $this->showInputFrame();
00463         }
00464 
00465 
00466         function input()
00467         {
00468                 if(!$_POST["message"])
00469                 {
00470                         sendInfo($this->lng->txt("chat_insert_message"),true);
00471                 }
00472                 if($_POST["message"] and $this->object->chat_room->checkWriteAccess())
00473                 {
00474                         // FORMAT MESSAGE
00475                         $message = $this->__formatMessage();
00476                         
00477                         // SET MESSAGE AND SEND IT
00478                         $this->object->server_comm->setMessage($message);
00479                         if((int) $_GET["p_id"])
00480                         {
00481                                 $this->object->server_comm->setType('private');
00482                         }
00483                         if(!$this->object->server_comm->send())
00484                         {
00485                                 $this->error = $this->lng->txt("chat_no_connection");
00486                         }
00487                 }
00488                 $this->showInputFrame();
00489         }
00490 
00491         function invite()
00492         {
00493                 if($_GET["i_id"])
00494                 {
00495                         $this->object->chat_room->invite((int) $_GET["i_id"]);
00496                         $this->object->sendMessage((int) $_GET["i_id"]);
00497                         sendInfo($this->lng->txt("chat_user_invited"),true);
00498                         $this->showFrames();
00499                 }
00500         }
00501         function drop()
00502         {
00503                 if($_GET["i_id"])
00504                 {
00505                         $this->object->chat_room->drop((int) $_GET["i_id"]);
00506 
00507                         $tmp_user =& new ilObjUser($_GET["i_id"]);
00508                         $this->object->server_comm->setKickedUser($tmp_user->getLogin());
00509                         $this->object->server_comm->setType("kick");
00510                         $this->object->server_comm->send();
00511                         sendInfo($this->lng->txt("chat_user_dropped"),true);
00512                         $this->showFrames();
00513                 }
00514         }
00515         function closeFrame()
00516         {
00517                 $this->__loadStylesheet(true);
00518                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_close.html",true);
00519                 sendInfo("Your session is expired please login to ILIAS.");
00520                 $this->tpl->touchBlock("content");
00521         }
00522 
00523         function export()
00524         {
00525                 $tmp_tpl =& new ilTemplate("tpl.chat_export.html",true,true,true);
00526 
00527                 if($this->object->chat_room->getRoomId())
00528                 {
00529                         $tmp_tpl->setVariable("CHAT_NAME",$this->object->chat_room->getTitle());
00530                 }
00531                 else
00532                 {
00533                         $tmp_tpl->setVariable("CHAT_NAME",$this->object->getTitle());
00534                 }
00535                 $tmp_tpl->setVariable("CHAT_DATE",strftime("%c",time()));
00536                 $tmp_tpl->setVariable("CONTENT",$this->object->chat_room->getAllMessages());
00537                 ilUtil::deliverData($tmp_tpl->get(),"1.html");
00538                 exit;
00539         }
00540 
00541         // PRIVATE
00542         function __showOnlineUsers()
00543         {
00544                 $users = $this->object->chat_room->getOnlineUsers();
00545                 if(count($users) <= 1)
00546                 {
00547                         $this->tpl->setCurrentBlock("no_actice");
00548                         $this->tpl->setVariable("NO_ONLINE_USERS",$this->lng->txt("chat_no_active_users"));
00549                         $this->tpl->parseCurrentBlock();
00550                 }
00551                 else
00552                 {
00553                         $counter = 0;
00554                         foreach($users as $user)
00555                         {
00556                                 if($user["user_id"] == $_SESSION["AccountId"])
00557                                 {
00558                                         continue;
00559                                 }
00560                                 if(!($counter%2))
00561                                 {
00562                                         $this->tpl->touchBlock("online_row_start");
00563                                 }
00564                                 else
00565                                 {
00566                                         $this->tpl->touchBlock("online_row_end");
00567                                 }
00568 
00569                                 $this->tpl->setCurrentBlock("online");
00570                                 $this->tpl->setVariable("ONLINE_FONT_A",$_GET["p_id"] == $user["user_id"] ? "smallred" : "small");
00571                                 
00572                                 if($this->object->chat_room->isInvited($user["user_id"]))
00573                                 {
00574                                         $img = "minus.gif";
00575                                         $cmd = "drop";
00576                                 }
00577                                 else
00578                                 {
00579                                         $img = "plus.gif";
00580                                         $cmd = "invite";
00581                                 }
00582                                 $this->tpl->setVariable("ONLINE_LINK_A","chat.php?cmd=".$cmd.
00583                                                                                 "&ref_id=".$this->ref_id."&room_id=".
00584                                                                                 $_REQUEST["room_id"]."&i_id=".$user["user_id"]);
00585                                 $this->tpl->setVariable("TXT_INVITE_USER",$cmd == "invite" ? $this->lng->txt("chat_invite_user") :
00586                                         $this->lng->txt("chat_drop_user"));
00587                                 $this->tpl->setVariable("ONLINE_USER_NAME_A",$user["login"]);
00588                                 $this->tpl->setVariable("INVITE_IMG_SRC",ilUtil::getImagePath($img,true));
00589                                 
00590                                 $this->tpl->parseCurrentBlock();
00591                                 $counter++;
00592                         }
00593                 }
00594                 $this->tpl->setCurrentBlock("show_online");
00595                 $this->tpl->setVariable("ONLINE_USERS",$this->lng->txt("chat_online_users"));
00596                 $this->tpl->parseCurrentBlock();
00597         }
00598         function __showActiveUsers()
00599         {
00600                 if(isset($_GET["a_users"]))
00601                 {
00602                         if($_GET["a_users"])
00603                         {
00604                                 $_SESSION["a_users"] = true;
00605                         }
00606                         else
00607                         {
00608                                 $_SESSION["a_users"] = 0;
00609                                 unset($_SESSION["a_users"]);
00610                         }
00611                 }
00612 
00613                 $hide = $_SESSION["a_users"] ? true : false;
00614 
00615                 $this->tpl->setVariable("ACTIVE_USERS",$this->lng->txt("chat_active_users"));
00616                 $this->tpl->setVariable("DETAILS_B_TXT",$hide ? $this->lng->txt("chat_show_details") : $this->lng->txt("chat_hide_details"));
00617                 $this->tpl->setVariable("DETAILS_B","chat.php?ref_id=".$this->object->getRefId().
00618                                                                 "&room_id=".$this->object->chat_room->getRoomId().
00619                                                                 "&a_users=".($hide ? 0 : 1)."&cmd=showUserFrame");
00620 
00621                 if($hide)
00622                 {
00623                         return true;
00624                 }
00625                 $users = $this->object->chat_room->getActiveUsers();
00626                 if(count($users) <= 1)
00627                 {
00628                         $this->tpl->setCurrentBlock("no_actice");
00629                         $this->tpl->setVariable("NO_ACTIVE_USERS",$this->lng->txt("chat_no_active_users"));
00630                         $this->tpl->parseCurrentBlock();
00631                 }
00632                 else
00633                 {
00634                         $user_obj =& new ilObjUser();
00635                         $counter = 0;
00636                         foreach($users as $user)
00637                         {
00638                                 if($user == $_SESSION["AccountId"])
00639                                 {
00640                                         continue;
00641                                 }
00642                                 if(!($counter%2))
00643                                 {
00644                                         $this->tpl->touchBlock("active_row_start");
00645                                 }
00646                                 else
00647                                 {
00648                                         $this->tpl->touchBlock("active_row_end");
00649                                 }
00650                                 $user_obj->setId($user);
00651                                 $user_obj->read();
00652 
00653                                 $this->tpl->setCurrentBlock("active");
00654                                 $this->tpl->setVariable("ACTIVE_FONT_A",$_GET["p_id"] == $user ? "smallred" : "small");
00655                                 $this->tpl->setVariable("ACTIVE_LINK_A","chat.php?cmd=showInputFrame&".
00656                                                                                 "ref_id=".$this->ref_id."&room_id=".
00657                                                                                 $_REQUEST["room_id"]."&p_id=".$user);
00658                                 $this->tpl->setVariable("ACTIVE_USER_NAME_A",$user_obj->getLogin());
00659                                 $this->tpl->parseCurrentBlock();
00660                                 $counter++;
00661                         }
00662                 }
00663         }
00664         function __showAdminAddRoomSelect()
00665         {
00666                 $opt = array("createRoom" => $this->lng->txt("chat_room_select"));
00667 
00668                 return ilUtil::formSelect("","action_b",$opt,false,true);
00669         }
00670 
00671         function __showAdminRoomSelect()
00672         {
00673                 if(count($this->object->chat_room->getRoomsOfObject()))
00674                 {
00675                         $opt = array("renameRoom" => $this->lng->txt("rename"),
00676                                                  "refreshRoom" => $this->lng->txt("chat_refresh"),
00677                                                  "exportRoom" => $this->lng->txt("chat_html_export"),
00678                                                  "deleteRoom" => $this->lng->txt("delete"));
00679                 }
00680                 else
00681                 {
00682                         $opt = array("exportRoom" => $this->lng->txt("chat_html_export"));
00683                 }
00684                 if(!$this->object->server_comm->isAlive() or !$this->ilias->getSetting("chat_active"))
00685                 {
00686                         unset($opt["refreshRoom"]);
00687                 }
00688                 return ilUtil::formSelect(isset($_SESSION["room_id_delete"]) ? "deleteRoom" : "",
00689                                                                   "action",
00690                                                                   $opt,
00691                                                                   false,
00692                                                                   true);
00693         }
00694 
00695         function __showRooms()
00696         {
00697                 $public_rooms = $this->object->chat_room->getAllRooms();
00698                 $private_rooms = $this->object->chat_room->getRooms();
00699 
00700                 if(isset($_GET["h_rooms"]))
00701                 {
00702                         if($_GET["h_rooms"])
00703                         {
00704                                 $_SESSION["h_rooms"] = true;
00705                         }
00706                         else
00707                         {
00708                                 $_SESSION["h_rooms"] = 0;
00709                                 unset($_SESSION["h_rooms"]);
00710                         }
00711                 }
00712                 $hide = $_SESSION["h_rooms"] ? true : false;
00713 
00714                 $this->tpl->setVariable("ROOMS_ROOMS",$this->lng->txt("chat_rooms"));
00715                 $this->tpl->setVariable("DETAILS_TXT",$hide ? $this->lng->txt("chat_show_details") : $this->lng->txt("chat_hide_details"));
00716                 $this->tpl->setVariable("ROOMS_COUNT",count($public_rooms) + count($private_rooms));
00717                 $this->tpl->setVariable("DETAILS_A","chat.php?ref_id=".$this->object->getRefId().
00718                                                                 "&room_id=".$this->object->chat_room->getRoomId().
00719                                                                 "&h_rooms=".($hide ? 0 : 1)."&cmd=showUserFrame");
00720 
00721                 if($hide)
00722                 {
00723                         return true;
00724                 }
00725 
00726                 $counter = 0;
00727                 foreach($public_rooms as $room)
00728                 {
00729                         $this->tpl->setCurrentBlock("room_row");
00730                         $this->tpl->setVariable("ROOM_ROW_CSS",++$counter%2 ? "tblrow1" : "tblrow2");
00731                         $this->tpl->setVariable("ROOM_LINK","chat.php?ref_id=".$room["child"]);
00732                         $this->tpl->setVariable("ROOM_TARGET","_top");
00733                         $this->tpl->setVariable("ROOM_NAME",$room["title"]);
00734                         $this->tpl->setVariable("ROOM_ONLINE",$this->object->chat_room->getCountActiveUser($room["child"],0));
00735                         $this->tpl->parseCurrentBlock();
00736                 }
00737 
00738                 foreach($private_rooms as $room)
00739                 {
00740                         $this->tpl->setCurrentBlock("room_row");
00741                         $this->tpl->setVariable("ROOM_ROW_CSS",++$counter%2 ? "tblrow1" : "tblrow2");
00742                         $this->tpl->setVariable("ROOM_LINK","chat.php?ref_id=".$room["chat_id"].
00743                                                                                                                                                  "&room_id=".$room["room_id"]);
00744                         $this->tpl->setVariable("ROOM_TARGET","_top");
00745                         $this->tpl->setVariable("ROOM_NAME",$room["title"]);
00746                         $this->tpl->setVariable("ROOM_ONLINE",$this->object->chat_room->getCountActiveUser($room["chat_id"],$room["room_id"]));
00747                         $this->tpl->parseCurrentBlock();
00748                 }
00749 
00750         }
00751         function __loadStylesheet($expires = false)
00752         {
00753                 $this->tpl->setCurrentBlock("ChatStyle");
00754                 $this->tpl->setVariable("LOCATION_CHAT_STYLESHEET",ilUtil::getStyleSheetLocation());
00755                 if($expires)
00756                 {
00757                         $this->tpl->setVariable("EXPIRES","<meta http-equiv=\"expires\" content=\"now\">".
00758                                                                         "<meta http-equiv=\"refresh\" content=\"30\">");
00759                 }
00760                 $this->tpl->parseCurrentBlock();
00761         }
00762 
00763         function __getColorSelect()
00764         {
00765                 $colors = array("black" => $this->lng->txt("chat_black"),
00766                                                 "red" => $this->lng->txt("chat_red"),
00767                                                 "green" => $this->lng->txt("chat_green"),
00768                                                 "maroon" => $this->lng->txt("chat_maroon"),
00769                                                 "olive" => $this->lng->txt("chat_olive"),
00770                                                 "navy" => $this->lng->txt("chat_navy"),
00771                                                 "purple" => $this->lng->txt("chat_purple"),
00772                                                 "teal" => $this->lng->txt("chat_teal"),
00773                                                 "silver" => $this->lng->txt("chat_silver"),
00774                                                 "gray" => $this->lng->txt("chat_gray"),
00775                                                 "lime" => $this->lng->txt("chat_lime"),
00776                                                 "yellow" => $this->lng->txt("chat_yellow"),
00777                                                 "fuchsia" => $this->lng->txt("chat_fuchsia"),
00778                                                 "aqua" => $this->lng->txt("chat_aqua"),
00779                                                 "blue" => $this->lng->txt("chat_blue"));
00780 
00781                 return ilUtil::formSelect($_POST["color"],"color",$colors,false,true);
00782         }
00783 
00784         function __getFontType()
00785         {
00786                 $types = array("times" => $this->lng->txt("chat_times"),
00787                                            "tahoma" => $this->lng->txt("chat_tahoma"),
00788                                            "arial" => $this->lng->txt("chat_arial"));
00789 
00790                 $_POST["type"] = $_POST["type"] ? $_POST["type"] : "times";
00791 
00792                 foreach($types as $name => $type)
00793                 {
00794                         $this->tpl->setCurrentBlock("FONT_TYPES");
00795                         $this->tpl->setVariable("BL_TXT_TYPE",$type);
00796                         $this->tpl->setVariable("FONT_TYPE",$name);
00797                         $this->tpl->setVariable("TYPE_CHECKED",$_POST["type"] == $name ? "checked=\"checked\"" : "");
00798                         $this->tpl->parseCurrentBlock();
00799                 }
00800         }
00801 
00802         function __getFontFace()
00803         {
00804                 $_POST["face"] = is_array($_POST["face"]) ? $_POST["face"] : array();
00805 
00806                 $types = array("bold" => $this->lng->txt("chat_bold"),
00807                                            "italic" => $this->lng->txt("chat_italic"),
00808                                            "underlined" => $this->lng->txt("chat_underlined"));
00809 
00810                 $this->tpl->setCurrentBlock("FONT_FACES");
00811                 $this->tpl->setVariable("BL_TXT_FACE","<b>".$this->lng->txt("chat_bold")."</b>");
00812                 $this->tpl->setVariable("FONT_FACE","bold");
00813                 $this->tpl->setVariable("FACE_CHECKED",in_array("bold",$_POST["face"]) ? "checked=\"checked\"" : "");
00814                 $this->tpl->parseCurrentBlock();
00815 
00816                 $this->tpl->setCurrentBlock("FONT_FACES");
00817                 $this->tpl->setVariable("BL_TXT_FACE","<i>".$this->lng->txt("chat_italic")."</i>");
00818                 $this->tpl->setVariable("FONT_FACE","italic");
00819                 $this->tpl->setVariable("FACE_CHECKED",in_array("italic",$_POST["face"]) ? "checked=\"checked\"" : "");
00820                 $this->tpl->parseCurrentBlock();
00821 
00822                 $this->tpl->setCurrentBlock("FONT_FACES");
00823                 $this->tpl->setVariable("BL_TXT_FACE","<u>".$this->lng->txt("chat_underlined")."</u>");
00824                 $this->tpl->setVariable("FONT_FACE","underlined");
00825                 $this->tpl->setVariable("FACE_CHECKED",in_array("underlined",$_POST["face"]) ? "checked=\"checked\"" : "");
00826                 $this->tpl->parseCurrentBlock();
00827         }
00828 
00829         function __formatMessage()
00830         {
00831                 $tpl = new ilTemplate("tpl.chat_message.html",true,true,true);
00832 
00833                 $_POST['message'] = htmlentities(trim($_POST['message']),ENT_COMPAT,'utf-8');
00834 
00835                 $tpl->setVariable("MESSAGE",$_POST["message"]);
00836                 $tpl->setVariable("FONT_COLOR",$_POST["color"]);
00837                 $tpl->setVariable("FONT_FACE",$_POST["type"]);
00838 
00839                 if($_GET["p_id"])
00840                 {
00841                         $user_obj =& new ilObjUser((int) $_SESSION["AccountId"]);
00842                         $user_obj->read();
00843 
00844                         $tpl->setCurrentBlock("private");
00845                         $tpl->setVariable("PRIVATE_U_COLOR","red");
00846                         $tpl->setVariable("PRIVATE_FROM",$user_obj->getLogin());
00847 
00848                         $user_obj =& new ilObjUser((int) $_GET["p_id"]);
00849                         $user_obj->read();
00850                         $tpl->setVariable("PRIVATE_TO",$user_obj->getLogin());
00851                         $tpl->parseCurrentBlock();
00852                 }
00853                 else
00854                 {
00855                         $tpl->setCurrentBlock("normal");
00856                         $tpl->setVariable("NORMAL_U_COLOR","navy");
00857                         $tpl->setVariable("NORMAL_UNAME",$this->object->chat_user->getLogin());
00858                         $tpl->parseCurrentBlock();
00859                 }
00860                 // OPEN TAGS
00861                 if($_POST["face"])
00862                 {
00863                         foreach($_POST["face"] as $face)
00864                         {
00865                                 $tpl->setCurrentBlock("type_open");
00866                                 switch($face)
00867                                 {
00868                                         case "bold":
00869                                                 $tpl->setVariable("TYPE_TYPE_O","b");
00870                                                 break;
00871                                         case "italic":
00872                                                 $tpl->setVariable("TYPE_TYPE_O","i");
00873                                                 break;
00874 
00875                                         case "underlined":
00876                                                 $tpl->setVariable("TYPE_TYPE_O","u");
00877                                                 break;
00878                                 }
00879                                 $tpl->parseCurrentBlock();
00880                         }
00881                         $_POST["face"] = array_reverse($_POST["face"]);
00882                         foreach($_POST["face"] as $face)
00883                         {
00884                                 $tpl->setCurrentBlock("type_close");
00885                                 switch($face)
00886                                 {
00887                                         case "bold":
00888                                                 $tpl->setVariable("TYPE_TYPE_C","b");
00889                                                 break;
00890                                         case "italic":
00891                                                 $tpl->setVariable("TYPE_TYPE_C","i");
00892                                                 break;
00893 
00894                                         case "underlined":
00895                                                 $tpl->setVariable("TYPE_TYPE_C","u");
00896                                                 break;
00897                                 }
00898                                 $tpl->parseCurrentBlock();
00899                         }
00900                 }
00901 
00902                 $message = preg_replace("/\r/","",$tpl->get());
00903                 $message = preg_replace("/\n/","",$message);
00904 
00905                 return $message;
00906         }
00907         function __exportRooms()
00908         {
00909                 include_once "chat/classes/class.ilFileDataChat.php";
00910 
00911                 if(count($_POST["del_id"]) == 1)
00912                 {
00913                         $this->object->chat_room->setRoomId($_POST["del_id"][0]);
00914                         $this->export();
00915                 }
00916 
00917                 $file_obj =& new ilFileDataChat($this->object);
00918 
00919                 foreach($_POST["del_id"] as $id)
00920                 {
00921                         $this->object->chat_room->setRoomId((int) $id);
00922 
00923                         $tmp_tpl =& new ilTemplate("tpl.chat_export.html",true,true,true);
00924                         
00925                         if($id)
00926                         {
00927                                 $tmp_tpl->setVariable("CHAT_NAME",$this->object->chat_room->getTitle());
00928                         }
00929                         else
00930                         {
00931                                 $tmp_tpl->setVariable("CHAT_NAME",$this->object->getTitle());
00932                         }
00933                         $tmp_tpl->setVariable("CHAT_DATE",strftime("%c",time()));
00934                         $tmp_tpl->setVariable("CONTENT",$this->object->chat_room->getAllMessages());
00935 
00936                         $file_obj->addFile("chat_".$this->object->chat_room->getRoomId().".html",$tmp_tpl->get());
00937                 }
00938                 $fname = $file_obj->zip();
00939                 ilUtil::deliverFile($fname,"ilias_chat.zip");
00940         }
00941 } // END class.ilObjChatGUI
00942 ?>

Generated on Fri Dec 13 2013 09:06:33 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1