ILIAS  release_8 Revision v8.23
ILIAS\OnScreenChat\Provider\OnScreenChatProvider Class Reference

Class OnScreenChatProvider. More...

+ Inheritance diagram for ILIAS\OnScreenChat\Provider\OnScreenChatProvider:
+ Collaboration diagram for ILIAS\OnScreenChat\Provider\OnScreenChatProvider:

Public Member Functions

 __construct (Container $dic, ?Conversation $conversationRepo=null, ?Subscriber $subscriberRepo=null)
 
 getStaticTopItems ()
 
 getStaticSubItems ()
 
 getAsyncItem (string $conversationIds, bool $withAggregates)
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Scope\MainMenu\Provider\AbstractStaticMainMenuProvider
 __construct (Container $dic)
 
 getAllIdentifications ()
 
 provideTypeInformation ()
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 __construct (Container $dic)
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 

Private Member Functions

 getSlateMessageBox ()
 

Private Attributes

Conversation $conversationRepo
 
Subscriber $subscriberRepo
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 globalScreen ()
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Scope\MainMenu\Provider\AbstractStaticMainMenuProvider
Container $dic
 
IdentificationProviderInterface $if
 
MainMenuItemFactory $mainmenu
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
Container $dic
 

Detailed Description

Class OnScreenChatProvider.

Author
Ingmar Szmais iszma.nosp@m.is@d.nosp@m.ataba.nosp@m.y.de

Definition at line 45 of file OnScreenChatProvider.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\OnScreenChat\Provider\OnScreenChatProvider::__construct ( Container  $dic,
?Conversation  $conversationRepo = null,
?Subscriber  $subscriberRepo = null 
)

Definition at line 50 of file OnScreenChatProvider.php.

References ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\DI\Container\language().

54  {
56  $dic->language()->loadLanguageModule('chatroom');
57  $this->conversationRepo = $conversationRepo ?? new Conversation($this->dic->database(), $this->dic->user());
58  $this->subscriberRepo = $subscriberRepo ?? new Subscriber($this->dic->database(), $this->dic->user());
59  }
language()
Get interface to the i18n service.
Definition: Container.php:86
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getAsyncItem()

ILIAS\OnScreenChat\Provider\OnScreenChatProvider::getAsyncItem ( string  $conversationIds,
bool  $withAggregates 
)
Returns
Shy[]|MessageBox[]
Exceptions
JsonException
ilDateTimeException

Definition at line 142 of file OnScreenChatProvider.php.

References $id, ILIAS\UI\Component\Symbol\Icon\Standard\CON, ilDatePresentation\formatDate(), ILIAS\UI\Component\Symbol\Icon\Standard\GCON, ILIAS\OnScreenChat\Provider\OnScreenChatProvider\getSlateMessageBox(), IL_CAL_UNIX, and ILIAS\UI\Implementation\Component\withAdditionalOnLoadCode().

142  : array
143  {
144  $conversationIds = array_filter(explode(',', $conversationIds));
145 
146  if (!$withAggregates || !$this->dic->user()->getId() || $this->dic->user()->isAnonymous()) {
147  return [$this->getSlateMessageBox()];
148  }
149 
150  $conversations = $this->conversationRepo->findByIds($conversationIds);
151 
152  $allUsrIds = [];
153  foreach ($conversations as $conversation) {
154  foreach ($conversation->getSubscriberUsrIds() as $id) {
155  if ($id !== $this->dic->user()->getId()) {
156  $allUsrIds[$id] = true;
157  }
158  }
159  }
160  $allUsrIds = array_keys($allUsrIds);
161  $user_data = $this->subscriberRepo->getDataByUserIds($allUsrIds);
162 
163  $items = [];
164  foreach ($conversations as $conversation) {
165  if ($conversation->isGroup()) {
166  $icon = $this->dic->ui()->factory()->symbol()->icon()->standard(Standard::GCON, 'group-conversation');
167  } else {
168  $icon = $this->dic->ui()->factory()->symbol()->icon()->standard(Standard::CON, 'conversation');
169  }
170 
171  $users = [];
172  foreach ($conversation->getSubscriberUsrIds() as $id) {
173  if ($id !== $this->dic->user()->getId()) {
174  $users[] = $user_data[$id]['public_name'];
175  }
176  }
177 
178  $cid = $conversation->getId();
179 
180  $items[] = $this->dic->ui()->factory()->item()->shy(implode(', ', $users))
181  ->withDescription($conversation->getLastMessage()->getMessage())
182  ->withProperties(
183  [$this->dic->language()->txt('time') . ':' =>
185  new ilDateTime(
186  (int) ($conversation->getLastMessage()->getCreatedTimestamp() / 1000),
188  )
189  )
190  ]
191  )
192  ->withLeadIcon($icon)
193  ->withClose($this->dic->ui()->factory()->button()->close())
195  function ($id) use ($cid) {
196  return "il.OnScreenChat.menuCollector.querySelector('#$id').dataset.id = '$cid';";
197  }
198  );
199  }
200 
201  if ($items === []) {
202  $items[] = $this->getSlateMessageBox();
203  }
204 
205  return $items;
206  }
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const IL_CAL_UNIX
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getSlateMessageBox()

ILIAS\OnScreenChat\Provider\OnScreenChatProvider::getSlateMessageBox ( )
private

Definition at line 69 of file OnScreenChatProvider.php.

References ilUtil\yn2tf().

Referenced by ILIAS\OnScreenChat\Provider\OnScreenChatProvider\getAsyncItem(), and ILIAS\OnScreenChat\Provider\OnScreenChatProvider\getStaticSubItems().

69  : MessageBox
70  {
71  $acceptsMessages = ilUtil::yn2tf((string) $this->dic->user()->getPref('chat_osc_accept_msg'));
72  if ($acceptsMessages) {
73  return $this->dic->ui()->factory()
74  ->messageBox()
75  ->info($this->dic->language()->txt('chat_osc_accept_no_conv_info_slate'));
76  }
77 
78  return $this->dic->ui()->factory()
79  ->messageBox()
80  ->info($this->dic->language()->txt('chat_osc_accept_msg_info_slate'))
81  ->withLinks([
82  $this->dic->ui()->factory()
83  ->link()
84  ->standard(
85  $this->dic->language()->txt('chat_osc_accept_msg_info_slate_link_txt'),
86  $this->dic->ctrl()->getLinkTargetByClass(
87  [
88  ilDashboardGUI::class,
89  ilPersonalProfileGUI::class,
90  ilUserPrivacySettingsGUI::class
91  ],
92  'showPrivacySettings'
93  )
94  )
95  ]);
96  }
static yn2tf(string $a_yn)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStaticSubItems()

ILIAS\OnScreenChat\Provider\OnScreenChatProvider::getStaticSubItems ( )

Implements ILIAS\GlobalScreen\Scope\MainMenu\Provider\StaticMainMenuProvider.

Definition at line 101 of file OnScreenChatProvider.php.

References $id, ILIAS\UI\Component\Symbol\Icon\Standard\CHTA, ILIAS\MainMenu\Provider\StandardTopItemsProvider\getInstance(), ILIAS\OnScreenChat\Provider\OnScreenChatProvider\getSlateMessageBox(), if, and ILIAS\GlobalScreen\Scope\MainMenu\Factory\withSymbol().

101  : array
102  {
103  $icon = $this->dic->ui()->factory()->symbol()->icon()->standard(
105  $this->dic->language()->txt('public_room')
106  );
107 
108  return [
109  $this->mainmenu->complex($this->if->identifier('mm_chat'))
110  ->withAvailableCallable(function (): bool {
111  $isUser = 0 !== $this->dic->user()->getId() && !$this->dic->user()->isAnonymous();
112  $chatSettings = new ilSetting('chatroom');
113  $isEnabled = $chatSettings->get('chat_enabled') && $chatSettings->get('enable_osc');
114 
115  return $isUser && $isEnabled;
116  })
117  ->withTitle($this->dic->language()->txt('mm_private_chats'))
118  ->withSymbol($icon)
119  ->withContentWrapper(function (): \ILIAS\UI\Component\Component {
120  $components = [
121  $this->getSlateMessageBox(),
122  $this->dic->ui()->factory()->item()->shy('')->withAdditionalOnLoadCode(
123  static function ($id): string {
124  return "il.OnScreenChat.menuCollector = $id.parentNode;$id.remove();";
125  }
126  )
127  ];
128 
129  return $this->dic->ui()->factory()->legacy($this->dic->ui()->renderer()->render($components));
130  })
131  ->withParent(StandardTopItemsProvider::getInstance()->getCommunicationIdentification())
132  ->withPosition(40)
133  ,
134  ];
135  }
Class Factory.
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getStaticTopItems()

ILIAS\OnScreenChat\Provider\OnScreenChatProvider::getStaticTopItems ( )

Implements ILIAS\GlobalScreen\Scope\MainMenu\Provider\StaticMainMenuProvider.

Definition at line 64 of file OnScreenChatProvider.php.

64  : array
65  {
66  return [];
67  }

Field Documentation

◆ $conversationRepo

Conversation ILIAS\OnScreenChat\Provider\OnScreenChatProvider::$conversationRepo
private

Definition at line 47 of file OnScreenChatProvider.php.

◆ $subscriberRepo

Subscriber ILIAS\OnScreenChat\Provider\OnScreenChatProvider::$subscriberRepo
private

Definition at line 48 of file OnScreenChatProvider.php.


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