26 return $chatSettings->
get(
'chat_enabled') && $chatSettings->
get(
'enable_osc') && $DIC->user() && !$DIC->user()->isAnonymous();
38 require_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
41 $smileys_array = ilChatroomSmilies::_getSmilies();
42 foreach ($smileys_array as $smiley_array) {
45 foreach ($smiley_array as
$key => $value) {
46 if (
$key ==
'smiley_keywords') {
47 $new_keys = explode(
"\n", $value);
50 if (
$key ==
'smiley_fullpath') {
55 if (!$new_keys || !$new_val) {
59 foreach ($new_keys as $new_key) {
60 $smileys[$new_key] = $new_val;
72 $cmd = $DIC->ctrl()->getCmd();
75 case 'getUserProfileData':
97 require_once
'Services/Authentication/classes/class.ilSession.php';
100 echo json_encode(array(
101 'loggedIn' => $DIC->user() && !$DIC->user()->isAnonymous()
110 if (!$DIC->user() || $DIC->user()->isAnonymous()) {
114 require_once
'Services/OnScreenChat/classes/class.ilOnScreenChatUserUserAutoComplete.php';
116 $auto->setUser($DIC->user());
118 if (($_REQUEST[
'fetchall'])) {
121 $auto->setMoreLinkAvailable(
true);
122 $auto->setSearchFields(array(
'firstname',
'lastname'));
123 $auto->setResultField(
'login');
124 $auto->enableFieldSearchableCheck(
true);
125 echo $auto->getList($_REQUEST[
'term']);
133 if (!$DIC->user() || $DIC->user()->isAnonymous()) {
134 echo json_encode([]);
138 if (!isset(
$_GET[
'usr_ids']) || strlen(
$_GET[
'usr_ids']) == 0) {
139 echo json_encode([]);
143 $DIC[
'lng']->loadLanguageModule(
'user');
145 $userProvider = new \ilOnScreenChatUserDataProvider($DIC->database(), $DIC->user());
146 $data = $userProvider->getDataByUserIds(explode(
',',
$_GET[
'usr_ids']));
148 require_once
'Services/Authentication/classes/class.ilSession.php';
151 echo json_encode($data);
162 if (!self::$frontend_initialized) {
163 $clientSettings =
new ilSetting(
'chatroom');
165 if (!self::isOnScreenChatAccessible($clientSettings)) {
166 self::$frontend_initialized =
true;
170 require_once
'Services/JSON/classes/class.ilJsonUtil.php';
172 $settings = self::loadServerSettings();
174 $DIC->language()->loadLanguageModule(
'chatroom');
175 $DIC->language()->loadLanguageModule(
'user');
177 $renderer = $DIC->ui()->renderer();
180 $chatWindowTemplate =
new ilTemplate(
'tpl.chat-window.html',
false,
false,
'Services/OnScreenChat');
181 $chatWindowTemplate->setVariable(
'SUBMIT_ACTION', $renderer ->render(
182 $factory->button()->standard($DIC->language()->txt(
'chat_osc_send'),
'onscreenchat-submit')
184 $chatWindowTemplate->setVariable(
'ADD_ACTION', $renderer ->render(
187 $chatWindowTemplate->setVariable(
'CLOSE_ACTION', $renderer ->render(
192 $userProvider = new \ilOnScreenChatUserDataProvider($DIC->database(), $DIC->user());
195 'chatWindowTemplate' => $chatWindowTemplate->get(),
196 'messageTemplate' => (
new ilTemplate(
'tpl.chat-message.html',
false,
false,
'Services/OnScreenChat'))->
get(),
197 'modalTemplate' => (
new ilTemplate(
'tpl.chat-add-user.html',
false,
false,
'Services/OnScreenChat'))->
get(),
198 'userId' => $DIC->user()->getId(),
199 'username' => $DIC->user()->getLogin(),
200 'userListURL' => $DIC->ctrl()->getLinkTargetByClass(
'ilonscreenchatgui',
'getUserList',
'',
true,
false),
201 'userProfileDataURL' => $DIC->ctrl()->getLinkTargetByClass(
'ilonscreenchatgui',
'getUserProfileData',
'',
true,
false),
202 'verifyLoginURL' => $DIC->ctrl()->getLinkTargetByClass(
'ilonscreenchatgui',
'verifyLogin',
'',
true,
false),
204 'emoticons' => self::getEmoticons($settings),
205 'locale' => $DIC->language()->getLangKey(),
206 'initialUserData' => $userProvider->getInitialUserProfileData(),
210 'url' => $settings->generateClientUrl() .
'/' . $settings->getInstance() .
'-im',
211 'subDirectory' => $settings->getSubDirectory() .
'/socket.io',
212 'userId' => $DIC->user()->getId(),
213 'username' => $DIC->user()->getLogin(),
216 $DIC->language()->toJS(array(
217 'chat_osc_no_usr_found',
'chat_osc_emoticons',
'chat_osc_write_a_msg',
'autocomplete_more',
218 'close',
'chat_osc_invite_to_conversation',
'chat_osc_user',
'chat_osc_add_user',
'chat_osc_subs_rej_msgs',
219 'chat_osc_subs_rej_msgs_p',
'chat_osc_self_rej_msgs',
'chat_osc_search_modal_info',
220 'chat_osc_head_grp_x_persons' 223 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
227 require_once
'Services/Link/classes/class.ilLinkifyUtil.php';
230 $DIC[
'tpl']->addJavaScript(
'./libs/bower/bower_components/jquery-outside-events/jquery.ba-outside-events.min.js');
231 $DIC[
'tpl']->addJavaScript(
'./libs/bower/bower_components/jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
232 $DIC[
'tpl']->addJavascript(
'./Services/UIComponent/Modal/js/Modal.js');
233 $DIC[
'tpl']->addJavascript(
'./libs/composer/components/moment/min/moment-with-locales.js');
234 $DIC[
'tpl']->addJavascript(
'./Services/OnScreenChat/js/moment.js');
235 $DIC[
'tpl']->addJavascript(
'./Modules/Chatroom/chat/node_modules/socket.io-client/dist/socket.io.js');
236 $DIC[
'tpl']->addJavascript(
'./Services/OnScreenChat/js/chat.js');
237 $DIC[
'tpl']->addJavascript(
'./Services/OnScreenChat/js/onscreenchat.js');
238 $DIC[
'tpl']->addOnLoadCode(
"il.Chat.setConfig(" . json_encode($chatConfig) .
");");
239 $DIC[
'tpl']->addOnLoadCode(
"il.OnScreenChat.setConfig(" . json_encode($guiConfig) .
");");
240 $DIC[
'tpl']->addOnLoadCode(
"il.OnScreenChat.init();");
242 self::$frontend_initialized =
true;
248 require_once
'./Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
static enableWebAccessWithoutSession($enable_web_access_without_session)
Class ilOnScreenChatUserUserAutoComplete.
static initializeFrontend()
Initialize frontend and delivers required javascript files and configuration to the global template...
const PRIVACY_MODE_RESPECT_USER_SETTING
static $frontend_initialized
static getEmoticons(ilChatroomServerSettings $chatSettings)
static isOnScreenChatAccessible(ilSetting $chatSettings)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
get($a_keyword, $a_default_value=false)
get setting
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
Class ilChatroomServerSettings.
verifyLogin()
Checks if a user is logged in.
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static loadServerSettings()
static initLinkify($a_tpl=null)
Init Linkify.