19 declare(strict_types=1);
39 private readonly \ILIAS\HTTP\GlobalHttpState
$http;
57 self::CONTACTS_VIEW_TABLE => self::CONTACTS_VIEW_TABLE,
58 self::CONTACTS_VIEW_GALLERY => self::CONTACTS_VIEW_GALLERY,
62 string $format_mail_class = ilFormatMail::class,
63 string $relations_table_class = RelationsTable::class
67 $this->tpl = $DIC[
'tpl'];
68 $this->
ctrl = $DIC[
'ilCtrl'];
69 $this->
lng = $DIC[
'lng'];
70 $this->tabs_gui = $DIC[
'ilTabs'];
71 $this->
help = $DIC[
'ilHelp'];
72 $this->
toolbar = $DIC[
'ilToolbar'];
73 $this->
user = $DIC[
'ilUser'];
74 $this->error = $DIC[
'ilErr'];
75 $this->rbacsystem = $DIC[
'rbacsystem'];
76 $this->
http = $DIC->http();
78 $this->ui_factory = $DIC->ui()->factory();
79 $this->ui_renderer = $DIC->ui()->renderer();
81 $this->
ctrl->saveParameter($this,
"mobj_id");
83 $this->umail =
new $format_mail_class($this->
user->getId());
84 $this->relations_table =
new $relations_table_class(
90 $this->
lng->loadLanguageModule(
'buddysystem');
97 $forward_class = $this->
ctrl->getNextClass($this) ??
'';
99 $this->umail->persistToStage($this->
user->getId(), [],
'',
'',
'',
'',
'',
false);
101 switch (strtolower($forward_class)) {
102 case strtolower(ilMailSearchCoursesGUI::class):
105 $this->
ctrl->setReturn($this,
"showContacts");
109 case strtolower(ilMailSearchGroupsGUI::class):
112 $this->
ctrl->setReturn($this,
"showContacts");
116 case strtolower(ilMailingListsGUI::class):
119 $this->
ctrl->setReturn($this,
"showContacts");
123 case strtolower(ilUsersGalleryGUI::class):
125 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
128 $this->tabs_gui->activateSubTab(
'buddy_view_gallery');
131 $this->tpl->printToStdout();
134 case strtolower(ilPublicUserProfileGUI::class):
136 $this->
http->wrapper()->query()->retrieve(
'user', $this->
refinery->kindlyTo()->int())
138 $profile_gui->setBackUrl($this->
ctrl->getLinkTarget($this,
'showContacts'));
139 $this->
ctrl->forwardCommand($profile_gui);
140 $this->tpl->printToStdout();
146 if (!($cmd = $this->
ctrl->getCmd())) {
148 $cmd =
'showContacts';
150 $this->
ctrl->redirectByClass(ilMailSearchCoursesGUI::class);
163 $galleryCmdClasses =
array_map(
'strtolower', [ilUsersGalleryGUI::class, self::class]);
164 if ($this->tabs_gui->hasTabs()) {
166 $this->tabs_gui->addSubTab(
168 $this->
lng->txt(
'my_contacts'),
169 $this->
ctrl->getLinkTarget($this)
172 if (in_array(strtolower($this->
ctrl->getCmdClass() ??
''), $galleryCmdClasses,
true)) {
173 $mode_options = array_combine(
175 fn(
string $mode):
string => $this->
lng->txt($mode),
176 array_keys($this->view_mode_options)
179 function (
string $mode):
string {
180 $this->
ctrl->setParameter($this,
'contacts_view', $mode);
181 $url = $this->
ctrl->getFormAction($this,
'changeContactsView');
182 $this->
ctrl->setParameter($this,
'contacts_view',
null);
186 array_keys($this->view_mode_options)
190 $active_mode = strtolower($this->
ctrl->getCmdClass() ??
'') === strtolower(ilUsersGalleryGUI::class)
191 ? self::CONTACTS_VIEW_GALLERY
192 : self::CONTACTS_VIEW_TABLE;
194 $sortViewControl = $this->ui_factory
196 ->mode($mode_options, $this->
lng->txt($active_mode))
197 ->withActive($this->
lng->txt($active_mode));
198 $this->
toolbar->addComponent($sortViewControl);
205 $this->tabs_gui->addSubTab(
206 'mail_my_mailing_lists',
207 $this->
lng->txt(
'mail_my_mailing_lists'),
208 $this->
ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
213 $this->tabs_gui->addSubTab(
215 $this->
lng->txt(
'mail_my_courses'),
216 $this->
ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
218 $this->tabs_gui->addSubTab(
220 $this->
lng->txt(
'mail_my_groups'),
221 $this->
ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
223 $this->has_sub_tabs =
true;
227 $this->
help->setScreenIdComponent(
'contacts');
230 $this->tabs_gui->addTab(
232 $this->
lng->txt(
'my_contacts'),
233 $this->
ctrl->getLinkTarget($this)
236 if (in_array(strtolower($this->
ctrl->getCmdClass() ??
''), $galleryCmdClasses,
true)) {
237 $this->tabs_gui->addSubTab(
239 $this->
lng->txt(
'buddy_view_table'),
240 $this->
ctrl->getLinkTarget($this)
242 $this->tabs_gui->addSubTab(
243 'buddy_view_gallery',
244 $this->
lng->txt(
'buddy_view_gallery'),
245 $this->
ctrl->getLinkTargetByClass(ilUsersGalleryGUI::class)
253 $this->tabs_gui->addTab(
254 'mail_my_mailing_lists',
255 $this->
lng->txt(
'mail_my_mailing_lists'),
256 $this->
ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
261 $this->tabs_gui->addTab(
263 $this->
lng->txt(
'mail_my_courses'),
264 $this->
ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
266 $this->tabs_gui->addTab(
268 $this->
lng->txt(
'mail_my_groups'),
269 $this->
ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
276 if ($this->has_sub_tabs) {
277 $this->tabs_gui->activateSubTab($a_id);
279 $this->tabs_gui->activateTab($a_id);
289 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
292 $contacts_view = $this->
http->wrapper()->query()->retrieve(
295 $this->refinery->kindlyTo()->string(),
296 $this->
refinery->always(self::CONTACTS_VIEW_TABLE)
300 switch ($contacts_view) {
301 case self::CONTACTS_VIEW_GALLERY:
302 $this->
ctrl->redirectByClass(ilUsersGalleryGUI::class);
305 case self::CONTACTS_VIEW_TABLE:
307 $this->
ctrl->redirect($this);
314 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
317 $this->tabs_gui->activateSubTab(
'buddy_view_table');
322 $chat_allowed = (bool) (
new ilSetting(
'chatroom'))->
get(
'chat_enabled',
'0');
323 $mail_allowed = $this->rbacsystem->checkAccess(
328 $content = array_merge($content, $this->relations_table->build(array_merge(
329 $chat_allowed ? [
'chat' => $action(
'standard',
'invite_to_chat',
'inviteToChat')] : [],
330 $mail_allowed ? [
'mail' => $action(
'standard',
'send_mail',
'mailToUsers')] : [],
331 ), $this->
ctrl->getLinkTarget($this,
'showContacts'), $action));
333 $this->tpl->setContent($this->ui_renderer->render($content));
334 $this->tpl->printToStdout();
339 $get = $this->
http->wrapper()->query()->retrieve(...);
341 $user_ids = $get(
'contact_user_ids', $this->
refinery->byTrying([
342 $this->refinery->null(),
344 $this->refinery->kindlyTo()->int(),
346 $this->
refinery->custom()->transformation(
347 fn($s): array => is_array($s) && join(
'', $s) ===
'ALL_OBJECTS' ?
348 array_column(RelationsTable::data(),
'user_id') :
353 $action = $get(
'contact_action', $this->
refinery->kindlyTo()->string());
355 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'),
true);
356 $this->
ctrl->redirect($this);
359 if (in_array($action, [
'inviteToChat',
'mailToUsers'],
true)) {
360 $this->$action($user_ids);
375 'You cannot perform a state transition for a non existing user (id: %s)',
380 $relation = $list->getRelationByUserId($user);
385 throw new ilException(
'The requested user does not want to get contact requests');
391 $this->tpl->setOnScreenMessage(
'failure', sprintf($this->
lng->txt($e->getMessage()), $login),
true);
393 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'buddy_bs_action_not_possible'),
true);
396 $this->
ctrl->redirect($this,
'showContacts');
405 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
409 $mail_data = $this->umail->retrieveFromStage();
410 foreach ($usr_ids as $usr_id) {
412 if (!$this->umail->existsRecipient($login, (
string) $mail_data[
'rcp_to'])) {
416 $logins = array_filter($logins);
418 if ($logins !== []) {
419 $mail_data = $this->umail->appendSearchResult($logins,
'to');
420 $this->umail->persistToStage(
421 (
int) $mail_data[
'user_id'],
422 $mail_data[
'attachments'],
423 $mail_data[
'rcp_to'],
424 $mail_data[
'rcp_cc'],
425 $mail_data[
'rcp_bcc'],
426 $mail_data[
'm_subject'],
427 $mail_data[
'm_message'],
428 $mail_data[
'use_placeholders'],
429 $mail_data[
'tpl_ctx_id'],
430 $mail_data[
'tpl_ctx_params']
434 $this->
ctrl->redirectToURL(
'ilias.php?baseClass=ilMailGUI&type=search_res');
440 $usr_ids = $this->
http->wrapper()->post()->retrieve(
'usr_ids', $this->
refinery->in()->series([
441 $this->
refinery->kindlyTo()->string(),
442 $this->
refinery->custom()->transformation(fn(
string $s) => explode(
',', $s)),
444 $this->
refinery->custom()->constraint(fn(array
$a) => $a !== [], fn() =>
'Empty array.'),
447 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'),
true);
448 $this->
ctrl->redirect($this);
452 $room_id = $this->
http->wrapper()->post()->retrieve(
'room_id', $this->
refinery->kindlyTo()->int());
454 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
464 $ref_id = $room->getRefIdByRoomId($room_id);
466 foreach ($usr_ids as $usr_id) {
469 $no_login[] = $usr_id;
472 $room->isUserBanned($usr_id)
474 $no_access[] = $login;
476 $valid_users[] = $usr_id;
481 $this->
asErrorMessage($no_access, $this->
lng->txt(
'chat_users_without_permission')),
486 $this->tpl->setOnScreenMessage(
'failure',
$message);
491 foreach ($valid_users as
$id) {
492 $room->sendInvitationNotification(
494 $this->
user->getId(),
500 $this->
ctrl->setParameter($this,
'inv_room_ref_id',
$ref_id);
501 $this->
ctrl->setParameter($this,
'inv_usr_ids', implode(
',', $valid_users));
503 $this->
ctrl->redirect($this);
511 $this->tabs_gui->activateSubTab(
'buddy_view_table');
514 $this->
lng->loadLanguageModule(
'chatroom');
516 $chat_rooms = (
new ilChatroom())->getAccessibleRoomIdByTitleMap($this->
user->getId());
518 $options = array_filter(
526 $this->tpl->setTitle($this->
lng->txt(
'mail_invite_users_to_chat'));
527 $this->tpl->setContent($this->
inviteToChatForm($options, $usr_ids)->getHTML());
528 $this->tpl->printToStdout();
541 fn($s) =>
'<li>' . htmlspecialchars((
string) $s) .
'</li>',
559 $form->setTitle($this->
lng->txt(
'mail_invite_users_to_chat'));
560 $form->addCommandButton(
'submitInvitation', $this->
lng->txt(
'submit'));
561 $form->addCommandButton(
'showContacts', $this->
lng->txt(
'cancel'));
562 $form->setFormAction($this->
ctrl->getFormAction($this,
'showContacts'));
566 $form->addItem($sel);
569 $hidden->setValue(implode(
',', $usr_ids));
570 $form->addItem($hidden);
580 $has = $this->
http->wrapper()->query()->has(...);
581 if (!$has(
'inv_room_ref_id') || !$has(
'inv_usr_ids')) {
585 $inv_room_ref_id = $this->
http->wrapper()->query()->retrieve(
589 $inv_usr_ids = $this->
http->wrapper()->query()->retrieve(
592 $this->
refinery->kindlyTo()->string(),
593 $this->
refinery->custom()->transformation(fn(
string $s): array => explode(
',', $s)),
595 $this->
refinery->custom()->constraint(fn(array
$a):
bool => $a !== [], fn():
string =>
'Empty array.'),
604 $this->ui_factory->messageBox()->success(
605 $this->
lng->txt(
'chat_users_have_been_invited') . $this->ui_renderer->render(
606 $this->ui_factory->listing()->unordered($userlist)
609 $this->ui_factory->button()->standard($this->
lng->txt(
'goto_invitation_chat'),
$url)
619 $url =
new URLBuilder(
new URI(rtrim(ILIAS_HTTP_PATH,
'/') .
'/' . $this->
ctrl->getLinkTarget($this,
'updateState')));
620 [
$url, $p,
$token] =
$url->acquireParameters([
'contact'],
'action',
'user_ids');
622 return fn(
string $type,
string $lang_var,
string $param):
Action => $this->ui_factory->table()->action()->$type(
623 $this->
lng->txt($lang_var),
624 $url->withParameter($p, $param),
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilUsersGalleryGUI: ilPublicUserProfileGUI ilUsersGalleryGUI: ilCourseMembershipGUI, ilGroupMembershipGUI
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupPref(int $a_usr_id, string $a_keyword)
Class ilBuddySystemException.
Class ilBuddySystemRelationStateTransitionException.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
GUI class for public user profile presentation.
static http()
Fetches the global http state from ILIAS.
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 _getStaticLink(?int $a_ref_id, string $a_type='', bool $a_fallback_goto=true, string $append="")
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static byRoomId(int $room_id, bool $initObject=false)
Class ilBuddySystemRelationStateAlreadyGivenException.
static _isAnonymous(int $usr_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static getMailObjectRefId()
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
static yn2tf(string $a_yn)
static getInstanceByGlobalUser(?ilObjUser $user=null)
static _lookupLogin(int $a_user_id)