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

Class ilOnScreenChatGUI. More...

+ Collaboration diagram for ilOnScreenChatGUI:

Public Member Functions

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

Static Public Member Functions

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

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 68 of file class.ilOnScreenChatGUI.php.

References $DIC, getUserList(), getUserProfileData(), and verifyLogin().

69  {
70  global $DIC;
71 
72  $cmd = $DIC->ctrl()->getCmd();
73 
74  switch ($cmd) {
75  case 'getUserProfileData':
76  $this->getUserProfileData();
77  break;
78  case 'verifyLogin':
79  $this->verifyLogin();
80  break;
81  case 'getUserlist':
82  default:
83  $this->getUserList();
84  }
85  }
global $DIC
Definition: saml.php:7
verifyLogin()
Checks if a user is logged in.
+ Here is the call graph for this function:

◆ getEmoticons()

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

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

References $key, and ilChatroomServerSettings\getSmiliesEnabled().

34  {
35  $smileys = array();
36 
37  if ($chatSettings->getSmiliesEnabled()) {
38  require_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
39  ;
40 
41  $smileys_array = ilChatroomSmilies::_getSmilies();
42  foreach ($smileys_array as $smiley_array) {
43  $new_keys = array();
44  $new_val = '';
45  foreach ($smiley_array as $key => $value) {
46  if ($key == 'smiley_keywords') {
47  $new_keys = explode("\n", $value);
48  }
49 
50  if ($key == 'smiley_fullpath') {
51  $new_val = $value;
52  }
53  }
54 
55  if (!$new_keys || !$new_val) {
56  continue;
57  }
58 
59  foreach ($new_keys as $new_key) {
60  $smileys[$new_key] = $new_val;
61  }
62  }
63  }
64 
65  return $smileys;
66  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ getUserList()

ilOnScreenChatGUI::getUserList ( )

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

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

Referenced by executeCommand().

107  {
108  global $DIC;
109 
110  if (!$DIC->user() || $DIC->user()->isAnonymous()) {
111  return;
112  }
113 
114  require_once 'Services/OnScreenChat/classes/class.ilOnScreenChatUserUserAutoComplete.php';
116  $auto->setUser($DIC->user());
118  if (($_REQUEST['fetchall'])) {
119  $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
120  }
121  $auto->setMoreLinkAvailable(true);
122  $auto->setSearchFields(array('firstname', 'lastname'));
123  $auto->setResultField('login');
124  $auto->enableFieldSearchableCheck(true);
125  echo $auto->getList($_REQUEST['term']);
126  exit;
127  }
Class ilOnScreenChatUserUserAutoComplete.
global $DIC
Definition: saml.php:7
exit
Definition: backend.php:16
+ Here is the caller graph for this function:

◆ getUserProfileData()

ilOnScreenChatGUI::getUserProfileData ( )

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

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

Referenced by executeCommand().

130  {
131  global $DIC;
132 
133  if (!$DIC->user() || $DIC->user()->isAnonymous()) {
134  echo json_encode([]);
135  exit();
136  }
137 
138  if (!isset($_GET['usr_ids']) || strlen($_GET['usr_ids']) == 0) {
139  echo json_encode([]);
140  exit();
141  }
142 
143  $DIC['lng']->loadLanguageModule('user');
144 
145  $userProvider = new \ilOnScreenChatUserDataProvider($DIC->database(), $DIC->user());
146  $data = $userProvider->getDataByUserIds(explode(',', $_GET['usr_ids']));
147 
148  require_once 'Services/Authentication/classes/class.ilSession.php';
150 
151  echo json_encode($data);
152  exit();
153  }
static enableWebAccessWithoutSession($enable_web_access_without_session)
global $DIC
Definition: saml.php:7
$_GET["client_id"]
exit
Definition: backend.php:16
$data
Definition: bench.php:6
+ 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 158 of file class.ilOnScreenChatGUI.php.

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

Referenced by ilMainMenuGUI\populateWithOnScreenChat().

159  {
160  global $DIC;
161 
162  if (!self::$frontend_initialized) {
163  $clientSettings = new ilSetting('chatroom');
164 
165  if (!self::isOnScreenChatAccessible($clientSettings)) {
166  self::$frontend_initialized = true;
167  return;
168  }
169 
170  require_once 'Services/JSON/classes/class.ilJsonUtil.php';
171 
172  $settings = self::loadServerSettings();
173 
174  $DIC->language()->loadLanguageModule('chatroom');
175  $DIC->language()->loadLanguageModule('user');
176 
177  $renderer = $DIC->ui()->renderer();
178  $factory = $DIC->ui()->factory();
179 
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')
183  ));
184  $chatWindowTemplate->setVariable('ADD_ACTION', $renderer ->render(
185  $factory->glyph()->add('addUser')
186  ));
187  $chatWindowTemplate->setVariable('CLOSE_ACTION', $renderer ->render(
188  $factory->button()->close()
189  ));
190  $chatWindowTemplate->setVariable('CONVERSATION_ICON', ilUtil::img(ilUtil::getImagePath('icon_chta.svg')));
191 
192  $userProvider = new \ilOnScreenChatUserDataProvider($DIC->database(), $DIC->user());
193 
194  $guiConfig = array(
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),
203  'loaderImg' => ilUtil::getImagePath('loader.svg'),
204  'emoticons' => self::getEmoticons($settings),
205  'locale' => $DIC->language()->getLangKey(),
206  'initialUserData' => $userProvider->getInitialUserProfileData(),
207  );
208 
209  $chatConfig = array(
210  'url' => $settings->generateClientUrl() . '/' . $settings->getInstance() . '-im',
211  'subDirectory' => $settings->getSubDirectory() . '/socket.io',
212  'userId' => $DIC->user()->getId(),
213  'username' => $DIC->user()->getLogin(),
214  );
215 
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'
221  ));
222 
223  require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
226 
227  require_once 'Services/Link/classes/class.ilLinkifyUtil.php';
229 
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();");
241 
242  self::$frontend_initialized = true;
243  }
244  }
global $DIC
Definition: saml.php:7
$factory
Definition: metadata.php:43
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.
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static initLinkify($a_tpl=null)
Init Linkify.
+ 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 22 of file class.ilOnScreenChatGUI.php.

References $DIC, and ilSetting\get().

23  {
24  global $DIC;
25 
26  return $chatSettings->get('chat_enabled') && $chatSettings->get('enable_osc') && $DIC->user() && !$DIC->user()->isAnonymous();
27  }
global $DIC
Definition: saml.php:7
get($a_keyword, $a_default_value=false)
get setting
+ Here is the call graph for this function:

◆ loadServerSettings()

static ilOnScreenChatGUI::loadServerSettings ( )
staticprotected

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

References ilChatroomServerSettings\loadDefault().

247  {
248  require_once './Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
250  }
+ Here is the call 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 93 of file class.ilOnScreenChatGUI.php.

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

Referenced by executeCommand().

94  {
95  global $DIC;
96 
97  require_once 'Services/Authentication/classes/class.ilSession.php';
99 
100  echo json_encode(array(
101  'loggedIn' => $DIC->user() && !$DIC->user()->isAnonymous()
102  ));
103  exit;
104  }
static enableWebAccessWithoutSession($enable_web_access_without_session)
global $DIC
Definition: saml.php:7
exit
Definition: backend.php:16
+ 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 16 of file class.ilOnScreenChatGUI.php.


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