1<?
php declare(strict_types=1);
8use Psr\Http\Message\ResponseInterface;
41 $this->
http = $DIC->http();
42 $this->ctrl =
$DIC->ctrl();
43 $this->actor =
$DIC->user();
52 return $this->dic->http()->response()->withBody(Streams::ofString($body));
63 return $chatSettings->
get(
'chat_enabled') && $chatSettings->
get(
'enable_osc') &&
$DIC->user() && !
$DIC->user()->isAnonymous();
75 require_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
78 $smileys_array = ilChatroomSmilies::_getSmilies();
79 foreach ($smileys_array as $smiley_array) {
82 foreach ($smiley_array as $key => $value) {
83 if ($key ==
'smiley_keywords') {
84 $new_keys = explode(
"\n", $value);
87 if ($key ==
'smiley_fullpath') {
92 if (!$new_keys || !$new_val) {
96 foreach ($new_keys as $new_key) {
97 $smileys[$new_key] = $new_val;
107 $cmd = $this->ctrl->getCmd();
109 case 'getUserProfileData':
117 case 'getRenderedNotificationItems':
120 new Conversation($this->dic->database(), $this->dic->user()),
121 new Subscriber($this->dic->database(), $this->dic->user())
124 $conversationIds = (string) ($this->dic->http()->request()->getQueryParams()[
'ids'] ??
'');
125 $noAggregates = ($this->dic->http()->request()->getQueryParams()[
'no_aggregates'] ??
'');
128 $this->dic->ui()->renderer()->renderAsync($provider->getAsyncItem(
130 $noAggregates !==
'true'
140 if ($this->ctrl->isAsynch()) {
142 $this->
http->sendResponse();
157 'loggedIn' => $this->actor->getId() && !$this->actor->isAnonymous()
166 if (!$this->actor->getId() || $this->actor->isAnonymous()) {
171 $auto->setUser($this->actor);
173 if (isset($this->
http->request()->getQueryParams()[
'fetchall'])) {
176 $auto->setMoreLinkAvailable(
true);
177 $auto->setSearchFields([
'firstname',
'lastname']);
178 $auto->setResultField(
'login');
179 $auto->enableFieldSearchableCheck(
true);
181 return $this->
getResponseWithText($auto->getList($this->http->request()->getQueryParams()[
'term'] ??
''));
190 if (!$this->actor->getId() || $this->actor->isAnonymous()) {
194 $usrIds = (string) ($this->
http->request()->getQueryParams()[
'usr_ids'] ??
'');
195 if (0 === strlen($usrIds)) {
199 $this->dic->language()->loadLanguageModule(
'user');
200 $subscriberRepo =
new Subscriber($this->dic->database(), $this->dic->user());
201 $data = $subscriberRepo->getDataByUserIds(explode(
',', $usrIds));
218 if (!self::$frontend_initialized) {
219 $clientSettings =
new ilSetting(
'chatroom');
221 if (!self::isOnScreenChatAccessible($clientSettings)) {
222 self::$frontend_initialized =
true;
228 $DIC->language()->loadLanguageModule(
'chatroom');
229 $DIC->language()->loadLanguageModule(
'user');
231 $renderer =
$DIC->ui()->renderer();
234 $chatWindowTemplate =
new ilTemplate(
'tpl.chat-window.html',
false,
false,
'Services/OnScreenChat');
235 $chatWindowTemplate->setVariable(
'SUBMIT_ACTION', $renderer->render(
236 $factory->button()->standard(
$DIC->language()->txt(
'chat_osc_send'),
'onscreenchat-submit')
238 $chatWindowTemplate->setVariable(
'ADD_ACTION', $renderer->render(
239 $factory->symbol()->glyph()->add(
'addUser')
241 $chatWindowTemplate->setVariable(
'CLOSE_ACTION', $renderer->render(
249 'chatWindowTemplate' => $chatWindowTemplate->get(),
251 'tpl.chat-message.html',
254 'Services/OnScreenChat'
257 'tpl.chat-add-user.html',
260 'Services/OnScreenChat'
262 'userId' =>
$DIC->user()->getId(),
263 'username' =>
$DIC->user()->getLogin(),
264 'userListURL' =>
$DIC->ctrl()->getLinkTargetByClass(
271 'userProfileDataURL' =>
$DIC->ctrl()->getLinkTargetByClass(
273 'getUserProfileData',
278 'verifyLoginURL' =>
$DIC->ctrl()->getLinkTargetByClass(
285 'renderNotificationItemsURL' =>
$DIC->ctrl()->getLinkTargetByClass(
287 'getRenderedNotificationItems',
293 'emoticons' => self::getEmoticons($settings),
294 'locale' =>
$DIC->language()->getLangKey(),
295 'initialUserData' => $subscriberRepo->getInitialUserProfileData(),
296 'enabledBrowserNotifications' => (
297 $clientSettings->get(
'enable_browser_notifications',
false) &&
304 'url' => $settings->generateClientUrl() .
'/' . $settings->getInstance() .
'-im',
305 'subDirectory' => $settings->getSubDirectory() .
'/socket.io',
306 'userId' =>
$DIC->user()->getId(),
307 'username' =>
$DIC->user()->getLogin(),
310 $DIC->language()->toJS([
311 'chat_osc_no_usr_found',
312 'chat_osc_emoticons',
313 'chat_osc_write_a_msg',
316 'chat_osc_invite_to_conversation',
319 'chat_osc_subs_rej_msgs',
320 'chat_osc_subs_rej_msgs_p',
321 'chat_osc_self_rej_msgs',
322 'chat_osc_search_modal_info',
323 'chat_osc_head_grp_x_persons',
325 'chat_osc_conversations',
326 'chat_osc_sure_to_leave_grp_conv',
327 'chat_osc_user_left_grp_conv',
330 'chat_osc_leave_grp_conv',
332 'chat_osc_nc_conv_x_p',
333 'chat_osc_nc_conv_x_s',
334 'chat_osc_nc_no_conv',
343 $page->
addJavaScript(
'./node_modules/jquery-outside-events/jquery.ba-outside-events.js');
344 $page->
addJavaScript(
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js');
345 $page->addJavascript(
'./Services/UIComponent/Modal/js/Modal.js');
346 $page->addJavascript(
'./node_modules/moment/min/moment-with-locales.min.js');
347 $page->addJavascript(
'./Services/Notifications/js/browser_notifications.js');
348 $page->addJavascript(
'./Services/OnScreenChat/js/onscreenchat-notifications.js');
349 $page->addJavascript(
'./Services/OnScreenChat/js/moment.js');
350 $page->addJavascript(
'./Modules/Chatroom/chat/node_modules/socket.io-client/dist/socket.io.js');
351 $page->addJavascript(
'./Services/OnScreenChat/js/chat.js');
352 $page->addJavascript(
'./Services/OnScreenChat/js/onscreenchat.js');
353 $page->
addOnLoadCode(
"il.Chat.setConfig(" . json_encode($chatConfig) .
");");
354 $page->
addOnLoadCode(
"il.OnScreenChat.setConfig(" . json_encode($guiConfig) .
");");
356 $page->
addOnLoadCode(
'il.OnScreenChatNotifications.init(' . json_encode([
357 'conversationIdleTimeThreshold' => max(
359 (
int) $clientSettings->get(
'conversation_idle_state_in_minutes', 1)
361 'logLevel' =>
$DIC[
'ilLoggerFactory']->getSettings()->getLevelByComponent(
'osch'),
364 self::$frontend_initialized =
true;
An exception for terminatinating execution or to throw for unit testing.
Class Streams Stream factory which enables the user to create streams without the knowledge of the co...
Class OnScreenChatNotificationProvider.
Class ilChatroomServerSettings.
static initLinkify($a_tpl=null)
Init Linkify.
static $frontend_initialized
static initializeFrontend(ilGlobalTemplateInterface $page)
Initialize frontend and delivers required javascript files and configuration to the global template.
static getEmoticons(ilChatroomServerSettings $chatSettings)
getResponseWithText(string $body)
verifyLogin()
Checks if a user is logged in.
__construct()
ilOnScreenChatGUI constructor.
static isOnScreenChatAccessible(ilSetting $chatSettings)
Class ilOnScreenChatUserUserAutoComplete.
static enableWebAccessWithoutSession($enable_web_access_without_session)
get($a_keyword, $a_default_value=false)
get setting
special template class to simplify handling of ITX/PEAR
const PRIVACY_MODE_RESPECT_USER_SETTING
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static yn2tf($a_yn)
convert "y"/"n" to true/false
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components....
addJavaScript($a_js_file, $a_add_version_parameter=true, $a_batch=2)
Add a javascript file that should be included in the header.
addOnLoadCode($a_code, $a_batch=2)
Add on load code.
static http()
Fetches the global http state from ILIAS.