ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilChatroomBlock Class Reference

ilChatroomBlock More...

+ Collaboration diagram for ilChatroomBlock:

Public Member Functions

 getRoomSelect (stdClass $response)
 
 getMessages (ilChatroom $room)
 

Private Member Functions

 getReadableAreas ()
 

Detailed Description

ilChatroomBlock

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 11 of file class.ilChatroomBlock.php.

Member Function Documentation

◆ getMessages()

ilChatroomBlock::getMessages ( ilChatroom  $room)
Parameters
ilChatroom$room
Returns
array

Definition at line 95 of file class.ilChatroomBlock.php.

References $DIC, $messages, ilChatroom\getLastMessagesForChatViewer(), and ilChatroom\getSetting().

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  }
global $DIC
Definition: saml.php:7
getSetting($name)
Returns setting from $this->settings array by given name.
$messages
Definition: en.php:5
getLastMessagesForChatViewer($number, $chatuser=null)
Class ilChatroomUser.
+ Here is the call graph for this function:

◆ getReadableAreas()

ilChatroomBlock::getReadableAreas ( )
private
Returns
array

Definition at line 54 of file class.ilChatroomBlock.php.

References $DIC, $title, ilChatroom\byObjectId(), ilChatroom\checkUserPermissions(), and ilChatroom\getUntrashedChatReferences().

Referenced by getRoomSelect().

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  }
static getUntrashedChatReferences($filter=array())
global $DIC
Definition: saml.php:7
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRoomSelect()

ilChatroomBlock::getRoomSelect ( stdClass  $response)
Parameters
stdClass$response
Returns
string
Exceptions
ilTemplateException

Definition at line 18 of file class.ilChatroomBlock.php.

References $DIC, $tpl, and getReadableAreas().

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  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
special template class to simplify handling of ITX/PEAR
$response
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: