ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilChatroomBlock.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
5 
12 {
16  public function getRoomSelect()
17  {
18  global $DIC;
19 
20  $readable = $this->getReadableAreas();
21  $tpl = new ilTemplate('tpl.chatroom_block_room_select.html', true, true, 'Modules/Chatroom');
22  $tpl->setVariable('TXT_SELECT_ROOM', $DIC->language()->txt('chat_select_room'));
23  foreach ($readable as $room) {
24  $tpl->setCurrentBlock('select_room_row');
25  $tpl->setVariable('ROW_VALUE', $room['ref_id']);
26  $tpl->setVariable('ROW_CAPTION', sprintf($DIC->language()->txt('room_in_container'), $room['title'], $room['parent_title']));
27 
28  if ($DIC->user()->getPref('chatviewer_last_selected_room') == $room['ref_id']) {
29  $tpl->setVariable('ROW_SELECTED', 'selected="selected"');
30  }
31 
32  $tpl->parseCurrentBlock();
33  }
34 
35  return $tpl->get();
36  }
37 
41  private function getReadableAreas()
42  {
43  global $DIC;
44 
45  $readable_rooms = array();
46 
48  'last_activity' => strtotime('-5 days', time())
49  ));
50  foreach ($chatroom_objects as $object) {
51  if (isset($readable_rooms[$object['obj_id']])) {
52  continue;
53  }
54 
55  if (ilChatroom::checkUserPermissions('read', $object['ref_id'], false)) {
56  $room = ilChatroom::byObjectId($object['obj_id']);
57  if ($room && !$room->isUserBanned($DIC->user()->getId())) {
58  $readable_rooms[$object['obj_id']] = array(
59  'ref_id' => $object['ref_id'],
60  'obj_id' => $object['obj_id'],
61  'room_id' => $room->getRoomId(),
62  'title' => $object['title'],
63  'parent_title' => $object['parent_title']
64  );
65  }
66  }
67  }
68 
69  $title = array();
70  foreach ($readable_rooms as $k => $v) {
71  $title[$k] = strtolower($v['title']);
72  }
73  array_multisort($title, SORT_STRING, $readable_rooms);
74 
75  return $readable_rooms;
76  }
77 
82  public function getMessages(ilChatroom $room)
83  {
84  global $DIC;
85 
86  include 'Modules/Chatroom/classes/class.ilChatroomUser.php';
88  $room->getSetting('display_past_msgs'),
89  new ilChatroomUser(
90  $DIC->user(),
91  $room
92  )
93  );
94 
95  $output_messages = array();
96 
97  foreach ($messages as $msg) {
98  $output_messages[] = $msg;
99  }
100 
101  return $output_messages;
102  }
103 }
static getUntrashedChatReferences($filter=array())
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
getSetting($name)
Returns setting from $this->settings array by given name.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
Class ilChatroom.
getLastMessagesForChatViewer($number, $chatuser=null)
$messages
Definition: en-x-test.php:7
getMessages(ilChatroom $room)
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.