ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilContactGUI Class Reference
+ Collaboration diagram for ilContactGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 submitInvitation ()
 

Data Fields

final const CONTACTS_VIEW_GALLERY = 'buddy_view_gallery'
 
final const 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...
 
 applyContactsTableFilter ()
 
 resetContactsTableFilter ()
 
 showContacts ()
 
 mailToUsers ()
 
 inviteToChat (?array $usr_ids=null)
 

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 ()
 
 showContactRequests ()
 
 asErrorMessage (array $array, string $title)
 
 inviteToChatForm (array $options, array $usr_ids)
 

Private Attributes

readonly ILIAS HTTP GlobalHttpState $http
 
array $view_mode_options
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilContactGUI::__construct ( )

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

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

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

Member Function Documentation

◆ activateTab()

ilContactGUI::activateTab ( string  $a_id)
protected

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

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

260  : void
261  {
262  if ($this->has_sub_tabs) {
263  $this->tabs_gui->activateSubTab($a_id);
264  } else {
265  $this->tabs_gui->activateTab($a_id);
266  }
267  }
+ Here is the caller graph for this function:

◆ applyContactsTableFilter()

ilContactGUI::applyContactsTableFilter ( )
protected

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

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

298  : void
299  {
300  if (!ilBuddySystem::getInstance()->isEnabled()) {
301  $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
302  }
303 
304  $table = new ilBuddySystemRelationsTableGUI($this, 'showContacts');
305 
306  $table->resetOffset();
307  $table->writeFilterToSession();
308 
309  $this->showContacts();
310  }
+ Here is the call graph for this function:

◆ asErrorMessage()

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

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

Referenced by submitInvitation().

558  : string
559  {
560  if ($array === []) {
561  return '';
562  }
563 
564  $items = array_map(
565  fn($s) => '<li>' . htmlspecialchars((string) $s) . '</li>',
566  $array
567  );
568 
569  return sprintf(
570  '%s<br><ul>%s</ul>',
571  $title,
572  join('', $items)
573  );
574  }
+ 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 272 of file class.ilContactGUI.php.

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

272  : void
273  {
274  if (!ilBuddySystem::getInstance()->isEnabled()) {
275  $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
276  }
277 
278  $contacts_view = $this->http->wrapper()->query()->retrieve(
279  'contacts_view',
280  $this->refinery->byTrying([
281  $this->refinery->kindlyTo()->string(),
282  $this->refinery->always(self::CONTACTS_VIEW_TABLE)
283  ])
284  );
285 
286  switch ($contacts_view) {
287  case self::CONTACTS_VIEW_GALLERY:
288  $this->ctrl->redirectByClass(ilUsersGalleryGUI::class);
289 
290  // no break
291  case self::CONTACTS_VIEW_TABLE:
292  default:
293  $this->ctrl->redirect($this);
294  }
295  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ executeCommand()

ilContactGUI::executeCommand ( )

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

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

79  : bool
80  {
81  $this->showSubTabs();
82 
83  $forward_class = $this->ctrl->getNextClass($this) ?? '';
84 
85  $this->umail->persistToStage($this->user->getId(), [], '', '', '', '', '', false);
86 
87  switch (strtolower($forward_class)) {
88  case strtolower(ilMailSearchCoursesGUI::class):
89  $this->activateTab('mail_my_courses');
90 
91  $this->ctrl->setReturn($this, "showContacts");
92  $this->ctrl->forwardCommand(new ilMailSearchCoursesGUI());
93  break;
94 
95  case strtolower(ilMailSearchGroupsGUI::class):
96  $this->activateTab('mail_my_groups');
97 
98  $this->ctrl->setReturn($this, "showContacts");
99  $this->ctrl->forwardCommand(new ilMailSearchGroupsGUI());
100  break;
101 
102  case strtolower(ilMailingListsGUI::class):
103  $this->activateTab('mail_my_mailing_lists');
104 
105  $this->ctrl->setReturn($this, "showContacts");
106  $this->ctrl->forwardCommand(new ilMailingListsGUI());
107  break;
108 
109  case strtolower(ilUsersGalleryGUI::class):
110  if (!ilBuddySystem::getInstance()->isEnabled()) {
111  $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
112  }
113 
114  $this->tabs_gui->activateSubTab('buddy_view_gallery');
115  $this->activateTab('my_contacts');
116  $this->ctrl->forwardCommand(new ilUsersGalleryGUI(new ilUsersGalleryContacts()));
117  $this->tpl->printToStdout();
118  break;
119 
120  case strtolower(ilPublicUserProfileGUI::class):
121  $profile_gui = new ilPublicUserProfileGUI(
122  $this->http->wrapper()->query()->retrieve('user', $this->refinery->kindlyTo()->int())
123  );
124  $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, 'showContacts'));
125  $this->ctrl->forwardCommand($profile_gui);
126  $this->tpl->printToStdout();
127  break;
128 
129  default:
130  $this->activateTab('mail_my_entries');
131 
132  if (!($cmd = $this->ctrl->getCmd())) {
133  if (ilBuddySystem::getInstance()->isEnabled()) {
134  $cmd = 'showContacts';
135  } else {
136  $this->ctrl->redirectByClass(ilMailSearchCoursesGUI::class);
137  }
138  }
139 
140  $this->$cmd();
141  break;
142  }
143  return true;
144  }
if(!file_exists('../ilias.ini.php'))
ilUsersGalleryGUI: ilPublicUserProfileGUI ilUsersGalleryGUI: ilCourseMembershipGUI, ilGroupMembershipGUI
setBackUrl(string $backurl)
Set Back Link URL.
GUI class for public user profile presentation.
static http()
Fetches the global http state from ILIAS.
activateTab(string $a_id)
+ Here is the call graph for this function:

◆ inviteToChat()

ilContactGUI::inviteToChat ( ?array  $usr_ids = null)
protected
Parameters
null|list<int>$usr_ids

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

References activateTab(), ilChatroom\byRoomId(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), inviteToChatForm(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

Referenced by submitInvitation().

523  : void
524  {
525  $this->tabs_gui->activateSubTab('buddy_view_table');
526  $this->activateTab('my_contacts');
527 
528  $this->lng->loadLanguageModule('chatroom');
529 
530  $usr_ids ??= $this->http->wrapper()->post()->retrieve('usr_ids', $this->refinery->byTrying([
531  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
532  $this->refinery->always([])
533  ]));
534 
535  if ([] === $usr_ids) {
536  $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_one'), true);
537  $this->ctrl->redirect($this);
538  }
539 
540  $chat_rooms = (new ilChatroom())->getAccessibleRoomIdByTitleMap($this->user->getId());
541 
542  $options = array_filter(
543  $chat_rooms,
544  fn(int $room_id) => !(ilChatroom::byRoomId($room_id))->isUserBanned($this->user->getId()),
545  ARRAY_FILTER_USE_KEY
546  );
547 
548  asort($options);
549 
550  $this->tpl->setTitle($this->lng->txt('mail_invite_users_to_chat'));
551  $this->tpl->setContent($this->inviteToChatForm($options, $usr_ids)->getHTML());
552  $this->tpl->printToStdout();
553  }
inviteToChatForm(array $options, array $usr_ids)
static http()
Fetches the global http state from ILIAS.
activateTab(string $a_id)
static byRoomId(int $room_id, bool $initObject=false)
+ 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 580 of file class.ilContactGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilSelectInputGUI\setOptions().

Referenced by inviteToChat().

581  {
582  $form = new ilPropertyFormGUI();
583  $form->setTitle($this->lng->txt('mail_invite_users_to_chat'));
584  $form->addCommandButton('submitInvitation', $this->lng->txt('submit'));
585  $form->addCommandButton('showContacts', $this->lng->txt('cancel'));
586  $form->setFormAction($this->ctrl->getFormAction($this, 'showContacts'));
587 
588  $sel = new ilSelectInputGUI($this->lng->txt('chat_select_room'), 'room_id');
589  $sel->setOptions($options);
590  $form->addItem($sel);
591 
592  $hidden = new ilHiddenInputGUI('usr_ids');
593  $hidden->setValue(implode(',', $usr_ids));
594  $form->addItem($hidden);
595 
596  return $form;
597  }
This class represents a selection list property in a property form.
setOptions(array $a_options)
This class represents a hidden form property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mailToUsers()

ilContactGUI::mailToUsers ( )
protected

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

References ilObjUser\_lookupLogin(), ILIAS\Repository\ctrl(), ilMailGlobalServices\getMailObjectRefId(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and showContacts().

400  : void
401  {
402  if (!$this->rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
403  $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
404  }
405 
406  try {
407  $usr_ids = $this->http->wrapper()->post()->retrieve(
408  'usr_ids',
409  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
410  );
411 
412  // TODO: Replace this with some kind of 'ArrayLengthConstraint'
413  if ($usr_ids === []) {
414  throw new LengthException('mail_select_one_entry');
415  }
416  } catch (Exception) {
417  $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one_entry'));
418  $this->showContacts();
419  return;
420  }
421 
422  $logins = [];
423  $mail_data = $this->umail->retrieveFromStage();
424  foreach ($usr_ids as $usr_id) {
425  $login = ilObjUser::_lookupLogin($usr_id);
426  if (!$this->umail->existsRecipient($login, (string) $mail_data['rcp_to'])) {
427  $logins[] = $login;
428  }
429  }
430  $logins = array_filter($logins);
431 
432  if ($logins !== []) {
433  $mail_data = $this->umail->appendSearchResult($logins, 'to');
434  $this->umail->persistToStage(
435  (int) $mail_data['user_id'],
436  $mail_data['attachments'],
437  $mail_data['rcp_to'],
438  $mail_data['rcp_cc'],
439  $mail_data['rcp_bcc'],
440  $mail_data['m_subject'],
441  $mail_data['m_message'],
442  $mail_data['use_placeholders'],
443  $mail_data['tpl_ctx_id'],
444  $mail_data['tpl_ctx_params']
445  );
446  }
447 
448  $this->ctrl->redirectToURL('ilias.php?baseClass=ilMailGUI&type=search_res');
449  }
static http()
Fetches the global http state from ILIAS.
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:

◆ resetContactsTableFilter()

ilContactGUI::resetContactsTableFilter ( )
protected

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

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

313  : void
314  {
315  if (!ilBuddySystem::getInstance()->isEnabled()) {
316  $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
317  }
318 
319  $table = new ilBuddySystemRelationsTableGUI($this, 'showContacts');
320 
321  $table->resetOffset();
322  $table->resetFilter();
323 
324  $this->showContacts();
325  }
+ Here is the call graph for this function:

◆ showContactRequests()

ilContactGUI::showContactRequests ( )
private

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

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

381  : void
382  {
383  if (!ilBuddySystem::getInstance()->isEnabled()) {
384  $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
385  }
386 
387  $table = new ilBuddySystemRelationsTableGUI($this, 'showContacts');
388 
389  $table->resetOffset();
390  $table->resetFilter();
391 
392  $table->applyFilterValue(
394  ilBuddySystemRequestedRelationState::class . '_p'
395  );
396 
397  $this->showContacts();
398  }
+ Here is the call graph for this function:

◆ showContacts()

ilContactGUI::showContacts ( )
protected

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

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

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

328  : void
329  {
330  if (!ilBuddySystem::getInstance()->isEnabled()) {
331  $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
332  }
333 
334  $content = [];
335 
336  $this->tabs_gui->activateSubTab('buddy_view_table');
337  $this->activateTab('my_contacts');
338 
339  if ($this->http->wrapper()->query()->has('inv_room_ref_id') &&
340  $this->http->wrapper()->query()->has('inv_usr_ids')) {
341  $inv_room_ref_id = $this->http->wrapper()->query()->retrieve(
342  'inv_room_ref_id',
343  $this->refinery->kindlyTo()->int()
344  );
345  $inv_usr_ids = $this->http->wrapper()->query()->retrieve(
346  'inv_usr_ids',
347  $this->refinery->in()->series([
348  $this->refinery->kindlyTo()->string(),
349  $this->refinery->custom()->transformation(fn(string $s): array => explode(',', $s)),
350  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
351  $this->refinery->custom()->constraint(fn(array $a) => $a !== [], fn() => 'Empty array.'),
352  ])
353  );
354 
355  $userlist = [];
356  foreach ($inv_usr_ids as $inv_usr_id) {
357  $login = ilObjUser::_lookupLogin($inv_usr_id);
358  $userlist[] = $login;
359  }
360 
361  if ($userlist !== []) {
362  $url = ilLink::_getStaticLink($inv_room_ref_id, 'chtr');
363  $content[] = $this->ui_factory->messageBox()->success(
364  $this->lng->txt('chat_users_have_been_invited') . $this->ui_renderer->render(
365  $this->ui_factory->listing()->unordered($userlist)
366  )
367  )->withButtons([
368  $this->ui_factory->button()->standard($this->lng->txt('goto_invitation_chat'), $url)
369  ]);
370  }
371  }
372 
373  $table = new ilBuddySystemRelationsTableGUI($this, 'showContacts');
374  $table->populate();
375  $content[] = $this->ui_factory->legacy()->content($table->getHTML());
376 
377  $this->tpl->setContent($this->ui_renderer->render($content));
378  $this->tpl->printToStdout();
379  }
$url
Definition: shib_logout.php:66
static http()
Fetches the global http state from ILIAS.
activateTab(string $a_id)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSubTabs()

ilContactGUI::showSubTabs ( )
private

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

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

Referenced by executeCommand().

147  : void
148  {
149  $galleryCmdClasses = array_map('strtolower', [ilUsersGalleryGUI::class, self::class]);
150  if ($this->tabs_gui->hasTabs()) {
151  if (ilBuddySystem::getInstance()->isEnabled()) {
152  $this->tabs_gui->addSubTab(
153  'my_contacts',
154  $this->lng->txt('my_contacts'),
155  $this->ctrl->getLinkTarget($this)
156  );
157 
158  if (in_array(strtolower($this->ctrl->getCmdClass() ?? ''), $galleryCmdClasses, true)) {
159  $mode_options = array_combine(
160  array_map(
161  fn(string $mode): string => $this->lng->txt($mode),
162  array_keys($this->view_mode_options)
163  ),
164  array_map(
165  function (string $mode): string {
166  $this->ctrl->setParameter($this, 'contacts_view', $mode);
167  $url = $this->ctrl->getFormAction($this, 'changeContactsView');
168  $this->ctrl->setParameter($this, 'contacts_view', null);
169 
170  return $url;
171  },
172  array_keys($this->view_mode_options)
173  ),
174  );
175 
176  $active_mode = strtolower($this->ctrl->getCmdClass() ?? '') === strtolower(ilUsersGalleryGUI::class)
177  ? self::CONTACTS_VIEW_GALLERY
178  : self::CONTACTS_VIEW_TABLE;
179 
180  $sortViewControl = $this->ui_factory
181  ->viewControl()
182  ->mode($mode_options, $this->lng->txt($active_mode))
183  ->withActive($this->lng->txt($active_mode));
184  $this->toolbar->addComponent($sortViewControl);
185  }
186 
187  if (
188  count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0 ||
189  (new ilMailingLists($this->user))->hasAny()
190  ) {
191  $this->tabs_gui->addSubTab(
192  'mail_my_mailing_lists',
193  $this->lng->txt('mail_my_mailing_lists'),
194  $this->ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
195  );
196  }
197  }
198 
199  $this->tabs_gui->addSubTab(
200  'mail_my_courses',
201  $this->lng->txt('mail_my_courses'),
202  $this->ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
203  );
204  $this->tabs_gui->addSubTab(
205  'mail_my_groups',
206  $this->lng->txt('mail_my_groups'),
207  $this->ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
208  );
209  $this->has_sub_tabs = true;
210  } else {
211  $this->tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_cadm.svg'));
212 
213  $this->help->setScreenIdComponent('contacts');
214 
215  if (ilBuddySystem::getInstance()->isEnabled()) {
216  $this->tabs_gui->addTab(
217  'my_contacts',
218  $this->lng->txt('my_contacts'),
219  $this->ctrl->getLinkTarget($this)
220  );
221 
222  if (in_array(strtolower($this->ctrl->getCmdClass() ?? ''), $galleryCmdClasses, true)) {
223  $this->tabs_gui->addSubTab(
224  'buddy_view_table',
225  $this->lng->txt('buddy_view_table'),
226  $this->ctrl->getLinkTarget($this)
227  );
228  $this->tabs_gui->addSubTab(
229  'buddy_view_gallery',
230  $this->lng->txt('buddy_view_gallery'),
231  $this->ctrl->getLinkTargetByClass(ilUsersGalleryGUI::class)
232  );
233  }
234 
235  if (
236  count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0 ||
237  (new ilMailingLists($this->user))->hasAny()
238  ) {
239  $this->tabs_gui->addTab(
240  'mail_my_mailing_lists',
241  $this->lng->txt('mail_my_mailing_lists'),
242  $this->ctrl->getLinkTargetByClass(ilMailingListsGUI::class)
243  );
244  }
245  }
246 
247  $this->tabs_gui->addTab(
248  'mail_my_courses',
249  $this->lng->txt('mail_my_courses'),
250  $this->ctrl->getLinkTargetByClass(ilMailSearchCoursesGUI::class)
251  );
252  $this->tabs_gui->addTab(
253  'mail_my_groups',
254  $this->lng->txt('mail_my_groups'),
255  $this->ctrl->getLinkTargetByClass(ilMailSearchGroupsGUI::class)
256  );
257  }
258  }
$url
Definition: shib_logout.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return 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)
static getInstanceByGlobalUser(?ilObjUser $user=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ submitInvitation()

ilContactGUI::submitInvitation ( )

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

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

451  : void
452  {
453  try {
454  $usr_ids = $this->http->wrapper()->post()->retrieve('usr_ids', $this->refinery->in()->series([
455  $this->refinery->kindlyTo()->string(),
456  $this->refinery->custom()->transformation(fn(string $s) => explode(',', $s)),
457  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
458  $this->refinery->custom()->constraint(fn(array $a) => $a !== [], fn() => 'Empty array.'),
459  ]));
460  } catch (Exception) {
461  $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_one'), true);
462  $this->ctrl->redirect($this);
463  }
464 
465  try {
466  $room_id = $this->http->wrapper()->post()->retrieve('room_id', $this->refinery->kindlyTo()->int());
467  } catch (Exception) {
468  $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_one'));
469  $this->inviteToChat($usr_ids);
470  return;
471  }
472 
473  $room = ilChatroom::byRoomId($room_id, true);
474 
475  $no_access = [];
476  $no_login = [];
477  $valid_users = [];
478  $ref_id = $room->getRefIdByRoomId($room_id);
479 
480  foreach ($usr_ids as $usr_id) {
481  $login = ilObjUser::_lookupLogin($usr_id);
482  if ($login === '') {
483  $no_login[] = $usr_id;
484  } elseif (
485  !ilChatroom::checkPermissionsOfUser($usr_id, 'read', $ref_id) ||
486  $room->isUserBanned($usr_id)
487  ) {
488  $no_access[] = $login;
489  } else {
490  $valid_users[] = $usr_id;
491  }
492  }
493 
494  $message = join('', [
495  $this->asErrorMessage($no_access, $this->lng->txt('chat_users_without_permission')),
496  $this->asErrorMessage($no_login, $this->lng->txt('chat_users_without_login')),
497  ]);
498 
499  if ($message !== '') {
500  $this->tpl->setOnScreenMessage('failure', $message);
501  $this->inviteToChat($usr_ids);
502  return;
503  }
504 
505  foreach ($valid_users as $id) {
506  $room->sendInvitationNotification(
507  null,
508  $this->user->getId(),
509  $id,
511  );
512  }
513 
514  $this->ctrl->setParameter($this, 'inv_room_ref_id', $ref_id);
515  $this->ctrl->setParameter($this, 'inv_usr_ids', implode(',', $valid_users));
516 
517  $this->ctrl->redirect($this);
518  }
asErrorMessage(array $array, string $title)
inviteToChat(?array $usr_ids=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
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 byRoomId(int $room_id, bool $initObject=false)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$message
Definition: xapiexit.php:31
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ilContactGUI::$ctrl
protected

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

◆ $error

ilErrorHandling ilContactGUI::$error
protected

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

◆ $has_sub_tabs

bool ilContactGUI::$has_sub_tabs = false
protected

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

◆ $help

ilHelpGUI ilContactGUI::$help
protected

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

◆ $http

readonly ILIAS HTTP GlobalHttpState ilContactGUI::$http
private

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

◆ $lng

ilLanguage ilContactGUI::$lng
protected

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

◆ $rbacsystem

ilRbacSystem ilContactGUI::$rbacsystem
protected

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

◆ $refinery

Refinery ilContactGUI::$refinery
protected

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

◆ $tabs_gui

ilTabsGUI ilContactGUI::$tabs_gui
protected

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

◆ $toolbar

ilToolbarGUI ilContactGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilContactGUI::$tpl
protected

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

◆ $ui_factory

ILIAS UI Factory ilContactGUI::$ui_factory
protected

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

◆ $ui_renderer

ILIAS UI Renderer ilContactGUI::$ui_renderer
protected

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

◆ $umail

ilFormatMail ilContactGUI::$umail
protected

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

◆ $user

ilObjUser ilContactGUI::$user
protected

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

◆ $view_mode_options

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

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

◆ CONTACTS_VIEW_GALLERY

final const ilContactGUI::CONTACTS_VIEW_GALLERY = 'buddy_view_gallery'

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

◆ CONTACTS_VIEW_TABLE

final const ilContactGUI::CONTACTS_VIEW_TABLE = 'buddy_view_table'

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


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