• 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 require_once "chat/classes/class.ilChatRecording.php";
00037 
00038 class ilObjChatGUI extends ilObjectGUI
00039 {
00040         var $target_script = "adm_object.php";
00041         var $in_module = false;
00042 
00047         function ilObjChatGUI($a_data,$a_id,$a_call_by_reference = true, $a_prepare_output = true)
00048         {
00049                 global $ilCtrl;
00050 
00051                 #define("ILIAS_MODULE","chat");
00052                 
00053                 $this->type = "chat";
00054                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output);
00055 
00056                 $this->ctrl =& $ilCtrl;
00057                 $this->ctrl->saveParameter($this,array("ref_id","cmdClass"));
00058 
00059 
00060                 if(is_object($this->object->chat_user))
00061                 {
00062                         $this->object->chat_user->setUserId($_SESSION["AccountId"]);
00063                 }
00064         }
00065 
00066         function &executeCommand()
00067         {
00068                 global $rbacsystem;
00069 
00070                 if($this->ctrl->getTargetScript() == 'chat.php')
00071                 {
00072                         $this->__prepareOutput();
00073                 }
00074 
00075                 $next_class = $this->ctrl->getNextClass($this);
00076 
00077                 $cmd = $this->ctrl->getCmd();
00078                 switch($next_class)
00079                 {
00080 
00081                         default:
00082                                 if(!$cmd)
00083                                 {
00084                                         $cmd = "view";
00085                                 }
00086                                 $cmd .= "Object";
00087                                 $this->$cmd();
00088                                         
00089                                 break;
00090                 }
00091                 return true;
00092         }
00093 
00094         function setTargetScript($a_script)
00095         {
00096                 $this->target_script = $a_script;
00097         }
00098         function getTargetScript($a_params)
00099         {
00100                 return $this->target_script."?".$a_params;
00101         }
00102         function setInModule($in_module)
00103         {
00104                 $this->in_module = $in_module;
00105         }
00106         function inModule()
00107         {
00108                 return $this->in_module;
00109         }
00110 
00111         function saveObject()
00112         {
00113                 global $ilUser,$rbacadmin;
00114 
00115                 $new_obj =& parent::saveObject();
00116                 
00117                 // Add new moderator role
00118                 $roles = $new_obj->initDefaultRoles();
00119 
00120                 // Assign current user.
00121                 $rbacadmin->assignUser($roles[0],$ilUser->getId());
00122                 
00123                 // Update active roles
00124                 ilObjUser::updateActiveRoles($ilUser->getId());
00125 
00126                 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?ref_id=".$new_obj->getRefId()));
00127         }
00128 
00129         // Methods for blocked users (administration)
00130         function blockedUsersObject()
00131         {
00132                 include_once 'chat/classes/class.ilChatBlockedUsers.php';
00133 
00134                 global $rbacsystem;
00135 
00136                 if(!$rbacsystem->checkAccess('chat_moderate',$this->object->getRefId()))
00137                 {
00138                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00139                 }
00140 
00141                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chat_blocked_users.html","chat");
00142                 $blocked_obj = new ilChatBlockedUsers($this->object->getId());
00143 
00144                 if(!count($blocked = $blocked_obj->getBlockedUsers()))
00145                 {
00146                         $this->tpl->setVariable("MESSAGE_NO_BLOCKED",$this->lng->txt('chat_no_blocked'));
00147                 }
00148                 else
00149                 {
00150                         $this->tpl->setCurrentBlock("delete_blocked");
00151                         $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('chat_blocked_unlocked'));
00152                         $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00153                         $this->tpl->parseCurrentBlock();
00154                 }
00155 
00156                 foreach($blocked as $usr_id)
00157                 {
00158                         $tmp_user =& new ilObjUser($usr_id);
00159 
00160                         $this->tpl->setCurrentBlock("blocked_users");
00161                         $this->tpl->setVariable("FULLNAME",$tmp_user->getFullname());
00162                         $this->tpl->setVariable("LOGIN",$tmp_user->getLogin());
00163                         $this->tpl->setVariable("BLOCK_CHECK",ilUtil::formCheckbox(0,'blocked_check[]',$tmp_user->getId()));
00164                         $this->tpl->parseCurrentBlock();
00165                 }
00166 
00167                 // Fill table
00168                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00169                 $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath('icon_usr_b.gif'));
00170                 $this->tpl->setVariable("TBL_TITLE_IMG_ALT",$this->lng->txt('chat_blocked_users'));
00171                 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('chat_blocked_users'));
00172                 $this->tpl->setVariable("HEADER_NAME",$this->lng->txt('chat_user_name'));
00173 
00174                 $this->tpl->setVariable("BTN_BLOCK",$this->lng->txt('chat_block_user'));
00175                 
00176         }
00177 
00178         function blockUserObject()
00179         {
00180                 include_once 'chat/classes/class.ilChatBlockedUsers.php';
00181 
00182                 global $rbacsystem;
00183 
00184                 if(!$rbacsystem->checkAccess('chat_moderate',$this->object->getRefId()))
00185                 {
00186                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00187                 }
00188 
00189                 $blocked_obj = new ilChatBlockedUsers($this->object->getId());
00190 
00191                 if(!$_POST['block'] or !($usr_id = ilObjUser::getUserIdByLogin($_POST['block'])))
00192                 {
00193                         sendInfo($this->lng->txt('chat_enter_valid_username'));
00194                         $this->blockedUsersObject();
00195 
00196                         return false;
00197                 }
00198                 if($blocked_obj->isBlocked($usr_id))
00199                 {
00200                         sendInfo($this->lng->txt('chat_user_already_blocked'));
00201                         $this->blockedUsersObject();
00202 
00203                         return false;
00204                 }                       
00205 
00206                 $blocked_obj->block($usr_id);
00207                 sendInfo($this->lng->txt('chat_user_blocked'));
00208                 $this->blockedUsersObject();
00209 
00210                 return true;
00211                 
00212         }
00213 
00214         function unblockUsersObject()
00215         {
00216                 include_once 'chat/classes/class.ilChatBlockedUsers.php';
00217 
00218                 global $rbacsystem;
00219 
00220                 if(!$rbacsystem->checkAccess('chat_moderate',$this->object->getRefId()))
00221                 {
00222                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00223                 }
00224 
00225                 $blocked_obj = new ilChatBlockedUsers($this->object->getId());
00226                 
00227                 if(!is_array($_POST['blocked_check']))
00228                 {
00229                         sendInfo($this->lng->txt('chat_no_users_selected'));
00230 
00231                         return $this->blockedUsersObject();
00232                 }
00233 
00234                 foreach($_POST['blocked_check'] as $usr_id)
00235                 {
00236                         $blocked_obj->unblock($usr_id);
00237                 }
00238 
00239                 sendInfo($this->lng->txt('chat_unblocked_user'));
00240                 return $this->blockedUsersObject();
00241         }
00242 
00243 
00244         function kickUser()
00245         {
00246                 global $rbacsystem;
00247 
00248                 if(!$rbacsystem->checkAccess('chat_moderate',$this->object->getRefId()))
00249                 {
00250                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00251                 }
00252 
00253                 if($_GET["kick_id"])
00254                 {
00255                         $tmp_user = new ilObjUser($_GET['kick_id']);
00256 
00257                         $this->object->server_comm->setKickedUser($tmp_user->getLogin());
00258                         $this->object->server_comm->setType("kick");
00259                         $this->object->server_comm->send();
00260 
00261                         $this->object->chat_room->setKicked((int)$_GET['kick_id']);
00262 
00263                         #sendInfo($this->lng->txt("chat_user_dropped"),true);
00264                         $this->showFrames();
00265                 }
00266         }
00267 
00268         function unkickUser()
00269         {
00270                 global $rbacsystem;
00271 
00272                 if(!$rbacsystem->checkAccess('chat_moderate',$this->object->getRefId()))
00273                 {
00274                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00275                 }
00276 
00277                 if($_GET["kick_id"])
00278                 {
00279                         $this->object->chat_room->setUnkicked((int)$_GET['kick_id']);
00280 
00281                         #sendInfo($this->lng->txt("chat_user_dropped"),true);
00282                         $this->showFrames();
00283                 }
00284         }
00285 
00286 
00287 
00288         function cancelObject()
00289         {
00290                 unset($_SESSION["room_id_rename"]);
00291                 unset($_SESSION["room_id_delete"]);
00292                 parent::cancelObject();
00293         }
00294 
00295 
00296         function viewObject()
00297         {
00298                 if($this->ctrl->getTargetScript() == 'adm_object.php')
00299                 {
00300                         return parent::viewObject();
00301                 }
00302 
00303                 // Check blocked
00304                 include_once 'chat/classes/class.ilChatBlockedUsers.php';
00305 
00306 
00307                 global $rbacsystem,$ilUser;
00308 
00309                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00310                 {
00311                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00312                 }
00313                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chat_view.html","chat");
00314 
00315                 // CHAT SERVER NOT ACTIVE
00316                 if(!$this->object->server_comm->isAlive() or !$this->ilias->getSetting("chat_active"))
00317                 {
00318                         sendInfo($this->lng->txt("chat_server_not_active"));
00319                 }
00320                 if(ilChatBlockedUsers::_isBlocked($this->object->getId(),$ilUser->getId()))
00321                 {
00322                         sendInfo($this->lng->txt('chat_access_blocked'));
00323 
00324                         return true;
00325                 }
00326 
00327 
00328                 // DELETE ROOMS CONFIRM
00329                 $checked = array();
00330                 if($_SESSION["room_id_delete"])
00331                 {
00332                         $checked = $_SESSION["room_id_delete"];
00333                         sendInfo($this->lng->txt("chat_delete_sure"));
00334                         $this->tpl->setCurrentBlock("confirm_delete");
00335                         $this->tpl->setVariable("TXT_DELETE_CANCEL",$this->lng->txt("cancel"));
00336                         $this->tpl->setVariable("TXT_DELETE_CONFIRM",$this->lng->txt("delete"));
00337                         $this->tpl->parseCurrentBlock();
00338                 }
00339 
00340                 // SHOW ROOMS TABLE
00341                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_chat.gif'));
00342                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_chat'));
00343                 $this->tpl->setVariable("TITLE",$this->lng->txt('chat_rooms'));
00344                                                                 
00345 
00346                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00347                 #$this->tpl->setVariable("TXT_CHATROOMS",$this->lng->txt("chat_chatrooms"));
00348 
00349                 $counter = 0;
00350 
00351                 if($rbacsystem->checkAccess('write',$this->ref_id))
00352                 {
00353                         $rooms = $this->object->chat_room->getAllRoomsOfObject();
00354                 }
00355                 else
00356                 {
00357                         $this->object->chat_room->setOwnerId($_SESSION["AccountId"]);
00358                         $rooms = $this->object->chat_room->getRoomsOfObject();
00359                 }
00360 
00361 
00362 
00363                 $script = $this->inModule() ? "./chat.php" : "./chat/chat.php";
00364 
00365                 // ADD PUBLIC ROOM
00366                 // CHAT SERVER  ACTIVE
00367                 
00368 
00369                 if(ilChatBlockedUsers::_isBlocked($this->object->getId(),$ilUser->getId()))
00370                 {
00371                         $this->tpl->setCurrentBlock("blocked");
00372                         $this->tpl->setVariable("MESSAGE_BLOCKED",$this->lng->txt('chat_blocked'));
00373                         $this->tpl->parseCurrentBlock();
00374                 }
00375                 elseif($this->object->server_comm->isAlive() and $this->ilias->getSetting("chat_active"))
00376                 {
00377                         $this->tpl->setCurrentBlock("active");
00378                         $this->tpl->setVariable("ROOM_LINK",$script."?ref_id=".$this->ref_id."&room_id=0");
00379                         $this->tpl->setVariable("ROOM_TARGET","_blank");
00380                         $this->tpl->setVariable("ROOM_TXT_LINK",$this->lng->txt("show"));
00381                         $this->tpl->parseCurrentBlock();
00382                 }
00383                 else
00384                 {
00385                         $this->tpl->touchBlock("not_active");
00386                 }
00387                 $this->tpl->setCurrentBlock("tbl_rooms_row");
00388                 $this->tpl->setVariable("ROWCOL",++$counter % 2 ? "tblrow1" : "tblrow2");
00389                 $this->tpl->setVariable("ROOM_CHECK",
00390                                                                 ilUtil::formCheckbox(in_array(0,$checked) ? 1 : 0,
00391                                                                                                          "del_id[]",
00392                                                                                                          0));
00393                 $this->tpl->setVariable("ROOM_NAME",$this->object->getTitle()." ".$this->lng->txt("chat_public_room"));
00394                 $this->tpl->parseCurrentBlock();
00395 
00396                 $script = $this->inModule() ? "./chat.php" : "./chat/chat.php";
00397 
00398 
00399 
00400                 foreach($rooms as $room)
00401                 {
00402                         // CHAT SERVER  ACTIVE
00403                         if($this->object->server_comm->isAlive() and $this->ilias->getSetting("chat_active"))
00404                         {
00405                                 $this->tpl->setCurrentBlock("active");
00406                                 $this->tpl->setVariable("ROOM_LINK",$script."?ref_id=".$this->ref_id."&room_id=".$room["room_id"]);
00407                                 $this->tpl->setVariable("ROOM_TARGET","_blank");
00408                                 $this->tpl->setVariable("ROOM_TXT_LINK",$this->lng->txt("show"));
00409                                 $this->tpl->parseCurrentBlock();
00410                         }
00411                         else
00412                         {
00413                                 $this->tpl->touchBlock("not_active");
00414                         }
00415                         $this->tpl->setCurrentBlock("tbl_rooms_row");
00416                         $this->tpl->setVariable("ROWCOL",++$counter % 2 ? "tblrow1" : "tblrow2");
00417                         $this->tpl->setVariable("ROOM_CHECK",
00418                                                                         ilUtil::formCheckbox(in_array($room["room_id"],$checked) ? 1 : 0,
00419                                                                         "del_id[]",
00420                                                                         $room["room_id"]));
00421 
00422                         $this->tpl->setVariable("ROOM_NAME",$room["title"]);
00423                         $this->tpl->parseCurrentBlock();
00424                 }
00425                 $this->tpl->setCurrentBlock("has_rooms");
00426                 $this->tpl->setVariable("TBL_FOOTER_IMG_SRC", ilUtil::getImagePath("arrow_downright.gif"));
00427                 $this->tpl->setVariable("TBL_FOOTER_SELECT",$this->__showAdminRoomSelect(count($rooms)));
00428                 $this->tpl->setVariable("FOOTER_HAS_ROOMS_OK",$this->lng->txt("ok"));
00429                 $this->tpl->parseCurrentBlock();
00430                 $this->tpl->setVariable("TBL_FOOTER_ADD_SELECT",$this->__showAdminAddRoomSelect());
00431                 $this->tpl->setVariable("FOOTER_OK",$this->lng->txt("add"));
00432         }
00433 
00434         function adminRoomsObject()
00435         {
00436                 global $rbacsystem;
00437 
00438                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00439                 {
00440                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00441                 }
00442                 
00443                 if(!isset($_POST["del_id"]))
00444                 {
00445                         sendInfo($this->lng->txt("chat_select_one_room"));
00446                         $this->viewObject();
00447                         
00448                         return false;
00449                 }
00450 
00451                 switch($_POST["action"])
00452                 {
00453                         case "renameRoom":
00454                                 if(count($_POST["del_id"]) > 1)
00455                                 {
00456                                         sendInfo($this->lng->txt("chat_select_one_room"));
00457                                         $this->viewObject();
00458 
00459                                         return false;
00460                                 }
00461                                 if(in_array(0,$_POST["del_id"]))
00462                                 {
00463                                         sendInfo($this->lng->txt("chat_no_rename_public"));
00464                                         $this->viewObject();
00465 
00466                                         return false;
00467                                 }
00468 
00469                                 // STORE ID IN SESSION
00470                                 $_SESSION["room_id_rename"] = (int) $_POST["del_id"][0];
00471 
00472                                 $room =& new ilChatRoom($this->ref_id);
00473                                 $room->setRoomId($_SESSION["room_id_rename"]);
00474 
00475                                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chat_edit_room.html","chat");
00476                                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00477                                 $this->tpl->setVariable("TXT_ROOM_NAME",$this->lng->txt("chat_room_name"));
00478                                 $this->tpl->setVariable("ROOM_CANCEL",$this->lng->txt("cancel"));
00479                                 $this->tpl->setVariable("TXT_EDIT_CHATROOMS",$this->lng->txt("chat_chatroom_rename"));
00480                                 $this->tpl->setVariable("ROOM_NAME",$room->getTitle());
00481                                 $this->tpl->setVariable("CMD","renameRoom");
00482                                 $this->tpl->setVariable("ROOM_EDIT",$this->lng->txt("rename"));
00483                                 break;
00484 
00485                         case "deleteRoom":
00486                                 if(in_array(0,$_POST["del_id"]))
00487                                 {
00488                                         sendInfo($this->lng->txt("chat_no_delete_public"));
00489                                         $this->viewObject();
00490 
00491                                         return false;
00492                                 }
00493                                 $_SESSION["room_id_delete"] = $_POST["del_id"];
00494                                 $this->viewObject();
00495 
00496                                 return true;
00497 
00498 
00499                         case "exportRoom":
00500                                 $this->__exportRooms();
00501                                 break;
00502 
00503                         case "refreshRoom":
00504                                 if(in_array(0,$_POST["del_id"]) and !$rbacsystem->checkAccess('write',$this->object->getRefId()))
00505                                 {
00506                                         sendInfo($this->lng->txt("chat_no_refresh_public"));
00507                                         $this->viewObject();
00508 
00509                                         return true;
00510                                 }
00511                                 foreach($_POST["del_id"] as $room_id)
00512                                 {
00513                                         $this->object->chat_room->setRoomId($room_id);
00514                                         $this->object->server_comm->setType("delete");
00515                                         $this->object->server_comm->send();
00516                                         $this->object->chat_room->deleteAllMessages();
00517                                 }
00518                                 sendInfo($this->lng->txt('chat_refreshed'));
00519                                 $this->viewObject();
00520 
00521                                 return true;
00522                 }       
00523                 
00524         }
00525 
00526         function emptyRoom()
00527         {
00528                 global  $rbacsystem;
00529 
00530                 if ($rbacsystem->checkAccess("moderate", $this->object->getRefId()) &&
00531                         $this->object->chat_room->checkWriteAccess())
00532                 {
00533                         $this->object->server_comm->setType('delete');
00534                         $message = $this->__formatMessage();
00535                         $this->object->server_comm->setMessage($message);
00536                         $this->object->server_comm->send();
00537 
00538                         $this->object->chat_room->deleteAllMessages();
00539                 }
00540                 unset($_GET["room_id_empty"]);
00541                 $this->showFrames();
00542         }
00543 
00544         function deleteRoom()
00545         {
00546                 global $rbacsystem;
00547 
00548                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00549                 {
00550                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00551                 }
00552                 if(!$_GET["room_id_delete"])
00553                 {
00554                         $this->ilias->raiseError($this->lng->txt("chat_select_one_room"),$this->ilias->error_obj->MESSAGE);
00555                 }
00556                 $this->object->chat_room->setOwnerId($_SESSION["AccountId"]);
00557                 $rooms = array($_GET["room_id_delete"]);
00558                 if (!$rbacsystem->checkAccess("write", $this->ref_id))
00559                 {
00560                         $delResult = $this->object->chat_room->deleteRooms($rooms, $this->object->chat_room->getOwnerId());
00561                 }
00562                 else
00563                 {
00564                         $delResult = $this->object->chat_room->deleteRooms($rooms);
00565                 }
00566                 if(!$delResult)
00567                 {
00568                         $this->ilias->raiseError($this->object->chat_room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
00569                 }
00570                 unset($_GET["room_id_delete"]);
00571                 sendInfo($this->lng->txt("chat_rooms_deleted"),true);
00572                 $this->showFrames();
00573         }
00574 
00575         function confirmedDeleteRoomObject()
00576         {
00577                 global $rbacsystem;
00578 
00579                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00580                 {
00581                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00582                 }
00583                 if(!$_SESSION["room_id_delete"])
00584                 {
00585                         $this->ilias->raiseError($this->lng->txt("chat_select_one_room"),$this->ilias->error_obj->MESSAGE);
00586                 }
00587                 $this->object->chat_room->setOwnerId($_SESSION["AccountId"]);
00588                 if(!$this->object->chat_room->deleteRooms($_SESSION["room_id_delete"]))
00589                 {
00590                         $this->ilias->raiseError($this->object->chat_room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
00591                 }
00592                 unset($_SESSION["room_id_delete"]);
00593                 sendInfo($this->lng->txt("chat_rooms_deleted"));
00594 
00595                 $this->viewObject();
00596                 return true;
00597         }
00598 
00599         function addRoom()
00600         {
00601                 global $rbacsystem;
00602 
00603                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00604                 {
00605                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00606                 }
00607                 $room =& new ilChatRoom($this->ref_id);
00608                 $room->setTitle(ilUtil::stripSlashes($_POST["room_name"]));
00609                 $room->setOwnerId($_SESSION["AccountId"]);
00610 
00611                 if(!$room->validate())
00612                 {
00613                         $this->ilias->raiseError($room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
00614                 }
00615                 $room->add();
00616 
00617                 #$this->input_message = $this->lng->txt('chat_room_added');
00618                 sendInfo($this->lng->txt("chat_room_added"),true);
00619                 $this->showFrames();
00620         }
00621 
00622         function addRoomObject()
00623         {
00624                 global $rbacsystem;
00625 
00626                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00627                 {
00628                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00629                 }
00630                 $room =& new ilChatRoom($this->ref_id);
00631                 $room->setTitle(ilUtil::stripSlashes($_POST["room_name"]));
00632                 $room->setOwnerId($_SESSION["AccountId"]);
00633 
00634                 if(!$room->validate())
00635                 {
00636                         $this->ilias->raiseError($room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
00637                 }
00638                 $room->add();
00639                 sendInfo($this->lng->txt("chat_room_added"));
00640                 $this->viewObject();
00641 
00642                 return true;
00643                 #header("location: ".$this->getTargetScript("cmd=gateway&ref_id=".$this->ref_id));
00644                 #exit;
00645         }
00646 
00647         function renameRoomObject()
00648         {
00649                 global $rbacsystem;
00650 
00651                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00652                 {
00653                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00654                 }
00655                 
00656                 $room =& new ilChatRoom($this->ref_id);
00657                 $room->setRoomId($_SESSION["room_id_rename"]);
00658                 $room->setTitle(ilUtil::stripSlashes($_POST["room_name"]));
00659                 if(!$room->validate())
00660                 {
00661                         $this->ilias->raiseError($room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
00662                 }
00663                 $room->rename();
00664 
00665                 unset($_SESSION["room_id_rename"]);
00666                 sendInfo($this->lng->txt("chat_room_renamed"));
00667                 $this->viewObject();
00668 
00669                 return true;
00670         }               
00671                 
00672 
00673 
00674         function adminAddRoomObject()
00675         {
00676                 global $rbacsystem;
00677 
00678                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00679                 {
00680                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00681                 }
00682                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chat_edit_room.html","chat");
00683                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00684                 $this->tpl->setVariable("TXT_ROOM_NAME",$this->lng->txt("chat_room_name"));
00685                 $this->tpl->setVariable("ROOM_CANCEL",$this->lng->txt("cancel"));
00686         
00687                 $this->tpl->setVariable("TXT_EDIT_CHATROOMS",$this->lng->txt("chat_chatroom_rename"));
00688                 $this->tpl->setVariable("ROOM_NAME","");
00689                 $this->tpl->setVariable("CMD","addRoom");
00690                 $this->tpl->setVariable("ROOM_EDIT",$this->lng->txt("add"));
00691 
00692         }       
00693 
00694         function recordingsObject()
00695         {
00696                 global $rbacsystem;
00697                 
00698                 if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
00699                 {
00700                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00701                 }
00702                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.chat_recordings.html","chat");
00703 
00704                 $this->object->chat_record = new ilChatRecording($this->object->getRefId());
00705                 if (!is_array($data = $this->object->chat_record->getRecordings()))
00706                 {
00707                         sendInfo($this->lng->txt('chat_no_recordings_available'));
00708                         return true;
00709                 }
00710 
00711                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00712                 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('chat_recordings'));
00713                 $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('chat_recording_description'));
00714                 $this->tpl->setVariable("HEADER_MOD",$this->lng->txt('chat_recording_moderator'));
00715                 $this->tpl->setVariable("HEADER_TIME",$this->lng->txt('chat_recording_time_frame'));
00716                 $this->tpl->setVariable("HEADER_ACTION",$this->lng->txt('chat_recording_action'));
00717                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00718                 $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('delete'));
00719 
00720                 $counter = 0;
00721                 for ($i = 0; $i < count($data); $i++)
00722                 {
00723                         $this->tpl->setCurrentBlock("recording_row");
00724                         $this->tpl->setVariable("CHECKBOX", ilUtil::formCheckbox(0,'recordings[]',$data[$i]["record_id"]));
00725                         if($data[$i]["title"] != "")
00726                         {
00727                                 $this->tpl->setVariable("RECORDING_TITLE", $data[$i]["title"]);
00728                         }
00729                         if ($data[$i]["description"] != "")
00730                         {
00731                                 $this->tpl->setVariable("RECORDING_DESCRIPTION", $data[$i]["description"]);
00732                         }
00733                         if (is_array($moderator = $this->object->chat_record->getModerator($data[$i]["moderator_id"])))
00734                         {
00735                                 $this->tpl->setVariable("MODERATOR", $moderator["login"]);
00736                         }
00737                         $this->tpl->setVariable("START_TIME", date("Y-m-d H:i:s", $data[$i]["start_time"]));
00738                         if ($data[$i]["end_time"] > 0)
00739                         {
00740                                 $this->tpl->setVariable("END_TIME", date("Y-m-d H:i:s", $data[$i]["end_time"]));
00741                                 $this->ctrl->setParameter($this,'record_id',$data[$i]["record_id"]);
00742                                 $this->tpl->setVariable("LINK_EXPORT",$this->ctrl->getLinkTarget($this,'exportRecording'));
00743                                 $this->tpl->setVariable("TXT_EXPORT",$this->lng->txt('export'));
00744                         }
00745                         $this->tpl->setVariable("ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
00746                         $this->tpl->parseCurrentBlock();
00747                 }
00748         }
00749 
00750         function askDeleteRecordingsObject()
00751         {
00752                 global $rbacsystem;
00753 
00754                 if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
00755                 {
00756                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00757                 }
00758 
00759                 if(!is_array($_POST['recordings']))
00760                 {
00761                         sendInfo($this->lng->txt('chat_recordings_select_one'));
00762                         $this->recordingsObject();
00763                         
00764                         return false;
00765                 }
00766 
00767                 $this->object->chat_record = new ilChatRecording($this->object->getRefId());
00768 
00769                 sendInfo($this->lng->txt('chat_recordings_delete_sure'));
00770                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.chat_ask_delete_recordings.html","chat");
00771 
00772                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00773                 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('chat_recordings'));
00774                 $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('chat_recording_description'));
00775                 $this->tpl->setVariable("HEADER_MOD",$this->lng->txt('chat_recording_moderator'));
00776                 $this->tpl->setVariable("HEADER_TIME",$this->lng->txt('chat_recording_time_frame'));
00777                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00778                 $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('delete'));
00779                 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt('cancel'));
00780 
00781                 $counter = 0;
00782                 for ($i = 0; $i < count($_POST["recordings"]); $i++)
00783                 {
00784                         $this->object->chat_record->getRecord($_POST["recordings"][$i]);
00785                         $this->tpl->setCurrentBlock("recordings_row");
00786                         if($this->object->chat_record->getTitle() != "")
00787                         {
00788                                 $this->tpl->setVariable("RECORDING_TITLE", $this->object->chat_record->getTitle());
00789                         }
00790                         if($this->object->chat_record->getDescription() != "")
00791                         {
00792                                 $this->tpl->setVariable("RECORDING_DESCRIPTION", $this->object->chat_record->getDescription());
00793                         }
00794                         if (is_array($moderator = $this->object->chat_record->getModerator()))
00795                         {
00796                                 $this->tpl->setVariable("MODERATOR", $moderator["login"]);
00797                         }
00798                         $this->tpl->setVariable("START_TIME", date("Y-m-d H:i:s", $this->object->chat_record->getStartTime()));
00799                         if ($this->object->chat_record->getEndTime() > 0)
00800                         {
00801                                 $this->tpl->setVariable("END_TIME", date("Y-m-d H:i:s", $this->object->chat_record->getEndTime()));
00802                         }
00803                         $this->tpl->setVariable("ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
00804                         $this->tpl->parseCurrentBlock();
00805                 }
00806                 $_SESSION['chat_recordings_del'] = $_POST['recordings'];
00807         }
00808 
00809         function deleteRecordingsObject()
00810         {
00811                 global $rbacsystem;
00812 
00813                 if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
00814                 {
00815                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00816                 }
00817 
00818                 if(!is_array($_SESSION['chat_recordings_del']))
00819                 {
00820                         sendInfo($this->lng->txt('chat_recordings_none_selected'));
00821                         $this->recordingsObject();
00822 
00823                         return false;
00824                 }
00825 
00826                 $this->object->chat_record = new ilChatRecording($this->object->getRefId());
00827 
00828                 foreach($_SESSION['chat_recordings_del'] as $record_id)
00829                 {
00830                         $this->object->chat_record->delete($record_id);
00831                 }
00832                 sendInfo($this->lng->txt('chat_recordings_deleted'));
00833                 $this->recordingsObject();
00834                 
00835                 unset($_SESSION['chat_recordings_del']);
00836                 return true;
00837         }
00838 
00839         function exportRecordingObject()
00840         {
00841                 global $rbacsystem;
00842                 
00843                 if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
00844                 {
00845                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00846                 }
00847 
00848                 $this->object->chat_record = new ilChatRecording($this->object->getRefId());
00849 
00850                 if (!$this->object->chat_record->getRecord($_GET["record_id"]) ||
00851                         $this->object->chat_record->getEndTime() == 0)
00852                 {
00853                         sendInfo($this->lng->txt('chat_recording_not_found'));
00854                         $this->recordingsObject();
00855 
00856                         return false;
00857                 }
00858 
00859                 $tmp_tpl =& new ilTemplate("tpl.chat_export_recording.html",true,true,"chat");
00860 
00861                 if($this->object->chat_record->getTitle())
00862                 {
00863                         $tmp_tpl->setVariable("TITLE",$this->object->chat_record->getTitle());
00864                 }
00865                 $tmp_tpl->setVariable("START_TIME",date("Y-m-d H:i:s", $this->object->chat_record->getStartTime()));
00866                 $tmp_tpl->setVariable("END_TIME",date("Y-m-d H:i:s", $this->object->chat_record->getEndTime()));
00867                 $tmp_tpl->setVariable("CONTENT",$this->object->chat_record->exportMessages());
00868 
00869                 ilUtil::deliverData($tmp_tpl->get(), "chat_recording_" . $_GET["record_id"] . ".html");
00870                 exit;
00871         }
00872 
00873         function startRecording()
00874         {
00875                 global $rbacsystem;
00876 
00877                 if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
00878                 {
00879                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00880                 }
00881 
00882                 $this->object->chat_record = new ilChatRecording($this->object->getRefId());
00883                 if($_GET["room_id"])
00884                 {
00885                         $this->object->chat_record->setRoomId($_GET["room_id"]);
00886                 }
00887                 if (!$this->object->chat_record->isRecording())
00888                 {
00889                         $this->object->chat_record->setModeratorId($_SESSION["AccountId"]);
00890                         $this->object->chat_record->startRecording($_POST["title"]);
00891                 }
00892                 sendInfo($this->lng->txt("chat_recording_started"),true);
00893                 $this->showFrames();
00894         }
00895 
00896         function stopRecording()
00897         {
00898                 global $rbacsystem;
00899 
00900                 if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
00901                 {
00902                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00903                 }
00904 
00905                 $this->object->chat_record = new ilChatRecording($this->object->getRefId());
00906                 if($_GET["room_id"])
00907                 {
00908                         $this->object->chat_record->setRoomId($_GET["room_id"]);
00909                 }
00910                 if ($this->object->chat_record->isRecording())
00911                 {
00912                         $this->object->chat_record->stopRecording($_SESSION["AccountId"]);
00913                 }
00914                 sendInfo($this->lng->txt("chat_recording_stopped"),true);
00915                 $this->showFrames();
00916         }
00917 
00918         function showFrames()
00919         {
00920                 global $rbacsystem;
00921 
00922                 if (!$rbacsystem->checkAccess("read", $this->ref_id))
00923                 {
00924                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00925                 }
00926 
00927                 // LOAD FRAMESET
00928                 $this->tpl = new ilTemplate("tpl.chat_start.html",false,false,true);
00929                 if ($_GET["p_id"])
00930                 {
00931                         $this->tpl->setVariable("USER_TARGET","chat.php?cmd=showUserFrame&ref_id=".
00932                                                                         $this->object->getRefId()."&room_id=".
00933                                                                         $_REQUEST["room_id"]."&p_id=".$_GET["p_id"]);
00934                         $this->tpl->setVariable("TOP_TARGET","chat.php?cmd=showTopFrame&ref_id=".
00935                                                                         $this->object->getRefId()."&room_id=".
00936                                                                         $_REQUEST["room_id"]."&p_id=".$_GET["p_id"]);
00937                         $this->tpl->setVariable("INPUT_TARGET","chat.php?cmd=showInputFrame&ref_id=".
00938                                                                         $this->object->getRefId()."&room_id=".
00939                                                                         $_REQUEST["room_id"]."&p_id=".$_GET["p_id"]);
00940                         $this->tpl->setVariable("RIGHT_TARGET","chat.php?cmd=showRightFrame&ref_id=".
00941                                                                         $this->object->getRefId()."&room_id=".
00942                                                                         $_REQUEST["room_id"]."&p_id=".$_GET["p_id"]);
00943                 }
00944                 else if ($_GET["a_id"])
00945                 {
00946                         $this->tpl->setVariable("USER_TARGET","chat.php?cmd=showUserFrame&ref_id=".
00947                                                                         $this->object->getRefId()."&room_id=".
00948                                                                         $_REQUEST["room_id"]."&pa_id=".$_GET["a_id"]);
00949                         $this->tpl->setVariable("TOP_TARGET","chat.php?cmd=showTopFrame&ref_id=".
00950                                                                         $this->object->getRefId()."&room_id=".
00951                                                                         $_REQUEST["room_id"]."&a_id=".$_GET["a_id"]);
00952                         $this->tpl->setVariable("INPUT_TARGET","chat.php?cmd=showInputFrame&ref_id=".
00953                                                                         $this->object->getRefId()."&room_id=".
00954                                                                         $_REQUEST["room_id"]."&a_id=".$_GET["a_id"]);
00955                         $this->tpl->setVariable("RIGHT_TARGET","chat.php?cmd=showRightFrame&ref_id=".
00956                                                                         $this->object->getRefId()."&room_id=".
00957                                                                         $_REQUEST["room_id"]."&a_id=".$_GET["a_id"]);
00958                 }
00959                 else
00960                 {
00961                         $this->tpl->setVariable("USER_TARGET","chat.php?cmd=showUserFrame&ref_id=".
00962                                                                         $this->object->getRefId()."&room_id=".
00963                                                                         $_REQUEST["room_id"]);
00964                         $this->tpl->setVariable("TOP_TARGET","chat.php?cmd=showTopFrame&ref_id=".
00965                                                                         $this->object->getRefId()."&room_id=".
00966                                                                         $_REQUEST["room_id"]);
00967                         $this->tpl->setVariable("INPUT_TARGET","chat.php?cmd=showInputFrame&ref_id=".
00968                                                                         $this->object->getRefId()."&room_id=".
00969                                                                         $_REQUEST["room_id"]);
00970                         $this->tpl->setVariable("RIGHT_TARGET","chat.php?cmd=showRightFrame&ref_id=".
00971                                                                         $this->object->getRefId()."&room_id=".
00972                                                                         $_REQUEST["room_id"]);
00973                 }
00974                 $this->tpl->setVariable("SERVER_TARGET",$this->object->server_comm->getServerFrameSource());
00975         }
00976         function showUserFrame()
00977         {
00978                 $this->object->chat_room->setUserId($_SESSION["AccountId"]);
00979                 $this->object->chat_room->updateLastVisit();
00980 
00981                 $this->__loadStylesheet(true);
00982                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_user_frame.html",true);
00983 
00984                 if($_REQUEST["room_id"])
00985                 {
00986                         $this->tpl->setVariable("TITLE",$this->object->chat_room->getTitle());
00987                 }
00988                 else
00989                 {
00990                         $this->tpl->setVariable("TITLE",$this->object->getTitle());
00991                 }
00992 
00993                 $this->__showRooms();
00994 
00995                 $this->tpl->setVariable("ADD_FORMACTION","chat.php?cmd=gateway&room_id=".
00996                                                                 $this->object->chat_room->getRoomId()."&ref_id=".$this->object->getRefId());
00997                 $this->tpl->setVariable("TXT_ADD_PRIVATE_CHATROOM", $this->lng->txt("chat_add_private_chatroom"));
00998                 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
00999 
01000                 $this->__showActiveUsers();
01001                 if($this->object->chat_room->isOwner())
01002                 {
01003                         $this->__showOnlineUsers();
01004                 }
01005                 
01006         }
01007         function showTopFrame()
01008         {
01009                 $this->__loadStylesheet();
01010                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_top_frame.html",true);
01011         }
01012         function showInputFrame()
01013         {
01014                 global $rbacsystem;
01015 
01016                 $this->__loadStylesheet();
01017                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_input_frame.html",true);
01018 
01019                 if($this->error)
01020                 {
01021                         sendInfo($this->error);
01022                 }
01023                 if($_GET["p_id"])
01024                 {
01025                         $user_obj =& new ilObjUser((int) $_GET["p_id"]);
01026                         $message = $this->lng->txt("chat_private_message")." ";
01027                         $message .= $this->object->chat_user->getLogin()." -> ".$user_obj->getLogin();
01028                         sendInfo($message);
01029                 }
01030                 else if($_GET["a_id"])
01031                 {
01032                         $user_obj =& new ilObjUser((int) $_GET["a_id"]);
01033                         $message = $this->lng->txt("chat_address_user")." ".$user_obj->getLogin();
01034                         sendInfo($message);
01035                 }
01036                 
01037                 if ($_GET["p_id"])
01038                 {
01039                         $this->tpl->setVariable("FORMACTION","chat.php?cmd=gateway&ref_id=".
01040                                                                         $this->object->getRefId()."&room_id=".
01041                                                                         $_REQUEST["room_id"]."&p_id=".$_GET["p_id"]);
01042                 }
01043                 else if ($_GET["a_id"])
01044                 {
01045                         $this->tpl->setVariable("FORMACTION","chat.php?cmd=gateway&ref_id=".
01046                                                                         $this->object->getRefId()."&room_id=".
01047                                                                         $_REQUEST["room_id"]."&a_id=".$_GET["a_id"]);
01048                 }
01049                 else
01050                 {
01051                         $this->tpl->setVariable("FORMACTION","chat.php?cmd=gateway&ref_id=".
01052                                                                         $this->object->getRefId()."&room_id=".
01053                                                                         $_REQUEST["room_id"]);
01054                 }
01055 
01056                 $this->tpl->setVariable("TXT_COLOR",$this->lng->txt("chat_color"));
01057                 $this->tpl->setVariable("TXT_TYPE",$this->lng->txt("chat_type"));
01058                 $this->tpl->setVariable("TXT_FACE",$this->lng->txt("chat_face"));
01059                 $this->tpl->setVariable("TXT_INPUT",$this->lng->txt("chat_input"));
01060 
01061                 if ($_GET["p_id"])
01062                 {
01063                         $this->tpl->setCurrentBlock("cancel");
01064                         $this->tpl->setVariable("TXT_SUBMIT_CANCEL",$this->lng->txt("cancel_whisper"));
01065                         $this->tpl->parseCurrentBlock();
01066                         $this->tpl->setVariable("TXT_SUBMIT_OK",$this->lng->txt("ok"));
01067                 }
01068                 elseif($_GET["a_id"])
01069                 {
01070                         $this->tpl->setCurrentBlock("cancel");
01071                         $this->tpl->setVariable("TXT_SUBMIT_CANCEL",$this->lng->txt("cancel_talk"));
01072                         $this->tpl->parseCurrentBlock();
01073                         $this->tpl->setVariable("TXT_SUBMIT_OK",$this->lng->txt("ok"));
01074                 }
01075                 else
01076                 {
01077                         $this->tpl->setVariable("TXT_SUBMIT_OK",$this->lng->txt("ok"));
01078                 }
01079                 $this->tpl->setVariable("SELECT_COLOR",$this->__getColorSelect());
01080                 $this->tpl->setVariable("RADIO_TYPE",$this->__getFontType());
01081                 $this->tpl->setVariable("CHECK_FACE",$this->__getFontFace());
01082 
01083                 if ($rbacsystem->checkAccess("moderate", $this->object->getRefId()))
01084                 {
01085                         $this->object->chat_record = new ilChatRecording($this->object->getRefId());
01086                         $this->tpl->setCurrentBlock("moderator");
01087                         $this->object->chat_record->setRoomId($this->object->chat_room->getRoomId());
01088                         if ($this->object->chat_record->isRecording())
01089                         {
01090                                 if ($this->object->chat_record->getTitle() != "")
01091                                 {
01092                                         $this->tpl->setVariable("TXT_TITLE_STOP_RECORDING", $this->lng->txt("chat_recording_title"));
01093                                         $this->tpl->setVariable("VAL_TITLE_STOP_RECORDING", $this->object->chat_record->getTitle());
01094                                 }
01095                                 if ($this->object->chat_record->getDescription() != "")
01096                                 {
01097                                         $this->tpl->setVariable("TXT_DESCRIPTION_STOP_RECORDING", $this->lng->txt("chat_recording_description"));
01098                                         $this->tpl->setVariable("VAL_DESCRIPTION_STOP_RECORDING", $this->object->chat_record->getDescription());
01099                                 }
01100                                 $this->tpl->setVariable("TXT_SUBMIT_STOP_RECORDING", $this->lng->txt("chat_stop_recording"));
01101                         }
01102                         else
01103                         {
01104                                 $this->tpl->setVariable("TXT_TITLE_START_RECORDING", $this->lng->txt("chat_recording_title"));
01105                                 $this->tpl->setVariable("TXT_DESCRIPTION_START_RECORDING", $this->lng->txt("chat_recording_description"));
01106                                 $this->tpl->setVariable("TXT_SUBMIT_START_RECORDING", $this->lng->txt("chat_start_recording"));
01107                         }
01108                         $this->tpl->setVariable("MODERATOR_FORMACTION","chat.php?cmd=gateway&ref_id=".
01109                                                                         $this->object->getRefId()."&room_id=".
01110                                                                         $this->object->chat_room->getRoomId());
01111                         $this->tpl->setVariable("MODERATOR_TARGET","_top");
01112                         $this->tpl->parseCurrentBlock("moderator");
01113                 }
01114         }
01115 
01116         function showRightFrame()
01117         {
01118                 $this->__loadStylesheet();
01119                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_right_frame.html",true);
01120         }
01121 
01122         function cancel()
01123         {
01124                 unset($_GET["p_id"]);
01125                 unset($_GET["a_id"]);
01126 
01127                 $this->showInputFrame();
01128         }
01129 
01130 
01131         function input()
01132         {
01133                 $this->object->chat_room->setUserId($_SESSION["AccountId"]);
01134                 $this->object->chat_room->updateLastVisit();
01135 
01136 
01137                 if(!$_POST["message"])
01138                 {
01139                         sendInfo($this->lng->txt("chat_insert_message"),true);
01140 
01141                         return $this->showInputFrame();
01142                 }
01143                 if($_POST["message"] and $this->object->chat_room->checkWriteAccess())
01144                 {
01145                         // FORMAT MESSAGE
01146                         $message = $this->__formatMessage();
01147                         
01148                         // SET MESSAGE AND SEND IT
01149                         $this->object->server_comm->setMessage($message);
01150                         if((int) $_GET["p_id"])
01151                         {
01152                                 $this->object->server_comm->setType('private');
01153                         }
01154                         else if((int) $_GET["a_id"])
01155                         {
01156                                 $this->object->server_comm->setType('address');
01157                         }
01158                         if(!$this->object->server_comm->send())
01159                         {
01160                                 $this->error = $this->lng->txt("chat_no_connection");
01161                         }
01162                 }
01163                 else
01164                 {
01165                         sendInfo($this->lng->txt('chat_kicked_from_room'),true);
01166                 }
01167                 $this->showInputFrame();
01168         }
01169 
01170         function invite()
01171         {
01172                 if($_GET["i_id"])
01173                 {
01174                         $this->object->chat_room->invite((int) $_GET["i_id"]);
01175                         $this->object->sendMessage((int) $_GET["i_id"]);
01176                         sendInfo($this->lng->txt("chat_user_invited"),true);
01177                         $this->showFrames();
01178                 }
01179         }
01180         function drop()
01181         {
01182                 if($_GET["i_id"])
01183                 {
01184                         $this->object->chat_room->drop((int) $_GET["i_id"]);
01185 
01186                         $tmp_user =& new ilObjUser($_GET["i_id"]);
01187                         $this->object->server_comm->setKickedUser($tmp_user->getLogin());
01188                         $this->object->server_comm->setType("kick");
01189                         $this->object->server_comm->send();
01190                         sendInfo($this->lng->txt("chat_user_dropped"),true);
01191                         $this->showFrames();
01192                 }
01193         }
01194         function closeFrame()
01195         {
01196                 $this->__loadStylesheet(true);
01197                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_close.html",true);
01198                 sendInfo("Your session is expired please login to ILIAS.");
01199                 $this->tpl->touchBlock("content");
01200         }
01201 
01202         function export()
01203         {
01204                 $tmp_tpl =& new ilTemplate("tpl.chat_export.html",true,true,"chat");
01205 
01206                 if($this->object->chat_room->getRoomId())
01207                 {
01208                         $tmp_tpl->setVariable("CHAT_NAME",$this->object->chat_room->getTitle());
01209                 }
01210                 else
01211                 {
01212                         $tmp_tpl->setVariable("CHAT_NAME",$this->object->getTitle());
01213                 }
01214                 $tmp_tpl->setVariable("CHAT_DATE",strftime("%c",time()));
01215                 $tmp_tpl->setVariable("CONTENT",$this->object->chat_room->getAllMessages());
01216                 ilUtil::deliverData($tmp_tpl->get(),"1.html");
01217                 exit;
01218         }
01219 
01220         // PRIVATE
01221         function __showOnlineUsers()
01222         {
01223                 include_once 'chat/classes/class.ilChatBlockedUsers.php';
01224 
01225                 $all_users = $this->object->chat_room->getOnlineUsers();
01226 
01227                 // filter blocked users 
01228                 $users = array();
01229                 foreach($all_users as $user)
01230                 {
01231                         if(!ilChatBlockedUsers::_isBlocked($this->object->getId(),$user['user_id']))
01232                         {
01233                                 $users[] = $user;
01234                         }
01235                 }
01236 
01237                 if(count($users) <= 1)
01238                 {
01239                         $this->tpl->setCurrentBlock("no_actice");
01240                         $this->tpl->setVariable("NO_ONLINE_USERS",$this->lng->txt("chat_no_active_users"));
01241                         $this->tpl->parseCurrentBlock();
01242                 }
01243                 else
01244                 {
01245                         $counter = 0;
01246                         foreach($users as $user)
01247                         {
01248                                 if($user["user_id"] == $_SESSION["AccountId"])
01249                                 {
01250                                         continue;
01251                                 }
01252                                 if(!($counter%2))
01253                                 {
01254                                         $this->tpl->touchBlock("online_row_start");
01255                                 }
01256                                 else
01257                                 {
01258                                         $this->tpl->touchBlock("online_row_end");
01259                                 }
01260 
01261                                 $this->tpl->setCurrentBlock("online");
01262                                 if ($_GET["p_id"] == $user["user_id"] ||
01263                                         $_GET["a_id"] == $user["user_id"])
01264                                 {
01265                                         $this->tpl->setVariable("ONLINE_FONT_A","smallred");
01266                                 }
01267                                 else
01268                                 {
01269                                         $this->tpl->setVariable("ONLINE_FONT_A","small");
01270                                 }
01271                                 
01272                                 if($this->object->chat_room->isInvited($user["user_id"]))
01273                                 {
01274                                         $img = "minus.gif";
01275                                         $cmd = "drop";
01276                                 }
01277                                 else
01278                                 {
01279                                         $img = "plus.gif";
01280                                         $cmd = "invite";
01281                                 }
01282                                 $this->tpl->setVariable("ONLINE_LINK_A","chat.php?cmd=".$cmd.
01283                                                                                 "&ref_id=".$this->ref_id."&room_id=".
01284                                                                                 $_REQUEST["room_id"]."&i_id=".$user["user_id"]);
01285                                 $this->tpl->setVariable("TXT_INVITE_USER",$cmd == "invite" ? $this->lng->txt("chat_invite_user") :
01286                                                                                 $this->lng->txt("chat_drop_user"));
01287                                 $this->tpl->setVariable("ONLINE_USER_NAME_A",$user["login"]);
01288                                 $this->tpl->setVariable("INVITE_IMG_SRC",ilUtil::getImagePath($img,true));
01289                                 
01290                                 $this->tpl->parseCurrentBlock();
01291                                 $counter++;
01292                         }
01293                 }
01294                 $this->tpl->setCurrentBlock("show_online");
01295                 $this->tpl->setVariable("ONLINE_USERS",$this->lng->txt("chat_online_users"));
01296                 $this->tpl->parseCurrentBlock();
01297         }
01298         function __showActiveUsers()
01299         {
01300                 global $rbacsystem;
01301 
01302                 if(isset($_GET["a_users"]))
01303                 {
01304                         if($_GET["a_users"])
01305                         {
01306                                 $_SESSION["a_users"] = true;
01307                         }
01308                         else
01309                         {
01310                                 $_SESSION["a_users"] = 0;
01311                                 unset($_SESSION["a_users"]);
01312                         }
01313                 }
01314 
01315                 $hide = $_SESSION["a_users"] ? true : false;
01316 
01317                 $this->tpl->setVariable("ACTIVE_USERS",$this->lng->txt("chat_active_users"));
01318                 $this->tpl->setVariable("DETAILS_B_TXT",$hide ? $this->lng->txt("chat_show_details") : $this->lng->txt("chat_hide_details"));
01319                 $this->tpl->setVariable("DETAILS_B","chat.php?ref_id=".$this->object->getRefId().
01320                                                                 "&room_id=".$this->object->chat_room->getRoomId().
01321                                                                 "&a_users=".($hide ? 0 : 1)."&cmd=showUserFrame");
01322 
01323                 if($hide)
01324                 {
01325                         return true;
01326                 }
01327                 $users = $this->object->chat_room->getActiveUsers();
01328                 if(count($users) <= 1)
01329                 {
01330                         $this->tpl->setCurrentBlock("no_actice");
01331                         $this->tpl->setVariable("NO_ACTIVE_USERS",$this->lng->txt("chat_no_active_users"));
01332                         $this->tpl->parseCurrentBlock();
01333                 }
01334                 else
01335                 {
01336                         $user_obj =& new ilObjUser();
01337                         foreach($users as $user)
01338                         {
01339                                 if($user == $_SESSION["AccountId"])
01340                                 {
01341                                         continue;
01342                                 }
01343                                 $user_obj->setId($user);
01344                                 $user_obj->read();
01345 
01346                                 if($rbacsystem->checkAccess('chat_moderate',$this->object->getRefId()) and !$_REQUEST['room_id'])
01347                                 {
01348                                         $this->tpl->setCurrentBlock("moderate");
01349                                         if($this->object->chat_room->isKicked($user_obj->getId()))
01350                                         {
01351                                                 $this->tpl->setVariable("MOD_INVITE_IMG_SRC",ilUtil::getImagePath('plus.gif',true));
01352                                                 $this->tpl->setVariable("MOD_TXT_INVITE_USER",$this->lng->txt('chat_unkick_user_session'));
01353                                                 $this->tpl->setVariable("MOD_ONLINE_LINK_A","chat.php?cmd=unkickUser&ref_id=".$this->ref_id.
01354                                                                                                 "&kick_id=".$user_obj->getId());
01355                                         }
01356                                         else
01357                                         {
01358                                                 $this->tpl->setVariable("MOD_INVITE_IMG_SRC",ilUtil::getImagePath('minus.gif',true));
01359                                                 $this->tpl->setVariable("MOD_TXT_INVITE_USER",$this->lng->txt('chat_kick_user_session'));
01360                                                 $this->tpl->setVariable("MOD_ONLINE_LINK_A","chat.php?cmd=kickUser&ref_id=".$this->ref_id.
01361                                                                                                 "&kick_id=".$user_obj->getId());
01362                                         }
01363 
01364                                         $this->tpl->setVariable("MOD_ONLINE_USER_NAME_A",$user_obj->getLogin());
01365                                         $this->tpl->parseCurrentBlock();
01366                                 }
01367                                 else
01368                                 {
01369                                         $this->tpl->setCurrentBlock("non_moderate");
01370                                         if ($_GET["p_id"] == $user ||
01371                                                 $_GET["a_id"] == $user)
01372                                         {
01373                                                 $this->tpl->setVariable("ACTIVE_FONT_A","smallred");
01374                                         }
01375                                         else
01376                                         {
01377                                                 $this->tpl->setVariable("ACTIVE_FONT_A","small");
01378                                         }
01379                                         $this->tpl->setVariable("ACTIVE_USER_NAME_A",$user_obj->getLogin());
01380                                         $this->tpl->parseCurrentBlock();
01381                                 }
01382 
01383                                 if($user_obj->getPref('public_profile') == 'y')
01384                                 {
01385                                         $this->tpl->setVariable("ACTIVE_ROW_TXT_PROFILE",$this->lng->txt("chat_profile"));
01386                                         $this->tpl->setVariable("ACTIVE_ROW_PROFILE_ID",$user_obj->getId());
01387                                 }
01388                                 /*
01389                                 if(!$_REQUEST['room_id'] and $rbacsystem->checkAccess('chat_moderate',$this->object->getRefId()))
01390                                 {
01391                                         $this->tpl->setCurrentBlock("kick_user");
01392                                         $this->tpl->setVariable("KICK_LINK","chat.php?cmd=kickUser&ref_id=".$this->ref_id."&kick_id=".$user);
01393                                         $this->tpl->setVariable("TXT_KICK",$this->lng->txt('chat_kick'));
01394                                         $this->tpl->parseCurrentBlock();
01395                                 }
01396                                 */
01397                                 $this->tpl->setCurrentBlock("active");
01398 
01399                                 $this->tpl->setVariable("ACTIVE_ADDRESS_A","chat.php?cmd=showInputFrame&".
01400                                                                                 "ref_id=".$this->ref_id."&room_id=".
01401                                                                                 $_REQUEST["room_id"]."&a_id=".$user);
01402                                 $this->tpl->setVariable("ACTIVE_TXT_ADDRESS_A",$this->lng->txt("chat_address"));
01403 
01404                                 $this->tpl->setVariable("ACTIVE_LINK_A","chat.php?cmd=showInputFrame&".
01405                                                                                 "ref_id=".$this->ref_id."&room_id=".
01406                                                                                 $_REQUEST["room_id"]."&p_id=".$user);
01407                                 $this->tpl->setVariable("ACTIVE_TXT_WHISPER_A",$this->lng->txt("chat_whisper"));
01408 
01409                                 $this->tpl->parseCurrentBlock();
01410                         }
01411                 }
01412         }
01413         function __showAdminAddRoomSelect()
01414         {
01415                 $opt = array("createRoom" => $this->lng->txt("chat_room_select"));
01416 
01417                 return ilUtil::formSelect("","action_b",$opt,false,true);
01418         }
01419 
01420         function __showAdminRoomSelect()
01421         {
01422                 global $rbacsystem;
01423 
01424                 $opt["exportRoom"] = $this->lng->txt("chat_html_export");
01425 
01426                 if($rbacsystem->checkAccess('write',$this->object->getRefId()) or
01427                    count($this->object->chat_room->getRoomsOfObject()))
01428                 {
01429                         $opt["refreshRoom"] = $this->lng->txt("chat_refresh");
01430                 }
01431                 
01432                 if(count($this->object->chat_room->getRoomsOfObject()))
01433                 {
01434                         $opt["renameRoom"] = $this->lng->txt("rename");
01435                         $opt["deleteRoom"] = $this->lng->txt("delete");
01436                 }
01437                 return ilUtil::formSelect(isset($_SESSION["room_id_delete"]) ? "deleteRoom" : "",
01438                                                                   "action",
01439                                                                   $opt,
01440                                                                   false,
01441                                                                   true);
01442         }
01443 
01444         function __showRooms()
01445         {
01446                 include_once 'chat/classes/class.ilChatBlockedUsers.php';
01447 
01448                 global $rbacsystem,$ilUser;
01449 
01450                 $public_rooms = $this->object->chat_room->getAllRooms();
01451                 $private_rooms = $this->object->chat_room->getRooms();
01452 
01453                 if(isset($_GET["h_rooms"]))
01454                 {
01455                         if($_GET["h_rooms"])
01456                         {
01457                                 $_SESSION["h_rooms"] = true;
01458                         }
01459                         else
01460                         {
01461                                 $_SESSION["h_rooms"] = 0;
01462                                 unset($_SESSION["h_rooms"]);
01463                         }
01464                 }
01465                 $hide = $_SESSION["h_rooms"] ? true : false;
01466 
01467                 $this->tpl->setVariable("ROOMS_ROOMS",$this->lng->txt("chat_rooms"));
01468                 $this->tpl->setVariable("DETAILS_TXT",$hide ? $this->lng->txt("chat_show_details") : $this->lng->txt("chat_hide_details"));
01469                 $this->tpl->setVariable("ROOMS_COUNT",count($public_rooms) + count($private_rooms));
01470                 $this->tpl->setVariable("DETAILS_A","chat.php?ref_id=".$this->object->getRefId().
01471                                                                 "&room_id=".$this->object->chat_room->getRoomId().
01472                                                                 "&h_rooms=".($hide ? 0 : 1)."&cmd=showUserFrame");
01473 
01474                 if($hide)
01475                 {
01476                         return true;
01477                 }
01478 
01479                 $this->object->chat_record = new ilChatRecording();
01480 
01481                 $user_obj =& new ilObjUser();
01482                 foreach($public_rooms as $room)
01483                 {
01484                         if(ilChatBlockedUsers::_isBlocked($room['obj_id'],$ilUser->getId()))
01485                         {
01486                                 continue;
01487                         }
01488 
01489                         $this->tpl->setCurrentBlock("room_row");
01490                         $this->tpl->setVariable("ROOM_ROW_CSS","tblrow1");
01491                         $this->tpl->setVariable("ROOM_LINK","chat.php?ref_id=".$room["child"]);
01492                         $this->tpl->setVariable("ROOM_TARGET","_top");
01493                         $this->tpl->setVariable("ROOM_NAME",$room["title"]);
01494                         $this->tpl->setVariable("ROOM_ONLINE",$this->object->chat_room->getCountActiveUser($room["child"],0));
01495                         $this->object->chat_record->setRefId($room["child"]);
01496                         if ($room["child"] == $this->object->getRefId() &&
01497                                 $this->object->chat_room->getRoomId() == 0 &&
01498                                 $rbacsystem->checkAccess("moderate", $this->object->getRefId()))
01499                         {
01500                                 $this->tpl->setVariable("TXT_EMPTY_ROOM", $this->lng->txt("chat_empty"));
01501                                 $this->tpl->setVariable("LINK_EMPTY_ROOM", "chat.php?cmd=emptyRoom&ref_id=".$room["child"]);
01502                         }
01503 
01504                         $this->object->chat_record->setRefId($room["child"]);
01505                         $this->object->chat_record->setRoomId(0);
01506                         if ($this->object->chat_record->isRecording())
01507                         {
01508                                 $this->tpl->setVariable("TXT_RECORDING", $this->lng->txt("chat_recording_running"));
01509                         }
01510                         $this->tpl->parseCurrentBlock();
01511 
01512                         reset($private_rooms);
01513                         foreach($private_rooms as $priv_room)
01514                         {
01515                                 if ($priv_room["chat_id"] == $room["child"])
01516                                 {
01517                                         $this->tpl->touchBlock("room_row_indent");
01518                                         $this->tpl->setCurrentBlock("room_row");
01519                                         $this->tpl->setVariable("ROOM_ROW_CSS","tblrow2");
01520                                         $this->tpl->setVariable("ROOM_LINK","chat.php?ref_id=".$priv_room["chat_id"].
01521                                                                                                                                                                  "&room_id=".$priv_room["room_id"]);
01522                                         $this->tpl->setVariable("ROOM_TARGET","_top");
01523                                         $this->tpl->setVariable("ROOM_NAME",$priv_room["title"]);
01524                                         $this->tpl->setVariable("ROOM_ONLINE",
01525                                                                                         $this->object->chat_room->getCountActiveUser($priv_room["chat_id"],$priv_room["room_id"])); 
01526                 
01527                                         if ($priv_room["owner"] != $_SESSION["AccountId"])
01528                                         {
01529                                                 $user_obj->setId($priv_room["owner"]);
01530                                                 $user_obj->read();
01531                                                 $this->tpl->setVariable("TXT_ROOM_INVITATION", $this->lng->txt("chat_invited_by"));
01532                                                 $this->tpl->setVariable("ROOM_INVITATION_USER", $user_obj->getLogin());
01533                                         }
01534                                         else
01535                                         {
01536                                                 $this->tpl->setVariable("TXT_DELETE_ROOM", $this->lng->txt("delete"));
01537                                                 $this->tpl->setVariable("LINK_DELETE_ROOM", "chat.php?cmd=deleteRoom&ref_id=".
01538                                                                                                 $this->object->getRefId()."&room_id=".$this->object->chat_room->getRoomId().
01539                                                                                                 "&room_id_delete=".$priv_room["room_id"]);
01540                                         }
01541                 
01542                                         $this->object->chat_record->setRefId($priv_room["chat_id"]);
01543                                         $this->object->chat_record->setRoomId($priv_room["room_id"]);
01544                                         if ($this->object->chat_record->isRecording())
01545                                         {
01546                                                 $this->tpl->setVariable("TXT_RECORDING", $this->lng->txt("chat_recording_running"));
01547                                         }
01548                 
01549                                         if ($priv_room["chat_id"] == $this->object->getRefId() &&
01550                                                 $priv_room["room_id"] == $this->object->chat_room->getRoomId() &&
01551                                                 $rbacsystem->checkAccess("moderate", $this->object->getRefId()))
01552                                         {
01553                                                 $this->tpl->setVariable("TXT_EMPTY_ROOM", $this->lng->txt("chat_empty"));
01554                                                 $this->tpl->setVariable("LINK_EMPTY_ROOM", 
01555                                                                                                 "chat.php?cmd=emptyRoom&ref_id=".$this->object->getRefId().
01556                                                                                                 "&room_id=".$this->object->chat_room->getRoomId());
01557                                         }
01558                 
01559                                         $this->tpl->parseCurrentBlock();
01560                                 }
01561                         }
01562                         
01563                 }
01564 
01565         }
01566         function __loadStylesheet($expires = false)
01567         {
01568                 $this->tpl->setCurrentBlock("ChatStyle");
01569                 $this->tpl->setVariable("LOCATION_CHAT_STYLESHEET",ilUtil::getStyleSheetLocation());
01570                 if($expires)
01571                 {
01572                         $this->tpl->setVariable("EXPIRES","<meta http-equiv=\"expires\" content=\"now\">".
01573                                                                         "<meta http-equiv=\"refresh\" content=\"30\">");
01574                 }
01575                 $this->tpl->parseCurrentBlock();
01576         }
01577 
01578         function __getColorSelect()
01579         {
01580                 $colors = array("black" => $this->lng->txt("chat_black"),
01581                                                 "red" => $this->lng->txt("chat_red"),
01582                                                 "green" => $this->lng->txt("chat_green"),
01583                                                 "maroon" => $this->lng->txt("chat_maroon"),
01584                                                 "olive" => $this->lng->txt("chat_olive"),
01585                                                 "navy" => $this->lng->txt("chat_navy"),
01586                                                 "purple" => $this->lng->txt("chat_purple"),
01587                                                 "teal" => $this->lng->txt("chat_teal"),
01588                                                 "silver" => $this->lng->txt("chat_silver"),
01589                                                 "gray" => $this->lng->txt("chat_gray"),
01590                                                 "lime" => $this->lng->txt("chat_lime"),
01591                                                 "yellow" => $this->lng->txt("chat_yellow"),
01592                                                 "fuchsia" => $this->lng->txt("chat_fuchsia"),
01593                                                 "aqua" => $this->lng->txt("chat_aqua"),
01594                                                 "blue" => $this->lng->txt("chat_blue"));
01595 
01596                 return ilUtil::formSelect($_POST["color"],"color",$colors,false,true);
01597         }
01598 
01599         function __getFontType()
01600         {
01601                 $types = array("times" => $this->lng->txt("chat_times"),
01602                                            "tahoma" => $this->lng->txt("chat_tahoma"),
01603                                            "arial" => $this->lng->txt("chat_arial"));
01604 
01605                 $_POST["type"] = $_POST["type"] ? $_POST["type"] : "times";
01606 
01607                 foreach($types as $name => $type)
01608                 {
01609                         $this->tpl->setCurrentBlock("FONT_TYPES");
01610                         $this->tpl->setVariable("BL_TXT_TYPE",$type);
01611                         $this->tpl->setVariable("FONT_TYPE",$name);
01612                         $this->tpl->setVariable("TYPE_CHECKED",$_POST["type"] == $name ? "checked=\"checked\"" : "");
01613                         $this->tpl->parseCurrentBlock();
01614                 }
01615         }
01616 
01617         function __getFontFace()
01618         {
01619                 $_POST["face"] = is_array($_POST["face"]) ? $_POST["face"] : array();
01620 
01621                 $types = array("bold" => $this->lng->txt("chat_bold"),
01622                                            "italic" => $this->lng->txt("chat_italic"),
01623                                            "underlined" => $this->lng->txt("chat_underlined"));
01624 
01625                 $this->tpl->setCurrentBlock("FONT_FACES");
01626                 $this->tpl->setVariable("BL_TXT_FACE","<b>".$this->lng->txt("chat_bold")."</b>");
01627                 $this->tpl->setVariable("FONT_FACE","bold");
01628                 $this->tpl->setVariable("FACE_CHECKED",in_array("bold",$_POST["face"]) ? "checked=\"checked\"" : "");
01629                 $this->tpl->parseCurrentBlock();
01630 
01631                 $this->tpl->setCurrentBlock("FONT_FACES");
01632                 $this->tpl->setVariable("BL_TXT_FACE","<i>".$this->lng->txt("chat_italic")."</i>");
01633                 $this->tpl->setVariable("FONT_FACE","italic");
01634                 $this->tpl->setVariable("FACE_CHECKED",in_array("italic",$_POST["face"]) ? "checked=\"checked\"" : "");
01635                 $this->tpl->parseCurrentBlock();
01636 
01637                 $this->tpl->setCurrentBlock("FONT_FACES");
01638                 $this->tpl->setVariable("BL_TXT_FACE","<u>".$this->lng->txt("chat_underlined")."</u>");
01639                 $this->tpl->setVariable("FONT_FACE","underlined");
01640                 $this->tpl->setVariable("FACE_CHECKED",in_array("underlined",$_POST["face"]) ? "checked=\"checked\"" : "");
01641                 $this->tpl->parseCurrentBlock();
01642         }
01643 
01644         function __formatMessage()
01645         {
01646                 $tpl = new ilTemplate("tpl.chat_message.html",true,true,true);
01647 
01648                 $_POST['message'] = htmlentities(trim($_POST['message']),ENT_COMPAT,'utf-8');
01649 
01650                 $tpl->setVariable("MESSAGE",$_POST["message"]);
01651                 $tpl->setVariable("FONT_COLOR",$_POST["color"]);
01652                 $tpl->setVariable("FONT_FACE",$_POST["type"]);
01653 
01654                 if($_GET["p_id"])
01655                 {
01656                         $user_obj =& new ilObjUser((int) $_SESSION["AccountId"]);
01657                         $user_obj->read();
01658 
01659                         $tpl->setCurrentBlock("private");
01660                         $tpl->setVariable("PRIVATE_U_COLOR","red");
01661                         $tpl->setVariable("PRIVATE_FROM",$user_obj->getLogin());
01662 
01663                         $user_obj =& new ilObjUser((int) $_GET["p_id"]);
01664                         $user_obj->read();
01665                         $tpl->setVariable("PRIVATE_TO",$user_obj->getLogin());
01666                         $tpl->parseCurrentBlock();
01667                 }
01668                 else if($_GET["a_id"])
01669                 {
01670                         $tpl->setCurrentBlock("address");
01671                         $tpl->setVariable("ADDRESS_FROM_COLOR","navy");
01672                         $user_obj =& new ilObjUser((int) $_SESSION["AccountId"]);
01673                         $user_obj->read();
01674                         $tpl->setVariable("ADDRESS_FROM",$user_obj->getLogin());
01675 
01676                         $tpl->setVariable("ADDRESS_TO_COLOR","red");
01677                         $user_obj =& new ilObjUser((int) $_GET["a_id"]);
01678                         $user_obj->read();
01679                         $tpl->setVariable("ADDRESS_TO",$user_obj->getLogin());
01680                         $tpl->parseCurrentBlock();
01681                 }
01682                 else
01683                 {
01684                         $tpl->setCurrentBlock("normal");
01685                         $tpl->setVariable("NORMAL_U_COLOR","navy");
01686                         $tpl->setVariable("NORMAL_UNAME",$this->object->chat_user->getLogin());
01687                         $tpl->parseCurrentBlock();
01688                 }
01689                 // OPEN TAGS
01690                 if($_POST["face"])
01691                 {
01692                         foreach($_POST["face"] as $face)
01693                         {
01694                                 $tpl->setCurrentBlock("type_open");
01695                                 switch($face)
01696                                 {
01697                                         case "bold":
01698                                                 $tpl->setVariable("TYPE_TYPE_O","b");
01699                                                 break;
01700                                         case "italic":
01701                                                 $tpl->setVariable("TYPE_TYPE_O","i");
01702                                                 break;
01703 
01704                                         case "underlined":
01705                                                 $tpl->setVariable("TYPE_TYPE_O","u");
01706                                                 break;
01707                                 }
01708                                 $tpl->parseCurrentBlock();
01709                         }
01710                         $_POST["face"] = array_reverse($_POST["face"]);
01711                         foreach($_POST["face"] as $face)
01712                         {
01713                                 $tpl->setCurrentBlock("type_close");
01714                                 switch($face)
01715                                 {
01716                                         case "bold":
01717                                                 $tpl->setVariable("TYPE_TYPE_C","b");
01718                                                 break;
01719                                         case "italic":
01720                                                 $tpl->setVariable("TYPE_TYPE_C","i");
01721                                                 break;
01722 
01723                                         case "underlined":
01724                                                 $tpl->setVariable("TYPE_TYPE_C","u");
01725                                                 break;
01726                                 }
01727                                 $tpl->parseCurrentBlock();
01728                         }
01729                 }
01730 
01731                 $message = preg_replace("/\r/","",$tpl->get());
01732                 $message = preg_replace("/\n/","",$message);
01733 
01734                 return $message;
01735         }
01736         function __exportRooms()
01737         {
01738                 include_once "chat/classes/class.ilFileDataChat.php";
01739 
01740                 if(count($_POST["del_id"]) == 1)
01741                 {
01742                         $this->object->chat_room->setRoomId($_POST["del_id"][0]);
01743                         $this->export();
01744                 }
01745 
01746                 $file_obj =& new ilFileDataChat($this->object);
01747 
01748                 foreach($_POST["del_id"] as $id)
01749                 {
01750                         $this->object->chat_room->setRoomId((int) $id);
01751 
01752                         $tmp_tpl =& new ilTemplate("tpl.chat_export.html",true,true,"chat");
01753                         
01754                         if($id)
01755                         {
01756                                 $tmp_tpl->setVariable("CHAT_NAME",$this->object->chat_room->getTitle());
01757                         }
01758                         else
01759                         {
01760                                 $tmp_tpl->setVariable("CHAT_NAME",$this->object->getTitle());
01761                         }
01762                         $tmp_tpl->setVariable("CHAT_DATE",strftime("%c",time()));
01763                         $tmp_tpl->setVariable("CONTENT",$this->object->chat_room->getAllMessages());
01764 
01765                         $file_obj->addFile("chat_".$this->object->chat_room->getRoomId().".html",$tmp_tpl->get());
01766                 }
01767                 $fname = $file_obj->zip();
01768                 ilUtil::deliverFile($fname,"ilias_chat.zip");
01769         }
01770 
01776         function getTabs(&$tabs_gui)
01777         {
01778                 global $rbacsystem,$rbacreview;
01779 
01780                 $this->ctrl->setParameter($this,"ref_id",$this->object->getRefId());
01781 
01782                 if($rbacsystem->checkAccess('read',$this->object->getRefId()))
01783                 {
01784                         $tabs_gui->addTarget("view_content",
01785                                                                  $this->ctrl->getLinkTarget($this, "view"), "view", get_class($this));
01786                 }
01787                 if($rbacsystem->checkAccess('write',$this->object->getRefId()))
01788                 {
01789                         $tabs_gui->addTarget("edit_properties",
01790                                                                  $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this));
01791                 }
01792                 if($rbacsystem->checkAccess('chat_moderate',$this->object->getRefId()))
01793                 {
01794                         $tabs_gui->addTarget("chat_recordings",
01795                                                                  $this->ctrl->getLinkTarget($this, "recordings"), "recordings", get_class($this));
01796                 }
01797                 if($rbacsystem->checkAccess('chat_moderate',$this->object->getRefId()))
01798                 {
01799                         $tabs_gui->addTarget("chat_blocked_users",
01800                                                                  $this->ctrl->getLinkTarget($this, "blockedUsers"), "blockedUsers", get_class($this));
01801                 }
01802 
01803                 if($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
01804                 {
01805                         $tabs_gui->addTarget("perm_settings",
01806                                                                  $this->ctrl->getLinkTarget($this, "perm"), "perm", get_class($this));
01807                 }
01808         }
01809 
01810 
01811 
01812         function __prepareOutput()
01813         {
01814                 // output objects
01815                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat.html",'chat');
01816                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01817 
01818                 // output locator
01819                 $this->__setLocator();
01820 
01821                 // output message
01822                 if ($this->message)
01823                 {
01824                         sendInfo($this->message);
01825                 }
01826 
01827                 // display infopanel if something happened
01828                 infoPanel();
01829 
01830                 // set header
01831                 $this->__setHeader();
01832         }
01833 
01834         function __setHeader()
01835         {
01836                 include_once './classes/class.ilTabsGUI.php';
01837 
01838                 $this->tpl->setVariable("HEADER",$this->object->getTitle());
01839                 $this->tpl->setVariable("H_DESCRIPTION",$this->object->getDescription());
01840 
01841                 $tabs_gui =& new ilTabsGUI();
01842                 $this->getTabs($tabs_gui);
01843 
01844                 // output tabs
01845                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
01846         }
01847 
01848         function __setLocator()
01849         {
01850                 global $tree;
01851                 global $ilias_locator;
01852 
01853                 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
01854 
01855                 $counter = 0;
01856                 foreach ($tree->getPathFull($this->object->getRefId()) as $key => $row)
01857                 {
01858                         if($counter++)
01859                         {
01860                                 $this->tpl->touchBlock('locator_separator_prefix');
01861                         }
01862 
01863                         $this->tpl->setCurrentBlock("locator_item");
01864 
01865                         if($row["type"] == 'chat')
01866                         {
01867                                 $this->tpl->setVariable("ITEM",$this->object->getTitle());
01868                                 $this->tpl->setVariable("LINK_ITEM",$this->ctrl->getLinkTarget($this));
01869                         }
01870                         elseif ($row["child"] != $tree->getRootId())
01871                         {
01872                                 $this->tpl->setVariable("ITEM", $row["title"]);
01873                                 $this->tpl->setVariable("LINK_ITEM","repository.php?ref_id=".$row["child"]);
01874                         }
01875                         else
01876                         {
01877                                 $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
01878                                 $this->tpl->setVariable("LINK_ITEM","repository.php?ref_id=".$row["child"]);
01879                         }
01880 
01881                         $this->tpl->parseCurrentBlock();
01882                 }
01883 
01884                 $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
01885                 $this->tpl->parseCurrentBlock();
01886         }
01887 
01888 
01889 }
01890 // END class.ilObjChatGUI
01891 ?>

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