ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 public function getRoomSelect()
17 {
22 global $lng, $ilUser;
23
24 $readable = $this->getReadableAreas();
25 $tpl = new ilTemplate('tpl.chatroom_block_room_select.html', true, true, 'Modules/Chatroom');
26 $tpl->setVariable('TXT_SELECT_ROOM', $lng->txt('chat_select_room'));
27 foreach($readable as $room)
28 {
29 $tpl->setCurrentBlock('select_room_row');
30 $tpl->setVariable('ROW_VALUE', $room['ref_id']);
31 $tpl->setVariable('ROW_CAPTION', sprintf($lng->txt('room_in_container'), $room['title'], $room['parent_title']));
32
33 if($ilUser->getPref('chatviewer_last_selected_room') == $room['ref_id'])
34 $tpl->setVariable('ROW_SELECTED', 'selected="selected"');
35
36 $tpl->parseCurrentBlock();
37 }
38
39 return $tpl->get();
40 }
41
45 private function getReadableAreas()
46 {
51 global $ilUser, $rbacsystem;
52
53 $readable_rooms = array();
54
55 $chatroom_objects = ilChatroom::getUntrashedChatReferences(array(
56 'last_activity' => strtotime('-5 days', time())
57 ));
58 foreach($chatroom_objects as $object)
59 {
60 if(isset($readable_rooms[$object['obj_id']]))
61 {
62 continue;
63 }
64
65 if($rbacsystem->checkAccess('read', '', $object['ref_id']))
66 {
67 $room = ilChatroom::byObjectId($object['obj_id']);
68 if($room && !$room->isUserBanned($ilUser->getId()))
69 {
70 $readable_rooms[$object['obj_id']] = array(
71 'ref_id' => $object['ref_id'],
72 'obj_id' => $object['obj_id'],
73 'room_id' => $room->getRoomId(),
74 'title' => $object['title'],
75 'parent_title' => $object['parent_title']
76 );
77 }
78 }
79 }
80
81 $title = array();
82 foreach($readable_rooms as $k => $v)
83 {
84 $title[$k] = strtolower($v['title']);
85 }
86 array_multisort($title, SORT_STRING, $readable_rooms);
87
88 return $readable_rooms;
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}
sprintf('%.4f', $callTime)
global $tpl
Definition: ilias.php:8
An exception for terminatinating execution or to throw for unit testing.
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.
getLastMessagesForChatViewer($number, $chatuser=null)
special template class to simplify handling of ITX/PEAR
$messages
Definition: en-x-test.php:7
global $lng
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:18