ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 (?StandardForm $form=null)
 
 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 28 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 47 of file class.ilMailMemberSearchGUI.php.

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

51  {
52  global $DIC;
53 
54  $this->ctrl = $DIC['ilCtrl'];
55  $this->tpl = $DIC['tpl'];
56  $this->lng = $DIC['lng'];
57  $this->access = $DIC['ilAccess'];
58  $this->httpRequest = $DIC->http()->request();
59 
60  $this->ui_factory = $DIC->ui()->factory();
61  $this->ui_renderer = $DIC->ui()->renderer();
62  $this->refinery = $DIC->refinery();
63  $this->http = $DIC->http();
64 
65  $this->lng->loadLanguageModule('mail');
66  $this->lng->loadLanguageModule('search');
67  $this->mail_roles = $objMailMemberRoles->getMailRoles($ref_id);
68  }
$ref_id
Definition: ltiauth.php:65
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

◆ executeCommand()

ilMailMemberSearchGUI::executeCommand ( )

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

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

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

◆ generateContextArray()

ilMailMemberSearchGUI::generateContextArray ( )
protected

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

206  : array
207  {
208  $contextParameters = [];
209 
210  $type = ilObject::_lookupType($this->ref_id, true);
211  switch ($type) {
212  case 'grp':
213  case 'crs':
214  if ($this->access->checkAccess('write', '', $this->ref_id)) {
215  $contextParameters = [
216  'ref_id' => $this->ref_id,
217  'ts' => time(),
219  ilObject::_lookupObjId($this->ref_id),
221  ''
222  )
223  ];
224 
225  if ('crs' === $type) {
227  }
228  }
229  break;
230 
231  case 'sess':
232  if ($this->access->checkAccess('write', '', $this->ref_id)) {
233  $contextParameters = [
235  'ref_id' => $this->ref_id,
236  'ts' => time()
237  ];
238  }
239  break;
240  }
241 
242  return $contextParameters;
243  }
const PROP_CONTEXT_SUBJECT_PREFIX
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:65
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
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 343 of file class.ilMailMemberSearchGUI.php.

References getMailRoles(), ILIAS\Repository\lng(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by initMailToMembersForm().

344  {
345  $mail_roles = $this->getMailRoles();
346 
347  $sub_items = [];
348  $values = [];
349  foreach ($mail_roles as $role) {
350  $chk_role = $this->ui_factory->input()->field()->checkbox($role['form_option_title'], $role['mailbox']);
351  $sub_items[$role['role_id']] = $chk_role;
352  if (isset($role['default_checked']) && $role['default_checked']) {
353  $values[$role['role_id']] = true;
354  } else {
355  $values[$role['role_id']] = false;
356  }
357  }
358 
359  return $this->ui_factory->input()->field()->switchableGroup(
360  [
361  'mail_sel_users' => $this->ui_factory->input()->field()->group([], $this->lng->txt('mail_sel_users')),
362  'mail_member_roles' => $this->ui_factory->input()->field()->group(
363  $sub_items,
364  $this->objMailMemberRoles->getRadioOptionTitle()
365  )
366  ],
367  $this->lng->txt('mail_sel_label')
368  )->withValue(
369  [
370  'mail_member_roles',
371  $values
372  ]
373  );
374  }
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
+ 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 338 of file class.ilMailMemberSearchGUI.php.

References $mail_roles.

Referenced by getMailRadioGroup().

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

◆ getObjParticipants()

ilMailMemberSearchGUI::getObjParticipants ( )
protected

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

References $objParticipants.

Referenced by sendMailToSelectedUsers(), and showSelectableUsers().

313  : ?ilParticipants
314  {
315  return $this->objParticipants;
316  }
Base class for course and group participants.
+ Here is the caller graph for this function:

◆ getStoredReferer()

ilMailMemberSearchGUI::getStoredReferer ( )
private

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

References ilSession\get().

Referenced by redirectToParentReferer().

148  : string
149  {
150  return (string) ilSession::get('ilMailMemberSearchGUIReferer');
151  }
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 70 of file class.ilMailMemberSearchGUI.php.

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

Referenced by executeCommand().

70  : void
71  {
72  $action = $this->http->wrapper()->query()->retrieve(
73  'contact_search_members_action',
74  $this->refinery->byTrying([
75  $this->refinery->kindlyTo()->string(),
76  $this->refinery->always('')
77  ])
78  );
79  match ($action) {
80  'sendMailToSelectedUsers' => $this->sendMailToSelectedUsers(),
81  default => $this->ctrl->redirect($this, 'showSelectableUsers'),
82  };
83  }
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 323 of file class.ilMailMemberSearchGUI.php.

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

Referenced by nextMailForm(), and showSearchForm().

323  : StandardForm
324  {
325  $this->lng->loadLanguageModule('mail');
326 
327  return $this->ui_factory->input()->container()->form()->standard(
328  $this->ctrl->getFormAction($this, 'nextMailForm'),
329  [
330  'mail_member_type' => $this->getMailRadioGroup()
331  ]
332  );
333  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nextMailForm()

ilMailMemberSearchGUI::nextMailForm ( )
protected

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

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

Referenced by executeCommand().

158  : void
159  {
160  $form = $this->initMailToMembersForm();
161  $form = $form->withRequest($this->http->request());
162  if (!$form->getError()) {
163  $data = $form->getData();
164 
165  if (isset($data['mail_member_type']) && $data['mail_member_type'][0] === 'mail_member_roles') {
166  if ($data['mail_member_type'][1]) {
167  $role_mail_boxes = [];
168  $roles = $data['mail_member_type'][1];
169  foreach ($roles as $role_id => $enabled) {
170  if ($enabled) {
171  $role_mail_boxes[] = $this->objMailMemberRoles->getMailboxRoleAddress((int) $role_id);
172  }
173  }
174 
175  ilSession::set('mail_roles', $role_mail_boxes);
176 
177  $this->ctrl->redirectToURL(
179  $this,
180  'showSearchForm',
182  [
184  'rcp_to' => implode(',', $role_mail_boxes),
185  'sig' => $this->gui->createMailSignature()
186  ],
187  $this->generateContextArray()
188  )
189  );
190  } else {
191  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'));
192  $this->showSearchForm($form);
193 
194  return;
195  }
196  } else {
197  $this->showSelectableUsers();
198 
199  return;
200  }
201  }
202 
203  $this->showSearchForm($form);
204  }
static http()
Fetches the global http state from ILIAS.
showSearchForm(?StandardForm $form=null)
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 120 of file class.ilMailMemberSearchGUI.php.

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

Referenced by executeCommand().

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

◆ sendMailToSelectedUsers()

ilMailMemberSearchGUI::sendMailToSelectedUsers ( )
protected

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

254  : void
255  {
256  $selected_user_ids = $this->http->wrapper()->query()->retrieve(
257  'contact_search_members_user_ids',
258  $this->refinery->byTrying([
259  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
260  $this->refinery->always([])
261  ])
262  );
263 
264  if ((string) current($selected_user_ids) === 'ALL_OBJECTS') {
265  $selected_user_ids = [];
266  $provider = new ilMailMemberSearchDataProvider($this->getObjParticipants(), $this->ref_id);
267  $entries = $provider->getData();
268 
269  foreach ($entries as $entry) {
270  $selected_user_ids[] = (int) $entry['user_id'];
271  }
272  } else {
273  $selected_user_ids = array_map(intval(...), $selected_user_ids);
274  }
275 
276  $rcps = [];
277  foreach ($selected_user_ids as $usr_id) {
278  $rcps[] = ilObjUser::_lookupLogin($usr_id);
279  }
280 
281  if (array_filter($rcps) === []) {
282  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'));
283  $this->showSelectableUsers();
284  return;
285  }
286 
288 
289  $this->ctrl->redirectToURL(
291  $this,
292  'members',
293  [],
294  [
296  'sig' => $this->gui->createMailSignature(),
297  ],
298  $this->generateContextArray()
299  )
300  );
301  }
$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 318 of file class.ilMailMemberSearchGUI.php.

References $objParticipants.

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

318  : void
319  {
320  $this->objParticipants = $objParticipants;
321  }
+ Here is the caller graph for this function:

◆ showSearchForm()

ilMailMemberSearchGUI::showSearchForm ( ?StandardForm  $form = null)
protected

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

References initMailToMembersForm(), and storeReferer().

Referenced by executeCommand(), and nextMailForm().

303  : void
304  {
305  $this->storeReferer();
306 
307  if (!$form instanceof StandardForm) {
308  $form = $this->initMailToMembersForm();
309  }
310  $this->tpl->setContent($this->ui_renderer->render($form));
311  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSelectableUsers()

ilMailMemberSearchGUI::showSelectableUsers ( )
protected

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

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

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

245  : void
246  {
247  $this->tpl->loadStandardTemplate();
248  $provider = new ilMailMemberSearchDataProvider($this->getObjParticipants(), $this->ref_id);
249  $tbl = new MailMemberSearchTable($this->ref_id, $provider, $this->ctrl, $this->lng, $this->ui_factory, $this->http);
250 
251  $this->tpl->setContent($this->ui_renderer->render($tbl->getComponent()));
252  }
$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 127 of file class.ilMailMemberSearchGUI.php.

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

Referenced by showSearchForm().

127  : void
128  {
129  $back_link = $this->ctrl->getParentReturn($this);
130 
131  if (isset($this->httpRequest->getServerParams()['HTTP_REFERER'])) {
132  $referer = $this->httpRequest->getServerParams()['HTTP_REFERER'];
133  $urlParts = parse_url($referer);
134  if (is_array($urlParts) && isset($urlParts['path'])) {
135  $url = ltrim(basename($urlParts['path']), '/');
136  if (isset($urlParts['query'])) {
137  $url .= '?' . $urlParts['query'];
138  }
139  if ($url !== '') {
140  $back_link = $url;
141  }
142  }
143  }
144 
145  ilSession::set('ilMailMemberSearchGUIReferer', $back_link);
146  }
$url
Definition: shib_logout.php:66
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 153 of file class.ilMailMemberSearchGUI.php.

References ilSession\set().

Referenced by redirectToParentReferer().

153  : void
154  {
155  ilSession::set('ilMailMemberSearchGUIReferer', '');
156  }
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.

◆ $http

readonly Services ilMailMemberSearchGUI::$http
private

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

◆ $refinery

readonly Factory ilMailMemberSearchGUI::$refinery
private

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

◆ $tpl

readonly ilGlobalTemplateInterface ilMailMemberSearchGUI::$tpl
private

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

◆ $ui_factory

readonly ILIAS UI Factory ilMailMemberSearchGUI::$ui_factory
private

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

◆ $ui_renderer

readonly Renderer ilMailMemberSearchGUI::$ui_renderer
private

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


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