ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilOnScreenChatGUI Class Reference

Class ilOnScreenChatGUI. More...

+ Collaboration diagram for ilOnScreenChatGUI:

Public Member Functions

 executeCommand ()
 
 verifyLogin ()
 Checks if a user is logged in. More...
 
 getUserList ()
 
 getUserProfileImages ()
 

Static Public Member Functions

static initializeFrontend ()
 Initialize frontend and delivers required javascript files and configuration to the global template. More...
 

Data Fields

const WAC_TTL_TIME = 60
 

Static Protected Member Functions

static isOnScreenChatAccessible (ilSetting $chatSettings)
 
static getEmoticons (ilChatroomServerSettings $chatSettings)
 
static loadServerSettings ()
 

Static Protected Attributes

static $frontend_initialized = false
 

Detailed Description

Class ilOnScreenChatGUI.

Author
Thomas Joußen tjous.nosp@m.sen@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Since
26.07.16

Definition at line 9 of file class.ilOnScreenChatGUI.php.

Member Function Documentation

◆ executeCommand()

ilOnScreenChatGUI::executeCommand ( )

Definition at line 79 of file class.ilOnScreenChatGUI.php.

80 {
81 global $DIC;
82
83 $cmd = $DIC->ctrl()->getCmd();
84
85 switch($cmd)
86 {
87 case 'getUserProfileImages':
88 $this->getUserProfileImages();
89 break;
90 case 'verifyLogin':
91 $this->verifyLogin();
92 break;
93 case 'getUserlist':
94 default:
95 $this->getUserList();
96 }
97 }
verifyLogin()
Checks if a user is logged in.
$cmd
Definition: sahs_server.php:35
global $DIC

References $cmd, $DIC, getUserList(), getUserProfileImages(), and verifyLogin().

+ Here is the call graph for this function:

◆ getEmoticons()

static ilOnScreenChatGUI::getEmoticons ( ilChatroomServerSettings  $chatSettings)
staticprotected
Parameters
ilChatroomServerSettings$chatSettings
Returns
array

Definition at line 35 of file class.ilOnScreenChatGUI.php.

36 {
37 $smileys = array();
38
39 if($chatSettings->getSmiliesEnabled())
40 {
41 require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
42 require_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
43
45
46 $smileys_array = ilChatroomSmilies::_getSmilies();
47 foreach($smileys_array as $smiley_array)
48 {
49 $new_keys = array();
50 $new_val = '';
51 foreach($smiley_array as $key => $value)
52 {
53 if($key == 'smiley_keywords')
54 {
55 $new_keys = explode("\n", $value);
56 }
57
58 if($key == 'smiley_fullpath')
59 {
60 $new_val = ilWACSignedPath::signFile($value);
61 }
62 }
63
64 if(!$new_keys || !$new_val)
65 {
66 continue;
67 }
68
69 foreach($new_keys as $new_key)
70 {
71 $smileys[$new_key] = $new_val;
72 }
73 }
74 }
75
76 return $smileys;
77 }
static signFile($path_to_file)
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)

References ilChatroomServerSettings\getSmiliesEnabled(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), and ilWACSignedPath\signFile().

+ Here is the call graph for this function:

◆ getUserList()

ilOnScreenChatGUI::getUserList ( )

Definition at line 118 of file class.ilOnScreenChatGUI.php.

119 {
120 global $DIC;
121
122 if(!$DIC->user() || $DIC->user()->isAnonymous())
123 {
124 return;
125 }
126
127 require_once 'Services/OnScreenChat/classes/class.ilOnScreenChatUserUserAutoComplete.php';
129 $auto->setUser($DIC->user());
131 if(($_REQUEST['fetchall']))
132 {
133 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
134 }
135 $auto->setMoreLinkAvailable(true);
136 $auto->setSearchFields(array('firstname', 'lastname'));
137 $auto->setResultField('login');
138 $auto->enableFieldSearchableCheck(true);
139 echo $auto->getList($_REQUEST['term']);
140 exit;
141 }

References $DIC, exit, ilUserAutoComplete\MAX_ENTRIES, and ilUserAutoComplete\PRIVACY_MODE_RESPECT_USER_SETTING.

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ getUserProfileImages()

ilOnScreenChatGUI::getUserProfileImages ( )

Definition at line 143 of file class.ilOnScreenChatGUI.php.

144 {
145 global $DIC;
146
147 $response = array();
148
149 if(!$DIC->user() || $DIC->user()->isAnonymous())
150 {
151 echo json_encode($response);
152 exit();
153 }
154
155 if(!isset($_GET['usr_ids']) || strlen($_GET['usr_ids']) == 0)
156 {
157 echo json_encode($response);
158 exit();
159 }
160
161 $DIC['lng']->loadLanguageModule('user');
162
163 require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
165
166 $user_ids = array_filter(array_map('intval', array_map('trim', explode(',', $_GET['usr_ids']))));
167 require_once 'Services/User/classes/class.ilUserUtil.php';
168 $public_data = ilUserUtil::getNamePresentation($user_ids, true, false, '', false, true, false, true);
169 $public_names = ilUserUtil::getNamePresentation($user_ids, false, false, '', false, true, false, false);
170
171 foreach($user_ids as $usr_id)
172 {
173 $public_image = isset($public_data[$usr_id]) && isset($public_data[$usr_id]['img']) ? $public_data[$usr_id]['img'] : '';
174
175 $public_name = '';
176 if(isset($public_names[$usr_id]))
177 {
178 $public_name = $public_names[$usr_id];
179 if('unknown' == $public_name && isset($public_data[$usr_id]) && isset($public_data[$usr_id]['login']))
180 {
181 $public_name = $public_data[$usr_id]['login'];
182 }
183 }
184
185 $response[$usr_id] = array(
186 'public_name' => $public_name,
187 'profile_image' => $public_image
188 );
189 }
190
191 require_once 'Services/Authentication/classes/class.ilSession.php';
193
194 echo json_encode($response);
195 exit();
196 }
$_GET["client_id"]
static enableWebAccessWithoutSession($enable_web_access_without_session)
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false)
Default behaviour is:

References $_GET, $DIC, ilSession\enableWebAccessWithoutSession(), exit, ilUserUtil\getNamePresentation(), and ilWACSignedPath\setTokenMaxLifetimeInSeconds().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initializeFrontend()

static ilOnScreenChatGUI::initializeFrontend ( )
static

Initialize frontend and delivers required javascript files and configuration to the global template.

Definition at line 201 of file class.ilOnScreenChatGUI.php.

202 {
203 global $DIC;
204
205 if(!self::$frontend_initialized)
206 {
207 $clientSettings = new ilSetting('chatroom');
208
209 if(!self::isOnScreenChatAccessible($clientSettings))
210 {
211 self::$frontend_initialized = true;
212 return;
213 }
214
215 require_once 'Services/JSON/classes/class.ilJsonUtil.php';
216
217 $settings = self::loadServerSettings();
218
219 $DIC->language()->loadLanguageModule('chatroom');
220
221 $renderer = $DIC->ui()->renderer();
222 $factory = $DIC->ui()->factory();
223
224 $chatWindowTemplate = new ilTemplate('tpl.chat-window.html', false, false, 'Services/OnScreenChat');
225 $chatWindowTemplate->setVariable('SUBMIT_ACTION', $renderer ->render(
226 $factory->button()->standard($DIC->language()->txt('chat_osc_send'), 'onscreenchat-submit')
227 ));
228 $chatWindowTemplate->setVariable('ADD_ACTION', $renderer ->render(
229 $factory->glyph()->add('addUser')
230 ));
231 $chatWindowTemplate->setVariable('CLOSE_ACTION', $renderer ->render(
232 $factory->button()->close()
233 ));
234 $chatWindowTemplate->setVariable('CONVERSATION_ICON', ilUtil::img(ilUtil::getImagePath('icon_chta.svg')));
235
236 $guiConfig = array(
237 'chatWindowTemplate' => $chatWindowTemplate->get(),
238 'messageTemplate' => (new ilTemplate('tpl.chat-message.html', false, false, 'Services/OnScreenChat'))->get(),
239 'modalTemplate' => (new ilTemplate('tpl.chat-add-user.html', false, false, 'Services/OnScreenChat'))->get(),
240 'userId' => $DIC->user()->getId(),
241 'username' => $DIC->user()->getLogin(),
242 'userListURL' => $DIC->ctrl()->getLinkTargetByClass('ilonscreenchatgui', 'getUserList', '', true, false),
243 'userProfileDataURL' => $DIC->ctrl()->getLinkTargetByClass('ilonscreenchatgui', 'getUserProfileImages', '', true, false),
244 'verifyLoginURL' => $DIC->ctrl()->getLinkTargetByClass('ilonscreenchatgui', 'verifyLogin', '', true, false),
245 'loaderImg' => ilUtil::getImagePath('loader.svg'),
246 'emoticons' => self::getEmoticons($settings),
247 'locale' => $DIC->language()->getLangKey()
248 );
249
250 $chatConfig = array(
251 'url' => $settings->generateClientUrl() . '/' . $settings->getInstance() . '-im',
252 'subDirectory' => $settings->getSubDirectory() . '/socket.io',
253 'userId' => $DIC->user()->getId(),
254 'username' => $DIC->user()->getLogin()
255 );
256
257 $DIC->language()->toJS(array(
258 'chat_osc_no_usr_found', 'chat_osc_emoticons', 'chat_osc_write_a_msg', 'autocomplete_more',
259 'close', 'chat_osc_invite_to_conversation', 'chat_osc_user', 'chat_osc_add_user', 'chat_osc_subs_rej_msgs',
260 'chat_osc_subs_rej_msgs_p', 'chat_osc_self_rej_msgs'
261 ));
262
263 require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
266
267 require_once 'Services/Link/classes/class.ilLinkifyUtil.php';
269
270 $DIC['tpl']->addJavaScript('./Services/jQuery/js/jquery.outside.events.min.js');
271 $DIC['tpl']->addJavaScript('./Services/jQuery/js/jquery.ui.touch-punch.min.js');
272 $DIC['tpl']->addJavascript('./Services/UIComponent/Modal/js/Modal.js');
273 $DIC['tpl']->addJavascript('./libs/composer/components/moment/min/moment-with-locales.js');
274 $DIC['tpl']->addJavascript('./Services/OnScreenChat/js/moment.js');
275 $DIC['tpl']->addJavascript('./Modules/Chatroom/chat/node_modules/socket.io/node_modules/socket.io-client/socket.io.js');
276 $DIC['tpl']->addJavascript('./Services/OnScreenChat/js/chat.js');
277 $DIC['tpl']->addJavascript('./Services/OnScreenChat/js/onscreenchat.js');
278 $DIC['tpl']->addOnLoadCode("il.Chat.setConfig(".ilJsonUtil::encode($chatConfig).");");
279 $DIC['tpl']->addOnLoadCode("il.OnScreenChat.setConfig(".ilJsonUtil::encode($guiConfig).");");
280 $DIC['tpl']->addOnLoadCode("il.OnScreenChat.init();");
281
282 self::$frontend_initialized = true;
283 }
284 }
static encode($mixed, $suppress_native=false)
static initLinkify($a_tpl=null)
Init Linkify.
ILIAS Setting Class.
special template class to simplify handling of ITX/PEAR
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static initjQueryUI()
Init jQuery UI (see included_components.txt for included components)
static initjQuery($a_tpl=null)
Init jQuery.

References $DIC, ilJsonUtil\encode(), ilUtil\getImagePath(), ilUtil\img(), iljQueryUtil\initjQuery(), iljQueryUtil\initjQueryUI(), ilLinkifyUtil\initLinkify(), and loadServerSettings().

Referenced by ilMainMenuGUI\populateWithOnScreenChat().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isOnScreenChatAccessible()

static ilOnScreenChatGUI::isOnScreenChatAccessible ( ilSetting  $chatSettings)
staticprotected
Parameters
ilSetting$chatSettings
Returns
bool

Definition at line 24 of file class.ilOnScreenChatGUI.php.

25 {
26 global $DIC;
27
28 return $chatSettings->get('chat_enabled') && $chatSettings->get('enable_osc') && $DIC->user() && !$DIC->user()->isAnonymous();
29 }
get($a_keyword, $a_default_value=false)
get setting

References $DIC, and ilSetting\get().

+ Here is the call graph for this function:

◆ loadServerSettings()

static ilOnScreenChatGUI::loadServerSettings ( )
staticprotected

Definition at line 286 of file class.ilOnScreenChatGUI.php.

287 {
288 require_once './Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
289 return ilChatroomServerSettings::loadDefault();
290 }

Referenced by initializeFrontend().

+ Here is the caller graph for this function:

◆ verifyLogin()

ilOnScreenChatGUI::verifyLogin ( )

Checks if a user is logged in.

If not, this function should cause an redirect, to disallow chatting while not logged into ILIAS.

Returns
bool

Definition at line 105 of file class.ilOnScreenChatGUI.php.

106 {
107 global $DIC;
108
109 require_once 'Services/Authentication/classes/class.ilSession.php';
111
112 echo json_encode(array(
113 'loggedIn' => $DIC->user() && !$DIC->user()->isAnonymous()
114 ));
115 exit;
116 }

References $DIC, ilSession\enableWebAccessWithoutSession(), and exit.

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $frontend_initialized

ilOnScreenChatGUI::$frontend_initialized = false
staticprotected

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

◆ WAC_TTL_TIME

const ilOnScreenChatGUI::WAC_TTL_TIME = 60

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


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