ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
5
12{
16 private function getReadableAreas()
17 {
22 global $ilUser, $rbacsystem;
23
24 $readable_rooms = array();
25
26 $chatroom_objects = ilChatroom::getUntrashedChatReferences(array(
27 'last_activity' => strtotime('-5 days', time())
28 ));
29 foreach($chatroom_objects as $object)
30 {
31 if(isset($readable_rooms[$object['obj_id']]))
32 {
33 continue;
34 }
35
36 if($rbacsystem->checkAccess('read', '', $object['ref_id']))
37 {
38 $room = ilChatroom::byObjectId($object['obj_id']);
39 if($room && !$room->isUserBanned($ilUser->getId()))
40 {
41 $readable_rooms[$object['obj_id']] = array(
42 'ref_id' => $object['ref_id'],
43 'obj_id' => $object['obj_id'],
44 'room_id' => $room->getRoomId(),
45 'title' => $object['title'],
46 'parent_title' => $object['parent_title']
47 );
48 }
49 }
50 }
51
52 $title = array();
53 foreach($readable_rooms as $k => $v)
54 {
55 $title[$k] = strtolower($v['title']);
56 }
57 array_multisort($title, SORT_STRING, $readable_rooms);
58
59 return $readable_rooms;
60 }
61
65 public function getRoomSelect()
66 {
71 global $lng, $ilUser;
72
73 $readable = $this->getReadableAreas();
74 $tpl = new ilTemplate('tpl.chatroom_block_room_select.html', true, true, 'Modules/Chatroom');
75 $tpl->setVariable('TXT_SELECT_ROOM', $lng->txt('chat_select_room'));
76 foreach($readable as $room)
77 {
78 $tpl->setCurrentBlock('select_room_row');
79 $tpl->setVariable('ROW_VALUE', $room['ref_id']);
80 $tpl->setVariable('ROW_CAPTION', sprintf($lng->txt('room_in_container'), $room['title'], $room['parent_title']));
81
82 if($ilUser->getPref('chatviewer_last_selected_room') == $room['ref_id'])
83 $tpl->setVariable('ROW_SELECTED', 'selected="selected"');
84
85 $tpl->parseCurrentBlock();
86 }
87
88 return $tpl->get();
89 }
90
95 public function getMessages(ilChatroom $room)
96 {
100 global $ilUser;
101
102 include 'Modules/Chatroom/classes/class.ilChatroomUser.php';
103 $messages = $room->getLastMessagesForChatViewer($room->getSetting('display_past_msgs'), new ilChatroomUser($ilUser, $room));
104
105 $output_messages = array();
106
107 foreach($messages as $msg)
108 {
109 $output_messages[] = $msg;
110 }
111
112 return $output_messages;
113 }
114}
global $tpl
Definition: ilias.php:8
Class ilChatroomUser.
Class ilChatroom.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
getSetting($name)
Returns setting from $this->settings array by given name.
special template class to simplify handling of ITX/PEAR
$messages
Definition: en-x-test.php:7
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15