19 declare(strict_types=1);
31 private \ILIAS\HTTP\GlobalHttpState
$http;
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();
67 $this->ui_factory = $DIC->ui()->factory();
68 $this->ui_renderer = $DIC->ui()->renderer();
70 $this->
ctrl->saveParameter($this,
"mobj_id");
73 $this->
lng->loadLanguageModule(
'buddysystem');
80 $forward_class = $this->
ctrl->getNextClass($this);
82 $this->umail->persistToStage($this->
user->getId(), [],
'',
'',
'',
'',
'',
false);
84 switch (strtolower($forward_class)) {
85 case strtolower(ilMailSearchCoursesGUI::class):
88 $this->
ctrl->setReturn($this,
"showContacts");
92 case strtolower(ilMailSearchGroupsGUI::class):
95 $this->
ctrl->setReturn($this,
"showContacts");
99 case strtolower(ilMailingListsGUI::class):
102 $this->
ctrl->setReturn($this,
"showContacts");
106 case strtolower(ilUsersGalleryGUI::class):
108 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
111 $this->tabs_gui->activateSubTab(
'buddy_view_gallery');
114 $this->tpl->printToStdout();
117 case strtolower(ilPublicUserProfileGUI::class):
119 $this->
http->wrapper()->query()->retrieve(
'user', $this->
refinery->kindlyTo()->int())
121 $profile_gui->setBackUrl($this->
ctrl->getLinkTarget($this,
'showContacts'));
122 $this->
ctrl->forwardCommand($profile_gui);
123 $this->tpl->printToStdout();
129 if (!($cmd = $this->
ctrl->getCmd())) {
131 $cmd =
'showContacts';
133 $this->
ctrl->redirectByClass(ilMailSearchCoursesGUI::class);
146 $galleryCmdClasses = array_map(
'strtolower', [ilUsersGalleryGUI::class, self::class]);
147 if ($this->tabs_gui->hasTabs()) {
149 $this->tabs_gui->addSubTab(
151 $this->
lng->txt(
'my_contacts'),
152 $this->
ctrl->getLinkTarget($this)
155 if (in_array(strtolower($this->
ctrl->getCmdClass()), $galleryCmdClasses,
true)) {
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')
161 $view_selection->setValue(
162 strtolower($this->
ctrl->getCmdClass()) === strtolower(ilUsersGalleryGUI::class)
163 ? (string) self::CONTACTS_VIEW_GALLERY
164 : (
string) self::CONTACTS_VIEW_TABLE
166 $this->
toolbar->addInputItem($view_selection);
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'));
179 $this->tabs_gui->addSubTab(
180 'mail_my_mailing_lists',
181 $this->
lng->txt(
'mail_my_mailing_lists'),
182 $this->
ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
187 $this->tabs_gui->addSubTab(
189 $this->
lng->txt(
'mail_my_courses'),
190 $this->
ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
192 $this->tabs_gui->addSubTab(
194 $this->
lng->txt(
'mail_my_groups'),
195 $this->
ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
197 $this->has_sub_tabs =
true;
201 $this->
help->setScreenIdComponent(
'contacts');
204 $this->tabs_gui->addTab(
206 $this->
lng->txt(
'my_contacts'),
207 $this->
ctrl->getLinkTarget($this)
210 if (in_array(strtolower($this->
ctrl->getCmdClass()), $galleryCmdClasses,
true)) {
211 $this->tabs_gui->addSubTab(
213 $this->
lng->txt(
'buddy_view_table'),
214 $this->
ctrl->getLinkTarget($this)
216 $this->tabs_gui->addSubTab(
217 'buddy_view_gallery',
218 $this->
lng->txt(
'buddy_view_gallery'),
219 $this->
ctrl->getLinkTargetByClass(ilUsersGalleryGUI::class)
227 $this->tabs_gui->addTab(
228 'mail_my_mailing_lists',
229 $this->
lng->txt(
'mail_my_mailing_lists'),
230 $this->
ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
235 $this->tabs_gui->addTab(
237 $this->
lng->txt(
'mail_my_courses'),
238 $this->
ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
240 $this->tabs_gui->addTab(
242 $this->
lng->txt(
'mail_my_groups'),
243 $this->
ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
250 if ($this->has_sub_tabs) {
251 $this->tabs_gui->activateSubTab($a_id);
253 $this->tabs_gui->activateTab($a_id);
263 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
266 if ($this->
http->wrapper()->post()->has(
'contacts_view')) {
267 switch ($this->
http->wrapper()->post()->retrieve(
'contacts_view', $this->
refinery->kindlyTo()->int())) {
268 case self::CONTACTS_VIEW_GALLERY:
269 $this->
ctrl->redirectByClass(ilUsersGalleryGUI::class);
272 case self::CONTACTS_VIEW_TABLE:
273 $this->
ctrl->redirect($this);
277 $this->
ctrl->redirect($this);
284 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
289 $table->resetOffset();
290 $table->writeFilterToSession();
299 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
304 $table->resetOffset();
305 $table->resetFilter();
314 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
319 $this->tabs_gui->activateSubTab(
'buddy_view_table');
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(
329 $inv_room_scope = $this->
http->wrapper()->query()->retrieve(
333 $inv_usr_ids = $this->
http->wrapper()->query()->retrieve(
336 $this->
refinery->kindlyTo()->string(),
337 $this->
refinery->custom()->transformation(fn (
string $value): array => explode(
',', $value)),
343 foreach ($inv_usr_ids as $inv_usr_id) {
345 $userlist[] = $login;
348 if ($userlist !== []) {
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)
356 $this->ui_factory->button()->standard($this->
lng->txt(
'goto_invitation_chat'),
$url)
363 $content[] = $this->ui_factory->legacy($table->getHTML());
365 $this->tpl->setContent($this->ui_renderer->render($content));
366 $this->tpl->printToStdout();
372 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
377 $table->resetOffset();
378 $table->resetFilter();
380 $table->applyFilterValue(
382 ilBuddySystemRequestedRelationState::class .
'_p' 391 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
395 $usr_ids = $this->
http->wrapper()->post()->retrieve(
401 if ($usr_ids === []) {
402 throw new LengthException(
'mail_select_one_entry');
405 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one_entry'));
411 $mail_data = $this->umail->retrieveFromStage();
412 foreach ($usr_ids as $usr_id) {
414 if (!$this->umail->existsRecipient($login, (
string) $mail_data[
'rcp_to'])) {
418 $logins = array_filter($logins);
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']
436 $this->
ctrl->redirectToURL(
'ilias.php?baseClass=ilMailGUI&type=search_res');
447 $usr_ids = $this->
refinery->kindlyTo()->listOf(
449 )->transform(explode(
',', $this->
http->wrapper()->post()->retrieve(
451 $this->
refinery->kindlyTo()->string()
455 if ($usr_ids === []) {
456 throw new LengthException(
'select_one');
459 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'),
true);
460 $this->
ctrl->redirect($this);
463 if (!$this->
http->wrapper()->post()->has(
'room_id')) {
464 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
465 $this->postUsrId = $usr_ids;
471 $room_ids = $this->
refinery->kindlyTo()->listOf(
473 )->transform(explode(
',', $this->
http->wrapper()->post()->retrieve(
475 $this->
refinery->kindlyTo()->string()
478 $room_id = (
int) $room_ids[0];
481 if (count($room_ids) > 1) {
489 $valid_user_to_login_map = [];
491 foreach ($usr_ids as $usr_id) {
494 $no_login[$usr_id] = $usr_id;
498 $ref_id = $room->getRefIdByRoomId($room_id);
502 $room->isUserBanned((
int) $usr_id)
504 $no_access[$usr_id] = $login;
506 $valid_users[$usr_id] = $usr_id;
507 $valid_user_to_login_map[$usr_id] = $login;
511 if (count($no_access) || count($no_login)) {
514 if (count($no_access) > 0) {
515 $message .= $this->
lng->txt(
'chat_users_without_permission') .
':<br>';
518 foreach ($no_access as $usr_id => $login) {
519 $list .=
'<li>' . $login .
'</li>';
527 if (count($no_login) > 0) {
528 $message .= $this->
lng->txt(
'chat_users_without_login') .
':<br>';
531 foreach ($no_login as $usr_id) {
532 $list .=
'<li>' . $usr_id .
'</li>';
540 $this->tpl->setOnScreenMessage(
'failure',
$message);
541 $this->postUsrId = $usr_ids;
546 $ref_id = $room->getRefIdByRoomId($room_id);
550 foreach ($valid_users as
$id) {
551 $room->inviteUserToPrivateRoom((
int) $id,
$scope);
552 $room->sendInvitationNotification(
554 $this->
user->getId(),
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));
565 $this->
ctrl->redirect($this);
573 $this->tabs_gui->activateSubTab(
'buddy_view_table');
576 $this->
lng->loadLanguageModule(
'chatroom');
579 if (!is_array($usr_ids)) {
581 $usr_ids = $this->
http->wrapper()->post()->retrieve(
590 if (!is_array($usr_ids) || [] === $usr_ids) {
591 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'),
true);
592 $this->
ctrl->redirect($this);
595 $usr_ids = $this->
refinery->kindlyTo()->listOf(
597 )->transform($usr_ids);
600 $chat_rooms = $ilChatroom->getAccessibleRoomIdByTitleMap($this->
user->getId());
603 foreach ($chat_rooms as $room_id => $title) {
604 $subrooms[] = $ilChatroom->getPrivateSubRooms($room_id, $this->
user->getId());
608 $form->setTitle($this->
lng->txt(
'mail_invite_users_to_chat'));
614 foreach ($chat_rooms as $room_id => $room) {
617 if ($ilChatroom->isUserBanned($this->user->getId())) {
623 foreach ($subrooms as $subroom) {
624 foreach ($subroom as $sub_id => $parent_id) {
627 $options[
$ref_id .
',' . $sub_id] =
'+ ' . $title;
634 $form->addItem($psel);
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'));
642 $this->tpl->setTitle($this->
lng->txt(
'mail_invite_users_to_chat'));
643 $this->tpl->setContent($form->getHTML());
644 $this->tpl->printToStdout();
static getInstanceByGlobalUser()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static lookupPrivateRoomTitle(int $proom_id)
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...
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="")
Get static link.
static byRoomId(int $room_id, bool $initObject=false)
Error Handling & global info handling uses PEAR error class.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static getMailObjectRefId()
const STATE_FILTER_ELM_ID
static _lookupLogin(int $a_user_id)