ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMailMemberSearchGUI Class Reference
+ Inheritance diagram for ilMailMemberSearchGUI:
+ 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)
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 

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.

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:66
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilMailMemberSearchGUI::executeCommand ( )

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

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':
106 break;
107
108 default:
109 if (isset($this->httpRequest->getQueryParams()['returned_from_mail']) &&
110 $this->httpRequest->getQueryParams()['returned_from_mail'] === '1') {
112 }
113 $this->showSearchForm();
114 break;
115 }
116
117 return true;
118 }
showSearchForm(?StandardForm $form=null)

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

+ Here is the call graph for this function:

◆ generateContextArray()

ilMailMemberSearchGUI::generateContextArray ( )
protected

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

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 }
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
final const string CONTEXT_KEY
const string PROP_CONTEXT_SUBJECT_PREFIX
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)

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.

+ Here is the call graph for this function:

◆ getMailRadioGroup()

ilMailMemberSearchGUI::getMailRadioGroup ( )
protected

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

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 }
This describes switchable group inputs.

References $mail_roles, and getMailRoles().

+ Here is the call 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.

338 : array
339 {
340 return $this->mail_roles;
341 }

References $mail_roles.

Referenced by getMailRadioGroup().

+ Here is the caller graph for this function:

◆ getObjParticipants()

ilMailMemberSearchGUI::getObjParticipants ( )
protected

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

314 {
316 }
Base class for course and group participants.

References $objParticipants.

Referenced by sendMailToSelectedUsers(), and showSelectableUsers().

+ Here is the caller graph for this function:

◆ getSafePostCommands()

ilMailMemberSearchGUI::getSafePostCommands ( )

This method must return a list of safe POST commands.

Safe post commands returned by this method will no longer be CSRF protected and will NOT be appended by an ilCtrlToken.

Returns
string[]

Implements ilCtrlSecurityInterface.

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

383 : array
384 {
385 return [];
386 }

◆ getStoredReferer()

ilMailMemberSearchGUI::getStoredReferer ( )
private

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

148 : string
149 {
150 return (string) ilSession::get('ilMailMemberSearchGUIReferer');
151 }
static get(string $a_var)

References ilSession\get().

Referenced by redirectToParentReferer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUnsafeGetCommands()

ilMailMemberSearchGUI::getUnsafeGetCommands ( )

This method must return a list of unsafe GET commands.

Unsafe get commands returned by this method will now be CSRF protected, which means an ilCtrlToken is appended each time a link-target is generated to the class implementing this interface with a command from that list.

Tokens will be validated in

See also
ilCtrlInterface::getCmd(), whereas the fallback command will be used if the CSRF validation fails.
Returns
string[]

Implements ilCtrlSecurityInterface.

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

376 : array
377 {
378 return [
379 'handleSearchMembersActions'
380 ];
381 }

◆ handleSearchMembersActions()

ilMailMemberSearchGUI::handleSearchMembersActions ( )
private

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

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 }

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

Referenced by executeCommand().

+ 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.

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 }

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

Referenced by nextMailForm(), and showSearchForm().

+ 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.

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 getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
final const string MAIL_FORM_TYPE_ROLE
static set(string $a_var, $a_val)
Set a value.

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

Referenced by executeCommand().

+ 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.

120 : void
121 {
122 $url = $this->getStoredReferer();
123 $this->unsetStoredReferer();
124 $this->ctrl->redirectToURL($url);
125 }
$url
Definition: shib_logout.php:68

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

Referenced by executeCommand().

+ 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.

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 }
static setRecipients(array $recipients, string $type='to')
final const string MAIL_FORM_TYPE_NEW
Class ilMailMemberSearchDataProvider.
static _lookupLogin(int $a_user_id)
$provider
Definition: ltitoken.php:80

References $provider, ilObjUser\_lookupLogin(), ILIAS\Repository\ctrl(), 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().

+ 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.

318 : void
319 {
320 $this->objParticipants = $objParticipants;
321 }

References $objParticipants.

◆ showSearchForm()

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

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

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 }

References initMailToMembersForm(), and storeReferer().

Referenced by executeCommand(), and nextMailForm().

+ 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.

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 }

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

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

+ 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.

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 }

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

Referenced by showSearchForm().

+ 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.

153 : void
154 {
155 ilSession::set('ilMailMemberSearchGUIReferer', '');
156 }

References ilSession\set().

Referenced by redirectToParentReferer().

+ 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 getMailRadioGroup(), and 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: