ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
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 204 of file class.ilMailMemberSearchGUI.php.

204 : array
205 {
206 $contextParameters = [];
207
208 $type = ilObject::_lookupType($this->ref_id, true);
209 switch ($type) {
210 case 'grp':
211 case 'crs':
212 if ($this->access->checkAccess('write', '', $this->ref_id)) {
213 $contextParameters = [
214 'ref_id' => $this->ref_id,
215 'ts' => time(),
217 ilObject::_lookupObjId($this->ref_id),
219 ''
220 )
221 ];
222
223 if ('crs' === $type) {
225 }
226 }
227 break;
228
229 case 'sess':
230 if ($this->access->checkAccess('write', '', $this->ref_id)) {
231 $contextParameters = [
233 'ref_id' => $this->ref_id,
234 'ts' => time()
235 ];
236 }
237 break;
238 }
239
240 return $contextParameters;
241 }
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 341 of file class.ilMailMemberSearchGUI.php.

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

336 : array
337 {
338 return $this->mail_roles;
339 }

References $mail_roles.

Referenced by getMailRadioGroup().

+ Here is the caller graph for this function:

◆ getObjParticipants()

ilMailMemberSearchGUI::getObjParticipants ( )
protected

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

312 {
314 }
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 381 of file class.ilMailMemberSearchGUI.php.

381 : array
382 {
383 return [];
384 }

◆ 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 374 of file class.ilMailMemberSearchGUI.php.

374 : array
375 {
376 return [
377 'handleSearchMembersActions'
378 ];
379 }

◆ 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 321 of file class.ilMailMemberSearchGUI.php.

321 : StandardForm
322 {
323 $this->lng->loadLanguageModule('mail');
324
325 return $this->ui_factory->input()->container()->form()->standard(
326 $this->ctrl->getFormAction($this, 'nextMailForm'),
327 [
328 'mail_member_type' => $this->getMailRadioGroup()
329 ]
330 );
331 }

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 }
197
198 $this->ctrl->redirect($this, 'showSelectableUsers');
199 }
200
201 $this->showSearchForm($form);
202 }
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(), and showSearchForm().

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:70

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 252 of file class.ilMailMemberSearchGUI.php.

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

316 : void
317 {
318 $this->objParticipants = $objParticipants;
319 }

References $objParticipants.

◆ showSearchForm()

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

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

301 : void
302 {
303 $this->storeReferer();
304
305 if (!$form instanceof StandardForm) {
306 $form = $this->initMailToMembersForm();
307 }
308 $this->tpl->setContent($this->ui_renderer->render($form));
309 }

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 243 of file class.ilMailMemberSearchGUI.php.

243 : void
244 {
245 $this->tpl->loadStandardTemplate();
246 $provider = new ilMailMemberSearchDataProvider($this->getObjParticipants(), $this->ref_id);
247 $tbl = new MailMemberSearchTable($this->ref_id, $provider, $this->ctrl, $this->lng, $this->ui_factory, $this->http);
248
249 $this->tpl->setContent($this->ui_renderer->render($tbl->getComponent()));
250 }

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

Referenced by executeCommand(), 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: