ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilMailMemberSearchGUI Class Reference
+ Collaboration diagram for ilMailMemberSearchGUI:

Public Member Functions

 __construct (private readonly object $gui, public int $ref_id, private readonly ilAbstractMailMemberRoles $objMailMemberRoles)
 
 executeCommand ()
 
 storeReferer ()
 
 setObjParticipants (ilParticipants $objParticipants)
 

Protected Member Functions

 nextMailForm ()
 
 generateContextArray ()
 
 showSelectableUsers ()
 
 sendMailToSelectedUsers ()
 
 showSearchForm ()
 
 getObjParticipants ()
 
 initMailToMembersForm ()
 
 getMailRadioGroup ()
 

Private Member Functions

 handleSearchMembersActions ()
 
 redirectToParentReferer ()
 
 getStoredReferer ()
 
 unsetStoredReferer ()
 
 getMailRoles ()
 

Private Attributes

readonly ServerRequestInterface $httpRequest
 
readonly array $mail_roles
 
ilParticipants $objParticipants = null
 
readonly ilCtrlInterface $ctrl
 
readonly ilGlobalTemplateInterface $tpl
 
readonly ilLanguage $lng
 
readonly ilAccessHandler $access
 
readonly ILIAS UI Factory $ui_factory
 
readonly Services $http
 
readonly Renderer $ui_renderer
 
readonly Factory $refinery
 

Detailed Description

Definition at line 27 of file class.ilMailMemberSearchGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailMemberSearchGUI::__construct ( private readonly object  $gui,
public int  $ref_id,
private readonly ilAbstractMailMemberRoles  $objMailMemberRoles 
)
Parameters
ilObjGroupGUI | ilObjCourseGUI | ilMembershipGUI$gui
ilAbstractMailMemberRoles$objMailMemberRoles

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

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

50  {
51  global $DIC;
52 
53  $this->ctrl = $DIC['ilCtrl'];
54  $this->tpl = $DIC['tpl'];
55  $this->lng = $DIC['lng'];
56  $this->access = $DIC['ilAccess'];
57  $this->httpRequest = $DIC->http()->request();
58 
59  $this->ui_factory = $DIC->ui()->factory();
60  $this->ui_renderer = $DIC->ui()->renderer();
61  $this->refinery = $DIC->refinery();
62  $this->http = $DIC->http();
63 
64  $this->lng->loadLanguageModule('mail');
65  $this->lng->loadLanguageModule('search');
66  $this->mail_roles = $objMailMemberRoles->getMailRoles($ref_id);
67  }
$ref_id
Definition: ltiauth.php:66
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilMailMemberSearchGUI::executeCommand ( )

Definition at line 84 of file class.ilMailMemberSearchGUI.php.

References ILIAS\Repository\ctrl(), handleSearchMembersActions(), nextMailForm(), redirectToParentReferer(), showSearchForm(), and showSelectableUsers().

84  : bool
85  {
86  $cmd = $this->ctrl->getCmd();
87 
88  $this->ctrl->setReturn($this, '');
89 
90  switch ($cmd) {
91  case 'handleSearchMembersActions':
93  break;
94 
95  case 'showSelectableUsers':
96  $this->showSelectableUsers();
97  break;
98 
99  case 'nextMailForm':
100  $this->nextMailForm();
101  break;
102 
103  case 'cancel':
104  $this->redirectToParentReferer();
105  break;
106 
107  default:
108  if (isset($this->httpRequest->getQueryParams()['returned_from_mail']) &&
109  $this->httpRequest->getQueryParams()['returned_from_mail'] === '1') {
110  $this->redirectToParentReferer();
111  }
112  $this->showSearchForm();
113  break;
114  }
115 
116  return true;
117  }
+ Here is the call graph for this function:

◆ generateContextArray()

ilMailMemberSearchGUI::generateContextArray ( )
protected

Definition at line 201 of file class.ilMailMemberSearchGUI.php.

References $ref_id, ilContainer\_lookupContainerSetting(), ilObject\_lookupObjId(), ilObject\_lookupType(), ILIAS\Repository\access(), ilMailFormCall\CONTEXT_KEY, ilObjectServiceSettingsGUI\EXTERNAL_MAIL_PREFIX, ilCourseMailTemplateTutorContext\ID, ilSessionMailTemplateParticipantContext\ID, and ilMail\PROP_CONTEXT_SUBJECT_PREFIX.

Referenced by nextMailForm(), and sendMailToSelectedUsers().

201  : array
202  {
203  $contextParameters = [];
204 
205  $type = ilObject::_lookupType($this->ref_id, true);
206  switch ($type) {
207  case 'grp':
208  case 'crs':
209  if ($this->access->checkAccess('write', '', $this->ref_id)) {
210  $contextParameters = [
211  'ref_id' => $this->ref_id,
212  'ts' => time(),
214  ilObject::_lookupObjId($this->ref_id),
216  ''
217  )
218  ];
219 
220  if ('crs' === $type) {
222  }
223  }
224  break;
225 
226  case 'sess':
227  if ($this->access->checkAccess('write', '', $this->ref_id)) {
228  $contextParameters = [
230  'ref_id' => $this->ref_id,
231  'ts' => time()
232  ];
233  }
234  break;
235  }
236 
237  return $contextParameters;
238  }
const PROP_CONTEXT_SUBJECT_PREFIX
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:66
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMailRadioGroup()

ilMailMemberSearchGUI::getMailRadioGroup ( )
protected

Definition at line 342 of file class.ilMailMemberSearchGUI.php.

References ilRadioOption\addSubItem(), getMailRoles(), and ILIAS\Repository\lng().

Referenced by initMailToMembersForm().

343  {
344  $mail_roles = $this->getMailRoles();
345 
346  $radio_grp = new ilRadioGroupInputGUI($this->lng->txt('mail_sel_label'), 'mail_member_type');
347 
348  $radio_sel_users = new ilRadioOption($this->lng->txt('mail_sel_users'), 'mail_sel_users');
349 
350  $radio_roles = new ilRadioOption($this->objMailMemberRoles->getRadioOptionTitle(), 'mail_member_roles');
351  foreach ($mail_roles as $role) {
352  $chk_role = new ilCheckboxInputGUI($role['form_option_title'], 'roles[' . $role['role_id'] . ']');
353 
354  if (isset($role['default_checked']) && $role['default_checked']) {
355  $chk_role->setChecked(true);
356  }
357  $chk_role->setValue((string) $role['role_id']);
358  $chk_role->setInfo($role['mailbox']);
359  $radio_roles->addSubItem($chk_role);
360  }
361 
362  $radio_grp->setValue('mail_member_roles');
363 
364  $radio_grp->addOption($radio_sel_users);
365  $radio_grp->addOption($radio_roles);
366 
367  return $radio_grp;
368  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMailRoles()

ilMailMemberSearchGUI::getMailRoles ( )
private
Returns
array{role_id: int, mailbox: string, form_option_title: string, default_checked?: bool}[]

Definition at line 337 of file class.ilMailMemberSearchGUI.php.

References $mail_roles.

Referenced by getMailRadioGroup().

337  : array
338  {
339  return $this->mail_roles;
340  }
+ Here is the caller graph for this function:

◆ getObjParticipants()

ilMailMemberSearchGUI::getObjParticipants ( )
protected

Definition at line 306 of file class.ilMailMemberSearchGUI.php.

References $objParticipants.

Referenced by sendMailToSelectedUsers(), and showSelectableUsers().

306  : ?ilParticipants
307  {
308  return $this->objParticipants;
309  }
Base class for course and group participants.
+ Here is the caller graph for this function:

◆ getStoredReferer()

ilMailMemberSearchGUI::getStoredReferer ( )
private

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

References ilSession\get().

Referenced by redirectToParentReferer().

147  : string
148  {
149  return (string) ilSession::get('ilMailMemberSearchGUIReferer');
150  }
static get(string $a_var)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleSearchMembersActions()

ilMailMemberSearchGUI::handleSearchMembersActions ( )
private

Definition at line 69 of file class.ilMailMemberSearchGUI.php.

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

Referenced by executeCommand().

69  : void
70  {
71  $action = $this->http->wrapper()->query()->retrieve(
72  'contact_search_members_action',
73  $this->refinery->byTrying([
74  $this->refinery->kindlyTo()->string(),
75  $this->refinery->always('')
76  ])
77  );
78  match ($action) {
79  'sendMailToSelectedUsers' => $this->sendMailToSelectedUsers(),
80  default => $this->ctrl->redirect($this, 'showSelectableUsers'),
81  };
82  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initMailToMembersForm()

ilMailMemberSearchGUI::initMailToMembersForm ( )
protected

Definition at line 316 of file class.ilMailMemberSearchGUI.php.

References ILIAS\Repository\ctrl(), getMailRadioGroup(), and ILIAS\Repository\lng().

Referenced by nextMailForm(), and showSearchForm().

317  {
318  $this->lng->loadLanguageModule('mail');
319 
320  $form = new ilPropertyFormGUI();
321  $form->setTitle($this->lng->txt('mail_members'));
322 
323  $form->setFormAction($this->ctrl->getFormAction($this, 'nextMailForm'));
324 
325  $radio_grp = $this->getMailRadioGroup();
326 
327  $form->addItem($radio_grp);
328  $form->addCommandButton('nextMailForm', $this->lng->txt('mail_members_search_continue'));
329  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
330 
331  return $form;
332  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nextMailForm()

ilMailMemberSearchGUI::nextMailForm ( )
protected

Definition at line 157 of file class.ilMailMemberSearchGUI.php.

References ILIAS\Repository\ctrl(), generateContextArray(), ilMailFormCall\getRedirectTarget(), initMailToMembersForm(), ILIAS\Repository\lng(), ilMailFormGUI\MAIL_FORM_TYPE_ROLE, ilSession\set(), showSearchForm(), and showSelectableUsers().

Referenced by executeCommand().

157  : void
158  {
159  $form = $this->initMailToMembersForm();
160  if ($form->checkInput()) {
161  if ($form->getInput('mail_member_type') === 'mail_member_roles') {
162  if (is_array($form->getInput('roles')) && $form->getInput('roles') !== []) {
163  $role_mail_boxes = [];
164  $roles = $form->getInput('roles');
165  foreach ($roles as $role_id) {
166  $mailbox = $this->objMailMemberRoles->getMailboxRoleAddress((int) $role_id);
167  $role_mail_boxes[] = $mailbox;
168  }
169 
170  ilSession::set('mail_roles', $role_mail_boxes);
171 
172  $this->ctrl->redirectToURL(
174  $this,
175  'showSearchForm',
177  [
179  'rcp_to' => implode(',', $role_mail_boxes),
180  'sig' => $this->gui->createMailSignature()
181  ],
182  $this->generateContextArray()
183  )
184  );
185  } else {
186  $form->setValuesByPost();
187  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'));
188  $this->showSearchForm();
189  return;
190  }
191  } else {
192  $this->showSelectableUsers();
193  return;
194  }
195  }
196 
197  $form->setValuesByPost();
198  $this->showSearchForm();
199  }
static getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
final const MAIL_FORM_TYPE_ROLE
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redirectToParentReferer()

ilMailMemberSearchGUI::redirectToParentReferer ( )
private

Definition at line 119 of file class.ilMailMemberSearchGUI.php.

References $url, ILIAS\Repository\ctrl(), getStoredReferer(), and unsetStoredReferer().

Referenced by executeCommand().

119  : void
120  {
121  $url = $this->getStoredReferer();
122  $this->unsetStoredReferer();
123  $this->ctrl->redirectToURL($url);
124  }
$url
Definition: shib_logout.php:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMailToSelectedUsers()

ilMailMemberSearchGUI::sendMailToSelectedUsers ( )
protected

Definition at line 249 of file class.ilMailMemberSearchGUI.php.

References $provider, ilObjUser\_lookupLogin(), ILIAS\Repository\ctrl(), generateContextArray(), getObjParticipants(), ilMailFormCall\getRedirectTarget(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilMailFormGUI\MAIL_FORM_TYPE_NEW, ILIAS\Repository\refinery(), ilMailFormCall\setRecipients(), and showSelectableUsers().

Referenced by handleSearchMembersActions().

249  : void
250  {
251  $selected_user_ids = $this->http->wrapper()->query()->retrieve(
252  'contact_search_members_user_ids',
253  $this->refinery->byTrying([
254  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
255  $this->refinery->always([])
256  ])
257  );
258 
259  if ((string) current($selected_user_ids) === 'ALL_OBJECTS') {
260  $selected_user_ids = [];
261  $provider = new ilMailMemberSearchDataProvider($this->getObjParticipants(), $this->ref_id);
262  $entries = $provider->getData();
263 
264  foreach ($entries as $entry) {
265  $selected_user_ids[] = (int) $entry['user_id'];
266  }
267  } else {
268  $selected_user_ids = array_map(intval(...), $selected_user_ids);
269  }
270 
271  $rcps = [];
272  foreach ($selected_user_ids as $usr_id) {
273  $rcps[] = ilObjUser::_lookupLogin($usr_id);
274  }
275 
276  if (array_filter($rcps) === []) {
277  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'));
278  $this->showSelectableUsers();
279  return;
280  }
281 
283 
284  $this->ctrl->redirectToURL(
286  $this,
287  'members',
288  [],
289  [
291  'sig' => $this->gui->createMailSignature(),
292  ],
293  $this->generateContextArray()
294  )
295  );
296  }
$provider
Definition: ltitoken.php:80
static http()
Fetches the global http state from ILIAS.
static setRecipients(array $recipients, string $type='to')
final const MAIL_FORM_TYPE_NEW
static getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setObjParticipants()

ilMailMemberSearchGUI::setObjParticipants ( ilParticipants  $objParticipants)

Definition at line 311 of file class.ilMailMemberSearchGUI.php.

References $objParticipants.

Referenced by ilObjGroupGUI\executeCommand(), and ilObjCourseGUI\executeCommand().

311  : void
312  {
313  $this->objParticipants = $objParticipants;
314  }
+ Here is the caller graph for this function:

◆ showSearchForm()

ilMailMemberSearchGUI::showSearchForm ( )
protected

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

References initMailToMembersForm(), and storeReferer().

Referenced by executeCommand(), and nextMailForm().

298  : void
299  {
300  $this->storeReferer();
301 
302  $form = $this->initMailToMembersForm();
303  $this->tpl->setContent($form->getHTML());
304  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSelectableUsers()

ilMailMemberSearchGUI::showSelectableUsers ( )
protected

Definition at line 240 of file class.ilMailMemberSearchGUI.php.

References $provider, ILIAS\Repository\ctrl(), getObjParticipants(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

Referenced by executeCommand(), nextMailForm(), and sendMailToSelectedUsers().

240  : void
241  {
242  $this->tpl->loadStandardTemplate();
243  $provider = new ilMailMemberSearchDataProvider($this->getObjParticipants(), $this->ref_id);
244  $tbl = new MailMemberSearchTable($this->ref_id, $provider, $this->ctrl, $this->lng, $this->ui_factory, $this->http);
245 
246  $this->tpl->setContent($this->ui_renderer->render($tbl->getComponent()));
247  }
$provider
Definition: ltitoken.php:80
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeReferer()

ilMailMemberSearchGUI::storeReferer ( )

Definition at line 126 of file class.ilMailMemberSearchGUI.php.

References $url, ILIAS\Repository\ctrl(), and ilSession\set().

Referenced by showSearchForm().

126  : void
127  {
128  $back_link = $this->ctrl->getParentReturn($this);
129 
130  if (isset($this->httpRequest->getServerParams()['HTTP_REFERER'])) {
131  $referer = $this->httpRequest->getServerParams()['HTTP_REFERER'];
132  $urlParts = parse_url($referer);
133  if (is_array($urlParts) && isset($urlParts['path'])) {
134  $url = ltrim(basename($urlParts['path']), '/');
135  if (isset($urlParts['query'])) {
136  $url .= '?' . $urlParts['query'];
137  }
138  if ($url !== '') {
139  $back_link = $url;
140  }
141  }
142  }
143 
144  ilSession::set('ilMailMemberSearchGUIReferer', $back_link);
145  }
$url
Definition: shib_logout.php:63
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unsetStoredReferer()

ilMailMemberSearchGUI::unsetStoredReferer ( )
private

Definition at line 152 of file class.ilMailMemberSearchGUI.php.

References ilSession\set().

Referenced by redirectToParentReferer().

152  : void
153  {
154  ilSession::set('ilMailMemberSearchGUIReferer', '');
155  }
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

readonly ilAccessHandler ilMailMemberSearchGUI::$access
private

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

◆ $ctrl

readonly ilCtrlInterface ilMailMemberSearchGUI::$ctrl
private

Definition at line 33 of file class.ilMailMemberSearchGUI.php.

◆ $http

readonly Services ilMailMemberSearchGUI::$http
private

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

◆ $httpRequest

readonly ServerRequestInterface ilMailMemberSearchGUI::$httpRequest
private

Definition at line 29 of file class.ilMailMemberSearchGUI.php.

◆ $lng

readonly ilLanguage ilMailMemberSearchGUI::$lng
private

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

◆ $mail_roles

readonly array ilMailMemberSearchGUI::$mail_roles
private

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

Referenced by getMailRoles().

◆ $objParticipants

ilParticipants ilMailMemberSearchGUI::$objParticipants = null
private

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

Referenced by getObjParticipants(), and setObjParticipants().

◆ $refinery

readonly Factory ilMailMemberSearchGUI::$refinery
private

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

◆ $tpl

readonly ilGlobalTemplateInterface ilMailMemberSearchGUI::$tpl
private

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

◆ $ui_factory

readonly ILIAS UI Factory ilMailMemberSearchGUI::$ui_factory
private

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

◆ $ui_renderer

readonly Renderer ilMailMemberSearchGUI::$ui_renderer
private

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


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