ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilContactGUI Class Reference
+ Inheritance diagram for ilContactGUI:
+ Collaboration diagram for ilContactGUI:

Public Member Functions

 __construct (string $format_mail_class=ilFormatMail::class, string $relations_table_class=RelationsTable::class)
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 
 executeCommand ()
 
 submitInvitation ()
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 

Data Fields

final const string CONTACTS_VIEW_GALLERY = 'buddy_view_gallery'
 
final const string CONTACTS_VIEW_TABLE = 'buddy_view_table'
 

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...
 
 showContacts ()
 
 mailToUsers (array $usr_ids)
 
 inviteToChat (array $usr_ids)
 

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
 
Refinery $refinery
 
ILIAS UI Factory $ui_factory
 
ILIAS UI Renderer $ui_renderer
 

Private Member Functions

 showSubTabs ()
 
 updateState ()
 
 confirmUnlinkContact ()
 
 unlinkContact ()
 
 updateRelationState (int $user, string $action)
 
 asErrorMessage (array $array, string $title)
 
 inviteToChatForm (array $options, array $usr_ids)
 
 chatroomInvitationMessage ()
 
 contactAction ()
 
 linkToProfile (int $user, string $label)
 

Private Attributes

readonly ILIAS HTTP GlobalHttpState $http
 
readonly RelationsTable $relations_table
 
array $view_mode_options
 

Detailed Description

Author
Jens Conze

@ilCtrl_Calls ilContactGUI: ilMailSearchCoursesGUI, ilMailSearchGroupsGUI, ilMailSearchLearningSequenceGUI, ilMailingListsGUI @ilCtrl_Calls ilContactGUI: ilUsersGalleryGUI, ILIAS\User\Profile\PublicProfileGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilContactGUI::__construct ( string  $format_mail_class = ilFormatMail::class,
string  $relations_table_class = RelationsTable::class 
)

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

65 {
66 global $DIC;
67
68 $this->tpl = $DIC['tpl'];
69 $this->ctrl = $DIC['ilCtrl'];
70 $this->lng = $DIC['lng'];
71 $this->tabs_gui = $DIC['ilTabs'];
72 $this->help = $DIC['ilHelp'];
73 $this->toolbar = $DIC['ilToolbar'];
74 $this->user = $DIC['ilUser'];
75 $this->error = $DIC['ilErr'];
76 $this->rbacsystem = $DIC['rbacsystem'];
77 $this->http = $DIC->http();
78 $this->refinery = $DIC->refinery();
79 $this->ui_factory = $DIC->ui()->factory();
80 $this->ui_renderer = $DIC->ui()->renderer();
81
82 $this->ctrl->saveParameter($this, "mobj_id");
83
84 $this->umail = new $format_mail_class($this->user->getId());
85 $this->relations_table = new $relations_table_class(
86 $this->ui_factory,
87 $this->lng,
88 $DIC->uiService(),
89 $this->http,
90 $this->linkToProfile(...)
91 );
92 $this->lng->loadLanguageModule('buddysystem');
93 }
error(string $a_errmsg)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

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 288 of file class.ilContactGUI.php.

288 : void
289 {
290 if ($this->has_sub_tabs) {
291 $this->tabs_gui->activateSubTab($a_id);
292 } else {
293 $this->tabs_gui->activateTab($a_id);
294 }
295 }

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

+ Here is the caller graph for this function:

◆ asErrorMessage()

ilContactGUI::asErrorMessage ( array  $array,
string  $title 
)
private
Parameters
list<string|int>$array

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

579 : string
580 {
581 if ($array === []) {
582 return '';
583 }
584
585 $items = array_map(
586 fn($s) => '<li>' . htmlspecialchars((string) $s) . '</li>',
587 $array
588 );
589
590 return sprintf(
591 '%s<br><ul>%s</ul>',
592 $title,
593 join('', $items)
594 );
595 }

Referenced by submitInvitation().

+ Here is the caller 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 300 of file class.ilContactGUI.php.

300 : void
301 {
302 if (!ilBuddySystem::getInstance()->isEnabled()) {
303 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
304 }
305
306 $contacts_view = $this->http->wrapper()->query()->retrieve(
307 'contacts_view',
308 $this->refinery->byTrying([
309 $this->refinery->kindlyTo()->string(),
310 $this->refinery->always(self::CONTACTS_VIEW_TABLE)
311 ])
312 );
313
314 switch ($contacts_view) {
316 $this->ctrl->redirectByClass(ilUsersGalleryGUI::class);
317
318 // no break
320 default:
321 $this->ctrl->redirect($this);
322 }
323 }
final const string CONTACTS_VIEW_TABLE
final const string CONTACTS_VIEW_GALLERY

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

+ Here is the call graph for this function:

◆ chatroomInvitationMessage()

ilContactGUI::chatroomInvitationMessage ( )
private
Returns
Component[]

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

623 : array
624 {
625 $has = $this->http->wrapper()->query()->has(...);
626 if (!$has('inv_room_ref_id') || !$has('inv_usr_ids')) {
627 return [];
628 }
629
630 $inv_room_ref_id = $this->http->wrapper()->query()->retrieve(
631 'inv_room_ref_id',
632 $this->refinery->kindlyTo()->int()
633 );
634 $inv_usr_ids = $this->http->wrapper()->query()->retrieve(
635 'inv_usr_ids',
636 $this->refinery->in()->series([
637 $this->refinery->kindlyTo()->string(),
638 $this->refinery->custom()->transformation(fn(string $s): array => explode(',', $s)),
639 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
640 $this->refinery->custom()->constraint(fn(array $a): bool => $a !== [], fn(): string => 'Empty array.'),
641 ])
642 );
643
644 $userlist = array_map(ilObjUser::_lookupLogin(...), $inv_usr_ids);
645
646 $url = ilLink::_getStaticLink($inv_room_ref_id, 'chtr');
647
648 return [
649 $this->ui_factory->messageBox()->success(
650 $this->lng->txt('chat_users_have_been_invited') . $this->ui_renderer->render(
651 $this->ui_factory->listing()->unordered($userlist)
652 )
653 )->withButtons([
654 $this->ui_factory->button()->standard($this->lng->txt('goto_invitation_chat'), $url)
655 ])
656 ];
657 }
static _lookupLogin(int $a_user_id)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$url
Definition: shib_logout.php:70

References Vendor\Package\$a, $url, ilLink\_getStaticLink(), ilObjUser\_lookupLogin(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by showContacts().

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

◆ confirmUnlinkContact()

ilContactGUI::confirmUnlinkContact ( )
private

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

386 : void
387 {
388 $this->activateTab('my_contacts');
389 $this->tabs_gui->activateSubTab('buddy_view_table');
390
391 $user_id = $this->http->wrapper()->query()->retrieve('user_id', $this->refinery->kindlyTo()->int());
392
393 $confirmation_gui = new ilConfirmationGUI();
394 $confirmation_gui->setHeaderText($this->lng->txt('buddy_confirm_unlink'));
395 $confirmation_gui->addItem('user_id', (string) $user_id, ilObjUser::_lookupLogin($user_id));
396 $confirmation_gui->setConfirm($this->lng->txt('confirm'), 'unlinkContact');
397 $confirmation_gui->setCancel($this->lng->txt('cancel'), 'showContacts');
398 $confirmation_gui->setFormAction($this->ctrl->getFormActionByClass(self::class, 'showContacts'));
399
400 $this->tpl->setContent($confirmation_gui->getHTML());
401 $this->tpl->printToStdout();
402 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
activateTab(string $a_id)

References $user_id, ilObjUser\_lookupLogin(), activateTab(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ contactAction()

ilContactGUI::contactAction ( )
private
Returns
Closure(string, string, string): Action

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

662 : Closure
663 {
664 $url = new URLBuilder(new URI(rtrim(ILIAS_HTTP_PATH, '/') . '/' . $this->ctrl->getLinkTarget($this, 'updateState')));
665 [$url, $p, $token] = $url->acquireParameters(['contact'], 'action', 'user_ids');
666
667 return fn(string $type, string $lang_var, string $param): Action => $this->ui_factory->table()->action()->$type(
668 $this->lng->txt($lang_var),
669 $url->withParameter($p, $param),
670 $token
671 );
672 }
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
$token
Definition: xapitoken.php:67
$param
Definition: xapitoken.php:44

References $param, $token, $url, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by showContacts().

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

◆ executeCommand()

ilContactGUI::executeCommand ( )

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

107 : bool
108 {
109 $this->showSubTabs();
110
111 $forward_class = $this->ctrl->getNextClass($this) ?? '';
112
113 $this->umail->persistToStage($this->user->getId(), '', '', '', '', '', null, false);
114
115 switch (strtolower($forward_class)) {
116 case strtolower(ilMailSearchCoursesGUI::class):
117 $this->activateTab('mail_my_courses');
118
119 $this->ctrl->setReturn($this, "showContacts");
120 $this->ctrl->forwardCommand(new ilMailSearchCoursesGUI());
121 break;
122
123 case strtolower(ilMailSearchGroupsGUI::class):
124 $this->activateTab('mail_my_groups');
125
126 $this->ctrl->setReturn($this, "showContacts");
127 $this->ctrl->forwardCommand(new ilMailSearchGroupsGUI());
128 break;
129
130 case strtolower(ilMailingListsGUI::class):
131 $this->activateTab('mail_my_mailing_lists');
132
133 $this->ctrl->setReturn($this, "showContacts");
134 $this->ctrl->forwardCommand(new ilMailingListsGUI());
135 break;
136
137 case strtolower(ilUsersGalleryGUI::class):
138 if (!ilBuddySystem::getInstance()->isEnabled()) {
139 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
140 }
141
142 $this->tabs_gui->activateSubTab('buddy_view_gallery');
143 $this->activateTab('my_contacts');
144 $this->ctrl->forwardCommand(new ilUsersGalleryGUI(new ilUsersGalleryContacts()));
145 $this->tpl->printToStdout();
146 break;
147
148 case strtolower(PublicProfileGUI::class):
149 $profile_gui = new PublicProfileGUI(
150 $this->http->wrapper()->query()->retrieve('user', $this->refinery->kindlyTo()->int())
151 );
152 $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, 'showContacts'));
153 $this->ctrl->forwardCommand($profile_gui);
154 $this->tpl->printToStdout();
155 break;
156
157 default:
158 $this->activateTab('mail_my_entries');
159
160 if (!($cmd = $this->ctrl->getCmd())) {
161 if (ilBuddySystem::getInstance()->isEnabled()) {
162 $cmd = 'showContacts';
163 } else {
164 $this->ctrl->redirectByClass(ilMailSearchCoursesGUI::class);
165 }
166 }
167
168 $this->$cmd();
169 break;
170 }
171 return true;
172 }
GUI class for public user profile presentation.
setBackUrl(string $backurl)
Set Back Link URL.
Class ilBuddySystem.
@ilCtrl_Calls ilUsersGalleryGUI: ILIAS\User\Profile\PublicProfileGUI @ilCtrl_isCalledBy ilUsersGaller...
if(!file_exists('../ilias.ini.php'))

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:

◆ getSafePostCommands()

ilContactGUI::getSafePostCommands ( )

This method must return a list of safe POST commands.

Safe post commands returned by this method will no longer be CSRF protected and will NOT be appended by an ilCtrlToken.

Returns
string[]

Implements ilCtrlSecurityInterface.

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

102 : array
103 {
104 return [];
105 }

◆ getUnsafeGetCommands()

ilContactGUI::getUnsafeGetCommands ( )

This method must return a list of unsafe GET commands.

Unsafe get commands returned by this method will now be CSRF protected, which means an ilCtrlToken is appended each time a link-target is generated to the class implementing this interface with a command from that list.

Tokens will be validated in

See also
ilCtrlInterface::getCmd(), whereas the fallback command will be used if the CSRF validation fails.
Returns
string[]

Implements ilCtrlSecurityInterface.

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

95 : array
96 {
97 return [
98 'updateState'
99 ];
100 }

◆ inviteToChat()

ilContactGUI::inviteToChat ( array  $usr_ids)
protected
Parameters
non-empty-array<int>$usr_ids

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

554 : void
555 {
556 $this->tabs_gui->activateSubTab('buddy_view_table');
557 $this->activateTab('my_contacts');
558
559 $this->lng->loadLanguageModule('chatroom');
560
561 $chat_rooms = (new ilChatroom())->getAccessibleRoomIdByTitleMap($this->user->getId());
562
563 $options = array_filter(
564 $chat_rooms,
565 fn(int $room_id) => !(ilChatroom::byRoomId($room_id))->isUserBanned($this->user->getId()),
566 ARRAY_FILTER_USE_KEY
567 );
568
569 asort($options);
570
571 $this->tpl->setTitle($this->lng->txt('mail_invite_users_to_chat'));
572 $this->tpl->setContent($this->inviteToChatForm($options, $usr_ids)->getHTML());
573 $this->tpl->printToStdout();
574 }
Class ilChatroom.
static byRoomId(int $room_id, bool $initObject=false)
inviteToChatForm(array $options, array $usr_ids)

References ILIAS\UI\Implementation\Component\Input\Field\$options, activateTab(), ilChatroom\byRoomId(), inviteToChatForm(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by submitInvitation().

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

◆ inviteToChatForm()

ilContactGUI::inviteToChatForm ( array  $options,
array  $usr_ids 
)
private
Parameters
array<string,string>$options
list<int>$usr_ids

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

602 {
603 $form = new ilPropertyFormGUI();
604 $form->setTitle($this->lng->txt('mail_invite_users_to_chat'));
605 $form->addCommandButton('submitInvitation', $this->lng->txt('submit'));
606 $form->addCommandButton('showContacts', $this->lng->txt('cancel'));
607 $form->setFormAction($this->ctrl->getFormAction($this, 'showContacts'));
608
609 $sel = new ilSelectInputGUI($this->lng->txt('chat_select_room'), 'room_id');
610 $sel->setOptions($options);
611 $form->addItem($sel);
612
613 $hidden = new ilHiddenInputGUI('usr_ids');
614 $hidden->setValue(implode(',', $usr_ids));
615 $form->addItem($hidden);
616
617 return $form;
618 }
This class represents a hidden form property in a property form.
This class represents a property form user interface.
This class represents a selection list property in a property form.

References ILIAS\UI\Implementation\Component\Input\Field\$options, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by inviteToChat().

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

◆ linkToProfile()

ilContactGUI::linkToProfile ( int  $user,
string  $label 
)
private

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

674 : string
675 {
676 $public_profile = ilObjUser::_lookupPref($user, 'public_profile');
677 if (($this->user->isAnonymous() || $public_profile !== 'y') && $public_profile !== 'g') {
678 return $label;
679 }
680
681 $this->ctrl->setParameterByClass(PublicProfileGUI::class, 'user', (string) $user);
682 $profile_target = $this->ctrl->getLinkTargetByClass(
683 PublicProfileGUI::class,
684 'getHTML'
685 );
686
687 return $this->ui_renderer->render($this->ui_factory->link()->standard($label, $profile_target));
688 }
static _lookupPref(int $a_usr_id, string $a_keyword)

References $user, ilObjUser\_lookupPref(), ILIAS\Repository\ctrl(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ mailToUsers()

ilContactGUI::mailToUsers ( array  $usr_ids)
protected
Parameters
non-empty-array<int>$usr_ids

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

447 : void
448 {
449 if (!$this->rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
450 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
451 }
452
453 $logins = [];
454 $mail_data = $this->umail->retrieveFromStage();
455 foreach ($usr_ids as $usr_id) {
456 $login = ilObjUser::_lookupLogin($usr_id);
457 if (!$this->umail->existsRecipient($login, (string) $mail_data['rcp_to'])) {
458 $logins[] = $login;
459 }
460 }
461 $logins = array_filter($logins);
462
463 if ($logins !== []) {
464 $mail_data = $this->umail->appendSearchResult($logins, 'to');
465 $this->umail->persistToStage(
466 (int) $mail_data['user_id'],
467 $mail_data['rcp_to'],
468 $mail_data['rcp_cc'],
469 $mail_data['rcp_bcc'],
470 $mail_data['m_subject'],
471 $mail_data['m_message'],
472 $mail_data['attachments'],
473 $mail_data['use_placeholders'],
474 $mail_data['tpl_ctx_id'],
475 $mail_data['tpl_ctx_params']
476 );
477 }
478
479 $this->ctrl->redirectToURL('ilias.php?baseClass=ilMailGUI&type=search_res');
480 }

References ilObjUser\_lookupLogin(), ILIAS\Repository\ctrl(), error(), ilMailGlobalServices\getMailObjectRefId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ showContacts()

ilContactGUI::showContacts ( )
protected

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

325 : void
326 {
327 if (!ilBuddySystem::getInstance()->isEnabled()) {
328 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
329 }
330
331 $this->tabs_gui->activateSubTab('buddy_view_table');
332 $this->activateTab('my_contacts');
333
334 $content = $this->chatroomInvitationMessage();
335 $action = $this->contactAction();
336 $chat_allowed = (bool) (new ilSetting('chatroom'))->get('chat_enabled', '0');
337 $mail_allowed = $this->rbacsystem->checkAccess(
338 'internal_mail',
340 );
341
342 $content = array_merge($content, $this->relations_table->build(array_merge(
343 $chat_allowed ? ['chat' => $action('standard', 'invite_to_chat', 'inviteToChat')] : [],
344 $mail_allowed ? ['mail' => $action('standard', 'send_mail', 'mailToUsers')] : [],
345 ), $this->ctrl->getLinkTarget($this, 'showContacts'), $action));
346
347 $this->tpl->setContent($this->ui_renderer->render($content));
348 $this->tpl->printToStdout();
349 }
ILIAS Setting Class.

References activateTab(), chatroomInvitationMessage(), contactAction(), ILIAS\Repository\ctrl(), error(), ilBuddySystem\getInstance(), ilMailGlobalServices\getMailObjectRefId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ showSubTabs()

ilContactGUI::showSubTabs ( )
private

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

175 : void
176 {
177 $galleryCmdClasses = array_map('strtolower', [ilUsersGalleryGUI::class, self::class]);
178 if ($this->tabs_gui->hasTabs()) {
179 if (ilBuddySystem::getInstance()->isEnabled()) {
180 $this->tabs_gui->addSubTab(
181 'my_contacts',
182 $this->lng->txt('my_contacts'),
183 $this->ctrl->getLinkTarget($this)
184 );
185
186 if (in_array(strtolower($this->ctrl->getCmdClass() ?? ''), $galleryCmdClasses, true)) {
187 $mode_options = array_combine(
188 array_map(
189 fn(string $mode): string => $this->lng->txt($mode),
190 array_keys($this->view_mode_options)
191 ),
192 array_map(
193 function (string $mode): string {
194 $this->ctrl->setParameter($this, 'contacts_view', $mode);
195 $url = $this->ctrl->getFormAction($this, 'changeContactsView');
196 $this->ctrl->setParameter($this, 'contacts_view', null);
197
198 return $url;
199 },
200 array_keys($this->view_mode_options)
201 ),
202 );
203
204 $active_mode = strtolower($this->ctrl->getCmdClass() ?? '') === strtolower(ilUsersGalleryGUI::class)
207
208 $sortViewControl = $this->ui_factory
209 ->viewControl()
210 ->mode($mode_options, $this->lng->txt($active_mode))
211 ->withActive($this->lng->txt($active_mode));
212 $this->toolbar->addComponent($sortViewControl);
213 }
214
215 if (
216 count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0 ||
217 (new ilMailingLists($this->user))->hasAny()
218 ) {
219 $this->tabs_gui->addSubTab(
220 'mail_my_mailing_lists',
221 $this->lng->txt('mail_my_mailing_lists'),
222 $this->ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
223 );
224 }
225 }
226
227 $this->tabs_gui->addSubTab(
228 'mail_my_courses',
229 $this->lng->txt('mail_my_courses'),
230 $this->ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
231 );
232 $this->tabs_gui->addSubTab(
233 'mail_my_groups',
234 $this->lng->txt('mail_my_groups'),
235 $this->ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
236 );
237 $this->has_sub_tabs = true;
238 } else {
239 $this->tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_cadm.svg'));
240
241 $this->help->setScreenIdComponent('contacts');
242
243 if (ilBuddySystem::getInstance()->isEnabled()) {
244 $this->tabs_gui->addTab(
245 'my_contacts',
246 $this->lng->txt('my_contacts'),
247 $this->ctrl->getLinkTarget($this)
248 );
249
250 if (in_array(strtolower($this->ctrl->getCmdClass() ?? ''), $galleryCmdClasses, true)) {
251 $this->tabs_gui->addSubTab(
252 'buddy_view_table',
253 $this->lng->txt('buddy_view_table'),
254 $this->ctrl->getLinkTarget($this)
255 );
256 $this->tabs_gui->addSubTab(
257 'buddy_view_gallery',
258 $this->lng->txt('buddy_view_gallery'),
259 $this->ctrl->getLinkTargetByClass(ilUsersGalleryGUI::class)
260 );
261 }
262
263 if (
264 count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0 ||
265 (new ilMailingLists($this->user))->hasAny()
266 ) {
267 $this->tabs_gui->addTab(
268 'mail_my_mailing_lists',
269 $this->lng->txt('mail_my_mailing_lists'),
270 $this->ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
271 );
272 }
273 }
274
275 $this->tabs_gui->addTab(
276 'mail_my_courses',
277 $this->lng->txt('mail_my_courses'),
278 $this->ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
279 );
280 $this->tabs_gui->addTab(
281 'mail_my_groups',
282 $this->lng->txt('mail_my_groups'),
283 $this->ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
284 );
285 }
286 }
static getInstanceByGlobalUser(?ilObjUser $user=null)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

References $url, CONTACTS_VIEW_GALLERY, CONTACTS_VIEW_TABLE, ILIAS\Repository\ctrl(), ilUtil\getImagePath(), ilBuddySystem\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 ( )

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

482 : void
483 {
484 try {
485 $usr_ids = $this->http->wrapper()->post()->retrieve('usr_ids', $this->refinery->in()->series([
486 $this->refinery->kindlyTo()->string(),
487 $this->refinery->custom()->transformation(fn(string $s) => explode(',', $s)),
488 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
489 $this->refinery->custom()->constraint(fn(array $a) => $a !== [], fn() => 'Empty array.'),
490 ]));
491 } catch (Exception) {
492 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_one'), true);
493 $this->ctrl->redirect($this);
494 }
495
496 try {
497 $room_id = $this->http->wrapper()->post()->retrieve('room_id', $this->refinery->kindlyTo()->int());
498 } catch (Exception) {
499 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_one'));
500 $this->inviteToChat($usr_ids);
501 return;
502 }
503
504 $room = ilChatroom::byRoomId($room_id, true);
505
506 $no_access = [];
507 $no_login = [];
508 $valid_users = [];
509 $ref_id = $room->getRefIdByRoomId($room_id);
510
511 foreach ($usr_ids as $usr_id) {
512 $login = ilObjUser::_lookupLogin($usr_id);
513 if ($login === '') {
514 $no_login[] = $usr_id;
515 } elseif (
516 !ilChatroom::checkPermissionsOfUser($usr_id, 'read', $ref_id) ||
517 $room->isUserBanned($usr_id)
518 ) {
519 $no_access[] = $login;
520 } else {
521 $valid_users[] = $usr_id;
522 }
523 }
524
525 $message = join('', [
526 $this->asErrorMessage($no_access, $this->lng->txt('chat_users_without_permission')),
527 $this->asErrorMessage($no_login, $this->lng->txt('chat_users_without_login')),
528 ]);
529
530 if ($message !== '') {
531 $this->tpl->setOnScreenMessage('failure', $message);
532 $this->inviteToChat($usr_ids);
533 return;
534 }
535
536 foreach ($valid_users as $id) {
537 $room->sendInvitationNotification(
538 null,
539 $this->user->getId(),
540 $id,
542 );
543 }
544
545 $this->ctrl->setParameter($this, 'inv_room_ref_id', $ref_id);
546 $this->ctrl->setParameter($this, 'inv_usr_ids', implode(',', $valid_users));
547
548 $this->ctrl->redirect($this);
549 }
$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.
asErrorMessage(array $array, string $title)
inviteToChat(array $usr_ids)
$ref_id
Definition: ltiauth.php:66

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

+ Here is the call graph for this function:

◆ unlinkContact()

ilContactGUI::unlinkContact ( )
private

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

404 : void
405 {
406 $user_id = $this->http->wrapper()->post()->retrieve('user_id', $this->refinery->kindlyTo()->int());
407
408 $this->updateRelationState($user_id, 'unlink');
409 $this->ctrl->redirectByClass(self::class, 'showContacts');
410 }
updateRelationState(int $user, string $action)

References $user_id, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\refinery(), and updateRelationState().

+ Here is the call graph for this function:

◆ updateRelationState()

ilContactGUI::updateRelationState ( int  $user,
string  $action 
)
private

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

412 : void
413 {
416 throw new ilBuddySystemException('You cannot perform a state transition for the anonymous user');
417 }
418 if (!$login) {
419 throw new ilBuddySystemException(sprintf(
420 'You cannot perform a state transition for a non existing user (id: %s)',
421 $user
422 ));
423 }
425 $relation = $list->getRelationByUserId($user);
426 if (
427 $relation->isUnlinked() &&
428 !ilUtil::yn2tf((string) ilObjUser::_lookupPref($relation->getBuddyUsrId(), 'bs_allow_to_contact_me'))
429 ) {
430 throw new ilException('The requested user does not want to get contact requests');
431 }
432
433 try {
434 $list->$action($relation);
436 $this->tpl->setOnScreenMessage('failure', sprintf($this->lng->txt($e->getMessage()), $login), true);
437 } catch (Exception) {
438 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('buddy_bs_action_not_possible'), true);
439 }
440
441 $this->ctrl->redirect($this, 'showContacts');
442 }
$relation
Class ilBuddySystemException.
Base class for ILIAS Exception handling.
static _isAnonymous(int $usr_id)
static yn2tf(string $a_yn)

References Vendor\Package\$e, $relation, $user, ilObjUser\_isAnonymous(), ilObjUser\_lookupLogin(), ilObjUser\_lookupPref(), ILIAS\Repository\ctrl(), ilBuddyList\getInstanceByGlobalUser(), ILIAS\Repository\lng(), and ilUtil\yn2tf().

Referenced by unlinkContact(), and updateState().

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

◆ updateState()

ilContactGUI::updateState ( )
private

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

351 : void
352 {
353 $get = $this->http->wrapper()->query()->retrieve(...);
354
355 $user_ids = $get('contact_user_ids', $this->refinery->byTrying([
356 $this->refinery->null(),
357 $this->refinery->kindlyTo()->listOf($this->refinery->byTrying([
358 $this->refinery->kindlyTo()->int(),
359 ])),
360 $this->refinery->custom()->transformation(
361 fn($s): array => is_array($s) && join('', $s) === 'ALL_OBJECTS' ?
362 array_column(RelationsTable::data(), 'user_id') :
363 throw new Exception('Nope')
364 ),
365 ]));
366
367 $action = $get('contact_action', $this->refinery->kindlyTo()->string());
368 if (!$user_ids) {
369 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_one'), true);
370 $this->ctrl->redirect($this);
371 }
372
373 if (in_array($action, ['inviteToChat', 'mailToUsers'], true)) {
374 $this->$action($user_ids);
375 return;
376 }
377
378 if ($action === 'unlink') {
379 $this->ctrl->setParameterByClass(self::class, 'user_id', current($user_ids));
380 $this->ctrl->redirectByClass(self::class, 'confirmUnlinkContact');
381 }
382
383 $this->updateRelationState(current($user_ids), $action);
384 }

References ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and updateRelationState().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ilContactGUI::$ctrl
protected

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

◆ $error

ilErrorHandling ilContactGUI::$error
protected

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

◆ $has_sub_tabs

bool ilContactGUI::$has_sub_tabs = false
protected

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

◆ $help

ilHelpGUI ilContactGUI::$help
protected

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

◆ $http

readonly ILIAS HTTP GlobalHttpState ilContactGUI::$http
private

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

◆ $lng

ilLanguage ilContactGUI::$lng
protected

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

◆ $rbacsystem

ilRbacSystem ilContactGUI::$rbacsystem
protected

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

◆ $refinery

Refinery ilContactGUI::$refinery
protected

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

◆ $relations_table

readonly RelationsTable ilContactGUI::$relations_table
private

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

◆ $tabs_gui

ilTabsGUI ilContactGUI::$tabs_gui
protected

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

◆ $toolbar

ilToolbarGUI ilContactGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilContactGUI::$tpl
protected

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

◆ $ui_factory

ILIAS UI Factory ilContactGUI::$ui_factory
protected

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

◆ $ui_renderer

ILIAS UI Renderer ilContactGUI::$ui_renderer
protected

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

◆ $umail

ilFormatMail ilContactGUI::$umail
protected

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

◆ $user

ilObjUser ilContactGUI::$user
protected

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

Referenced by linkToProfile(), and updateRelationState().

◆ $view_mode_options

array ilContactGUI::$view_mode_options
private
Initial value:
= [
self::CONTACTS_VIEW_TABLE => self::CONTACTS_VIEW_TABLE,
self::CONTACTS_VIEW_GALLERY => self::CONTACTS_VIEW_GALLERY,
]

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

◆ CONTACTS_VIEW_GALLERY

final const string ilContactGUI::CONTACTS_VIEW_GALLERY = 'buddy_view_gallery'

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

Referenced by changeContactsView(), and showSubTabs().

◆ CONTACTS_VIEW_TABLE

final const string ilContactGUI::CONTACTS_VIEW_TABLE = 'buddy_view_table'

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

Referenced by changeContactsView(), and showSubTabs().


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