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