4 require_once
'Services/Block/classes/class.ilBlockGUI.php';
5 require_once
'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
6 require_once
'Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
7 require_once
'Services/JSON/classes/class.ilJsonUtil.php';
8 require_once
'Modules/Chatroom/classes/class.ilChatroomBlock.php';
9 require_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
34 $lng->loadLanguageModule(
'chatroom');
37 $this->
setTitle($lng->txt(
'chat_chatviewer'));
39 $this->allow_moving =
true;
77 public function executeCommand()
84 $cmd = $ilCtrl->getCmd(
'getHTML');
120 if($ilCtrl->isAsynch())
122 return $this->getMessages();
125 $tpl->addJavascript(
'./Modules/Chatroom/js/chatviewer.js');
126 $tpl->addCss(
'./Modules/Chatroom/templates/default/style.css');
129 $body_tpl =
new ilTemplate(
'tpl.chatroom_block_message_body.html',
true,
true,
'Modules/Chatroom');
136 $body_tpl->setVariable(
'BLOCK_HEIGHT', $height);
137 $body_tpl->setVariable(
'TXT_ENABLE_AUTOSCROLL', $lng->txt(
'chat_enable_autoscroll'));
139 $ilCtrl->setParameterByClass(
'ilcolumngui',
'block_id',
'block_' . $this->
getBlockType() .
'_' . (
int)$this->
getBlockId());
140 $ilCtrl->setParameterByClass(
'ilcolumngui',
'ref_id',
'#__ref_id');
141 $body_tpl->setVariable(
'CHATBLOCK_BASE_URL', $ilCtrl->getLinkTargetByClass(
'ilcolumngui',
'updateBlock',
'',
true));
142 $ilCtrl->setParameterByClass(
'ilcolumngui',
'block_id',
'');
143 $ilCtrl->setParameterByClass(
'ilcolumngui',
'ref_id',
'');
147 if($settings->getSmiliesEnabled())
150 foreach($smilies_array as $smiley_array)
152 foreach($smiley_array as $key => $value)
154 if($key ==
'smiley_keywords')
156 $new_keys = explode(
"\n", $value);
159 if($key ==
'smiley_fullpath')
165 foreach($new_keys as $new_key)
167 $smilieys[$new_key] = $new_val;
173 $smilieys =
new stdClass();
175 $body_tpl->setVariable(
'SMILIES', json_encode($smilieys));
177 $js_translations = array(
178 'LBL_CONNECT' =>
'chat_connection_established',
179 'LBL_DISCONNECT' =>
'chat_connection_disconnected',
180 'LBL_TIMEFORMAT' =>
'lang_timeformat_no_sec',
181 'LBL_DATEFORMAT' =>
'lang_dateformat'
183 foreach($js_translations as $placeholder => $lng_variable)
185 $body_tpl->setVariable($placeholder, json_encode($lng->txt($lng_variable)));
188 $content = $body_tpl->get() . $chatblock->getRoomSelect();
195 protected function getMessages()
217 if(!$object || !$rbacsystem->checkAccess(
'read', (
int)$_REQUEST[
'ref_id']))
219 ilObjUser::_writePref
221 $ilUser->getId(),
'chatviewer_last_selected_room',
225 $result->errormsg = $lng->txt(
'msg_no_perm_read');
230 require_once
'Modules/Chatroom/classes/class.ilChatroom.php';
234 $msg = $block->getMessages($room);
238 'chatviewer_last_selected_room',
241 ilObjUser::_writePref
243 $ilUser->getId(),
'chatviewer_last_selected_room',
247 $result->messages = array_reverse($msg);
250 include_once
'Services/JSON/classes/class.ilJsonUtil.php';