ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjChatGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
37 require_once "classes/class.ilObjectGUI.php";
38 require_once "Modules/Chat/classes/class.ilChatRecording.php";
39 
41 {
42  var $target_script = "adm_object.php";
43  var $in_module = false;
44 
49  function ilObjChatGUI($a_data,$a_id,$a_call_by_reference = true, $a_prepare_output = true)
50  {
51  global $ilCtrl;
52 
53  $this->type = "chat";
54  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output);
55 
56  $this->ctrl =& $ilCtrl;
57  $this->ctrl->saveParameter($this,array("ref_id","cmdClass"));
58 
59 
60  if(is_object($this->object->chat_user))
61  {
62  $this->object->chat_user->setUserId($_SESSION["AccountId"]);
63  }
64  }
65 
66  function &executeCommand()
67  {
68  global $rbacsystem;
69 
70  if($_GET["baseClass"] == "ilChatPresentationGUI")
71  {
72  $this->__prepareOutput();
73  }
74  else
75  {
76  $this->prepareOutput();
77  }
78 
79  $next_class = $this->ctrl->getNextClass($this);
80  $cmd = $this->ctrl->getCmd();
81 //var_dump($_GET);
82 //var_dump($_POST);
83 //echo "-$cmd-"; exit;
84  switch($next_class)
85  {
86  case 'ilpermissiongui':
87  include_once("./classes/class.ilPermissionGUI.php");
88  $perm_gui =& new ilPermissionGUI($this);
89  $ret =& $this->ctrl->forwardCommand($perm_gui);
90  break;
91 
92  case "ilpublicuserprofilegui":
93  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
94  $profile_gui = new ilPublicUserProfileGUI((int)$_GET['user']);
95  $ret = $this->ctrl->forwardCommand($profile_gui);
96  break;
97 
98  case 'ilinfoscreengui':
99  //$this->prepareOutput();
100  $this->infoScreen();
101  break;
102 
103  default:
104  if(!$cmd)
105  {
106  $cmd = "view";
107  }
108  $cmd .= "Object";
109  $this->$cmd();
110 
111  break;
112  }
113 
114  return true;
115  }
116 
124  public function cancelObject()
125  {
126  unset($_SESSION["room_id_rename"]);
127  unset($_SESSION["room_id_delete"]);
128  unset($_SESSION['saved_post']);
129  ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
130  $this->ctrl->redirect($this);
131  }
132 
138  {
139  global $ilLocator,$tree,$ilObjDataCache;
140 
141  if ($_GET["admin_mode"] == "settings") // system settings
142  {
143  $ilLocator->addItem($this->lng->txt("administration"),
144  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
145  ilFrameTargetInfo::_getFrame("MainContent"));
146 
147  // add chat settings
148  $chat_settings_ref_id = $tree->getParentId($this->object->getRefId());
149  $chat_settings_obj_id = $ilObjDataCache->lookupObjId($chat_settings_ref_id);
150 
151  $this->ctrl->setParameterByClass('ilobjchatservergui','ref_id',$chat_settings_ref_id);
152  $ilLocator->addItem($ilObjDataCache->lookupTitle($chat_settings_obj_id),
153  $this->ctrl->getLinkTargetByClass(array('iladministrationgui','ilobjchatservergui'),
154  'view'));
155 
156 
157  if ($this->object->getRefId() != SYSTEM_FOLDER_ID)
158  {
159  $ilLocator->addItem($this->object->getTitle(),
160  $this->ctrl->getLinkTarget($this, "view"));
161  }
162  }
163  else // repository administration
164  {
166  }
167 
168  }
169 
170 
171  function setTargetScript($a_script)
172  {
173  $this->target_script = $a_script;
174  }
175  function getTargetScript($a_params)
176  {
177  return $this->target_script."?".$a_params;
178  }
180  {
181  $this->in_module = $in_module;
182  }
183  function inModule()
184  {
185  return $this->in_module;
186  }
187 
188  function saveObject()
189  {
190  global $ilUser,$rbacadmin;
191 
192  $new_obj =& parent::saveObject();
193 
194  // Add new moderator role
195  $roles = $new_obj->initDefaultRoles();
196 
197  // Assign current user.
198  $rbacadmin->assignUser($roles[0],$ilUser->getId());
199 
200 
201  //$this->ctrl->setParameter($this, "ref_id", $new_obj->getRefId());
202  ilUtil::redirect($this->getReturnLocation("save",
203  "ilias.php?baseClass=ilChatHandlerGUI&ref_id=".$new_obj->getRefId()."&amp;cmd=view"));
204  }
205 
206  // Methods for blocked users (administration)
208  {
209  include_once 'Modules/Chat/classes/class.ilChatBlockedUsers.php';
210 
211  global $rbacsystem;
212 
213  if(!$rbacsystem->checkAccess('moderate',$this->object->getRefId()))
214  {
215  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
216  }
217 
218  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chat_blocked_users.html","Modules/Chat");
219  $blocked_obj = new ilChatBlockedUsers($this->object->getId());
220 
221  if(!count($blocked = $blocked_obj->getBlockedUsers()))
222  {
223  $this->tpl->setVariable("MESSAGE_NO_BLOCKED",$this->lng->txt('chat_no_blocked'));
224  }
225  else
226  {
227  $this->tpl->setCurrentBlock("delete_blocked");
228  $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('chat_blocked_unlocked'));
229  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
230  $this->tpl->parseCurrentBlock();
231  }
232 
233  foreach($blocked as $usr_id)
234  {
235  $tmp_user =& new ilObjUser($usr_id);
236 
237  $this->tpl->setCurrentBlock("blocked_users");
238  $this->tpl->setVariable("FULLNAME",$tmp_user->getFullname());
239  $this->tpl->setVariable("LOGIN",$tmp_user->getLogin());
240  $this->tpl->setVariable("BLOCK_CHECK",ilUtil::formCheckbox(0,'blocked_check[]',$tmp_user->getId()));
241  $this->tpl->parseCurrentBlock();
242  }
243 
244  // Fill table
245  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
246  $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath('icon_usr.gif'));
247  $this->tpl->setVariable("TBL_TITLE_IMG_ALT",$this->lng->txt('chat_blocked_users'));
248  $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('chat_blocked_users'));
249  $this->tpl->setVariable("HEADER_NAME",$this->lng->txt('chat_user_name'));
250 
251  $this->tpl->setVariable("BTN_BLOCK",$this->lng->txt('chat_block_user'));
252 
253  }
254 
255  function blockUserObject()
256  {
257  include_once 'Modules/Chat/classes/class.ilChatBlockedUsers.php';
258 
259  global $rbacsystem;
260 
261  if(!$rbacsystem->checkAccess('moderate',$this->object->getRefId()))
262  {
263  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
264  }
265 
266  $blocked_obj = new ilChatBlockedUsers($this->object->getId());
267 
268  if(!$_POST['block'] or !($usr_id = ilObjUser::getUserIdByLogin($_POST['block'])))
269  {
270  ilUtil::sendInfo($this->lng->txt('chat_enter_valid_username'));
271  $this->blockedUsersObject();
272 
273  return false;
274  }
275  if($blocked_obj->isBlocked($usr_id))
276  {
277  ilUtil::sendInfo($this->lng->txt('chat_user_already_blocked'));
278  $this->blockedUsersObject();
279 
280  return false;
281  }
282 
283  $blocked_obj->block($usr_id);
284  ilUtil::sendInfo($this->lng->txt('chat_user_blocked'));
285  $this->blockedUsersObject();
286 
287  return true;
288 
289  }
290 
292  {
293  include_once 'Modules/Chat/classes/class.ilChatBlockedUsers.php';
294 
295  global $rbacsystem;
296 
297  if(!$rbacsystem->checkAccess('moderate',$this->object->getRefId()))
298  {
299  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
300  }
301 
302  $blocked_obj = new ilChatBlockedUsers($this->object->getId());
303 
304  if(!is_array($_POST['blocked_check']))
305  {
306  ilUtil::sendInfo($this->lng->txt('chat_no_users_selected'));
307 
308  return $this->blockedUsersObject();
309  }
310 
311  foreach($_POST['blocked_check'] as $usr_id)
312  {
313  $blocked_obj->unblock($usr_id);
314  }
315 
316  ilUtil::sendInfo($this->lng->txt('chat_unblocked_user'));
317  return $this->blockedUsersObject();
318  }
319 
320 
321  function kickUserObject()
322  {
323  global $rbacsystem;
324 
325  if(!$rbacsystem->checkAccess('moderate',$this->object->getRefId()))
326  {
327  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
328  }
329 
330  if($_GET["kick_id"])
331  {
332  $tmp_user = new ilObjUser($_GET['kick_id']);
333 
334  $this->object->server_comm->setKickedUser($tmp_user->getLogin());
335  $this->object->server_comm->setType("kick");
336  $this->object->server_comm->send();
337 
338  $this->object->chat_room->setKicked((int)$_GET['kick_id']);
339 
340  #ilUtil::sendInfo($this->lng->txt("chat_user_dropped"),true);
341  $this->showFramesObject();
342  }
343  }
344 
345  function unkickUserObject()
346  {
347  global $rbacsystem;
348 
349  if(!$rbacsystem->checkAccess('moderate',$this->object->getRefId()))
350  {
351  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
352  }
353 
354  if($_GET["kick_id"])
355  {
356  $this->object->chat_room->setUnkicked((int)$_GET['kick_id']);
357 
358  #ilUtil::sendInfo($this->lng->txt("chat_user_dropped"),true);
359  $this->showFramesObject();
360  }
361  }
362 
363  function viewObject()
364  {
365  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
366  {
368  return true;
369  }
370 
371  // Check blocked
372  include_once 'Modules/Chat/classes/class.ilChatBlockedUsers.php';
373 
374  global $rbacsystem,$ilUser;
375 
376  if (!$rbacsystem->checkAccess("read", $this->ref_id))
377  {
378  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
379  }
380  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chat_view.html","Modules/Chat");
381 
382  // CHAT SERVER NOT ACTIVE
383  if(!$this->object->server_comm->isAlive() or !$this->ilias->getSetting("chat_active"))
384  {
385  ilUtil::sendInfo($this->lng->txt("chat_server_not_active"));
386  }
387  if(ilChatBlockedUsers::_isBlocked($this->object->getId(),$ilUser->getId()))
388  {
389  ilUtil::sendInfo($this->lng->txt('chat_access_blocked'));
390 
391  return true;
392  }
393 
394 
395  // DELETE ROOMS CONFIRM
396  $checked = array();
397  if($_SESSION["room_id_delete"])
398  {
399  $checked = $_SESSION["room_id_delete"];
400  ilUtil::sendInfo($this->lng->txt("chat_delete_sure"));
401  $this->tpl->setCurrentBlock("confirm_delete");
402  $this->tpl->setVariable("TXT_DELETE_CANCEL",$this->lng->txt("cancel"));
403  $this->tpl->setVariable("TXT_DELETE_CONFIRM",$this->lng->txt("delete"));
404  $this->tpl->parseCurrentBlock();
405  }
406 
407  // SHOW ROOMS TABLE
408  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_chat.gif'));
409  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_chat'));
410  $this->tpl->setVariable("TITLE",$this->lng->txt('chat_rooms'));
411 
412 
413  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
414  $this->tpl->setVariable("TXT_CHATROOMS",$this->lng->txt("chat_chatrooms"));
415  $this->tpl->setVariable("ACTIONS",$this->lng->txt('actions'));
416 
417  $counter = 0;
418 
419  if($rbacsystem->checkAccess('write',$this->ref_id))
420  {
421  $rooms = $this->object->chat_room->getAllRoomsOfObject();
422  }
423  else
424  {
425  $this->object->chat_room->setOwnerId($_SESSION["AccountId"]);
426  $rooms = $this->object->chat_room->getRoomsOfObject();
427  }
428 
429  $script = './ilias.php?baseClass=ilChatPresentationGUI';
430 
431  // ADD PUBLIC ROOM
432  // CHAT SERVER ACTIVE
433 
434 
435  if(ilChatBlockedUsers::_isBlocked($this->object->getId(),$ilUser->getId()))
436  {
437  $this->tpl->setCurrentBlock("blocked");
438  $this->tpl->setVariable("MESSAGE_BLOCKED",$this->lng->txt('chat_blocked'));
439  $this->tpl->parseCurrentBlock();
440  }
441  elseif($this->object->server_comm->isAlive() and $this->ilias->getSetting("chat_active"))
442  {
443  $this->tpl->setCurrentBlock("active");
444  $this->tpl->setVariable("ROOM_LINK",$script."&ref_id=".$this->ref_id."&room_id=0");
445  $this->tpl->setVariable("ROOM_TARGET","chat");
446  $this->tpl->setVariable("ROOM_TXT_LINK",$this->lng->txt("show"));
447  $this->tpl->parseCurrentBlock();
448  }
449  else
450  {
451  $this->tpl->touchBlock("not_active");
452  }
453  $this->tpl->setCurrentBlock("tbl_rooms_row");
454  $this->tpl->setVariable("ROWCOL",++$counter % 2 ? "tblrow1" : "tblrow2");
455  $this->tpl->setVariable("ROOM_CHECK",
456  ilUtil::formCheckbox(in_array(0,$checked) ? 1 : 0,
457  "del_id[]",
458  0));
459  $this->tpl->setVariable("ROOM_NAME",$this->object->getTitle()." ".$this->lng->txt("chat_public_room"));
460  $this->tpl->setVariable("USERS_ONLINE",
461  $this->lng->txt('chat_users_active').': '.
462  ilChatRoom::_getCountActiveUsers($this->object->getId()));
463  $this->tpl->parseCurrentBlock();
464 
465  foreach($rooms as $room)
466  {
467  // CHAT SERVER ACTIVE
468  if($this->object->server_comm->isAlive() and $this->ilias->getSetting("chat_active"))
469  {
470  $this->tpl->setCurrentBlock("active");
471  $this->tpl->setVariable("ROOM_LINK",$script."&ref_id=".$this->ref_id."&room_id=".$room["room_id"]);
472  $this->tpl->setVariable("ROOM_TARGET","chat");
473  $this->tpl->setVariable("ROOM_TXT_LINK",$this->lng->txt("show"));
474  $this->tpl->parseCurrentBlock();
475  }
476  else
477  {
478  $this->tpl->touchBlock("not_active");
479  }
480  $this->tpl->setCurrentBlock("tbl_rooms_row");
481  $this->tpl->setVariable("ROWCOL",++$counter % 2 ? "tblrow1" : "tblrow2");
482  $this->tpl->setVariable("ROOM_CHECK",
483  ilUtil::formCheckbox(in_array($room["room_id"],$checked) ? 1 : 0,
484  "del_id[]",
485  $room["room_id"]));
486 
487  $this->tpl->setVariable("ROOM_NAME",$room["title"]);
488  $this->tpl->setVariable("USERS_ONLINE",
489  $this->lng->txt('chat_users_active').': '.
490  ilChatRoom::_getCountActiveUsers($this->object->getId(),$room['room_id']));
491  $this->tpl->parseCurrentBlock();
492  }
493  $this->tpl->setCurrentBlock("has_rooms");
494  $this->tpl->setVariable("TBL_FOOTER_IMG_SRC", ilUtil::getImagePath("arrow_downright.gif"));
495  $this->tpl->setVariable("TBL_FOOTER_SELECT",$this->__showAdminRoomSelect(count($rooms)));
496  $this->tpl->setVariable("FOOTER_HAS_ROOMS_OK",$this->lng->txt("ok"));
497  $this->tpl->parseCurrentBlock();
498  $this->tpl->setVariable("TBL_FOOTER_ADD_SELECT",$this->__showAdminAddRoomSelect());
499  $this->tpl->setVariable("FOOTER_OK",$this->lng->txt("add"));
500 
501  // permanent link
502  $this->tpl->setCurrentBlock("perma_link");
503  $this->tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH.
504  "/goto.php?target=".
505  $this->object->getType().
506  "_".$this->object->getRefId()."&client_id=".CLIENT_ID);
507  $this->tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
508  $this->tpl->setVariable("PERMA_TARGET", "_top");
509  $this->tpl->parseCurrentBlock();
510 
511  }
512 
513  function adminRoomsObject()
514  {
515  global $rbacsystem;
516 
517  if (!$rbacsystem->checkAccess("read", $this->ref_id))
518  {
519  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
520  }
521 
522  if(!isset($_POST["del_id"]))
523  {
524  ilUtil::sendInfo($this->lng->txt("chat_select_one_room"));
525  $this->viewObject();
526 
527  return false;
528  }
529 
530  switch($_POST["action"])
531  {
532  case "renameRoom":
533  if(count($_POST["del_id"]) > 1)
534  {
535  ilUtil::sendInfo($this->lng->txt("chat_select_one_room"));
536  $this->viewObject();
537 
538  return false;
539  }
540  if(in_array(0,$_POST["del_id"]))
541  {
542  ilUtil::sendInfo($this->lng->txt("chat_no_rename_public"));
543  $this->viewObject();
544 
545  return false;
546  }
547 
548  // STORE ID IN SESSION
549  $_SESSION["room_id_rename"] = (int) $_POST["del_id"][0];
550 
551  $room =& new ilChatRoom($this->object->getId());
552  $room->setRoomId($_SESSION["room_id_rename"]);
553 
554  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chat_edit_room.html","Modules/Chat");
555  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
556  $this->tpl->setVariable("TXT_ROOM_NAME",$this->lng->txt("chat_room_name"));
557  $this->tpl->setVariable("ROOM_CANCEL",$this->lng->txt("cancel"));
558  $this->tpl->setVariable("TXT_EDIT_CHATROOMS",$this->lng->txt("chat_chatroom_rename"));
559  $this->tpl->setVariable("ROOM_NAME",$room->getTitle());
560  $this->tpl->setVariable("CMD","renameRoom");
561  $this->tpl->setVariable("ROOM_EDIT",$this->lng->txt("rename"));
562  break;
563 
564  case "deleteRoom":
565  if(in_array(0,$_POST["del_id"]))
566  {
567  ilUtil::sendInfo($this->lng->txt("chat_no_delete_public"));
568  $this->viewObject();
569 
570  return false;
571  }
572  $_SESSION["room_id_delete"] = $_POST["del_id"];
573  $this->viewObject();
574 
575  return true;
576 
577 
578  case "exportRoom":
579  $this->__exportRooms();
580  break;
581 
582  case "refreshRoom":
583  if(in_array(0,$_POST["del_id"]) and !$rbacsystem->checkAccess('write',$this->object->getRefId()))
584  {
585  ilUtil::sendInfo($this->lng->txt("chat_no_refresh_public"));
586  $this->viewObject();
587 
588  return true;
589  }
590  foreach($_POST["del_id"] as $room_id)
591  {
592  $this->object->chat_room->setRoomId($room_id);
593  $this->object->server_comm->setType("delete");
594  $this->object->server_comm->send();
595  $this->object->chat_room->deleteAllMessages();
596  }
597  ilUtil::sendInfo($this->lng->txt('chat_refreshed'));
598  $this->viewObject();
599 
600  return true;
601  }
602 
603  }
604 
605  function emptyRoomObject()
606  {
607  global $rbacsystem;
608 
609  if ($rbacsystem->checkAccess("moderate", $this->object->getRefId()) &&
610  $this->object->chat_room->checkWriteAccess())
611  {
612  $this->object->server_comm->setType('delete');
613  $message = $this->__formatMessage();
614  $this->object->server_comm->setMessage($message);
615  $this->object->server_comm->send();
616 
617  $this->object->chat_room->deleteAllMessages();
618  }
619  unset($_GET["room_id_empty"]);
620  $this->showFramesObject();
621  }
622 
623  function deleteRoomObject()
624  {
625  global $rbacsystem;
626 
627  if (!$rbacsystem->checkAccess("read", $this->ref_id))
628  {
629  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
630  }
631  if(!$_GET["room_id_delete"])
632  {
633  $this->ilias->raiseError($this->lng->txt("chat_select_one_room"),$this->ilias->error_obj->MESSAGE);
634  }
635  $this->object->chat_room->setOwnerId($_SESSION["AccountId"]);
636  $rooms = array($_GET["room_id_delete"]);
637  if (!$rbacsystem->checkAccess("write", $this->ref_id))
638  {
639  $delResult = $this->object->chat_room->deleteRooms($rooms, $this->object->chat_room->getOwnerId());
640  }
641  else
642  {
643  $delResult = $this->object->chat_room->deleteRooms($rooms);
644  }
645  if(!$delResult)
646  {
647  $this->ilias->raiseError($this->object->chat_room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
648  }
649  unset($_GET["room_id_delete"]);
650  ilUtil::sendInfo($this->lng->txt("chat_rooms_deleted"), true);
651  //$this->showFramesObject();
652  $this->ctrl->redirect($this, 'showFrames');
653  }
654 
656  {
657  global $rbacsystem;
658 
659  if (!$rbacsystem->checkAccess("read", $this->ref_id))
660  {
661  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
662  }
663  if(!$_SESSION["room_id_delete"])
664  {
665  $this->ilias->raiseError($this->lng->txt("chat_select_one_room"),$this->ilias->error_obj->MESSAGE);
666  }
667  $this->object->chat_room->setOwnerId($_SESSION["AccountId"]);
668  if(!$this->object->chat_room->deleteRooms($_SESSION["room_id_delete"]))
669  {
670  $this->ilias->raiseError($this->object->chat_room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
671  }
672  unset($_SESSION["room_id_delete"]);
673  ilUtil::sendInfo($this->lng->txt("chat_rooms_deleted"));
674 
675  $this->viewObject();
676  return true;
677  }
678 
680  {
681  global $rbacsystem;
682 
683  if (!$rbacsystem->checkAccess("read", $this->ref_id))
684  {
685  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
686  exit;
687  }
688  else
689  {
690  $room =& new ilChatRoom($this->object->getId());
691  $room->setTitle(ilUtil::stripSlashes($_POST["room_name"]));
692  $room->setOwnerId($_SESSION["AccountId"]);
693 
694  if(!$room->validate())
695  {
696  ilUtil::sendInfo($room->getErrorMessage(), true);
697  }
698  else
699  {
700  $room->add();
701  ilUtil::sendInfo($this->lng->txt("chat_room_added"),true);
702  }
703  $this->showFramesObject();
704  }
705  }
706 
707  function addRoomObject()
708  {
709  global $rbacsystem;
710 
711  if (!$rbacsystem->checkAccess("read", $this->ref_id))
712  {
713  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
714  }
715  $room =& new ilChatRoom($this->object->getId());
716  $room->setTitle(ilUtil::stripSlashes($_POST["room_name"]));
717  $room->setOwnerId($_SESSION["AccountId"]);
718 
719  if(!$room->validate())
720  {
721  $this->ilias->raiseError($room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
722  }
723  $room->add();
724  ilUtil::sendInfo($this->lng->txt("chat_room_added"));
725  $this->viewObject();
726 
727  return true;
728  #header("location: ".$this->getTargetScript("cmd=gateway&ref_id=".$this->ref_id));
729  #exit;
730  }
731 
732  function renameRoomObject()
733  {
734  global $rbacsystem;
735 
736  if (!$rbacsystem->checkAccess("read", $this->ref_id))
737  {
738  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
739  }
740 
741  $room =& new ilChatRoom($this->object->getId());
742  $room->setRoomId($_SESSION["room_id_rename"]);
743  $room->setTitle(ilUtil::stripSlashes($_POST["room_name"]));
744  if(!$room->validate())
745  {
746  $this->ilias->raiseError($room->getErrorMessage(),$this->ilias->error_obj->MESSAGE);
747  }
748  $room->rename();
749 
750  unset($_SESSION["room_id_rename"]);
751  ilUtil::sendInfo($this->lng->txt("chat_room_renamed"));
752  $this->viewObject();
753 
754  return true;
755  }
756 
757 
758 
760  {
761  global $rbacsystem;
762 
763  if (!$rbacsystem->checkAccess("read", $this->ref_id))
764  {
765  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
766  }
767  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.chat_edit_room.html","Modules/Chat");
768  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
769  $this->tpl->setVariable("TXT_ROOM_NAME",$this->lng->txt("chat_room_name"));
770  $this->tpl->setVariable("ROOM_CANCEL",$this->lng->txt("cancel"));
771 
772  $this->tpl->setVariable("TXT_EDIT_CHATROOMS",$this->lng->txt("chat_chatroom_rename"));
773  $this->tpl->setVariable("ROOM_NAME","");
774  $this->tpl->setVariable("CMD","addRoom");
775  $this->tpl->setVariable("ROOM_EDIT",$this->lng->txt("add"));
776 
777  }
778 
779  function recordingsObject()
780  {
781  global $rbacsystem;
782 
783  if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
784  {
785  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
786  }
787  $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.chat_recordings.html","Modules/Chat");
788 
789  $this->object->__initChatRecording();
790 
791  if (!is_array($data = $this->object->chat_recording->getRecordings()))
792  {
793  ilUtil::sendInfo($this->lng->txt('chat_no_recordings_available'));
794  return true;
795  }
796 
797  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
798  $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('chat_recordings'));
799  $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('chat_recording_description'));
800  $this->tpl->setVariable("HEADER_MOD",$this->lng->txt('chat_recording_moderator'));
801  $this->tpl->setVariable("HEADER_TIME",$this->lng->txt('chat_recording_time_frame'));
802  $this->tpl->setVariable("HEADER_ACTION",$this->lng->txt('chat_recording_action'));
803  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
804  $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('delete'));
805 
806  $counter = 0;
807  for ($i = 0; $i < count($data); $i++)
808  {
809  $this->tpl->setCurrentBlock("recording_row");
810  $this->tpl->setVariable("CHECKBOX", ilUtil::formCheckbox(0,'recordings[]',$data[$i]["record_id"]));
811  if($data[$i]["title"] != "")
812  {
813  $this->tpl->setVariable("RECORDING_TITLE", $data[$i]["title"]);
814  }
815  if ($data[$i]["description"] != "")
816  {
817  $this->tpl->setVariable("RECORDING_DESCRIPTION", $data[$i]["description"]);
818  }
819  if (is_array($moderator = $this->object->chat_recording->getModerator($data[$i]["moderator_id"])))
820  {
821  $this->tpl->setVariable("MODERATOR", $moderator);
822  }
823  $this->tpl->setVariable("START_TIME", date("Y-m-d H:i:s", $data[$i]["start_time"]));
824  if ($data[$i]["end_time"] > 0)
825  {
826  $this->tpl->setVariable("END_TIME", date("Y-m-d H:i:s", $data[$i]["end_time"]));
827  $this->ctrl->setParameter($this,'record_id',$data[$i]["record_id"]);
828  $this->tpl->setVariable("LINK_EXPORT",$this->ctrl->getLinkTarget($this,'exportRecording'));
829  $this->tpl->setVariable("TXT_EXPORT",$this->lng->txt('export'));
830  }
831  $this->tpl->setVariable("ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
832  $this->tpl->parseCurrentBlock();
833  }
834  }
835 
837  {
838  global $rbacsystem;
839 
840  if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
841  {
842  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
843  }
844 
845  if(!is_array($_POST['recordings']))
846  {
847  ilUtil::sendInfo($this->lng->txt('chat_recordings_select_one'));
848  $this->recordingsObject();
849 
850  return false;
851  }
852 
853  $this->object->__initChatRecording();
854 
855  ilUtil::sendInfo($this->lng->txt('chat_recordings_delete_sure'));
856  $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.chat_ask_delete_recordings.html","Modules/Chat");
857 
858  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
859  $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('chat_recordings'));
860  $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('chat_recording_description'));
861  $this->tpl->setVariable("HEADER_MOD",$this->lng->txt('chat_recording_moderator'));
862  $this->tpl->setVariable("HEADER_TIME",$this->lng->txt('chat_recording_time_frame'));
863  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
864  $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('delete'));
865  $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt('cancel'));
866 
867  $counter = 0;
868  for ($i = 0; $i < count($_POST["recordings"]); $i++)
869  {
870  $this->object->chat_recording->getRecord($_POST["recordings"][$i]);
871  $this->tpl->setCurrentBlock("recordings_row");
872  if($this->object->chat_recording->getTitle() != "")
873  {
874  $this->tpl->setVariable("RECORDING_TITLE", $this->object->chat_recording->getTitle());
875  }
876  if($this->object->chat_recording->getDescription() != "")
877  {
878  $this->tpl->setVariable("RECORDING_DESCRIPTION", $this->object->chat_recording->getDescription());
879  }
880  if ($moderator = $this->object->chat_recording->getModerator())
881  {
882  $this->tpl->setVariable("MODERATOR", $moderator);
883  }
884  $this->tpl->setVariable("START_TIME", date("Y-m-d H:i:s", $this->object->chat_recording->getStartTime()));
885  if ($this->object->chat_recording->getEndTime() > 0)
886  {
887  $this->tpl->setVariable("END_TIME", date("Y-m-d H:i:s", $this->object->chat_recording->getEndTime()));
888  }
889  $this->tpl->setVariable("ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
890  $this->tpl->parseCurrentBlock();
891  }
892  $_SESSION['chat_recordings_del'] = $_POST['recordings'];
893  }
894 
896  {
897  global $rbacsystem;
898 
899  if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
900  {
901  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
902  }
903 
904  if(!is_array($_SESSION['chat_recordings_del']))
905  {
906  ilUtil::sendInfo($this->lng->txt('chat_recordings_none_selected'));
907  $this->recordingsObject();
908 
909  return false;
910  }
911 
912  $this->object->__initChatRecording();
913 
914  foreach($_SESSION['chat_recordings_del'] as $record_id)
915  {
916  $this->object->chat_recording->delete($record_id);
917  }
918  ilUtil::sendInfo($this->lng->txt('chat_recordings_deleted'));
919  $this->recordingsObject();
920 
921  unset($_SESSION['chat_recordings_del']);
922  return true;
923  }
924 
926  {
927  global $rbacsystem;
928 
929  if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
930  {
931  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
932  }
933  $this->object->__initChatRecording();
934 
935  if (!$this->object->chat_recording->getRecord($_GET["record_id"]) ||
936  $this->object->chat_recording->getEndTime() == 0)
937  {
938  ilUtil::sendInfo($this->lng->txt('chat_recording_not_found'));
939  $this->recordingsObject();
940 
941  return false;
942  }
943 
944  $tmp_tpl =& new ilTemplate("tpl.chat_export_recording.html",true,true,"Modules/Chat");
945 
946  if($this->object->chat_recording->getTitle())
947  {
948  $tmp_tpl->setVariable("TITLE",$this->object->chat_recording->getTitle());
949  }
950  $tmp_tpl->setVariable("START_TIME",date("Y-m-d H:i:s", $this->object->chat_recording->getStartTime()));
951  $tmp_tpl->setVariable("END_TIME",date("Y-m-d H:i:s", $this->object->chat_recording->getEndTime()));
952  $tmp_tpl->setVariable("CONTENT",$this->object->chat_recording->exportMessages());
953 
954  ilUtil::deliverData($tmp_tpl->get(), "chat_recording_" . $_GET["record_id"] . ".html");
955  exit;
956  }
957 
959  {
960  global $rbacsystem,$ilUser;
961 
962  if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
963  {
964  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
965  }
966 
967  $this->object->__initChatRecording();
968  if($_GET["room_id"])
969  {
970  $this->object->chat_recording->setRoomId($_GET["room_id"]);
971  }
972  if (!$this->object->chat_recording->isRecording())
973  {
974  $this->object->chat_recording->setModeratorId($ilUser->getId());
975  $this->object->chat_recording->startRecording($_POST["title"]);
976  }
977  ilUtil::sendInfo($this->lng->txt("chat_recording_started"),true);
978  $this->showFramesObject();
979  }
980 
982  {
983  global $rbacsystem,$ilUser;
984 
985  if (!$rbacsystem->checkAccess("moderate", $this->object->getRefId()))
986  {
987  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
988  }
989 
990  $this->object->__initChatRecording();
991  if($_GET["room_id"])
992  {
993  $this->object->chat_recording->setRoomId($_GET["room_id"]);
994  }
995  if ($this->object->chat_recording->isRecording())
996  {
997  $this->object->chat_recording->stopRecording($ilUser->getId());
998  }
999  ilUtil::sendInfo($this->lng->txt("chat_recording_stopped"),true);
1000  $this->showFramesObject();
1001  }
1002 
1006  function showFramesObject()
1007  {
1008  global $rbacsystem, $ilCtrl;
1009 
1010  if (!$rbacsystem->checkAccess("read", $this->ref_id))
1011  {
1012  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1013  }
1014 
1015  // LOAD FRAMESET
1016  $this->tpl = new ilTemplate("tpl.chat_start.html",false,false,'Modules/Chat');
1017  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1018  $ilCtrl->setParameter($this, "room_id", $_REQUEST["room_id"]);
1019  if ($_GET["p_id"])
1020  {
1021  $ilCtrl->setParameter($this, "p_id", $_GET["p_id"]);
1022  }
1023  else if ($_GET["a_id"])
1024  {
1025  $ilCtrl->setParameter($this, "pa_id", $_GET["a_id"]);
1026  $ilCtrl->setParameter($this, "a_id", $_GET["a_id"]);
1027  }
1028  $this->tpl->setVariable("USER_TARGET",
1029  $ilCtrl->getLinkTarget($this, "showUserFrame"));
1030  $this->tpl->setVariable("TOP_TARGET",
1031  $ilCtrl->getLinkTarget($this, "showTopFrame"));
1032  $this->tpl->setVariable("INPUT_TARGET",
1033  $ilCtrl->getLinkTarget($this, "showInputFrame"));
1034  $this->tpl->setVariable("RIGHT_TARGET",
1035  $ilCtrl->getLinkTarget($this, "showRightFrame"));
1036 
1037  $this->tpl->setVariable("SERVER_TARGET",$this->object->server_comm->getServerFrameSource());
1038 
1039  $this->tpl->show(false, false);
1040  exit;
1041  }
1042 
1047  {
1048  global $ilCtrl, $ilMainMenu, $ilLocator, $ilUser;
1049 
1050  $this->object->chat_room->setUserId($_SESSION["AccountId"]);
1051  $this->object->chat_room->updateLastVisit();
1052  $this->tpl = new ilTemplate("tpl.main.html", true, true);
1053  $this->__loadStylesheet(true);
1054  $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_user_frame.html",'Modules/Chat');
1055  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1056 
1057  $ilMainMenu->setSmallMode(true);
1058  $this->tpl->setVariable("MAINMENU", $ilMainMenu->getHTML());
1059  $this->tpl->addJavascript("./Services/Javascript/js/Basic.js");
1060  $this->tpl->addJavascript("./Services/Navigation/js/ServiceNavigation.js");
1061  $this->tpl->fillJavaScriptFiles();
1062 
1063  $ilLocator->addRepositoryItems($this->object->getRefId());
1064  $ilLocator->addItem($this->object->getTitle(), 'repository.php?ref_id='.$this->object->getRefId(), '_top', $this->object->getRefId());
1065  $this->tpl->setLocator();
1066 
1067  if($_REQUEST["room_id"])
1068  {
1069  $this->tpl->setVariable("TITLE",$this->object->chat_room->getTitle());
1070  }
1071  else
1072  {
1073  $this->tpl->setVariable("TITLE",$this->object->getTitle());
1074  }
1075 
1076  $this->__showRooms();
1077 
1078  if($ilUser->getId() != ANONYMOUS_USER_ID)
1079  {
1080  $ilCtrl->setParameter($this, "room_id", $this->object->chat_room->getRoomId());
1081  $this->tpl->setVariable("ADD_FORMACTION",
1082  $ilCtrl->getFormAction($this, "addPrivateRoom"));
1083  $this->tpl->setVariable("TXT_ADD_PRIVATE_CHATROOM", $this->lng->txt("chat_add_private_chatroom"));
1084  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
1085  }
1086 
1087  $this->__showActiveUsers();
1088  if($this->object->chat_room->isOwner())
1089  {
1090  $this->__showOnlineUsers();
1091  }
1092 
1093  $this->tpl->show(false);
1094  exit;
1095  }
1096 
1098  {
1099  $this->tpl = new ilTemplate("tpl.main.html", true, true);
1100  $this->__loadStylesheet();
1101  $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_top_frame.html",'Modules/Chat');
1102  //$this->tpl->setVariable("TXT_NEW_MESSAGE",'Current discussion');
1103  $this->tpl->show(false);
1104  exit;
1105  }
1106 
1108  {
1109  global $rbacsystem, $ilCtrl, $ilUser;
1110 
1111  $this->tpl = new ilTemplate("tpl.main.html", true, true);
1112  $this->__loadStylesheet();
1113  $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_input_frame.html",'Modules/Chat');
1114 
1115  if($this->error)
1116  {
1117  ilUtil::sendInfo($this->error);
1118  }
1119  // @todo: mjansen: enable chat for anonymous users
1120  if(true || $ilUser->getId() != ANONYMOUS_USER_ID)
1121  {
1122  if($_GET["p_id"])
1123  {
1124  $user_obj =& new ilObjUser((int) $_GET["p_id"]);
1125  $message = $this->lng->txt("chat_private_message")." ";
1126  $message .= $this->object->chat_user->getLogin()." -> ".$user_obj->getLogin();
1127  ilUtil::sendInfo($message);
1128  }
1129  else if($_GET["a_id"])
1130  {
1131  $user_obj =& new ilObjUser((int) $_GET["a_id"]);
1132  $message = $this->lng->txt("chat_address_user")." ".$user_obj->getLogin();
1133  ilUtil::sendInfo($message);
1134  }
1135 
1136  $ilCtrl->setParameter($this, "room_id", $_REQUEST["room_id"]);
1137  if ($_GET["p_id"])
1138  {
1139  $ilCtrl->setParameter($this, "p_id", $_GET["p_id"]);
1140  }
1141  else if ($_GET["a_id"])
1142  {
1143  $ilCtrl->setParameter($this, "a_id", $_GET["a_id"]);
1144  }
1145  $this->tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this, "input"));
1146  $ilCtrl->clearParameters($this);
1147 
1148  $this->tpl->setVariable("TXT_NEW_MESSAGE",$this->lng->txt('chat_new_message'));
1149  $this->tpl->setVariable("TXT_COLOR",$this->lng->txt("chat_color"));
1150  $this->tpl->setVariable("TXT_TYPE",$this->lng->txt("chat_type"));
1151  $this->tpl->setVariable("TXT_FACE",$this->lng->txt("chat_face"));
1152  $this->tpl->setVariable("TXT_INPUT",$this->lng->txt("chat_input"));
1153 
1154  if ($_GET["p_id"])
1155  {
1156  $this->tpl->setCurrentBlock("cancel");
1157  $this->tpl->setVariable("TXT_SUBMIT_CANCEL",$this->lng->txt("cancel_whisper"));
1158  $this->tpl->parseCurrentBlock();
1159  $this->tpl->setVariable("TXT_SUBMIT_OK",$this->lng->txt("ok"));
1160  }
1161  elseif($_GET["a_id"])
1162  {
1163  $this->tpl->setCurrentBlock("cancel");
1164  $this->tpl->setVariable("TXT_SUBMIT_CANCEL",$this->lng->txt("cancel_talk"));
1165  $this->tpl->parseCurrentBlock();
1166  $this->tpl->setVariable("TXT_SUBMIT_OK",$this->lng->txt("ok"));
1167  }
1168  else
1169  {
1170  $this->tpl->setVariable("TXT_SUBMIT_OK",$this->lng->txt("ok"));
1171  }
1172  $this->tpl->setVariable("TXT_HTML_EXPORT",$this->lng->txt('exp_html'));
1173  $this->tpl->setVariable("SELECT_COLOR",$this->__getColorSelect());
1174  $this->tpl->setVariable("RADIO_TYPE",$this->__getFontType());
1175  $this->tpl->setVariable("CHECK_FACE",$this->__getFontFace());
1176 
1177  if ($rbacsystem->checkAccess("moderate", $this->object->getRefId()))
1178  {
1179  $this->object->__initChatRecording();
1180  $this->tpl->setCurrentBlock("moderator");
1181  $this->object->chat_recording->setRoomId($this->object->chat_room->getRoomId());
1182  if ($this->object->chat_recording->isRecording())
1183  {
1184  if ($this->object->chat_recording->getTitle() != "")
1185  {
1186  $this->tpl->setVariable("TXT_TITLE_STOP_RECORDING", $this->lng->txt("chat_recording_title"));
1187  $this->tpl->setVariable("VAL_TITLE_STOP_RECORDING", $this->object->chat_recording->getTitle());
1188  }
1189  if ($this->object->chat_recording->getDescription() != "")
1190  {
1191  $this->tpl->setVariable("TXT_DESCRIPTION_STOP_RECORDING", $this->lng->txt("chat_recording_description"));
1192  $this->tpl->setVariable("VAL_DESCRIPTION_STOP_RECORDING", $this->object->chat_recording->getDescription());
1193  }
1194  $this->tpl->setVariable("TXT_SUBMIT_STOP_RECORDING", $this->lng->txt("chat_stop_recording"));
1195  }
1196  else
1197  {
1198  $this->tpl->setVariable("TXT_TITLE_START_RECORDING", $this->lng->txt("chat_recording_title"));
1199  $this->tpl->setVariable("TXT_DESCRIPTION_START_RECORDING", $this->lng->txt("chat_recording_description"));
1200  $this->tpl->setVariable("TXT_SUBMIT_START_RECORDING", $this->lng->txt("chat_start_recording"));
1201  }
1202 
1203  $ilCtrl->setParameter($this, "room_id", $this->object->chat_room->getRoomId());
1204  $this->tpl->setVariable("MODERATOR_FORMACTION",
1205  $ilCtrl->getFormAction($this, "startRecording"));
1206  $this->tpl->setVariable("TXT_RECORDINGS",$this->lng->txt('chat_recordings'));
1207  $this->tpl->setVariable("MODERATOR_TARGET","_top");
1208  $this->tpl->parseCurrentBlock("moderator");
1209  }
1210  }
1211  // permanent link
1212  $this->tpl->setCurrentBlock('perma_link');
1213  $this->tpl->setVariable('PERMA_LINK', ILIAS_HTTP_PATH.'/goto.php?target='.$this->object->getType().'_'.$this->object->getRefId().'&client_id='.CLIENT_ID);
1214  $this->tpl->setVariable('TXT_PERMA_LINK', $this->lng->txt('chat_link_to_this_chat'));
1215  $this->tpl->setVariable('PERMA_TARGET', '_top');
1216  $this->tpl->parseCurrentBlock();
1217 
1218  $this->tpl->show(false);
1219  exit;
1220  }
1221 
1223  {
1224  $this->tpl = new ilTemplate("tpl.main.html", true, true);
1225  $this->__loadStylesheet();
1226  $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_right_frame.html",'Modules/Chat');
1227  $this->tpl->show(false);
1228  exit;
1229  }
1230 
1231  function cancel()
1232  {
1233  unset($_GET["p_id"]);
1234  unset($_GET["a_id"]);
1235 
1236  $this->showInputFrameObject();
1237  }
1238 
1240  {
1241  unset($_GET["p_id"]);
1242  unset($_GET["a_id"]);
1243 
1244  $this->showInputFrameObject();
1245  }
1246 
1247 
1248  function inputObject()
1249  {
1250  $this->object->chat_room->setUserId($_SESSION["AccountId"]);
1251  $this->object->chat_room->updateLastVisit();
1252 
1253 
1254  if(!$_POST["message"])
1255  {
1256  ilUtil::sendInfo($this->lng->txt("chat_insert_message"),true);
1257 
1258  return $this->showInputFrameObject();
1259  }
1260  if($_POST["message"] and $this->object->chat_room->checkWriteAccess())
1261  {
1262  // FORMAT MESSAGE
1263  $message = $this->__formatMessage();
1264 
1265  // SET MESSAGE AND SEND IT
1266  $this->object->server_comm->setMessage($message);
1267  if((int) $_GET["p_id"])
1268  {
1269  $this->object->server_comm->setType('private');
1270  }
1271  else if((int) $_GET["a_id"])
1272  {
1273  $this->object->server_comm->setType('address');
1274  }
1275  if(!$this->object->server_comm->send())
1276  {
1277  $this->error = $this->lng->txt("chat_no_connection");
1278  }
1279  }
1280  else
1281  {
1282  ilUtil::sendInfo($this->lng->txt('chat_kicked_from_room'),true);
1283  }
1284  $this->showInputFrameObject();
1285  }
1286 
1287  function inviteObject()
1288  {
1289  if($_GET["i_id"])
1290  {
1291  $this->object->chat_room->invite((int) $_GET["i_id"]);
1292  $this->object->sendMessage((int) $_GET["i_id"]);
1293  if((int)$this->object->chat_room->getRoomId())
1294  {
1295  ilUtil::sendInfo(sprintf($this->lng->txt("chat_user_invited_private"), $this->object->chat_room->getTitle()),true);
1296  }
1297  else
1298  {
1299  ilUtil::sendInfo(sprintf($this->lng->txt("chat_user_invited_public"), $this->object->getTitle()),true);
1300  }
1301  $this->showFramesObject();
1302  }
1303  }
1304 
1305  // Direct invitations from personal desktop
1306  function invitePDObject()
1307  {
1308  global $ilUser;
1309 
1310  if(!$_GET['usr_id'])
1311  {
1312  ilUtil::sendInfo($this->lng->txt('chat_no_user_selected',true));
1313  $this->showFramesObject();
1314  }
1315  // Create room
1316  $this->object->chat_room->setOwnerId($ilUser->getId());
1317  $this->object->chat_room->setTitle(ilObjUser::_lookupLogin($ilUser->getId()).
1318  ' : '.
1319  ilObjUser::_lookupLogin($_GET['usr_id']));
1320 
1321  // only add room if it doesn't exist
1322  if(!$id = $this->object->chat_room->lookupRoomId())
1323  {
1324  $id = $this->object->chat_room->add();
1325  }
1326 
1327  // Send message
1328  $this->object->chat_room->setRoomId($id);
1329  $this->object->chat_room->invite((int) $_GET["usr_id"]);
1330  $this->object->sendMessage((int) $_GET['usr_id']);
1331 
1332  if((int)$this->object->chat_room->getRoomId())
1333  {
1334  ilUtil::sendInfo(sprintf($this->lng->txt("chat_user_invited_private"), $this->object->chat_room->getTitle()),true);
1335  }
1336  else
1337  {
1338  ilUtil::sendInfo(sprintf($this->lng->txt("chat_user_invited_public"), $this->object->getTitle()),true);
1339  }
1340 
1341  ilUtil::redirect('ilias.php?baseClass=ilChatPresentationGUI&ref_id='.$this->object->getRefId().'&room_id='.$id);
1342  }
1343 
1344  function dropObject()
1345  {
1346  if($_GET["i_id"])
1347  {
1348  $this->object->chat_room->drop((int) $_GET["i_id"]);
1349 
1350  $tmp_user =& new ilObjUser($_GET["i_id"]);
1351  $this->object->server_comm->setKickedUser($tmp_user->getLogin());
1352  $this->object->server_comm->setType("kick");
1353  $this->object->server_comm->send();
1354  ilUtil::sendInfo($this->lng->txt("chat_user_dropped_private"),true);
1355  $this->showFramesObject();
1356  }
1357  }
1358  function closeFrame()
1359  {
1360  $this->__loadStylesheet(true);
1361  $this->tpl->addBlockFile("CONTENT", "content", "tpl.chat_close.html",'Modules/Chat');
1362  ilUtil::sendInfo("Your session is expired please login to ILIAS.");
1363  $this->tpl->touchBlock("content");
1364  }
1365 
1366  function exportObject()
1367  {
1368  $tmp_tpl =& new ilTemplate("tpl.chat_export.html",true,true,"Modules/Chat");
1369 
1370  if($this->object->chat_room->getRoomId())
1371  {
1372  $tmp_tpl->setVariable("CHAT_NAME",$this->object->chat_room->getTitle());
1373  }
1374  else
1375  {
1376  $tmp_tpl->setVariable("CHAT_NAME",$this->object->getTitle());
1377  }
1378  $tmp_tpl->setVariable("CHAT_DATE",strftime("%c",time()));
1379  $tmp_tpl->setVariable("CONTENT",$this->object->chat_room->getAllMessages());
1380  ilUtil::deliverData($tmp_tpl->get(),"1.html");
1381  exit;
1382  }
1383 
1384  // PRIVATE
1386  {
1387  global $ilCtrl, $ilUser;
1388 
1389  include_once 'Modules/Chat/classes/class.ilChatBlockedUsers.php';
1390 
1391  $all_users = $this->object->chat_room->getOnlineUsers();
1392 
1393  // filter blocked users
1394  $filtered_users = array();
1395  foreach($all_users as $user)
1396  {
1397  if(!ilChatBlockedUsers::_isBlocked($this->object->getId(),$user['user_id']))
1398  {
1399  if($user['user_id'] == $_SESSION['AccountId'] ||
1400  $user['user_id'] == ANONYMOUS_USER_ID)
1401  {
1402  continue;
1403  }
1404 
1405  $oUser = new ilObjUser();
1406  $oUser->setId($user['user_id']);
1407  $oUser->read();
1408 
1409  if($oUser->getPref('hide_own_online_status') == 'y')
1410  {
1411  continue;
1412  }
1413 
1414  $filtered_users[] = $oUser;
1415  }
1416  }
1417 
1418  if(count($filtered_users) < 1)
1419  {
1420  $this->tpl->setCurrentBlock('no_online');
1421  $this->tpl->setVariable('NO_ONLINE_USERS', $this->lng->txt('chat_no_online_users'));
1422  $this->tpl->parseCurrentBlock();
1423  }
1424  else
1425  {
1426  $counter = 0;
1427  foreach($filtered_users as $user)
1428  {
1429  if(!($counter % 2))
1430  {
1431  $this->tpl->setCurrentBlock('online_row_start');
1432  $this->tpl->touchBlock('online_row_start');
1433  $this->tpl->parseCurrentBlock();
1434 
1435  if($counter == count($filtered_users) - 1)
1436  {
1437  $this->tpl->setCurrentBlock('online_empty_col');
1438  $this->tpl->touchBlock('online_empty_col');
1439  $this->tpl->parseCurrentBlock();
1440  }
1441  }
1442  if(($counter % 2) || $counter == count($filtered_users) - 1)
1443  {
1444  $this->tpl->setCurrentBlock('online_row_end');
1445  $this->tpl->touchBlock('online_row_end');
1446  $this->tpl->parseCurrentBlock();
1447  }
1448 
1449  $this->tpl->setCurrentBlock('online');
1450  if($ilUser->getId() != ANONYMOUS_USER_ID)
1451  {
1452  if ($_GET['p_id'] == $user->getId() ||
1453  $_GET['a_id'] == $user->getId())
1454  {
1455  $this->tpl->setVariable('ONLINE_FONT_A','smallred');
1456  }
1457  else
1458  {
1459  $this->tpl->setVariable('ONLINE_FONT_A','small');
1460  }
1461 
1462  if($this->object->chat_room->isInvited($user->getId()))
1463  {
1464  $img = 'minus.gif';
1465  $cmd = 'drop';
1466  }
1467  else
1468  {
1469  $img = 'plus.gif';
1470  $cmd = 'invite';
1471  }
1472  $ilCtrl->setParameter($this, 'room_id', $_REQUEST['room_id']);
1473  $ilCtrl->setParameter($this, 'i_id', $user->getId());
1474  $this->tpl->setVariable('ONLINE_LINK_A',
1475  $ilCtrl->getLinkTarget($this, $cmd));
1476  $ilCtrl->clearParameters($this);
1477  $this->tpl->setVariable('TXT_INVITE_USER',$cmd == 'invite' ? $this->lng->txt('chat_invite_user') :
1478  $this->lng->txt('chat_disinvite_user'));
1479  if($user->getPref('public_profile') == 'y')
1480  {
1481  $this->tpl->setVariable('ONLINE_USER_NAME_A',
1482  $user->getFirstname().' '.$user->getLastname().' ('.$user->getLogin().')');
1483  }
1484  else
1485  {
1486  $this->tpl->setVariable('ONLINE_USER_NAME_A', $user->getLogin());
1487  }
1488  $this->tpl->setVariable('INVITE_IMG_SRC',
1489  ilUtil::getImagePath($img, 'Modules/Chat'));
1490  }
1491  else
1492  {
1493  $this->tpl->setVariable('ONLINE_USER_NAME_A_NOT_INVITEABLE', $user->getLogin());
1494  }
1495  $this->tpl->parseCurrentBlock();
1496  $counter++;
1497  }
1498  }
1499  $this->tpl->setCurrentBlock('show_online');
1500  $this->tpl->setVariable('ONLINE_USERS', $this->lng->txt('chat_online_users'));
1501  $this->tpl->parseCurrentBlock();
1502  }
1503 
1505  {
1506  global $rbacsystem, $ilCtrl, $ilUser;
1507 
1508  if(isset($_GET["a_users"]))
1509  {
1510  if($_GET["a_users"])
1511  {
1512  $_SESSION["a_users"] = true;
1513  }
1514  else
1515  {
1516  $_SESSION["a_users"] = 0;
1517  unset($_SESSION["a_users"]);
1518  }
1519  }
1520 
1521  $hide = $_SESSION["a_users"] ? true : false;
1522 
1523  $this->tpl->setVariable("ACTIVE_USERS",$this->lng->txt("chat_active_users"));
1524  $this->tpl->setVariable("DETAILS_B_TXT",$hide ? $this->lng->txt("chat_show_details") : $this->lng->txt("chat_hide_details"));
1525  $ilCtrl->setParameter($this, "room_id", $this->object->chat_room->getRoomId());
1526  $ilCtrl->setParameter($this, "a_users", ($hide ? 0 : 1));
1527  $this->tpl->setVariable("DETAILS_B",
1528  $ilCtrl->getLinkTarget($this, "showUserFrame"));
1529  $ilCtrl->clearParameters($this);
1530 
1531  if($hide)
1532  {
1533  return true;
1534  }
1535  $users = $this->object->chat_room->getActiveUsers();
1536  if(count($users) <= 1)
1537  {
1538  $this->tpl->setCurrentBlock("no_actice");
1539  $this->tpl->setVariable("NO_ACTIVE_USERS",$this->lng->txt("chat_no_active_users"));
1540  $this->tpl->parseCurrentBlock();
1541  }
1542  else
1543  {
1544  $user_obj =& new ilObjUser();
1545  foreach($users as $user)
1546  {
1547  if($user == $_SESSION["AccountId"])
1548  {
1549  continue;
1550  }
1551  $user_obj->setId($user);
1552  $user_obj->read();
1553 
1554  if($rbacsystem->checkAccess('moderate',$this->object->getRefId()) and !$_REQUEST['room_id'])
1555  {
1556  $this->tpl->setCurrentBlock("moderate");
1557  $ilCtrl->setParameter($this, "kick_id", $user_obj->getId());
1558  if($this->object->chat_room->isKicked($user_obj->getId()))
1559  {
1560  $this->tpl->setVariable("MOD_INVITE_IMG_SRC",ilUtil::getImagePath('plus.gif','Modules/Chat'));
1561  $this->tpl->setVariable("MOD_TXT_INVITE_USER",$this->lng->txt('chat_unkick_user_session'));
1562  $this->tpl->setVariable("MOD_ONLINE_LINK_A",
1563  $ilCtrl->getLinkTarget($this, "unkickUser"));
1564  }
1565  else
1566  {
1567  $this->tpl->setVariable("MOD_INVITE_IMG_SRC",ilUtil::getImagePath('minus.gif','Modules/Chat'));
1568  $this->tpl->setVariable("MOD_TXT_INVITE_USER",$this->lng->txt('chat_kick_user_session'));
1569  $this->tpl->setVariable("MOD_ONLINE_LINK_A",
1570  $ilCtrl->getLinkTarget($this, "kickUser"));
1571  }
1572  $ilCtrl->clearParameters($this);
1573 
1574  if($user_obj->getPref('public_profile') == 'y')
1575  {
1576  $this->tpl->setVariable("MOD_ONLINE_USER_NAME_A", $user_obj->getFirstname()." ".$user_obj->getLastname()." (".$user_obj->getLogin().")");
1577  }
1578  else
1579  {
1580  $this->tpl->setVariable("MOD_ONLINE_USER_NAME_A",$user_obj->getLogin());
1581  }
1582 
1583 
1584  $this->tpl->parseCurrentBlock();
1585  }
1586  else
1587  {
1588  $this->tpl->setCurrentBlock("non_moderate");
1589  if ($_GET["p_id"] == $user ||
1590  $_GET["a_id"] == $user)
1591  {
1592  $this->tpl->setVariable("ACTIVE_FONT_A","smallred");
1593  }
1594  else
1595  {
1596  $this->tpl->setVariable("ACTIVE_FONT_A","small");
1597  }
1598  $this->tpl->setVariable("ACTIVE_USER_NAME_A",$user_obj->getLogin());
1599  $this->tpl->parseCurrentBlock();
1600  }
1601  $this->tpl->setCurrentBlock("active");
1602 
1603  if($ilUser->getId() != ANONYMOUS_USER_ID && $user != ANONYMOUS_USER_ID)
1604  {
1605  if($user_obj->getPref('public_profile') == 'y')
1606  {
1607  $this->tpl->setVariable('ACTIVE_ROW_TXT_PROFILE', $this->lng->txt('chat_profile'));
1608  $ilCtrl->setParameter($this, "user", $user_obj->getId());
1609  $this->tpl->setVariable('ACTIVE_ROW_PROFILE_LINK',
1610  $ilCtrl->getLinkTarget($this, "showUserProfile"));
1611  $ilCtrl->clearParameters($this);
1612  }
1613 
1614  $ilCtrl->setParameter($this, "room_id", $_REQUEST["room_id"]);
1615  $ilCtrl->setParameter($this, "a_id", $user);
1616  $this->tpl->setVariable("ACTIVE_ADDRESS_A",
1617  $ilCtrl->getLinkTarget($this, "showInputFrame"));
1618  $this->tpl->setVariable("ACTIVE_TXT_ADDRESS_A",$this->lng->txt("chat_address"));
1619 
1620  $ilCtrl->setParameter($this, "p_id", $user);
1621  $ilCtrl->setParameter($this, "a_id", "");
1622  $this->tpl->setVariable("ACTIVE_LINK_A",
1623  $ilCtrl->getLinkTarget($this, "showInputFrame"));
1624  $this->tpl->setVariable("ACTIVE_TXT_WHISPER_A",$this->lng->txt("chat_whisper"));
1625  $ilCtrl->setParameter($this, "p_id", "");
1626  }
1627 
1628  $this->tpl->parseCurrentBlock();
1629  }
1630  }
1631  }
1633  {
1634  $opt = array("createRoom" => $this->lng->txt("chat_room_select"));
1635 
1636  return ilUtil::formSelect("","action_b",$opt,false,true);
1637  }
1638 
1640  {
1641  global $rbacsystem;
1642 
1643  $opt["exportRoom"] = $this->lng->txt("chat_html_export");
1644 
1645  if($rbacsystem->checkAccess('write',$this->object->getRefId()) or
1646  count($this->object->chat_room->getRoomsOfObject()))
1647  {
1648  $opt["refreshRoom"] = $this->lng->txt("chat_refresh");
1649  }
1650 
1651  if(count($this->object->chat_room->getRoomsOfObject()))
1652  {
1653  $opt["renameRoom"] = $this->lng->txt("rename");
1654  $opt["deleteRoom"] = $this->lng->txt("delete");
1655  }
1656  return ilUtil::formSelect(isset($_SESSION["room_id_delete"]) ? "deleteRoom" : "",
1657  "action",
1658  $opt,
1659  false,
1660  true);
1661  }
1662 
1663  function __showRooms()
1664  {
1665  global $rbacsystem, $ilUser, $ilCtrl;
1666 
1667  include_once 'Modules/Chat/classes/class.ilChatBlockedUsers.php';
1668 
1669  $public_rooms = $this->object->chat_room->getAllRooms();
1670  $private_rooms = $this->object->chat_room->getRooms();
1671 
1672  if(isset($_GET["h_rooms"]))
1673  {
1674  if($_GET["h_rooms"])
1675  {
1676  $_SESSION["h_rooms"] = true;
1677  }
1678  else
1679  {
1680  $_SESSION["h_rooms"] = 0;
1681  unset($_SESSION["h_rooms"]);
1682  }
1683  }
1684  $hide = $_SESSION["h_rooms"] ? true : false;
1685 
1686  $this->tpl->setVariable("ROOMS_ROOMS",$this->lng->txt("chat_rooms"));
1687  $this->tpl->setVariable("DETAILS_TXT",$hide ? $this->lng->txt("chat_show_details") : $this->lng->txt("chat_hide_details"));
1688  $this->tpl->setVariable("ROOMS_COUNT",count($public_rooms) + count($private_rooms));
1689  $ilCtrl->setParameter($this, "room_id", $this->object->chat_room->getRoomId());
1690  $ilCtrl->setParameter($this, "h_rooms", ($hide ? 0 : 1));
1691  $this->tpl->setVariable("DETAILS_A",
1692  $ilCtrl->getLinkTarget($this, "showUserFrame"));
1693  $ilCtrl->clearParameters($this);
1694 
1695  if($hide)
1696  {
1697  return true;
1698  }
1699 
1700  $this->object->__initChatRecording();
1701 
1702  $user_obj =& new ilObjUser();
1703  foreach($public_rooms as $room)
1704  {
1705  $tblrow = ($room['child'] == $this->object->getRefId()) ? 'tblrowmarked' : 'tblrow1';
1706 
1707  if(ilChatBlockedUsers::_isBlocked($room['obj_id'],$ilUser->getId()))
1708  {
1709  continue;
1710  }
1711 
1712  $this->tpl->setCurrentBlock("room_row");
1713  $this->tpl->setVariable("ROOM_ROW_CSS",$tblrow);
1714  $ilCtrl->setParameter($this, "ref_id", $room["child"]);
1715  $this->tpl->setVariable("ROOM_LINK", $ilCtrl->getLinkTarget($this, "showFrames"));
1716  $ilCtrl->setParameter($this, "ref_id", $_GET["ref_id"]);
1717  $this->tpl->setVariable("ROOM_TARGET","_top");
1718  $this->tpl->setVariable("ROOM_NAME",$room["title"]);
1719  $this->tpl->setVariable("ROOM_ONLINE",$this->object->chat_room->getCountActiveUser($room["obj_id"],0));
1720  $this->object->chat_recording->setObjId($room["obj_id"]);
1721  if ($room["child"] == $this->object->getRefId() &&
1722  $this->object->chat_room->getRoomId() == 0 &&
1723  $rbacsystem->checkAccess("moderate", $this->object->getRefId()))
1724  {
1725  $this->tpl->setVariable("TXT_EMPTY_ROOM", $this->lng->txt("chat_empty"));
1726  $ilCtrl->setParameter($this, "ref_id", $room["child"]);
1727  $this->tpl->setVariable("LINK_EMPTY_ROOM",
1728  $ilCtrl->getLinkTarget($this, "emptyRoom"));
1729  $ilCtrl->setParameter($this, "ref_id", $_GET["ref_id"]);
1730  }
1731 
1732  $this->object->chat_recording->setObjId($room["obj_id"]);
1733  $this->object->chat_recording->setRoomId(0);
1734  if ($this->object->chat_recording->isRecording())
1735  {
1736  $this->tpl->setVariable("TXT_RECORDING", $this->lng->txt("chat_recording_running"));
1737  }
1738  $this->tpl->parseCurrentBlock();
1739 
1740  reset($private_rooms);
1741  foreach($private_rooms as $priv_room)
1742  {
1743  if ($priv_room["chat_id"] == $room["obj_id"])
1744  {
1745  $this->tpl->touchBlock("room_row_indent");
1746  $this->tpl->setCurrentBlock("room_row");
1747  $this->tpl->setVariable("ROOM_ROW_CSS",$tblrow);
1748  $ilCtrl->setParameter($this, "ref_id", $room["child"]);
1749  $ilCtrl->setParameter($this, "room_id", $priv_room["room_id"]);
1750  $this->tpl->setVariable("ROOM_LINK",
1751  $ilCtrl->getLinkTarget($this, "showFrames"));
1752  $ilCtrl->clearParameters($this);
1753 
1754  $this->tpl->setVariable("ROOM_TARGET","_top");
1755  $this->tpl->setVariable("ROOM_NAME",$priv_room["title"]);
1756  $this->tpl->setVariable("ROOM_ONLINE",
1757  $this->object->chat_room->getCountActiveUser($priv_room["chat_id"],$priv_room["room_id"]));
1758 
1759  if ($priv_room["owner"] != $_SESSION["AccountId"] &&
1760  !$rbacsystem->checkAccess('moderate', $this->object->getRefId()))
1761  {
1762  if($user_obj =& ilObjectFactory::getInstanceByObjId($priv_room['owner'],false))
1763  {
1764  $this->tpl->setVariable("TXT_ROOM_INVITATION", $this->lng->txt("chat_invited_by"));
1765  $this->tpl->setVariable("ROOM_INVITATION_USER", $user_obj->getLogin());
1766  }
1767  }
1768  else
1769  {
1770  $this->tpl->setVariable("TXT_DELETE_ROOM", $this->lng->txt("delete"));
1771  $ilCtrl->setParameter($this, "room_id", $this->object->chat_room->getRoomId());
1772  $ilCtrl->setParameter($this, "room_id_delete", $priv_room["room_id"]);
1773  $this->tpl->setVariable("LINK_DELETE_ROOM",
1774  $ilCtrl->getLinkTarget($this, "deleteRoom"));
1775  }
1776 
1777  $this->object->chat_recording->setObjId($priv_room["chat_id"]);
1778  $this->object->chat_recording->setRoomId($priv_room["room_id"]);
1779  if ($this->object->chat_recording->isRecording())
1780  {
1781  $this->tpl->setVariable("TXT_RECORDING", $this->lng->txt("chat_recording_running"));
1782  }
1783 
1784  if ($priv_room["chat_id"] == $this->object->getRefId() &&
1785  $priv_room["room_id"] == $this->object->chat_room->getRoomId() &&
1786  $rbacsystem->checkAccess("moderate", $this->object->getRefId()))
1787  {
1788  $this->tpl->setVariable("TXT_EMPTY_ROOM", $this->lng->txt("chat_empty"));
1789  $ilCtrl->setParameter($this, "ref_id", $this->object->getRefId());
1790  $ilCtrl->setParameter($this, "room_id", $this->object->chat_room->getRoomId());
1791  $this->tpl->setVariable("LINK_EMPTY_ROOM",
1792  $ilCtrl->getLinkTarget($this, "emptyRoom"));
1793  $ilCtrl->clearParameters($this);
1794  }
1795 
1796  $this->tpl->parseCurrentBlock();
1797  }
1798  }
1799 
1800  }
1801 
1802  }
1803  function __loadStylesheet($expires = false)
1804  {
1805  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1806  $this->tpl->setCurrentBlock("ChatStyle");
1807  $this->tpl->setVariable("LOCATION_CHAT_STYLESHEET", ilUtil::getStyleSheetLocation());
1808  if($expires)
1809  {
1810  $this->tpl->setVariable("EXPIRES","<meta http-equiv=\"expires\" content=\"now\">".
1811  "<meta http-equiv=\"refresh\" content=\"30\">");
1812  }
1813  $this->tpl->parseCurrentBlock();
1814  }
1815 
1816  function __getColorSelect()
1817  {
1818  $colors = array("black" => $this->lng->txt("chat_black"),
1819  "red" => $this->lng->txt("chat_red"),
1820  "green" => $this->lng->txt("chat_green"),
1821  "maroon" => $this->lng->txt("chat_maroon"),
1822  "olive" => $this->lng->txt("chat_olive"),
1823  "navy" => $this->lng->txt("chat_navy"),
1824  "purple" => $this->lng->txt("chat_purple"),
1825  "teal" => $this->lng->txt("chat_teal"),
1826  "silver" => $this->lng->txt("chat_silver"),
1827  "gray" => $this->lng->txt("chat_gray"),
1828  "lime" => $this->lng->txt("chat_lime"),
1829  "yellow" => $this->lng->txt("chat_yellow"),
1830  "fuchsia" => $this->lng->txt("chat_fuchsia"),
1831  "aqua" => $this->lng->txt("chat_aqua"),
1832  "blue" => $this->lng->txt("chat_blue"));
1833 
1834  return ilUtil::formSelect($_POST["color"],"color",$colors,false,true);
1835  }
1836 
1837  function __getFontType()
1838  {
1839  $types = array("times" => $this->lng->txt("chat_times"),
1840  "tahoma" => $this->lng->txt("chat_tahoma"),
1841  "arial" => $this->lng->txt("chat_arial"));
1842 
1843  $_POST["type"] = $_POST["type"] ? $_POST["type"] : "times";
1844 
1845  foreach($types as $name => $type)
1846  {
1847  $this->tpl->setCurrentBlock("FONT_TYPES");
1848  $this->tpl->setVariable("BL_TXT_TYPE",$type);
1849  $this->tpl->setVariable("FONT_TYPE",$name);
1850  $this->tpl->setVariable("TYPE_CHECKED",$_POST["type"] == $name ? "checked=\"checked\"" : "");
1851  $this->tpl->parseCurrentBlock();
1852  }
1853  }
1854 
1855  function __getFontFace()
1856  {
1857  $_POST["face"] = is_array($_POST["face"]) ? $_POST["face"] : array();
1858 
1859  $types = array("bold" => $this->lng->txt("chat_bold"),
1860  "italic" => $this->lng->txt("chat_italic"),
1861  "underlined" => $this->lng->txt("chat_underlined"));
1862 
1863  $this->tpl->setCurrentBlock("FONT_FACES");
1864  $this->tpl->setVariable("BL_TXT_FACE","<b>".$this->lng->txt("chat_bold")."</b>");
1865  $this->tpl->setVariable("FONT_FACE","bold");
1866  $this->tpl->setVariable("FACE_CHECKED",in_array("bold",$_POST["face"]) ? "checked=\"checked\"" : "");
1867  $this->tpl->parseCurrentBlock();
1868 
1869  $this->tpl->setCurrentBlock("FONT_FACES");
1870  $this->tpl->setVariable("BL_TXT_FACE","<i>".$this->lng->txt("chat_italic")."</i>");
1871  $this->tpl->setVariable("FONT_FACE","italic");
1872  $this->tpl->setVariable("FACE_CHECKED",in_array("italic",$_POST["face"]) ? "checked=\"checked\"" : "");
1873  $this->tpl->parseCurrentBlock();
1874 
1875  $this->tpl->setCurrentBlock("FONT_FACES");
1876  $this->tpl->setVariable("BL_TXT_FACE","<u>".$this->lng->txt("chat_underlined")."</u>");
1877  $this->tpl->setVariable("FONT_FACE","underlined");
1878  $this->tpl->setVariable("FACE_CHECKED",in_array("underlined",$_POST["face"]) ? "checked=\"checked\"" : "");
1879  $this->tpl->parseCurrentBlock();
1880  }
1881 
1882  function __formatMessage()
1883  {
1884  $tpl = new ilTemplate("tpl.chat_message.html",true,true,'Modules/Chat');
1885 
1886  $_POST['message'] = htmlentities(trim($_POST['message']),ENT_QUOTES,'utf-8');
1887  $_POST['message'] = ilUtil::stripSlashes($_POST['message']);
1888 
1889  $tpl->setVariable("MESSAGE",$_POST["message"]);
1890  $tpl->setVariable("FONT_COLOR",$_POST["color"]);
1891  $tpl->setVariable("FONT_FACE",$_POST["type"]);
1892 
1893  if($_GET["p_id"])
1894  {
1895  $user_obj =& new ilObjUser((int) $_SESSION["AccountId"]);
1896  $user_obj->read();
1897 
1898  $tpl->setCurrentBlock("private");
1899  $tpl->setVariable("PRIVATE_U_COLOR","red");
1900  $tpl->setVariable("PRIVATE_FROM",$user_obj->getLogin());
1901 
1902  $user_obj =& new ilObjUser((int) $_GET["p_id"]);
1903  $user_obj->read();
1904  $tpl->setVariable("PRIVATE_TO",$user_obj->getLogin());
1905  $tpl->parseCurrentBlock();
1906  }
1907  else if($_GET["a_id"])
1908  {
1909  $tpl->setCurrentBlock("address");
1910  $tpl->setVariable("ADDRESS_FROM_COLOR","navy");
1911  $user_obj =& new ilObjUser((int) $_SESSION["AccountId"]);
1912  $user_obj->read();
1913  $tpl->setVariable("ADDRESS_FROM",$user_obj->getLogin());
1914 
1915  $tpl->setVariable("ADDRESS_TO_COLOR","red");
1916  $user_obj =& new ilObjUser((int) $_GET["a_id"]);
1917  $user_obj->read();
1918  $tpl->setVariable("ADDRESS_TO",$user_obj->getLogin());
1919  $tpl->parseCurrentBlock();
1920  }
1921  else
1922  {
1923  $tpl->setCurrentBlock("normal");
1924  $tpl->setVariable("NORMAL_U_COLOR","navy");
1925  $tpl->setVariable("NORMAL_UNAME",$this->object->chat_user->getLogin());
1926  $tpl->parseCurrentBlock();
1927  }
1928  // OPEN TAGS
1929  if($_POST["face"])
1930  {
1931  foreach($_POST["face"] as $face)
1932  {
1933  $tpl->setCurrentBlock("type_open");
1934  switch($face)
1935  {
1936  case "bold":
1937  $tpl->setVariable("TYPE_TYPE_O","b");
1938  break;
1939  case "italic":
1940  $tpl->setVariable("TYPE_TYPE_O","i");
1941  break;
1942 
1943  case "underlined":
1944  $tpl->setVariable("TYPE_TYPE_O","u");
1945  break;
1946  }
1947  $tpl->parseCurrentBlock();
1948  }
1949  $_POST["face"] = array_reverse($_POST["face"]);
1950  foreach($_POST["face"] as $face)
1951  {
1952  $tpl->setCurrentBlock("type_close");
1953  switch($face)
1954  {
1955  case "bold":
1956  $tpl->setVariable("TYPE_TYPE_C","b");
1957  break;
1958  case "italic":
1959  $tpl->setVariable("TYPE_TYPE_C","i");
1960  break;
1961 
1962  case "underlined":
1963  $tpl->setVariable("TYPE_TYPE_C","u");
1964  break;
1965  }
1966  $tpl->parseCurrentBlock();
1967  }
1968  }
1969 
1970  $message = preg_replace("/\r/","",$tpl->get());
1971  $message = preg_replace("/\n/","",$message);
1972 
1973  return $message;
1974  }
1975  function __exportRooms()
1976  {
1977  include_once "Modules/Chat/classes/class.ilFileDataChat.php";
1978 
1979  if(count($_POST["del_id"]) == 1)
1980  {
1981  $this->object->chat_room->setRoomId($_POST["del_id"][0]);
1982  $this->exportObject();
1983  }
1984 
1985  $file_obj =& new ilFileDataChat($this->object);
1986 
1987  foreach($_POST["del_id"] as $id)
1988  {
1989  $this->object->chat_room->setRoomId((int) $id);
1990 
1991  $tmp_tpl =& new ilTemplate("tpl.chat_export.html",true,true,"Modules/Chat");
1992 
1993  if($id)
1994  {
1995  $tmp_tpl->setVariable("CHAT_NAME",$this->object->chat_room->getTitle());
1996  }
1997  else
1998  {
1999  $tmp_tpl->setVariable("CHAT_NAME",$this->object->getTitle());
2000  }
2001  $tmp_tpl->setVariable("CHAT_DATE",strftime("%c",time()));
2002  $tmp_tpl->setVariable("CONTENT",$this->object->chat_room->getAllMessages());
2003 
2004  $file_obj->addFile("chat_".$this->object->chat_room->getRoomId().".html",$tmp_tpl->get());
2005  }
2006  $fname = $file_obj->zip();
2007  ilUtil::deliverFile($fname,"ilias_chat.zip");
2008  }
2009 
2015  function getTabs(&$tabs_gui)
2016  {
2017  global $rbacsystem,$rbacreview, $ilAccess;
2018 
2019  $this->ctrl->setParameter($this,"ref_id",$this->object->getRefId());
2020 
2021 //echo "-".$this->ctrl->getCmd()."-";
2022 
2023  if($rbacsystem->checkAccess('read',$this->object->getRefId()))
2024  {
2025  $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "view")
2026  ? true
2027  : false;
2028  $tabs_gui->addTarget("chat_rooms",
2029  $this->ctrl->getLinkTarget($this, "view"), array("view", ""), get_class($this),
2030  "", $force_active);
2031  }
2032 
2033  // info tab
2034  if ($ilAccess->checkAccess('visible', '', $this->ref_id))
2035  {
2036  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
2037  || strtolower($_GET["cmdClass"]) == "ilnotegui")
2038  ? true
2039  : false;
2040  //echo "-$force_active-";
2041  $tabs_gui->addTarget("info_short",
2042  $this->ctrl->getLinkTargetByClass(
2043  array("ilobjchatgui", "ilinfoscreengui"), "showSummary"),
2044  array("showSummary", "infoScreen"),
2045  "", "", $force_active);
2046  }
2047 
2048  if($rbacsystem->checkAccess('write',$this->object->getRefId()))
2049  {
2050  $force_active = ($_GET["cmd"] == "edit")
2051  ? true
2052  : false;
2053  $tabs_gui->addTarget("edit_properties",
2054  $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this),
2055  "", $force_active);
2056  }
2057  if($rbacsystem->checkAccess('moderate',$this->object->getRefId()))
2058  {
2059  $tabs_gui->addTarget("chat_recordings",
2060  $this->ctrl->getLinkTarget($this, "recordings"), "recordings", get_class($this));
2061  }
2062  if($rbacsystem->checkAccess('moderate',$this->object->getRefId()))
2063  {
2064  $tabs_gui->addTarget("chat_blocked_users",
2065  $this->ctrl->getLinkTarget($this, "blockedUsers"),
2066  array("blockedUsers", "unBlockUsers", "blockUser"), get_class($this));
2067  }
2068 
2069  if($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
2070  {
2071  $tabs_gui->addTarget("perm_settings",
2072  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
2073  }
2074  }
2075 
2076  function __prepareOutput()
2077  {
2078  // output objects
2079  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2080  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
2081 
2082  // output locator
2083  $this->__setLocator();
2084 
2085  // output message
2086  if ($this->message)
2087  {
2088  ilUtil::sendInfo($this->message);
2089  }
2090 
2091  // display infopanel if something happened
2093 
2094  // set header
2095  $this->__setHeader();
2096  }
2097 
2098  function __setHeader()
2099  {
2100  include_once './classes/class.ilTabsGUI.php';
2101 
2102  $this->tpl->setCurrentBlock("header_image");
2103  $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_chat_b.gif"));
2104  $this->tpl->parseCurrentBlock();
2105  $this->tpl->setVariable("HEADER",$this->object->getTitle());
2106  $this->tpl->setVariable("H_DESCRIPTION",$this->object->getDescription());
2107 
2108  #$tabs_gui =& new ilTabsGUI();
2109  $this->getTabs($this->tabs_gui);
2110 
2111  // output tabs
2112  #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
2113  }
2114 
2115  function __setLocator()
2116  {
2117  global $tree;
2118  global $ilias_locator;
2119 
2120  $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
2121 
2122  $counter = 0;
2123  foreach ($tree->getPathFull($this->object->getRefId()) as $key => $row)
2124  {
2125  if($counter++)
2126  {
2127  $this->tpl->touchBlock('locator_separator_prefix');
2128  }
2129 
2130  $this->tpl->setCurrentBlock("locator_item");
2131 
2132  if($row["type"] == 'chat')
2133  {
2134  $this->tpl->setVariable("ITEM",$this->object->getTitle());
2135  $this->tpl->setVariable("LINK_ITEM",$this->ctrl->getLinkTarget($this));
2136  }
2137  elseif ($row["child"] != $tree->getRootId())
2138  {
2139  $this->tpl->setVariable("ITEM", $row["title"]);
2140  $this->tpl->setVariable("LINK_ITEM","repository.php?ref_id=".$row["child"]);
2141  }
2142  else
2143  {
2144  $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
2145  $this->tpl->setVariable("LINK_ITEM","repository.php?ref_id=".$row["child"]);
2146  }
2147 
2148  $this->tpl->parseCurrentBlock();
2149  }
2150 
2151  $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
2152  $this->tpl->parseCurrentBlock();
2153  }
2154 
2155  function _goto($a_target)
2156  {
2157  global $ilAccess, $ilErr, $lng;
2158 
2159  if ($ilAccess->checkAccess("read", "", $a_target))
2160  {
2161  $_GET["ref_id"] = $a_target;
2162  $_GET["cmd"] = "view";
2163  $_GET["baseClass"] = "ilChatHandlerGUI";
2164  include("ilias.php");
2165  exit;
2166  }
2167  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
2168  {
2169  $_GET["cmd"] = "frameset";
2170  $_GET["target"] = "";
2171  $_GET["ref_id"] = ROOT_FOLDER_ID;
2172  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
2173  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
2174  include("repository.php");
2175  exit;
2176  }
2177 
2178  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2179  }
2180 
2181  public function showUserProfileObject()
2182  {
2183  global $tpl, $ilCtrl;
2184 
2185  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
2186 
2187  //$tpl->addBlockFile('CONTENT', 'content', 'tpl.chat_profile_view.html','Modules/Chat');
2188 
2189  $profile_gui = new ilPublicUserProfileGUI((int)$_GET['user']);
2190  //$tpl->setVariable('USR_PROFILE', $ilCtrl->getHTML($profile_gui));
2191  $tpl->setContent($ilCtrl->getHTML($profile_gui));
2192  $tpl->show();
2193  exit();
2194  }
2195 
2196  public function addLocatorItems()
2197  {
2198  global $ilLocator;
2199 
2200  if (is_object($this->object))
2201  {
2202  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ''), '', $_GET['ref_id']);
2203  }
2204  }
2205 
2211  function infoScreenObject()
2212  {
2213  $this->ctrl->setCmd("showSummary");
2214  $this->ctrl->setCmdClass("ilinfoscreengui");
2215  $this->infoScreen();
2216  }
2217 
2221  function infoScreen()
2222  {
2223  global $ilAccess;
2224 
2225  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
2226  {
2227  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
2228  }
2229 
2230  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
2231  $info = new ilInfoScreenGUI($this);
2232 
2233  $info->enablePrivateNotes();
2234 
2235  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2236  {
2237  //$info->enableNews();
2238  }
2239 
2240  // no news editing for files, just notifications
2241 // $info->enableNewsEditing(false);
2242  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
2243  {
2244 // $news_set = new ilSetting("news");
2245 // $enable_internal_rss = $news_set->get("enable_rss_for_internal");
2246 
2247 // if ($enable_internal_rss)
2248 // {
2249 // $info->setBlockProperty("news", "settings", true);
2250 // $info->setBlockProperty("news", "public_notifications_option", true);
2251 // }
2252  }
2253 
2254  // standard meta data
2255  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
2256 
2257  // forward the command
2258  $this->ctrl->forwardCommand($info);
2259 
2260  }
2261 
2262 }
2263 // END class.ilObjChatGUI
2264 ?>