19declare(strict_types=1);
40 private readonly \ILIAS\HTTP\GlobalHttpState
$http;
63 string $format_mail_class = ilFormatMail::class,
64 string $relations_table_class = RelationsTable::class
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();
79 $this->ui_factory =
$DIC->ui()->factory();
80 $this->ui_renderer =
$DIC->ui()->renderer();
82 $this->
ctrl->saveParameter($this,
"mobj_id");
84 $this->umail =
new $format_mail_class($this->
user->getId());
85 $this->relations_table =
new $relations_table_class(
90 $this->linkToProfile(...)
92 $this->
lng->loadLanguageModule(
'buddysystem');
111 $forward_class = $this->
ctrl->getNextClass($this) ??
'';
113 $this->umail->persistToStage($this->
user->getId(),
'',
'',
'',
'',
'',
null,
false);
115 switch (strtolower($forward_class)) {
116 case strtolower(ilMailSearchCoursesGUI::class):
119 $this->
ctrl->setReturn($this,
"showContacts");
123 case strtolower(ilMailSearchGroupsGUI::class):
126 $this->
ctrl->setReturn($this,
"showContacts");
130 case strtolower(ilMailingListsGUI::class):
133 $this->
ctrl->setReturn($this,
"showContacts");
137 case strtolower(ilUsersGalleryGUI::class):
139 $this->
error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
142 $this->tabs_gui->activateSubTab(
'buddy_view_gallery');
145 $this->tpl->printToStdout();
148 case strtolower(PublicProfileGUI::class):
150 $this->
http->wrapper()->query()->retrieve(
'user', $this->refinery->kindlyTo()->int())
152 $profile_gui->setBackUrl($this->
ctrl->getLinkTarget($this,
'showContacts'));
153 $this->
ctrl->forwardCommand($profile_gui);
154 $this->tpl->printToStdout();
160 if (!($cmd = $this->
ctrl->getCmd())) {
162 $cmd =
'showContacts';
164 $this->
ctrl->redirectByClass(ilMailSearchCoursesGUI::class);
177 $galleryCmdClasses = array_map(
'strtolower', [ilUsersGalleryGUI::class, self::class]);
178 if ($this->tabs_gui->hasTabs()) {
180 $this->tabs_gui->addSubTab(
182 $this->
lng->txt(
'my_contacts'),
183 $this->ctrl->getLinkTarget($this)
186 if (in_array(strtolower($this->
ctrl->getCmdClass() ??
''), $galleryCmdClasses,
true)) {
187 $mode_options = array_combine(
189 fn(
string $mode):
string => $this->
lng->txt($mode),
190 array_keys($this->view_mode_options)
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);
200 array_keys($this->view_mode_options)
204 $active_mode = strtolower($this->
ctrl->getCmdClass() ??
'') === strtolower(ilUsersGalleryGUI::class)
208 $sortViewControl = $this->ui_factory
210 ->mode($mode_options, $this->
lng->txt($active_mode))
211 ->withActive($this->
lng->txt($active_mode));
212 $this->
toolbar->addComponent($sortViewControl);
219 $this->tabs_gui->addSubTab(
220 'mail_my_mailing_lists',
221 $this->
lng->txt(
'mail_my_mailing_lists'),
222 $this->ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
227 $this->tabs_gui->addSubTab(
229 $this->
lng->txt(
'mail_my_courses'),
230 $this->ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
232 $this->tabs_gui->addSubTab(
234 $this->
lng->txt(
'mail_my_groups'),
235 $this->ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
237 $this->has_sub_tabs =
true;
241 $this->
help->setScreenIdComponent(
'contacts');
244 $this->tabs_gui->addTab(
246 $this->
lng->txt(
'my_contacts'),
247 $this->ctrl->getLinkTarget($this)
250 if (in_array(strtolower($this->
ctrl->getCmdClass() ??
''), $galleryCmdClasses,
true)) {
251 $this->tabs_gui->addSubTab(
253 $this->
lng->txt(
'buddy_view_table'),
254 $this->ctrl->getLinkTarget($this)
256 $this->tabs_gui->addSubTab(
257 'buddy_view_gallery',
258 $this->
lng->txt(
'buddy_view_gallery'),
259 $this->ctrl->getLinkTargetByClass(ilUsersGalleryGUI::class)
267 $this->tabs_gui->addTab(
268 'mail_my_mailing_lists',
269 $this->
lng->txt(
'mail_my_mailing_lists'),
270 $this->ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
275 $this->tabs_gui->addTab(
277 $this->
lng->txt(
'mail_my_courses'),
278 $this->ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
280 $this->tabs_gui->addTab(
282 $this->
lng->txt(
'mail_my_groups'),
283 $this->ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
290 if ($this->has_sub_tabs) {
291 $this->tabs_gui->activateSubTab($a_id);
293 $this->tabs_gui->activateTab($a_id);
303 $this->
error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
306 $contacts_view = $this->
http->wrapper()->query()->retrieve(
309 $this->refinery->kindlyTo()->string(),
310 $this->refinery->always(self::CONTACTS_VIEW_TABLE)
314 switch ($contacts_view) {
316 $this->
ctrl->redirectByClass(ilUsersGalleryGUI::class);
321 $this->
ctrl->redirect($this);
328 $this->
error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
331 $this->tabs_gui->activateSubTab(
'buddy_view_table');
336 $chat_allowed = (bool) (
new ilSetting(
'chatroom'))->
get(
'chat_enabled',
'0');
337 $mail_allowed = $this->rbacsystem->checkAccess(
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));
347 $this->tpl->setContent($this->ui_renderer->render($content));
348 $this->tpl->printToStdout();
353 $get = $this->
http->wrapper()->query()->retrieve(...);
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(),
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')
367 $action = $get(
'contact_action', $this->
refinery->kindlyTo()->string());
369 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'),
true);
370 $this->
ctrl->redirect($this);
373 if (in_array($action, [
'inviteToChat',
'mailToUsers'],
true)) {
374 $this->$action($user_ids);
378 if ($action ===
'unlink') {
379 $this->
ctrl->setParameterByClass(self::class,
'user_id', current($user_ids));
380 $this->
ctrl->redirectByClass(self::class,
'confirmUnlinkContact');
389 $this->tabs_gui->activateSubTab(
'buddy_view_table');
391 $user_id = $this->
http->wrapper()->query()->retrieve(
'user_id', $this->
refinery->kindlyTo()->int());
394 $confirmation_gui->setHeaderText($this->
lng->txt(
'buddy_confirm_unlink'));
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'));
400 $this->tpl->setContent($confirmation_gui->getHTML());
401 $this->tpl->printToStdout();
406 $user_id = $this->
http->wrapper()->post()->retrieve(
'user_id', $this->
refinery->kindlyTo()->int());
409 $this->
ctrl->redirectByClass(self::class,
'showContacts');
420 'You cannot perform a state transition for a non existing user (id: %s)',
430 throw new ilException(
'The requested user does not want to get contact requests');
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);
441 $this->
ctrl->redirect($this,
'showContacts');
450 $this->
error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
454 $mail_data = $this->umail->retrieveFromStage();
455 foreach ($usr_ids as $usr_id) {
457 if (!$this->umail->existsRecipient($login, (
string) $mail_data[
'rcp_to'])) {
461 $logins = array_filter($logins);
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']
479 $this->
ctrl->redirectToURL(
'ilias.php?baseClass=ilMailGUI&type=search_res');
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.'),
491 }
catch (Exception) {
492 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'),
true);
493 $this->
ctrl->redirect($this);
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'));
509 $ref_id = $room->getRefIdByRoomId($room_id);
511 foreach ($usr_ids as $usr_id) {
514 $no_login[] = $usr_id;
517 $room->isUserBanned($usr_id)
519 $no_access[] = $login;
521 $valid_users[] = $usr_id;
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')),
530 if ($message !==
'') {
531 $this->tpl->setOnScreenMessage(
'failure', $message);
536 foreach ($valid_users as
$id) {
537 $room->sendInvitationNotification(
539 $this->
user->getId(),
545 $this->
ctrl->setParameter($this,
'inv_room_ref_id',
$ref_id);
546 $this->
ctrl->setParameter($this,
'inv_usr_ids', implode(
',', $valid_users));
548 $this->
ctrl->redirect($this);
556 $this->tabs_gui->activateSubTab(
'buddy_view_table');
559 $this->
lng->loadLanguageModule(
'chatroom');
561 $chat_rooms = (
new ilChatroom())->getAccessibleRoomIdByTitleMap($this->
user->getId());
571 $this->tpl->setTitle($this->
lng->txt(
'mail_invite_users_to_chat'));
573 $this->tpl->printToStdout();
586 fn($s) =>
'<li>' . htmlspecialchars((
string) $s) .
'</li>',
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'));
611 $form->addItem($sel);
614 $hidden->setValue(implode(
',', $usr_ids));
615 $form->addItem($hidden);
625 $has = $this->
http->wrapper()->query()->has(...);
626 if (!$has(
'inv_room_ref_id') || !$has(
'inv_usr_ids')) {
630 $inv_room_ref_id = $this->
http->wrapper()->query()->retrieve(
634 $inv_usr_ids = $this->
http->wrapper()->query()->retrieve(
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.'),
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)
654 $this->ui_factory->button()->standard($this->lng->txt(
'goto_invitation_chat'),
$url)
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');
667 return fn(
string $type,
string $lang_var,
string $param):
Action => $this->ui_factory->table()->action()->$type(
668 $this->
lng->txt($lang_var),
677 if (($this->
user->isAnonymous() || $public_profile !==
'y') && $public_profile !==
'g') {
681 $this->
ctrl->setParameterByClass(PublicProfileGUI::class,
'user', (
string)
$user);
682 $profile_target = $this->
ctrl->getLinkTargetByClass(
683 PublicProfileGUI::class,
687 return $this->ui_renderer->render($this->ui_factory->link()->standard($label, $profile_target));
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
The scope of this class is split ilias-conform URI's into components.
GUI class for public user profile presentation.
static getInstanceByGlobalUser(?ilObjUser $user=null)
Class ilBuddySystemException.
Class ilBuddySystemRelationStateAlreadyGivenException.
Class ilBuddySystemRelationStateTransitionException.
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Error Handling & global info handling.
Base class for ILIAS Exception handling.
static _getStaticLink(?int $a_ref_id, string $a_type='', bool $a_fallback_goto=true, string $append="")
static getMailObjectRefId()
static _isAnonymous(int $usr_id)
static _lookupPref(int $a_usr_id, string $a_keyword)
static _lookupLogin(int $a_user_id)
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@ilCtrl_Calls ilUsersGalleryGUI: ILIAS\User\Profile\PublicProfileGUI @ilCtrl_isCalledBy ilUsersGaller...
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 yn2tf(string $a_yn)
A component is the most general form of an entity in the UI.
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.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples