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