ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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{
18 public function getRoomSelect(stdClass $response)
19 {
20 global $DIC;
21
22 $readable = $this->getReadableAreas();
23
24 $tpl = new ilTemplate('tpl.chatroom_block_room_select.html', true, true, 'Modules/Chatroom');
25
26 if (count($readable) > 0) {
27 $response->has_records = true;
28 $tpl->setVariable('TXT_SELECT_ROOM', $DIC->language()->txt('chat_select_room'));
29
30 foreach ($readable as $room) {
31 $tpl->setCurrentBlock('select_room_row');
32 $tpl->setVariable('ROW_VALUE', $room['ref_id']);
33 $tpl->setVariable(
34 'ROW_CAPTION',
35 sprintf($DIC->language()->txt('room_in_container'), $room['title'], $room['parent_title'])
36 );
37
38 if ($DIC->user()->getPref('chatviewer_last_selected_room') == $room['ref_id']) {
39 $tpl->setVariable('ROW_SELECTED', 'selected="selected"');
40 }
41
42 $tpl->parseCurrentBlock();
43 }
44 } else {
45 $tpl->setVariable('TXT_NO_ROOMS', $DIC->language()->txt('chatviewer_no_rooms'));
46 }
47
48 return $tpl->get();
49 }
50
54 private function getReadableAreas()
55 {
56 global $DIC;
57
58 $readable_rooms = array();
59
60 $chatroom_objects = ilChatroom::getUntrashedChatReferences(array(
61 'last_activity' => strtotime('-5 days', time())
62 ));
63 foreach ($chatroom_objects as $object) {
64 if (isset($readable_rooms[$object['obj_id']])) {
65 continue;
66 }
67
68 if (ilChatroom::checkUserPermissions('read', $object['ref_id'], false)) {
69 $room = ilChatroom::byObjectId($object['obj_id']);
70 if ($room && !$room->isUserBanned($DIC->user()->getId())) {
71 $readable_rooms[$object['obj_id']] = array(
72 'ref_id' => $object['ref_id'],
73 'obj_id' => $object['obj_id'],
74 'room_id' => $room->getRoomId(),
75 'title' => $object['title'],
76 'parent_title' => $object['parent_title']
77 );
78 }
79 }
80 }
81
82 $title = array();
83 foreach ($readable_rooms as $k => $v) {
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 {
97 global $DIC;
98
99 include 'Modules/Chatroom/classes/class.ilChatroomUser.php';
101 $room->getSetting('display_past_msgs'),
102 new ilChatroomUser(
103 $DIC->user(),
104 $room
105 )
106 );
107
108 $output_messages = array();
109
110 foreach ($messages as $msg) {
111 $output_messages[] = $msg;
112 }
113
114 return $output_messages;
115 }
116}
$tpl
Definition: ilias.php:10
An exception for terminatinating execution or to throw for unit testing.
getMessages(ilChatroom $room)
getRoomSelect(stdClass $response)
Class ilChatroomUser.
Class ilChatroom.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
getSetting($name)
Returns setting from $this->settings array by given name.
static getUntrashedChatReferences($filter=array())
getLastMessagesForChatViewer($number, $chatuser=null)
special template class to simplify handling of ITX/PEAR
$messages
Definition: en.php:5
$response
global $DIC
Definition: saml.php:7