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