ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMailMemberSearchGUI Class Reference

Class ilMailMemberSearchGUI. More...

+ Collaboration diagram for ilMailMemberSearchGUI:

Public Member Functions

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

Data Fields

int $ref_id
 

Protected Member Functions

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

Private Member Functions

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

Private Attributes

ServerRequestInterface $httpRequest
 
array $mail_roles
 
 $gui
 
ilAbstractMailMemberRoles $objMailMemberRoles
 
ilParticipants $objParticipants
 
ilCtrlInterface $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilAccessHandler $access
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilMailMemberSearchGUI constructor.

Parameters
ilObjGroupGUI | ilObjCourseGUI | ilMembershipGUI$gui
int$ref_id
ilAbstractMailMemberRoles$objMailMemberRoles

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

References $DIC, $gui, $objMailMemberRoles, $ref_id, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilAbstractMailMemberRoles\getMailRoles(), and ILIAS\Repository\lng().

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->lng->loadLanguageModule('mail');
60  $this->lng->loadLanguageModule('search');
61 
62  $this->gui = $gui;
63  $this->ref_id = $ref_id;
64 
65  $this->objMailMemberRoles = $objMailMemberRoles;
66  $this->mail_roles = $objMailMemberRoles->getMailRoles($ref_id);
67  }
ilAbstractMailMemberRoles $objMailMemberRoles
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilMailMemberSearchGUI::executeCommand ( )

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

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

70  : bool
71  {
72  $next_class = $this->ctrl->getNextClass($this);
73  $cmd = $this->ctrl->getCmd();
74 
75  $this->ctrl->setReturn($this, '');
76 
77  switch ($cmd) {
78  case 'sendMailToSelectedUsers':
79  $this->sendMailToSelectedUsers();
80  break;
81 
82  case 'showSelectableUsers':
83  $this->showSelectableUsers();
84  break;
85 
86  case 'nextMailForm':
87  $this->nextMailForm();
88  break;
89 
90  case 'cancel':
91  $this->redirectToParentReferer();
92  break;
93 
94  default:
95  if (isset($this->httpRequest->getQueryParams()['returned_from_mail']) && $this->httpRequest->getQueryParams()['returned_from_mail'] === '1') {
96  $this->redirectToParentReferer();
97  }
98  $this->showSearchForm();
99  break;
100  }
101 
102 
103  return true;
104  }
+ Here is the call graph for this function:

◆ generateContextArray()

ilMailMemberSearchGUI::generateContextArray ( )
protected

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

References $ref_id, $type, 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().

187  : array
188  {
189  $contextParameters = [];
190 
191  $type = ilObject::_lookupType($this->ref_id, true);
192  switch ($type) {
193  case 'grp':
194  case 'crs':
195  if ($this->access->checkAccess('write', '', $this->ref_id)) {
196  $contextParameters = [
197  'ref_id' => $this->ref_id,
198  'ts' => time(),
200  ilObject::_lookupObjId($this->ref_id),
202  ''
203  )
204  ];
205 
206  if ('crs' === $type) {
208  }
209  }
210  break;
211 
212  case 'sess':
213  if ($this->access->checkAccess('write', '', $this->ref_id)) {
214  $contextParameters = [
216  'ref_id' => $this->ref_id,
217  'ts' => time()
218  ];
219  }
220  break;
221  }
222 
223  return $contextParameters;
224  }
$type
const PROP_CONTEXT_SUBJECT_PREFIX
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
static _lookupObjId(int $ref_id)
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 320 of file class.ilMailMemberSearchGUI.php.

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

Referenced by initMailToMembersForm().

321  {
322  $mail_roles = $this->getMailRoles();
323 
324  $radio_grp = new ilRadioGroupInputGUI($this->lng->txt('mail_sel_label'), 'mail_member_type');
325 
326  $radio_sel_users = new ilRadioOption($this->lng->txt('mail_sel_users'), 'mail_sel_users');
327 
328  $radio_roles = new ilRadioOption($this->objMailMemberRoles->getRadioOptionTitle(), 'mail_member_roles');
329  foreach ($mail_roles as $role) {
330  $chk_role = new ilCheckboxInputGUI($role['form_option_title'], 'roles[' . $role['role_id'] . ']');
331 
332  if (isset($role['default_checked']) && $role['default_checked'] === true) {
333  $chk_role->setChecked(true);
334  }
335  $chk_role->setValue((string) $role['role_id']);
336  $chk_role->setInfo($role['mailbox']);
337  $radio_roles->addSubItem($chk_role);
338  }
339 
340  $radio_grp->setValue('mail_member_roles');
341 
342  $radio_grp->addOption($radio_sel_users);
343  $radio_grp->addOption($radio_roles);
344 
345  return $radio_grp;
346  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
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 314 of file class.ilMailMemberSearchGUI.php.

References $mail_roles.

Referenced by getMailRadioGroup().

314  : array
315  {
316  return $this->mail_roles;
317  }
+ Here is the caller graph for this function:

◆ getObjParticipants()

ilMailMemberSearchGUI::getObjParticipants ( )
protected

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

References $objParticipants.

Referenced by showSelectableUsers().

279  : ?ilParticipants
280  {
281  return $this->objParticipants;
282  }
Base class for course and group participants.
+ Here is the caller graph for this function:

◆ getStoredReferer()

ilMailMemberSearchGUI::getStoredReferer ( )
private

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

References ilSession\get().

Referenced by redirectToParentReferer().

135  : string
136  {
137  return (string) ilSession::get('ilMailMemberSearchGUIReferer');
138  }
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 293 of file class.ilMailMemberSearchGUI.php.

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

Referenced by nextMailForm(), and showSearchForm().

294  {
295  $this->lng->loadLanguageModule('mail');
296 
297  $form = new ilPropertyFormGUI();
298  $form->setTitle($this->lng->txt('mail_members'));
299 
300  $form->setFormAction($this->ctrl->getFormAction($this, 'nextMailForm'));
301 
302  $radio_grp = $this->getMailRadioGroup();
303 
304  $form->addItem($radio_grp);
305  $form->addCommandButton('nextMailForm', $this->lng->txt('mail_members_search_continue'));
306  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
307 
308  return $form;
309  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nextMailForm()

ilMailMemberSearchGUI::nextMailForm ( )
protected

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

145  : void
146  {
147  $form = $this->initMailToMembersForm();
148  if ($form->checkInput()) {
149  if ($form->getInput('mail_member_type') === 'mail_member_roles') {
150  if (is_array($form->getInput('roles')) && count($form->getInput('roles')) > 0) {
151  $role_mail_boxes = [];
152  $roles = $form->getInput('roles');
153  foreach ($roles as $role_id) {
154  $mailbox = $this->objMailMemberRoles->getMailboxRoleAddress((int) $role_id);
155  $role_mail_boxes[] = $mailbox;
156  }
157 
158  ilSession::set('mail_roles', $role_mail_boxes);
159 
160  $this->ctrl->redirectToURL(ilMailFormCall::getRedirectTarget(
161  $this,
162  'showSearchForm',
164  [
166  'rcp_to' => implode(',', $role_mail_boxes),
167  'sig' => $this->gui->createMailSignature()
168  ],
169  $this->generateContextArray()
170  ));
171  } else {
172  $form->setValuesByPost();
173  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'));
174  $this->showSearchForm();
175  return;
176  }
177  } else {
178  $this->showSelectableUsers();
179  return;
180  }
181  }
182 
183  $form->setValuesByPost();
184  $this->showSearchForm();
185  }
static getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
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 106 of file class.ilMailMemberSearchGUI.php.

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

Referenced by executeCommand().

106  : void
107  {
108  $url = $this->getStoredReferer();
109  $this->unsetStoredReferer();
110  $this->ctrl->redirectToURL($url);
111  }
$url
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMailToSelectedUsers()

ilMailMemberSearchGUI::sendMailToSelectedUsers ( )
protected

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

237  : void
238  {
239  if (!isset($this->httpRequest->getParsedBody()['user_ids']) || !is_array($this->httpRequest->getParsedBody()['user_ids']) || 0 === count($this->httpRequest->getParsedBody()['user_ids'])) {
240  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"));
241  $this->showSelectableUsers();
242  return;
243  }
244 
245  $rcps = [];
246  foreach ($this->httpRequest->getParsedBody()['user_ids'] as $usr_id) {
247  $rcps[] = ilObjUser::_lookupLogin((int) $usr_id);
248  }
249 
250  if (!count(array_filter($rcps))) {
251  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"));
252  $this->showSelectableUsers();
253  return;
254  }
255 
257 
258  $this->ctrl->redirectToURL(ilMailFormCall::getRedirectTarget(
259  $this,
260  'members',
261  [],
262  [
264  'sig' => $this->gui->createMailSignature(),
265  ],
266  $this->generateContextArray()
267  ));
268  }
static setRecipients(array $recipients, string $type='to')
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)
Parameters
ilParticipants$objParticipants

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

References $objParticipants.

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

287  : void
288  {
289  $this->objParticipants = $objParticipants;
290  }
+ Here is the caller graph for this function:

◆ showSearchForm()

ilMailMemberSearchGUI::showSearchForm ( )
protected

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

References initMailToMembersForm(), and storeReferer().

Referenced by executeCommand(), and nextMailForm().

270  : void
271  {
272  $this->storeReferer();
273 
274  $form = $this->initMailToMembersForm();
275  $this->tpl->setContent($form->getHTML());
276  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSelectableUsers()

ilMailMemberSearchGUI::showSelectableUsers ( )
protected

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

References $provider, and getObjParticipants().

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

226  : void
227  {
228  $this->tpl->loadStandardTemplate();
229  $tbl = new ilMailMemberSearchTableGUI($this, 'showSelectableUsers');
230  $provider = new ilMailMemberSearchDataProvider($this->getObjParticipants(), $this->ref_id);
231  $tbl->setData($provider->getData());
232 
233  $this->tpl->setContent($tbl->getHTML());
234  }
$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 113 of file class.ilMailMemberSearchGUI.php.

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

Referenced by showSearchForm().

113  : void
114  {
115  $back_link = $this->ctrl->getParentReturn($this);
116 
117  if (isset($this->httpRequest->getServerParams()['HTTP_REFERER'])) {
118  $referer = $this->httpRequest->getServerParams()['HTTP_REFERER'];
119  $urlParts = parse_url($referer);
120 
121  if (isset($urlParts['path'])) {
122  $url = ltrim(basename($urlParts['path']), '/');
123  if (isset($urlParts['query'])) {
124  $url .= '?' . $urlParts['query'];
125  }
126  if ($url !== '') {
127  $back_link = $url;
128  }
129  }
130  }
131 
132  ilSession::set('ilMailMemberSearchGUIReferer', $back_link);
133  }
$url
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 140 of file class.ilMailMemberSearchGUI.php.

References ilSession\set().

Referenced by redirectToParentReferer().

140  : void
141  {
142  ilSession::set('ilMailMemberSearchGUIReferer', '');
143  }
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

ilAccessHandler ilMailMemberSearchGUI::$access
private

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

◆ $ctrl

ilCtrlInterface ilMailMemberSearchGUI::$ctrl
private

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

◆ $gui

ilMailMemberSearchGUI::$gui
private

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

Referenced by __construct().

◆ $httpRequest

ServerRequestInterface ilMailMemberSearchGUI::$httpRequest
private

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

◆ $lng

ilLanguage ilMailMemberSearchGUI::$lng
private

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

◆ $mail_roles

array ilMailMemberSearchGUI::$mail_roles
private

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

Referenced by getMailRoles().

◆ $objMailMemberRoles

ilAbstractMailMemberRoles ilMailMemberSearchGUI::$objMailMemberRoles
private

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

Referenced by __construct().

◆ $objParticipants

ilParticipants ilMailMemberSearchGUI::$objParticipants
private

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

Referenced by getObjParticipants(), and setObjParticipants().

◆ $ref_id

int ilMailMemberSearchGUI::$ref_id

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

Referenced by __construct(), and generateContextArray().

◆ $tpl

ilGlobalTemplateInterface ilMailMemberSearchGUI::$tpl
private

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


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