ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMailMemberSearchGUI Class Reference

Class ilMailMemberSearchGUI. More...

+ Collaboration diagram for ilMailMemberSearchGUI:

Public Member Functions

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

Protected Member Functions

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

Private Member Functions

 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
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailMemberSearchGUI::__construct ( private readonly object  $gui,
public int  $ref_id,
private readonly ilAbstractMailMemberRoles  $objMailMemberRoles 
)

ilMailMemberSearchGUI constructor.

Parameters
ilObjGroupGUI | ilObjCourseGUI | ilMembershipGUI$gui
ilAbstractMailMemberRoles$objMailMemberRoles

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

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

45  {
46  global $DIC;
47 
48  $this->ctrl = $DIC['ilCtrl'];
49  $this->tpl = $DIC['tpl'];
50  $this->lng = $DIC['lng'];
51  $this->access = $DIC['ilAccess'];
52  $this->httpRequest = $DIC->http()->request();
53 
54  $this->lng->loadLanguageModule('mail');
55  $this->lng->loadLanguageModule('search');
56  $this->mail_roles = $objMailMemberRoles->getMailRoles($ref_id);
57  }
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilMailMemberSearchGUI::executeCommand ( )

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

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

60  : bool
61  {
62  $cmd = $this->ctrl->getCmd();
63 
64  $this->ctrl->setReturn($this, '');
65 
66  switch ($cmd) {
67  case 'sendMailToSelectedUsers':
68  $this->sendMailToSelectedUsers();
69  break;
70 
71  case 'showSelectableUsers':
72  $this->showSelectableUsers();
73  break;
74 
75  case 'nextMailForm':
76  $this->nextMailForm();
77  break;
78 
79  case 'cancel':
80  $this->redirectToParentReferer();
81  break;
82 
83  default:
84  if (isset($this->httpRequest->getQueryParams()['returned_from_mail']) && $this->httpRequest->getQueryParams()['returned_from_mail'] === '1') {
85  $this->redirectToParentReferer();
86  }
87  $this->showSearchForm();
88  break;
89  }
90 
91  return true;
92  }
+ Here is the call graph for this function:

◆ generateContextArray()

ilMailMemberSearchGUI::generateContextArray ( )
protected

Definition at line 175 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().

175  : array
176  {
177  $contextParameters = [];
178 
179  $type = ilObject::_lookupType($this->ref_id, true);
180  switch ($type) {
181  case 'grp':
182  case 'crs':
183  if ($this->access->checkAccess('write', '', $this->ref_id)) {
184  $contextParameters = [
185  'ref_id' => $this->ref_id,
186  'ts' => time(),
188  ilObject::_lookupObjId($this->ref_id),
190  ''
191  )
192  ];
193 
194  if ('crs' === $type) {
196  }
197  }
198  break;
199 
200  case 'sess':
201  if ($this->access->checkAccess('write', '', $this->ref_id)) {
202  $contextParameters = [
204  'ref_id' => $this->ref_id,
205  'ts' => time()
206  ];
207  }
208  break;
209  }
210 
211  return $contextParameters;
212  }
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:67
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 305 of file class.ilMailMemberSearchGUI.php.

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

Referenced by initMailToMembersForm().

306  {
307  $mail_roles = $this->getMailRoles();
308 
309  $radio_grp = new ilRadioGroupInputGUI($this->lng->txt('mail_sel_label'), 'mail_member_type');
310 
311  $radio_sel_users = new ilRadioOption($this->lng->txt('mail_sel_users'), 'mail_sel_users');
312 
313  $radio_roles = new ilRadioOption($this->objMailMemberRoles->getRadioOptionTitle(), 'mail_member_roles');
314  foreach ($mail_roles as $role) {
315  $chk_role = new ilCheckboxInputGUI($role['form_option_title'], 'roles[' . $role['role_id'] . ']');
316 
317  if (isset($role['default_checked']) && $role['default_checked']) {
318  $chk_role->setChecked(true);
319  }
320  $chk_role->setValue((string) $role['role_id']);
321  $chk_role->setInfo($role['mailbox']);
322  $radio_roles->addSubItem($chk_role);
323  }
324 
325  $radio_grp->setValue('mail_member_roles');
326 
327  $radio_grp->addOption($radio_sel_users);
328  $radio_grp->addOption($radio_roles);
329 
330  return $radio_grp;
331  }
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 299 of file class.ilMailMemberSearchGUI.php.

References $mail_roles.

Referenced by getMailRadioGroup().

299  : array
300  {
301  return $this->mail_roles;
302  }
+ Here is the caller graph for this function:

◆ getObjParticipants()

ilMailMemberSearchGUI::getObjParticipants ( )
protected

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

References $objParticipants.

Referenced by showSelectableUsers().

267  : ?ilParticipants
268  {
269  return $this->objParticipants;
270  }
Base class for course and group participants.
+ Here is the caller graph for this function:

◆ getStoredReferer()

ilMailMemberSearchGUI::getStoredReferer ( )
private

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

References ilSession\get().

Referenced by redirectToParentReferer().

123  : string
124  {
125  return (string) ilSession::get('ilMailMemberSearchGUIReferer');
126  }
static get(string $a_var)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initMailToMembersForm()

ilMailMemberSearchGUI::initMailToMembersForm ( )
protected

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

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

Referenced by nextMailForm(), and showSearchForm().

279  {
280  $this->lng->loadLanguageModule('mail');
281 
282  $form = new ilPropertyFormGUI();
283  $form->setTitle($this->lng->txt('mail_members'));
284 
285  $form->setFormAction($this->ctrl->getFormAction($this, 'nextMailForm'));
286 
287  $radio_grp = $this->getMailRadioGroup();
288 
289  $form->addItem($radio_grp);
290  $form->addCommandButton('nextMailForm', $this->lng->txt('mail_members_search_continue'));
291  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
292 
293  return $form;
294  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nextMailForm()

ilMailMemberSearchGUI::nextMailForm ( )
protected

Definition at line 133 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().

133  : void
134  {
135  $form = $this->initMailToMembersForm();
136  if ($form->checkInput()) {
137  if ($form->getInput('mail_member_type') === 'mail_member_roles') {
138  if (is_array($form->getInput('roles')) && $form->getInput('roles') !== []) {
139  $role_mail_boxes = [];
140  $roles = $form->getInput('roles');
141  foreach ($roles as $role_id) {
142  $mailbox = $this->objMailMemberRoles->getMailboxRoleAddress((int) $role_id);
143  $role_mail_boxes[] = $mailbox;
144  }
145 
146  ilSession::set('mail_roles', $role_mail_boxes);
147 
148  $this->ctrl->redirectToURL(ilMailFormCall::getRedirectTarget(
149  $this,
150  'showSearchForm',
152  [
154  'rcp_to' => implode(',', $role_mail_boxes),
155  'sig' => $this->gui->createMailSignature()
156  ],
157  $this->generateContextArray()
158  ));
159  } else {
160  $form->setValuesByPost();
161  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'));
162  $this->showSearchForm();
163  return;
164  }
165  } else {
166  $this->showSelectableUsers();
167  return;
168  }
169  }
170 
171  $form->setValuesByPost();
172  $this->showSearchForm();
173  }
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 94 of file class.ilMailMemberSearchGUI.php.

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

Referenced by executeCommand().

94  : void
95  {
96  $url = $this->getStoredReferer();
97  $this->unsetStoredReferer();
98  $this->ctrl->redirectToURL($url);
99  }
$url
Definition: ltiregstart.php:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMailToSelectedUsers()

ilMailMemberSearchGUI::sendMailToSelectedUsers ( )
protected

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

References ilObjUser\_lookupLogin(), ILIAS\Repository\ctrl(), generateContextArray(), ilMailFormCall\getRedirectTarget(), ILIAS\Repository\lng(), ilMailFormGUI\MAIL_FORM_TYPE_NEW, ilMailFormCall\setRecipients(), and showSelectableUsers().

Referenced by executeCommand().

225  : void
226  {
227  if (!isset($this->httpRequest->getParsedBody()['user_ids']) || !is_array($this->httpRequest->getParsedBody()['user_ids']) || [] === $this->httpRequest->getParsedBody()['user_ids']) {
228  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"));
229  $this->showSelectableUsers();
230  return;
231  }
232 
233  $rcps = [];
234  foreach ($this->httpRequest->getParsedBody()['user_ids'] as $usr_id) {
235  $rcps[] = ilObjUser::_lookupLogin((int) $usr_id);
236  }
237 
238  if (array_filter($rcps) === []) {
239  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"));
240  $this->showSelectableUsers();
241  return;
242  }
243 
245 
246  $this->ctrl->redirectToURL(ilMailFormCall::getRedirectTarget(
247  $this,
248  'members',
249  [],
250  [
252  'sig' => $this->gui->createMailSignature(),
253  ],
254  $this->generateContextArray()
255  ));
256  }
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 272 of file class.ilMailMemberSearchGUI.php.

References $objParticipants.

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

272  : void
273  {
274  $this->objParticipants = $objParticipants;
275  }
+ Here is the caller graph for this function:

◆ showSearchForm()

ilMailMemberSearchGUI::showSearchForm ( )
protected

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

References initMailToMembersForm(), and storeReferer().

Referenced by executeCommand(), and nextMailForm().

258  : void
259  {
260  $this->storeReferer();
261 
262  $form = $this->initMailToMembersForm();
263  $this->tpl->setContent($form->getHTML());
264  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSelectableUsers()

ilMailMemberSearchGUI::showSelectableUsers ( )
protected

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

References $provider, and getObjParticipants().

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

214  : void
215  {
216  $this->tpl->loadStandardTemplate();
217  $tbl = new ilMailMemberSearchTableGUI($this, 'showSelectableUsers');
218  $provider = new ilMailMemberSearchDataProvider($this->getObjParticipants(), $this->ref_id);
219  $tbl->setData($provider->getData());
220 
221  $this->tpl->setContent($tbl->getHTML());
222  }
$provider
Definition: ltitoken.php:83
Class ilMailMemberSearchDataProvider.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeReferer()

ilMailMemberSearchGUI::storeReferer ( )

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

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

Referenced by showSearchForm().

101  : void
102  {
103  $back_link = $this->ctrl->getParentReturn($this);
104 
105  if (isset($this->httpRequest->getServerParams()['HTTP_REFERER'])) {
106  $referer = $this->httpRequest->getServerParams()['HTTP_REFERER'];
107  $urlParts = parse_url($referer);
108 
109  if (isset($urlParts['path'])) {
110  $url = ltrim(basename($urlParts['path']), '/');
111  if (isset($urlParts['query'])) {
112  $url .= '?' . $urlParts['query'];
113  }
114  if ($url !== '') {
115  $back_link = $url;
116  }
117  }
118  }
119 
120  ilSession::set('ilMailMemberSearchGUIReferer', $back_link);
121  }
$url
Definition: ltiregstart.php:35
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 128 of file class.ilMailMemberSearchGUI.php.

References ilSession\set().

Referenced by redirectToParentReferer().

128  : void
129  {
130  ilSession::set('ilMailMemberSearchGUIReferer', '');
131  }
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 37 of file class.ilMailMemberSearchGUI.php.

◆ $ctrl

readonly ilCtrlInterface ilMailMemberSearchGUI::$ctrl
private

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

◆ $httpRequest

readonly ServerRequestInterface ilMailMemberSearchGUI::$httpRequest
private

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

◆ $lng

readonly ilLanguage ilMailMemberSearchGUI::$lng
private

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

◆ $mail_roles

readonly array ilMailMemberSearchGUI::$mail_roles
private

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

Referenced by getMailRoles().

◆ $objParticipants

ilParticipants ilMailMemberSearchGUI::$objParticipants = null
private

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

Referenced by getObjParticipants(), and setObjParticipants().

◆ $tpl

readonly ilGlobalTemplateInterface ilMailMemberSearchGUI::$tpl
private

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


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