ILIAS  release_8 Revision v8.24
ilMailSearchObjectGUI Class Reference
+ Inheritance diagram for ilMailSearchObjectGUI:
+ Collaboration diagram for ilMailSearchObjectGUI:

Public Member Functions

 __construct ($wsp_access_handler=null, ?int $wsp_node_id=null)
 
 mailMembers ()
 
 cancel ()
 
 executeCommand ()
 

Protected Member Functions

 getObjectType ()
 
 getLocalDefaultRolePrefixes ()
 
 getRequestValue (string $key, \ILIAS\Refinery\Transformation $trafo, $default=null)
 
 addPermission (array $a_obj_ids)
 
 share ()
 
 mail ()
 
 mailObjects ()
 
 doesExposeMembers (ilObject $object)
 

Protected Attributes

GlobalHttpState $http
 
Refinery $refinery
 
string $view = null
 
ilGlobalTemplateInterface $tpl
 
ilCtrlInterface $ctrl
 
ilLanguage $lng
 
ilObjUser $user
 
ilErrorHandling $error
 
ilRbacSystem $rbacsystem
 
ilRbacReview $rbacreview
 
ilTree $tree
 
ilObjectDataCache $cache
 
ilFormatMail $umail
 
bool $mailing_allowed
 
 $wsp_access_handler = null
 
int $wsp_node_id = null
 

Private Member Functions

 isDefaultRequestContext ()
 
 getContext ()
 
 isLocalRoleTitle (string $title)
 

Detailed Description

Definition at line 24 of file class.ilMailSearchObjectGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailSearchObjectGUI::__construct (   $wsp_access_handler = null,
?int  $wsp_node_id = null 
)
Parameters
ilWorkspaceAccessHandler | ilPortfolioAccessHandler | null$wsp_access_handler
int | null$wsp_node_id
Exceptions
ilCtrlException

Definition at line 51 of file class.ilMailSearchObjectGUI.php.

52 {
53 global $DIC;
54
55 $this->tpl = $DIC['tpl'];
56 $this->ctrl = $DIC['ilCtrl'];
57 $this->lng = $DIC['lng'];
58 $this->user = $DIC['ilUser'];
59 $this->error = $DIC['ilErr'];
60 $this->rbacsystem = $DIC['rbacsystem'];
61 $this->rbacreview = $DIC['rbacreview'];
62 $this->tree = $DIC['tree'];
63 $this->cache = $DIC['ilObjDataCache'];
64 $this->http = $DIC->http();
65 $this->refinery = $DIC->refinery();
66
67 $this->wsp_access_handler = $wsp_access_handler;
68 $this->wsp_node_id = $wsp_node_id;
69
70 $this->ctrl->saveParameter($this, 'mobj_id');
71 $this->ctrl->saveParameter($this, 'ref');
72
73 $mail = new ilMail($this->user->getId());
74 $this->mailing_allowed = $this->rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId());
75
76 $this->umail = new ilFormatMail($this->user->getId());
77 }
error(string $a_errmsg)
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.

References $DIC, $wsp_access_handler, $wsp_node_id, ILIAS\Repository\ctrl(), error(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addPermission()

ilMailSearchObjectGUI::addPermission ( array  $a_obj_ids)
protected
Parameters
int[]$a_obj_ids

Definition at line 132 of file class.ilMailSearchObjectGUI.php.

132 : void
133 {
134 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
135 $added = false;
136 foreach ($a_obj_ids as $object_id) {
137 if (!in_array($object_id, $existing, true)) {
138 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
139 }
140 }
141
142 if ($added) {
143 $this->tpl->setOnScreenMessage('success', $this->lng->txt('wsp_share_success'), true);
144 }
145 $this->ctrl->redirectByClass(ilWorkspaceAccessGUI::class, 'share');
146 }

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

Referenced by share().

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

◆ cancel()

ilMailSearchObjectGUI::cancel ( )

Definition at line 365 of file class.ilMailSearchObjectGUI.php.

365 : void
366 {
367 $view = '';
368 if ($this->http->wrapper()->query()->has('view')) {
369 $view = $this->http->wrapper()->query()->retrieve('view', $this->refinery->kindlyTo()->string());
370 }
371
372 if ($view === 'myobjects' && $this->isDefaultRequestContext()) {
373 $this->ctrl->returnToParent($this);
374 } else {
375 $this->showMyObjects();
376 }
377 }

References $view, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), isDefaultRequestContext(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ doesExposeMembers()

◆ executeCommand()

ilMailSearchObjectGUI::executeCommand ( )

Definition at line 619 of file class.ilMailSearchObjectGUI.php.

619 : bool
620 {
621 $forward_class = $this->ctrl->getNextClass($this);
622 switch (strtolower($forward_class)) {
623 case strtolower(ilBuddySystemGUI::class):
624 if (!ilBuddySystem::getInstance()->isEnabled()) {
625 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
626 }
627
628 $this->ctrl->saveParameter($this, 'search_' . $this->getObjectType());
629
630 $this->ctrl->setReturn($this, 'showMembers');
631 $this->ctrl->forwardCommand(new ilBuddySystemGUI());
632 break;
633
634 default:
635 if (!($cmd = $this->ctrl->getCmd())) {
636 $cmd = 'showMyObjects';
637 }
638
639 $this->$cmd();
640 break;
641 }
642
643 return true;
644 }
Class ilBuddySystemGUI.
Class ilBuddySystem.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20

References ILIAS\Repository\ctrl(), error(), ilBuddySystem\getInstance(), getObjectType(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getContext()

ilMailSearchObjectGUI::getContext ( )
private

Definition at line 87 of file class.ilMailSearchObjectGUI.php.

87 : string
88 {
89 $context = 'mail';
90 if ($this->http->wrapper()->query()->has('ref')) {
91 $context = $this->http->wrapper()->query()->retrieve('ref', $this->refinery->kindlyTo()->string());
92 }
93
94 return $context;
95 }
$context
Definition: webdav.php:29

References $context, ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by doesExposeMembers().

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

◆ getLocalDefaultRolePrefixes()

ilMailSearchObjectGUI::getLocalDefaultRolePrefixes ( )
abstractprotected
Returns
string[] Returns an array like ['il_crs_member_', 'il_crs_tutor', ...]

Reimplemented in ilMailSearchCoursesGUI, and ilMailSearchGroupsGUI.

Referenced by isLocalRoleTitle().

+ Here is the caller graph for this function:

◆ getObjectType()

ilMailSearchObjectGUI::getObjectType ( )
abstractprotected

Reimplemented in ilMailSearchCoursesGUI, and ilMailSearchGroupsGUI.

Referenced by doesExposeMembers(), executeCommand(), mail(), mailObjects(), and share().

+ Here is the caller graph for this function:

◆ getRequestValue()

ilMailSearchObjectGUI::getRequestValue ( string  $key,
\ILIAS\Refinery\Transformation  $trafo,
  $default = null 
)
protected

Definition at line 115 of file class.ilMailSearchObjectGUI.php.

116 {
117 $value = $default;
118 if ($this->http->wrapper()->query()->has($key)) {
119 $value = $this->http->wrapper()->query()->retrieve($key, $trafo);
120 }
121
122 if ($this->http->wrapper()->post()->has($key)) {
123 $value = $this->http->wrapper()->post()->retrieve($key, $trafo);
124 }
125
126 return $value;
127 }
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ isDefaultRequestContext()

ilMailSearchObjectGUI::isDefaultRequestContext ( )
private

Definition at line 79 of file class.ilMailSearchObjectGUI.php.

79 : bool
80 {
81 return (
82 !$this->http->wrapper()->query()->has('ref') ||
83 $this->http->wrapper()->query()->retrieve('ref', $this->refinery->kindlyTo()->string()) !== 'wsp'
84 );
85 }

References ILIAS\FileDelivery\http().

Referenced by cancel(), and doesExposeMembers().

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

◆ isLocalRoleTitle()

ilMailSearchObjectGUI::isLocalRoleTitle ( string  $title)
private

Definition at line 97 of file class.ilMailSearchObjectGUI.php.

97 : bool
98 {
99 foreach ($this->getLocalDefaultRolePrefixes() as $local_role_prefix) {
100 if (strpos($title, $local_role_prefix) === 0) {
101 return true;
102 }
103 }
104
105 return false;
106 }

References getLocalDefaultRolePrefixes().

Referenced by mailObjects().

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

◆ mail()

ilMailSearchObjectGUI::mail ( )
protected

Definition at line 204 of file class.ilMailSearchObjectGUI.php.

204 : void
205 {
206 $view = '';
207 if ($this->http->wrapper()->query()->has('view')) {
208 $view = $this->http->wrapper()->query()->retrieve('view', $this->refinery->kindlyTo()->string());
209 }
210
211 if ($view === 'myobjects') {
212 $obj_ids = [];
213 if ($this->http->wrapper()->query()->has('search_' . $this->getObjectType())) {
214 $obj_ids = [
215 $this->http->wrapper()->query()->retrieve(
216 'search_' . $this->getObjectType(),
217 $this->refinery->kindlyTo()->int()
218 )
219 ];
220 } elseif ($this->http->wrapper()->post()->has('search_' . $this->getObjectType())) {
221 $obj_ids = $this->http->wrapper()->post()->retrieve(
222 'search_' . $this->getObjectType(),
223 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
224 );
225 }
226
227 if ($obj_ids !== []) {
228 $this->mailObjects();
229 } else {
230 $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_course'));
231 $this->showMyObjects();
232 }
233 } elseif ($view === $this->getObjectType() . '_members') {
234 $usr_ids = [];
235 if ($this->http->wrapper()->query()->has('search_members')) {
236 $usr_ids = [
237 $this->http->wrapper()->query()->retrieve(
238 'search_members',
239 $this->refinery->kindlyTo()->int()
240 )
241 ];
242 } elseif ($this->http->wrapper()->post()->has('search_members')) {
243 $usr_ids = $this->http->wrapper()->post()->retrieve(
244 'search_members',
245 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
246 );
247 }
248
249 if ($usr_ids !== []) {
250 $this->mailMembers();
251 } else {
252 $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one_entry'));
253 $this->showMembers();
254 }
255 } else {
256 $this->showMyObjects();
257 }
258 }

References $view, getObjectType(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), mailMembers(), mailObjects(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ mailMembers()

ilMailSearchObjectGUI::mailMembers ( )

Definition at line 322 of file class.ilMailSearchObjectGUI.php.

322 : void
323 {
324 $members = [];
325 $usr_ids = [];
326 if ($this->http->wrapper()->query()->has('search_members')) {
327 $usr_ids = [
328 $this->http->wrapper()->query()->retrieve(
329 'search_members',
330 $this->refinery->kindlyTo()->int()
331 )
332 ];
333 } elseif ($this->http->wrapper()->post()->has('search_members')) {
334 $usr_ids = $this->http->wrapper()->post()->retrieve(
335 'search_members',
336 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
337 );
338 }
339
340 $mail_data = $this->umail->retrieveFromStage();
341 foreach ($usr_ids as $usr_id) {
342 $login = ilObjUser::_lookupLogin($usr_id);
343 if (!$this->umail->existsRecipient($login, (string) $mail_data['rcp_to'])) {
344 $members[] = $login;
345 }
346 }
347 $mail_data = $this->umail->appendSearchResult(array_unique($members), 'to');
348
349 $this->umail->persistToStage(
350 (int) $mail_data['user_id'],
351 $mail_data['attachments'],
352 $mail_data['rcp_to'],
353 $mail_data['rcp_cc'],
354 $mail_data['rcp_bcc'],
355 $mail_data['m_subject'],
356 $mail_data['m_message'],
357 $mail_data['use_placeholders'],
358 $mail_data['tpl_ctx_id'],
359 $mail_data['tpl_ctx_params']
360 );
361
362 $this->ctrl->redirectToURL('ilias.php?baseClass=ilMailGUI&type=search_res');
363 }
static _lookupLogin(int $a_user_id)

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

Referenced by mail().

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

◆ mailObjects()

ilMailSearchObjectGUI::mailObjects ( )
protected

Definition at line 260 of file class.ilMailSearchObjectGUI.php.

260 : void
261 {
262 $members = [];
263 $mail_data = $this->umail->retrieveFromStage();
264
265 $obj_ids = [];
266 if ($this->http->wrapper()->query()->has('search_' . $this->getObjectType())) {
267 $obj_ids = [
268 $this->http->wrapper()->query()->retrieve(
269 'search_' . $this->getObjectType(),
270 $this->refinery->kindlyTo()->int()
271 )
272 ];
273 } elseif ($this->http->wrapper()->post()->has('search_' . $this->getObjectType())) {
274 $obj_ids = $this->http->wrapper()->post()->retrieve(
275 'search_' . $this->getObjectType(),
276 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
277 );
278 }
279
280 foreach ($obj_ids as $obj_id) {
281 $ref_ids = ilObject::_getAllReferences($obj_id);
282 foreach ($ref_ids as $ref_id) {
283 $can_send_mails = ilParticipants::canSendMailToMembers(
284 $ref_id,
285 $this->user->getId(),
287 );
288 if (!$can_send_mails) {
289 continue;
290 }
291
292 $roles = $this->rbacreview->getAssignableChildRoles($ref_id);
293 foreach ($roles as $role) {
294 if ($this->isLocalRoleTitle($role['title'])) {
295 $recipient = (new ilRoleMailboxAddress($role['obj_id']))->value();
296 if (!$this->umail->existsRecipient($recipient, (string) $mail_data['rcp_to'])) {
297 $members[] = $recipient;
298 }
299 }
300 }
301 }
302 }
303
304 $mail_data = $members !== [] ? $this->umail->appendSearchResult(array_unique($members), 'to') : $this->umail->retrieveFromStage();
305
306 $this->umail->persistToStage(
307 (int) $mail_data['user_id'],
308 $mail_data['attachments'],
309 $mail_data['rcp_to'],
310 $mail_data['rcp_cc'],
311 $mail_data['rcp_bcc'],
312 $mail_data['m_subject'],
313 $mail_data['m_message'],
314 $mail_data['use_placeholders'],
315 $mail_data['tpl_ctx_id'],
316 $mail_data['tpl_ctx_params']
317 );
318
319 $this->ctrl->redirectToURL('ilias.php?baseClass=ilMailGUI&type=search_res');
320 }
static _getAllReferences(int $id)
get all reference ids for object ID
static canSendMailToMembers( $ref_id_or_instance, ?int $usr_id=null, ?int $mail_obj_ref_id=null)
This method was introduced as a band-aid fix for #22764.
Class ilRoleMailboxAddress.
$ref_id
Definition: ltiauth.php:67

References $ref_id, ilObject\_getAllReferences(), ilParticipants\canSendMailToMembers(), ILIAS\Repository\ctrl(), ilMailGlobalServices\getMailObjectRefId(), getObjectType(), ILIAS\FileDelivery\http(), isLocalRoleTitle(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

Referenced by mail().

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

◆ share()

ilMailSearchObjectGUI::share ( )
protected

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

148 : void
149 {
150 $view = '';
151 if ($this->http->wrapper()->query()->has('view')) {
152 $view = $this->http->wrapper()->query()->retrieve('view', $this->refinery->kindlyTo()->string());
153 }
154
155 if ($view === 'myobjects') {
156 $obj_ids = [];
157 if ($this->http->wrapper()->query()->has('search_' . $this->getObjectType())) {
158 $obj_ids = [
159 $this->http->wrapper()->query()->retrieve(
160 'search_' . $this->getObjectType(),
161 $this->refinery->kindlyTo()->int()
162 )
163 ];
164 } elseif ($this->http->wrapper()->post()->has('search_' . $this->getObjectType())) {
165 $obj_ids = $this->http->wrapper()->post()->retrieve(
166 'search_' . $this->getObjectType(),
167 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
168 );
169 }
170
171 if ($obj_ids !== []) {
172 $this->addPermission($obj_ids);
173 } else {
174 $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_course'));
175 $this->showMyObjects();
176 }
177 } elseif ($view === $this->getObjectType() . '_members') {
178 $usr_ids = [];
179 if ($this->http->wrapper()->query()->has('search_members')) {
180 $usr_ids = [
181 $this->http->wrapper()->query()->retrieve(
182 'search_members',
183 $this->refinery->kindlyTo()->int()
184 )
185 ];
186 } elseif ($this->http->wrapper()->post()->has('search_members')) {
187 $usr_ids = $this->http->wrapper()->post()->retrieve(
188 'search_members',
189 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
190 );
191 }
192
193 if ($usr_ids !== []) {
194 $this->addPermission($usr_ids);
195 } else {
196 $this->tpl->setOnScreenMessage('info', $this->lng->txt('mail_select_one_entry'));
197 $this->showMembers();
198 }
199 } else {
200 $this->showMyObjects();
201 }
202 }

References $view, addPermission(), getObjectType(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Field Documentation

◆ $cache

ilObjectDataCache ilMailSearchObjectGUI::$cache
protected

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

◆ $ctrl

ilCtrlInterface ilMailSearchObjectGUI::$ctrl
protected

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

◆ $error

ilErrorHandling ilMailSearchObjectGUI::$error
protected

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

◆ $http

GlobalHttpState ilMailSearchObjectGUI::$http
protected

Definition at line 26 of file class.ilMailSearchObjectGUI.php.

◆ $lng

ilLanguage ilMailSearchObjectGUI::$lng
protected

Definition at line 31 of file class.ilMailSearchObjectGUI.php.

◆ $mailing_allowed

bool ilMailSearchObjectGUI::$mailing_allowed
protected

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

◆ $rbacreview

ilRbacReview ilMailSearchObjectGUI::$rbacreview
protected

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

◆ $rbacsystem

ilRbacSystem ilMailSearchObjectGUI::$rbacsystem
protected

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

◆ $refinery

Refinery ilMailSearchObjectGUI::$refinery
protected

Definition at line 27 of file class.ilMailSearchObjectGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilMailSearchObjectGUI::$tpl
protected

Definition at line 29 of file class.ilMailSearchObjectGUI.php.

◆ $tree

ilTree ilMailSearchObjectGUI::$tree
protected

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

◆ $umail

ilFormatMail ilMailSearchObjectGUI::$umail
protected

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

◆ $user

ilObjUser ilMailSearchObjectGUI::$user
protected

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

◆ $view

string ilMailSearchObjectGUI::$view = null
protected

Definition at line 28 of file class.ilMailSearchObjectGUI.php.

Referenced by cancel(), mail(), and share().

◆ $wsp_access_handler

ilMailSearchObjectGUI::$wsp_access_handler = null
protected

Definition at line 43 of file class.ilMailSearchObjectGUI.php.

Referenced by __construct().

◆ $wsp_node_id

int ilMailSearchObjectGUI::$wsp_node_id = null
protected

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

Referenced by __construct().


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