ILIAS  release_8 Revision v8.24
ilContactGUI Class Reference
+ Collaboration diagram for ilContactGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 submitInvitation ()
 Last step of chat invitations check access for every selected user and send invitation. More...
 

Data Fields

const CONTACTS_VIEW_GALLERY = 1
 
const CONTACTS_VIEW_TABLE = 2
 

Protected Member Functions

 activateTab (string $a_id)
 
 changeContactsView ()
 This method is used to switch the contacts view between gallery and table in the mail system. More...
 
 applyContactsTableFilter ()
 
 resetContactsTableFilter ()
 
 showContacts ()
 
 mailToUsers ()
 
 inviteToChat ()
 Send chat invitations to selected Users. More...
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
ilCtrlInterface $ctrl
 
ilLanguage $lng
 
ilTabsGUI $tabs_gui
 
ilHelpGUI $help
 
ilToolbarGUI $toolbar
 
ilFormatMail $umail
 
ilObjUser $user
 
ilErrorHandling $error
 
ilRbacSystem $rbacsystem
 
bool $has_sub_tabs = false
 
ILIAS Refinery Factory $refinery
 
ILIAS UI Factory $ui_factory
 
ILIAS UI Renderer $ui_renderer
 

Private Member Functions

 showSubTabs ()
 
 showContactRequests ()
 

Private Attributes

ILIAS HTTP GlobalHttpState $http
 
array $postUsrId = null
 

Detailed Description

Author
Jens Conze

@ilCtrl_Calls ilContactGUI: ilMailSearchCoursesGUI, ilMailSearchGroupsGUI, ilMailSearchLearningSequenceGUI, ilMailingListsGUI @ilCtrl_Calls ilContactGUI: ilUsersGalleryGUI, ilPublicUserProfileGUI

Definition at line 27 of file class.ilContactGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilContactGUI::__construct ( )

Definition at line 52 of file class.ilContactGUI.php.

53 {
54 global $DIC;
55
56 $this->tpl = $DIC['tpl'];
57 $this->ctrl = $DIC['ilCtrl'];
58 $this->lng = $DIC['lng'];
59 $this->tabs_gui = $DIC['ilTabs'];
60 $this->help = $DIC['ilHelp'];
61 $this->toolbar = $DIC['ilToolbar'];
62 $this->user = $DIC['ilUser'];
63 $this->error = $DIC['ilErr'];
64 $this->rbacsystem = $DIC['rbacsystem'];
65 $this->http = $DIC->http();
66 $this->refinery = $DIC->refinery();
67 $this->ui_factory = $DIC->ui()->factory();
68 $this->ui_renderer = $DIC->ui()->renderer();
69
70 $this->ctrl->saveParameter($this, "mobj_id");
71
72 $this->umail = new ilFormatMail($this->user->getId());
73 $this->lng->loadLanguageModule('buddysystem');
74 }
error(string $a_errmsg)
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.

References $DIC, ILIAS\Repository\ctrl(), error(), ILIAS\Repository\help(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ activateTab()

ilContactGUI::activateTab ( string  $a_id)
protected

Definition at line 248 of file class.ilContactGUI.php.

248 : void
249 {
250 if ($this->has_sub_tabs) {
251 $this->tabs_gui->activateSubTab($a_id);
252 } else {
253 $this->tabs_gui->activateTab($a_id);
254 }
255 }

Referenced by executeCommand(), inviteToChat(), and showContacts().

+ Here is the caller graph for this function:

◆ applyContactsTableFilter()

ilContactGUI::applyContactsTableFilter ( )
protected

Definition at line 281 of file class.ilContactGUI.php.

281 : void
282 {
283 if (!ilBuddySystem::getInstance()->isEnabled()) {
284 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
285 }
286
287 $table = new ilBuddySystemRelationsTableGUI($this, 'showContacts');
288
289 $table->resetOffset();
290 $table->writeFilterToSession();
291
292 $this->showContacts();
293 }

References error(), ilBuddySystem\getInstance(), ILIAS\Repository\lng(), and showContacts().

+ Here is the call graph for this function:

◆ changeContactsView()

ilContactGUI::changeContactsView ( )
protected

This method is used to switch the contacts view between gallery and table in the mail system.

Definition at line 260 of file class.ilContactGUI.php.

260 : void
261 {
262 if (!ilBuddySystem::getInstance()->isEnabled()) {
263 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
264 }
265
266 if ($this->http->wrapper()->post()->has('contacts_view')) {
267 switch ($this->http->wrapper()->post()->retrieve('contacts_view', $this->refinery->kindlyTo()->int())) {
269 $this->ctrl->redirectByClass(ilUsersGalleryGUI::class);
270
271 // no break
273 $this->ctrl->redirect($this);
274 }
275 }
276
277 $this->ctrl->redirect($this);
278 }

References CONTACTS_VIEW_GALLERY, CONTACTS_VIEW_TABLE, ILIAS\Repository\ctrl(), error(), ilBuddySystem\getInstance(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ executeCommand()

ilContactGUI::executeCommand ( )

Definition at line 76 of file class.ilContactGUI.php.

76 : bool
77 {
78 $this->showSubTabs();
79
80 $forward_class = $this->ctrl->getNextClass($this);
81
82 $this->umail->persistToStage($this->user->getId(), [], '', '', '', '', '', false);
83
84 switch (strtolower($forward_class)) {
85 case strtolower(ilMailSearchCoursesGUI::class):
86 $this->activateTab('mail_my_courses');
87
88 $this->ctrl->setReturn($this, "showContacts");
89 $this->ctrl->forwardCommand(new ilMailSearchCoursesGUI());
90 break;
91
92 case strtolower(ilMailSearchGroupsGUI::class):
93 $this->activateTab('mail_my_groups');
94
95 $this->ctrl->setReturn($this, "showContacts");
96 $this->ctrl->forwardCommand(new ilMailSearchGroupsGUI());
97 break;
98
99 case strtolower(ilMailingListsGUI::class):
100 $this->activateTab('mail_my_mailing_lists');
101
102 $this->ctrl->setReturn($this, "showContacts");
103 $this->ctrl->forwardCommand(new ilMailingListsGUI());
104 break;
105
106 case strtolower(ilUsersGalleryGUI::class):
107 if (!ilBuddySystem::getInstance()->isEnabled()) {
108 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
109 }
110
111 $this->tabs_gui->activateSubTab('buddy_view_gallery');
112 $this->activateTab('my_contacts');
113 $this->ctrl->forwardCommand(new ilUsersGalleryGUI(new ilUsersGalleryContacts()));
114 $this->tpl->printToStdout();
115 break;
116
117 case strtolower(ilPublicUserProfileGUI::class):
118 $profile_gui = new ilPublicUserProfileGUI(
119 $this->http->wrapper()->query()->retrieve('user', $this->refinery->kindlyTo()->int())
120 );
121 $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, 'showContacts'));
122 $this->ctrl->forwardCommand($profile_gui);
123 $this->tpl->printToStdout();
124 break;
125
126 default:
127 $this->activateTab('mail_my_entries');
128
129 if (!($cmd = $this->ctrl->getCmd())) {
130 if (ilBuddySystem::getInstance()->isEnabled()) {
131 $cmd = 'showContacts';
132 } else {
133 $this->ctrl->redirectByClass(ilMailSearchCoursesGUI::class);
134 }
135 }
136
137 $this->$cmd();
138 break;
139 }
140 return true;
141 }
Class ilBuddySystem.
activateTab(string $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setBackUrl(string $a_backurl)
Set Back Link URL.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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

References activateTab(), ILIAS\Repository\ctrl(), error(), ilBuddySystem\getInstance(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), showSubTabs(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ inviteToChat()

ilContactGUI::inviteToChat ( )
protected

Send chat invitations to selected Users.

Definition at line 571 of file class.ilContactGUI.php.

571 : void
572 {
573 $this->tabs_gui->activateSubTab('buddy_view_table');
574 $this->activateTab('my_contacts');
575
576 $this->lng->loadLanguageModule('chatroom');
577
578 $usr_ids = $this->postUsrId;
579 if (!is_array($usr_ids)) {
580 try {
581 $usr_ids = $this->http->wrapper()->post()->retrieve(
582 'usr_id',
583 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
584 );
585 } catch (Exception $e) {
586 $usr_ids = [];
587 }
588 }
589
590 if (!is_array($usr_ids) || [] === $usr_ids) {
591 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_one'), true);
592 $this->ctrl->redirect($this);
593 }
594
595 $usr_ids = $this->refinery->kindlyTo()->listOf(
596 $this->refinery->kindlyTo()->int()
597 )->transform($usr_ids);
598
599 $ilChatroom = new ilChatroom();
600 $chat_rooms = $ilChatroom->getAccessibleRoomIdByTitleMap($this->user->getId());
601 $subrooms = [];
602
603 foreach ($chat_rooms as $room_id => $title) {
604 $subrooms[] = $ilChatroom->getPrivateSubRooms($room_id, $this->user->getId());
605 }
606
607 $form = new ilPropertyFormGUI();
608 $form->setTitle($this->lng->txt('mail_invite_users_to_chat'));
609
610 $psel = new ilSelectInputGUI($this->lng->txt('chat_select_room'), 'room_id');
611 $options = [];
612
613 asort($chat_rooms);
614 foreach ($chat_rooms as $room_id => $room) {
615 $ref_id = $room_id;
616
617 if ($ilChatroom->isUserBanned($this->user->getId())) {
618 continue;
619 }
620
621 $options[$ref_id] = $room;
622
623 foreach ($subrooms as $subroom) {
624 foreach ($subroom as $sub_id => $parent_id) {
625 if ($parent_id === $ref_id) {
626 $title = ilChatroom::lookupPrivateRoomTitle($sub_id);
627 $options[$ref_id . ',' . $sub_id] = '+ ' . $title;
628 }
629 }
630 }
631 }
632
633 $psel->setOptions($options);
634 $form->addItem($psel);
635 $phidden = new ilHiddenInputGUI('usr_id');
636 $phidden->setValue(implode(',', $usr_ids));
637 $form->addItem($phidden);
638 $form->addCommandButton('submitInvitation', $this->lng->txt('submit'));
639 $form->addCommandButton('showContacts', $this->lng->txt('cancel'));
640 $form->setFormAction($this->ctrl->getFormAction($this, 'showContacts'));
641
642 $this->tpl->setTitle($this->lng->txt('mail_invite_users_to_chat'));
643 $this->tpl->setContent($form->getHTML());
644 $this->tpl->printToStdout();
645 }
Class ilChatroom.
static lookupPrivateRoomTitle(int $proom_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
This class represents a selection list property in a property form.
$ref_id
Definition: ltiauth.php:67

References Vendor\Package\$e, $postUsrId, $ref_id, activateTab(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ilChatroom\lookupPrivateRoomTitle(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

Referenced by submitInvitation().

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

◆ mailToUsers()

ilContactGUI::mailToUsers ( )
protected

Definition at line 388 of file class.ilContactGUI.php.

388 : void
389 {
390 if (!$this->rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
391 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
392 }
393
394 try {
395 $usr_ids = $this->http->wrapper()->post()->retrieve(
396 'usr_id',
397 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
398 );
399
400 // TODO: Replace this with some kind of 'ArrayLengthConstraint'
401 if ($usr_ids === []) {
402 throw new LengthException('mail_select_one_entry');
403 }
404 } catch (Exception $e) {
405 $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one_entry'));
406 $this->showContacts();
407 return;
408 }
409
410 $logins = [];
411 $mail_data = $this->umail->retrieveFromStage();
412 foreach ($usr_ids as $usr_id) {
413 $login = ilObjUser::_lookupLogin($usr_id);
414 if (!$this->umail->existsRecipient($login, (string) $mail_data['rcp_to'])) {
415 $logins[] = $login;
416 }
417 }
418 $logins = array_filter($logins);
419
420 if ($logins !== []) {
421 $mail_data = $this->umail->appendSearchResult($logins, 'to');
422 $this->umail->persistToStage(
423 (int) $mail_data['user_id'],
424 $mail_data['attachments'],
425 $mail_data['rcp_to'],
426 $mail_data['rcp_cc'],
427 $mail_data['rcp_bcc'],
428 $mail_data['m_subject'],
429 $mail_data['m_message'],
430 $mail_data['use_placeholders'],
431 $mail_data['tpl_ctx_id'],
432 $mail_data['tpl_ctx_params']
433 );
434 }
435
436 $this->ctrl->redirectToURL('ilias.php?baseClass=ilMailGUI&type=search_res');
437 }
static _lookupLogin(int $a_user_id)

References Vendor\Package\$e, ilObjUser\_lookupLogin(), ILIAS\Repository\ctrl(), error(), ilMailGlobalServices\getMailObjectRefId(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and showContacts().

+ Here is the call graph for this function:

◆ resetContactsTableFilter()

ilContactGUI::resetContactsTableFilter ( )
protected

Definition at line 296 of file class.ilContactGUI.php.

296 : void
297 {
298 if (!ilBuddySystem::getInstance()->isEnabled()) {
299 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
300 }
301
302 $table = new ilBuddySystemRelationsTableGUI($this, 'showContacts');
303
304 $table->resetOffset();
305 $table->resetFilter();
306
307 $this->showContacts();
308 }

References error(), ilBuddySystem\getInstance(), ILIAS\Repository\lng(), and showContacts().

+ Here is the call graph for this function:

◆ showContactRequests()

ilContactGUI::showContactRequests ( )
private

Definition at line 369 of file class.ilContactGUI.php.

369 : void
370 {
371 if (!ilBuddySystem::getInstance()->isEnabled()) {
372 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
373 }
374
375 $table = new ilBuddySystemRelationsTableGUI($this, 'showContacts');
376
377 $table->resetOffset();
378 $table->resetFilter();
379
380 $table->applyFilterValue(
382 ilBuddySystemRequestedRelationState::class . '_p'
383 );
384
385 $this->showContacts();
386 }

References error(), ilBuddySystem\getInstance(), ILIAS\Repository\lng(), showContacts(), and ilBuddySystemRelationsTableGUI\STATE_FILTER_ELM_ID.

+ Here is the call graph for this function:

◆ showContacts()

ilContactGUI::showContacts ( )
protected

Definition at line 311 of file class.ilContactGUI.php.

311 : void
312 {
313 if (!ilBuddySystem::getInstance()->isEnabled()) {
314 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
315 }
316
317 $content = [];
318
319 $this->tabs_gui->activateSubTab('buddy_view_table');
320 $this->activateTab('my_contacts');
321
322 if ($this->http->wrapper()->query()->has('inv_room_ref_id') &&
323 $this->http->wrapper()->query()->has('inv_room_scope') &&
324 $this->http->wrapper()->query()->has('inv_usr_ids')) {
325 $inv_room_ref_id = $this->http->wrapper()->query()->retrieve(
326 'inv_room_ref_id',
327 $this->refinery->kindlyTo()->int()
328 );
329 $inv_room_scope = $this->http->wrapper()->query()->retrieve(
330 'inv_room_scope',
331 $this->refinery->kindlyTo()->int()
332 );
333 $inv_usr_ids = $this->http->wrapper()->query()->retrieve(
334 'inv_usr_ids',
335 $this->refinery->in()->series([
336 $this->refinery->kindlyTo()->string(),
337 $this->refinery->custom()->transformation(fn (string $value): array => explode(',', $value)),
338 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
339 ])
340 );
341
342 $userlist = [];
343 foreach ($inv_usr_ids as $inv_usr_id) {
344 $login = ilObjUser::_lookupLogin($inv_usr_id);
345 $userlist[] = $login;
346 }
347
348 if ($userlist !== []) {
349 $url = $inv_room_scope !== 0 ? ilLink::_getStaticLink($inv_room_ref_id, 'chtr', true, '_' . $inv_room_scope) : ilLink::_getStaticLink($inv_room_ref_id, 'chtr');
350
351 $content[] = $this->ui_factory->messageBox()->success(
352 $this->lng->txt('chat_users_have_been_invited') . $this->ui_renderer->render(
353 $this->ui_factory->listing()->unordered($userlist)
354 )
355 )->withButtons([
356 $this->ui_factory->button()->standard($this->lng->txt('goto_invitation_chat'), $url)
357 ]);
358 }
359 }
360
361 $table = new ilBuddySystemRelationsTableGUI($this, 'showContacts');
362 $table->populate();
363 $content[] = $this->ui_factory->legacy($table->getHTML());
364
365 $this->tpl->setContent($this->ui_renderer->render($content));
366 $this->tpl->printToStdout();
367 }
$url

References $url, ilLink\_getStaticLink(), ilObjUser\_lookupLogin(), activateTab(), error(), ilBuddySystem\getInstance(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by applyContactsTableFilter(), mailToUsers(), resetContactsTableFilter(), and showContactRequests().

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

◆ showSubTabs()

ilContactGUI::showSubTabs ( )
private

Definition at line 144 of file class.ilContactGUI.php.

144 : void
145 {
146 $galleryCmdClasses = array_map('strtolower', [ilUsersGalleryGUI::class, self::class]);
147 if ($this->tabs_gui->hasTabs()) {
148 if (ilBuddySystem::getInstance()->isEnabled()) {
149 $this->tabs_gui->addSubTab(
150 'my_contacts',
151 $this->lng->txt('my_contacts'),
152 $this->ctrl->getLinkTarget($this)
153 );
154
155 if (in_array(strtolower($this->ctrl->getCmdClass()), $galleryCmdClasses, true)) {
156 $view_selection = new ilSelectInputGUI('', 'contacts_view');
157 $view_selection->setOptions([
158 (string) self::CONTACTS_VIEW_TABLE => $this->lng->txt('buddy_view_table'),
159 (string) self::CONTACTS_VIEW_GALLERY => $this->lng->txt('buddy_view_gallery')
160 ]);
161 $view_selection->setValue(
162 strtolower($this->ctrl->getCmdClass()) === strtolower(ilUsersGalleryGUI::class)
163 ? (string) self::CONTACTS_VIEW_GALLERY
164 : (string) self::CONTACTS_VIEW_TABLE
165 );
166 $this->toolbar->addInputItem($view_selection);
167
168 $contact_view_btn = ilSubmitButton::getInstance();
169 $contact_view_btn->setCaption('show');
170 $contact_view_btn->setCommand('changeContactsView');
171 $this->toolbar->addButtonInstance($contact_view_btn);
172 $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'changeContactsView'));
173 }
174
175 if (
176 count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0 ||
177 (new ilMailingLists($this->user))->hasAny()
178 ) {
179 $this->tabs_gui->addSubTab(
180 'mail_my_mailing_lists',
181 $this->lng->txt('mail_my_mailing_lists'),
182 $this->ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
183 );
184 }
185 }
186
187 $this->tabs_gui->addSubTab(
188 'mail_my_courses',
189 $this->lng->txt('mail_my_courses'),
190 $this->ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
191 );
192 $this->tabs_gui->addSubTab(
193 'mail_my_groups',
194 $this->lng->txt('mail_my_groups'),
195 $this->ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
196 );
197 $this->has_sub_tabs = true;
198 } else {
199 $this->tpl->setTitleIcon(ilUtil::getImagePath('icon_cadm.svg'));
200
201 $this->help->setScreenIdComponent('contacts');
202
203 if (ilBuddySystem::getInstance()->isEnabled()) {
204 $this->tabs_gui->addTab(
205 'my_contacts',
206 $this->lng->txt('my_contacts'),
207 $this->ctrl->getLinkTarget($this)
208 );
209
210 if (in_array(strtolower($this->ctrl->getCmdClass()), $galleryCmdClasses, true)) {
211 $this->tabs_gui->addSubTab(
212 'buddy_view_table',
213 $this->lng->txt('buddy_view_table'),
214 $this->ctrl->getLinkTarget($this)
215 );
216 $this->tabs_gui->addSubTab(
217 'buddy_view_gallery',
218 $this->lng->txt('buddy_view_gallery'),
219 $this->ctrl->getLinkTargetByClass(ilUsersGalleryGUI::class)
220 );
221 }
222
223 if (
224 count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0 ||
225 (new ilMailingLists($this->user))->hasAny()
226 ) {
227 $this->tabs_gui->addTab(
228 'mail_my_mailing_lists',
229 $this->lng->txt('mail_my_mailing_lists'),
230 $this->ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
231 );
232 }
233 }
234
235 $this->tabs_gui->addTab(
236 'mail_my_courses',
237 $this->lng->txt('mail_my_courses'),
238 $this->ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
239 );
240 $this->tabs_gui->addTab(
241 'mail_my_groups',
242 $this->lng->txt('mail_my_groups'),
243 $this->ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
244 );
245 }
246 }
static getInstanceByGlobalUser()
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

References ILIAS\Repository\ctrl(), ilUtil\getImagePath(), ilBuddySystem\getInstance(), ilSubmitButton\getInstance(), ilBuddyList\getInstanceByGlobalUser(), ILIAS\Repository\help(), ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

Referenced by executeCommand().

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

◆ submitInvitation()

ilContactGUI::submitInvitation ( )

Last step of chat invitations check access for every selected user and send invitation.

Definition at line 443 of file class.ilContactGUI.php.

443 : void
444 {
445 $usr_ids = [];
446 try {
447 $usr_ids = $this->refinery->kindlyTo()->listOf(
448 $this->refinery->kindlyTo()->int()
449 )->transform(explode(',', $this->http->wrapper()->post()->retrieve(
450 'usr_id',
451 $this->refinery->kindlyTo()->string()
452 )));
453
454 // TODO: Replace this with some kind of 'ArrayLengthConstraint'
455 if ($usr_ids === []) {
456 throw new LengthException('select_one');
457 }
458 } catch (Exception $e) {
459 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_one'), true);
460 $this->ctrl->redirect($this);
461 }
462
463 if (!$this->http->wrapper()->post()->has('room_id')) {
464 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_one'));
465 $this->postUsrId = $usr_ids;
466 $this->inviteToChat();
467 return;
468 }
469
470 // get selected chatroom from POST-String, format: "room_id,scope"
471 $room_ids = $this->refinery->kindlyTo()->listOf(
472 $this->refinery->kindlyTo()->int()
473 )->transform(explode(',', $this->http->wrapper()->post()->retrieve(
474 'room_id',
475 $this->refinery->kindlyTo()->string()
476 )));
477
478 $room_id = (int) $room_ids[0];
479
480 $scope = 0;
481 if (count($room_ids) > 1) {
482 $scope = (int) $room_ids[1];
483 }
484
485 $room = ilChatroom::byRoomId($room_id, true);
486 $no_access = [];
487 $no_login = [];
488 $valid_users = [];
489 $valid_user_to_login_map = [];
490
491 foreach ($usr_ids as $usr_id) {
492 $login = ilObjUser::_lookupLogin($usr_id);
493 if ($login === '') {
494 $no_login[$usr_id] = $usr_id;
495 continue;
496 }
497
498 $ref_id = $room->getRefIdByRoomId($room_id);
499
500 if (
501 !ilChatroom::checkPermissionsOfUser((int) $usr_id, 'read', $ref_id) ||
502 $room->isUserBanned((int) $usr_id)
503 ) {
504 $no_access[$usr_id] = $login;
505 } else {
506 $valid_users[$usr_id] = $usr_id;
507 $valid_user_to_login_map[$usr_id] = $login;
508 }
509 }
510
511 if (count($no_access) || count($no_login)) {
512 $message = '';
513
514 if (count($no_access) > 0) {
515 $message .= $this->lng->txt('chat_users_without_permission') . ':<br>';
516 $list = '';
517
518 foreach ($no_access as $usr_id => $login) {
519 $list .= '<li>' . $login . '</li>';
520 }
521
522 $message .= '<ul>';
523 $message .= $list;
524 $message .= '</ul>';
525 }
526
527 if (count($no_login) > 0) {
528 $message .= $this->lng->txt('chat_users_without_login') . ':<br>';
529 $list = '';
530
531 foreach ($no_login as $usr_id) {
532 $list .= '<li>' . $usr_id . '</li>';
533 }
534
535 $message .= '<ul>';
536 $message .= $list;
537 $message .= '</ul>';
538 }
539
540 $this->tpl->setOnScreenMessage('failure', $message);
541 $this->postUsrId = $usr_ids;
542 $this->inviteToChat();
543 return;
544 }
545
546 $ref_id = $room->getRefIdByRoomId($room_id);
547
548 $url = $scope !== 0 ? ilLink::_getStaticLink($ref_id, 'chtr', true, '_' . $scope) : ilLink::_getStaticLink($ref_id, 'chtr');
549
550 foreach ($valid_users as $id) {
551 $room->inviteUserToPrivateRoom((int) $id, $scope);
552 $room->sendInvitationNotification(
553 null,
554 $this->user->getId(),
555 (int) $id,
556 $scope,
557 $url
558 );
559 }
560
561 $this->ctrl->setParameter($this, 'inv_room_ref_id', $ref_id);
562 $this->ctrl->setParameter($this, 'inv_room_scope', (int) $scope);
563 $this->ctrl->setParameter($this, 'inv_usr_ids', implode(',', $valid_users));
564
565 $this->ctrl->redirect($this);
566 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static checkPermissionsOfUser(int $usr_id, $permissions, int $ref_id)
Checks user permissions in question for a given user id in relation to a given ref_id.
static byRoomId(int $room_id, bool $initObject=false)
inviteToChat()
Send chat invitations to selected Users.
$scope
Definition: ltiregstart.php:53
$message
Definition: xapiexit.php:32

References Vendor\Package\$e, $id, $message, $ref_id, $scope, $url, ilLink\_getStaticLink(), ilObjUser\_lookupLogin(), ilChatroom\byRoomId(), ilChatroom\checkPermissionsOfUser(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), inviteToChat(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ilContactGUI::$ctrl
protected

Definition at line 38 of file class.ilContactGUI.php.

◆ $error

ilErrorHandling ilContactGUI::$error
protected

Definition at line 45 of file class.ilContactGUI.php.

◆ $has_sub_tabs

bool ilContactGUI::$has_sub_tabs = false
protected

Definition at line 47 of file class.ilContactGUI.php.

◆ $help

ilHelpGUI ilContactGUI::$help
protected

Definition at line 41 of file class.ilContactGUI.php.

◆ $http

ILIAS HTTP GlobalHttpState ilContactGUI::$http
private

Definition at line 31 of file class.ilContactGUI.php.

◆ $lng

ilLanguage ilContactGUI::$lng
protected

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

◆ $postUsrId

array ilContactGUI::$postUsrId = null
private

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

Referenced by inviteToChat().

◆ $rbacsystem

ilRbacSystem ilContactGUI::$rbacsystem
protected

Definition at line 46 of file class.ilContactGUI.php.

◆ $refinery

ILIAS Refinery Factory ilContactGUI::$refinery
protected

Definition at line 48 of file class.ilContactGUI.php.

◆ $tabs_gui

ilTabsGUI ilContactGUI::$tabs_gui
protected

Definition at line 40 of file class.ilContactGUI.php.

◆ $toolbar

ilToolbarGUI ilContactGUI::$toolbar
protected

Definition at line 42 of file class.ilContactGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilContactGUI::$tpl
protected

Definition at line 37 of file class.ilContactGUI.php.

◆ $ui_factory

ILIAS UI Factory ilContactGUI::$ui_factory
protected

Definition at line 49 of file class.ilContactGUI.php.

◆ $ui_renderer

ILIAS UI Renderer ilContactGUI::$ui_renderer
protected

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

◆ $umail

ilFormatMail ilContactGUI::$umail
protected

Definition at line 43 of file class.ilContactGUI.php.

◆ $user

ilObjUser ilContactGUI::$user
protected

Definition at line 44 of file class.ilContactGUI.php.

◆ CONTACTS_VIEW_GALLERY

const ilContactGUI::CONTACTS_VIEW_GALLERY = 1

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

Referenced by changeContactsView().

◆ CONTACTS_VIEW_TABLE

const ilContactGUI::CONTACTS_VIEW_TABLE = 2

Definition at line 30 of file class.ilContactGUI.php.

Referenced by changeContactsView().


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