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

Class ilOnScreenChatMenuGUI. More...

+ Collaboration diagram for ilOnScreenChatMenuGUI:

Public Member Functions

 __construct ()
 ilOnScreenChatMenuGUI constructor. More...
 
 getMainMenuHTML ()
 

Protected Member Functions

 init ()
 

Protected Attributes

 $pub_ref_id
 
 $accessible = false
 
 $publicChatRoomAccess = false
 
 $oscAccess = false
 
 $ui
 

Detailed Description

Class ilOnScreenChatMenuGUI.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilOnScreenChatMenuGUI::__construct ( )

ilOnScreenChatMenuGUI constructor.

Definition at line 39 of file class.ilOnScreenChatMenuGUI.php.

References $DIC, and init().

40  {
41  global $DIC;
42 
43  $this->init();
44  $this->ui = $DIC->ui();
45  }
global $DIC
+ Here is the call graph for this function:

Member Function Documentation

◆ getMainMenuHTML()

ilOnScreenChatMenuGUI::getMainMenuHTML ( )
Returns
string

Definition at line 74 of file class.ilOnScreenChatMenuGUI.php.

References $config, $DIC, $oscAccess, $tpl, ilObject\_getIcon(), array, ilJsonUtil\encode(), ilUtil\getImagePath(), ilLinkifyUtil\initLinkify(), ILIAS\UI\Implementation\Component\withOnLoadCode(), and ilUtil\yn2tf().

75  {
76  global $DIC;
77 
78  if(!$this->accessible)
79  {
80  return '';
81  }
82 
83  require_once 'Services/Link/classes/class.ilLinkifyUtil.php';
85 
86  require_once 'Services/JSON/classes/class.ilJsonUtil.php';
87  $DIC->language()->loadLanguageModule('chatroom');
88 
89  $config = array(
90  'conversationTemplate' => (new ilTemplate('tpl.chat-menu-item.html', false, false, 'Services/OnScreenChat'))->get(),
91  'roomTemplate' => (new ilTemplate('tpl.chat-menu-item-room.html', false, false, 'Services/OnScreenChat'))->get(),
92  'infoTemplate' => (new ilTemplate('tpl.chat-menu-item-info.html', false, false, 'Services/OnScreenChat'))->get(),
93  'userId' => $DIC->user()->getId()
94  );
95 
96  $config['rooms'] = array();
97 
98  if($this->publicChatRoomAccess)
99  {
100  $config['rooms'][] = array(
101  'name' => $DIC['ilObjDataCache']->lookupTitle($DIC['ilObjDataCache']->lookupObjId($this->pub_ref_id)),
102  'url' => './ilias.php?baseClass=ilRepositoryGUI&cmd=view&ref_id=' . $this->pub_ref_id,
103  'icon' => ilObject::_getIcon($DIC['ilObjDataCache']->lookupObjId($this->pub_ref_id), 'small', 'chtr')
104  );
105  }
106 
107  $config['showAcceptMessageChange'] = (
108  !ilUtil::yn2tf($DIC->user()->getPref('chat_osc_accept_msg')) &&
109  !(bool)$DIC['ilSetting']->get('usr_settings_hide_chat_osc_accept_msg', false) &&
110  !(bool)$DIC['ilSetting']->get('usr_settings_disable_chat_osc_accept_msg', false)
111  );
112  $config['showOnScreenChat'] = $this->oscAccess;
113 
114  $DIC->language()->loadLanguageModule('chatroom');
115  $DIC->language()->toJS(array(
116  'chat_osc_conversations', 'chat_osc_section_head_other_rooms',
117  'chat_osc_sure_to_leave_grp_conv', 'chat_osc_user_left_grp_conv',
118  'confirm', 'cancel', 'chat_osc_leave_grp_conv', 'chat_osc_no_conv'
119  ));
120  $DIC->language()->toJSMap(array(
121  'chat_osc_dont_accept_msg' => sprintf(
122  $DIC->language()->txt('chat_osc_dont_accept_msg'),
123  $DIC->ctrl()->getLinkTargetByClass(array('ilPersonalDesktopGUI', 'ilPersonalSettingsGUI', 'ilPersonalChatSettingsFormGUI'), 'showChatOptions')
124  )
125  ));
126 
127  $DIC['tpl']->addJavascript('./Services/OnScreenChat/js/onscreenchat-menu.js');
128  $DIC['tpl']->addJavascript('./Services/UIComponent/Modal/js/Modal.js');
129 
130  $tpl = new ilTemplate('tpl.chat-menu.html', true, true, 'Services/OnScreenChat');
131 
132  $f = $this->ui->factory();
133  $renderer = $this->ui->renderer();
134 
135  $glyph = $f->glyph()->comment();
136  $glyph = $glyph->withCounter($f->counter()->status(0))->withCounter($f->counter()->novelty(0))->withOnLoadCode(function($id) use (&$glyph_id) {
137  $glyph_id = $id;
138  return '';
139  });
140  $glyph_html = $renderer->render($glyph);
141 
142  $config['triggerId'] = $glyph_id;
143  $config['conversationNoveltyCounter'] = $renderer->render($f->counter()->novelty(0));
144 
145  $DIC['tpl']->addOnLoadCode("il.OnScreenChatMenu.setConfig(".ilJsonUtil::encode($config).");");
146  $DIC['tpl']->addOnLoadCode("il.OnScreenChatMenu.init();");
147 
148  $tpl->setVariable('GLYPH', $glyph_html);
149  $tpl->setVariable('LOADER', ilUtil::getImagePath('loader.svg'));
150  return $tpl->get();
151  }
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
global $tpl
Definition: ilias.php:8
static encode($mixed, $suppress_native=false)
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
Create styles array
The data for the language used.
global $DIC
static yn2tf($a_yn)
convert "y"/"n" to true/false
static initLinkify($a_tpl=null)
Init Linkify.
+ Here is the call graph for this function:

◆ init()

ilOnScreenChatMenuGUI::init ( )
protected
Returns
bool

Definition at line 50 of file class.ilOnScreenChatMenuGUI.php.

References $DIC, $pub_ref_id, $publicChatRoomAccess, and ilObjChatroom\_getPublicRefId().

Referenced by __construct().

51  {
52  global $DIC;
53 
54  require_once 'Modules/Chatroom/classes/class.ilObjChatroom.php';
55  $this->pub_ref_id = ilObjChatroom::_getPublicRefId();
56 
57  if(!$DIC->user() || $DIC->user()->isAnonymous())
58  {
59  $this->accessible = false;
60  return;
61  }
62 
63  $chatSettings = new ilSetting('chatroom');
64 
65  $this->publicChatRoomAccess = $DIC->rbac()->system()->checkAccessOfUser($DIC->user()->getId(), 'read', $this->pub_ref_id);
66  $this->oscAccess = $chatSettings->get('enable_osc');
67 
68  $this->accessible = $chatSettings->get('chat_enabled') && ($this->oscAccess || $this->publicChatRoomAccess);
69  }
ILIAS Setting Class.
global $DIC
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $accessible

ilOnScreenChatMenuGUI::$accessible = false
protected

Definition at line 19 of file class.ilOnScreenChatMenuGUI.php.

◆ $oscAccess

ilOnScreenChatMenuGUI::$oscAccess = false
protected

Definition at line 29 of file class.ilOnScreenChatMenuGUI.php.

Referenced by getMainMenuHTML().

◆ $pub_ref_id

ilOnScreenChatMenuGUI::$pub_ref_id
protected

Definition at line 14 of file class.ilOnScreenChatMenuGUI.php.

Referenced by init().

◆ $publicChatRoomAccess

ilOnScreenChatMenuGUI::$publicChatRoomAccess = false
protected

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

Referenced by init().

◆ $ui

ilOnScreenChatMenuGUI::$ui
protected

Definition at line 34 of file class.ilOnScreenChatMenuGUI.php.


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