ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMailSearchObjectGUI Class Reference
+ Inheritance diagram for ilMailSearchObjectGUI:
+ Collaboration diagram for ilMailSearchObjectGUI:

Public Member Functions

 __construct (protected $wsp_access_handler=null, protected ?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
 
ILIAS UI Factory $ui_factory
 
ILIAS UI Renderer $ui_renderer
 

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 ( protected  $wsp_access_handler = null,
protected ?int  $wsp_node_id = null 
)
Parameters
ilWorkspaceAccessHandler | ilPortfolioAccessHandler | null$wsp_access_handler
Exceptions
ilCtrlException

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

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

References $DIC, 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 129 of file class.ilMailSearchObjectGUI.php.

129 : void
130 {
131 $added = $this->wsp_access_handler->addMissingPermissionForObjects($this->wsp_node_id, $a_obj_ids);
132
133 if ($added) {
134 $this->tpl->setOnScreenMessage('success', $this->lng->txt('wsp_share_success'), true);
135 }
136 $this->ctrl->redirectByClass(ilWorkspaceAccessGUI::class, 'share');
137 }

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 356 of file class.ilMailSearchObjectGUI.php.

356 : void
357 {
358 $view = '';
359 if ($this->http->wrapper()->query()->has('view')) {
360 $view = $this->http->wrapper()->query()->retrieve('view', $this->refinery->kindlyTo()->string());
361 }
362
363 if ($view === 'myobjects' && $this->isDefaultRequestContext()) {
364 $this->ctrl->returnToParent($this);
365 } else {
366 $this->showMyObjects();
367 }
368 }

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 625 of file class.ilMailSearchObjectGUI.php.

625 : bool
626 {
627 $forward_class = $this->ctrl->getNextClass($this) ?? '';
628 switch (strtolower($forward_class)) {
629 case strtolower(ilBuddySystemGUI::class):
630 if (!ilBuddySystem::getInstance()->isEnabled()) {
631 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
632 }
633
634 $this->ctrl->saveParameter($this, 'search_' . $this->getObjectType());
635
636 $this->ctrl->setReturn($this, 'showMembers');
637 $this->ctrl->forwardCommand(new ilBuddySystemGUI());
638 break;
639
640 default:
641 if (!($cmd = $this->ctrl->getCmd())) {
642 $cmd = 'showMyObjects';
643 }
644
645 $this->$cmd();
646 break;
647 }
648
649 return true;
650 }
Class ilBuddySystemGUI.
Class ilBuddySystem.
if(!file_exists('../ilias.ini.php'))

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 84 of file class.ilMailSearchObjectGUI.php.

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

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 112 of file class.ilMailSearchObjectGUI.php.

113 {
114 $value = $default;
115 if ($this->http->wrapper()->query()->has($key)) {
116 $value = $this->http->wrapper()->query()->retrieve($key, $trafo);
117 }
118
119 if ($this->http->wrapper()->post()->has($key)) {
120 $value = $this->http->wrapper()->post()->retrieve($key, $trafo);
121 }
122
123 return $value;
124 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ isDefaultRequestContext()

ilMailSearchObjectGUI::isDefaultRequestContext ( )
private

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

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

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 94 of file class.ilMailSearchObjectGUI.php.

94 : bool
95 {
96 foreach ($this->getLocalDefaultRolePrefixes() as $local_role_prefix) {
97 if (str_starts_with($title, $local_role_prefix)) {
98 return true;
99 }
100 }
101
102 return false;
103 }

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 195 of file class.ilMailSearchObjectGUI.php.

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

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 313 of file class.ilMailSearchObjectGUI.php.

313 : void
314 {
315 $members = [];
316 $usr_ids = [];
317 if ($this->http->wrapper()->query()->has('search_members')) {
318 $usr_ids = [
319 $this->http->wrapper()->query()->retrieve(
320 'search_members',
321 $this->refinery->kindlyTo()->int()
322 )
323 ];
324 } elseif ($this->http->wrapper()->post()->has('search_members')) {
325 $usr_ids = $this->http->wrapper()->post()->retrieve(
326 'search_members',
327 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
328 );
329 }
330
331 $mail_data = $this->umail->retrieveFromStage();
332 foreach ($usr_ids as $usr_id) {
333 $login = ilObjUser::_lookupLogin($usr_id);
334 if (!$this->umail->existsRecipient($login, (string) $mail_data['rcp_to'])) {
335 $members[] = $login;
336 }
337 }
338 $mail_data = $this->umail->appendSearchResult(array_unique($members), 'to');
339
340 $this->umail->persistToStage(
341 (int) $mail_data['user_id'],
342 $mail_data['attachments'],
343 $mail_data['rcp_to'],
344 $mail_data['rcp_cc'],
345 $mail_data['rcp_bcc'],
346 $mail_data['m_subject'],
347 $mail_data['m_message'],
348 $mail_data['use_placeholders'],
349 $mail_data['tpl_ctx_id'],
350 $mail_data['tpl_ctx_params']
351 );
352
353 $this->ctrl->redirectToURL('ilias.php?baseClass=ilMailGUI&type=search_res');
354 }
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 251 of file class.ilMailSearchObjectGUI.php.

251 : void
252 {
253 $members = [];
254 $mail_data = $this->umail->retrieveFromStage();
255
256 $obj_ids = [];
257 if ($this->http->wrapper()->query()->has('search_' . $this->getObjectType())) {
258 $obj_ids = [
259 $this->http->wrapper()->query()->retrieve(
260 'search_' . $this->getObjectType(),
261 $this->refinery->kindlyTo()->int()
262 )
263 ];
264 } elseif ($this->http->wrapper()->post()->has('search_' . $this->getObjectType())) {
265 $obj_ids = $this->http->wrapper()->post()->retrieve(
266 'search_' . $this->getObjectType(),
267 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
268 );
269 }
270
271 foreach ($obj_ids as $obj_id) {
272 $ref_ids = ilObject::_getAllReferences($obj_id);
273 foreach ($ref_ids as $ref_id) {
274 $can_send_mails = ilParticipants::canSendMailToMembers(
275 $ref_id,
276 $this->user->getId(),
278 );
279 if (!$can_send_mails) {
280 continue;
281 }
282
283 $roles = $this->rbacreview->getAssignableChildRoles($ref_id);
284 foreach ($roles as $role) {
285 if ($this->isLocalRoleTitle($role['title'])) {
286 $recipient = (new ilRoleMailboxAddress($role['obj_id']))->value();
287 if (!$this->umail->existsRecipient($recipient, (string) $mail_data['rcp_to'])) {
288 $members[] = $recipient;
289 }
290 }
291 }
292 }
293 }
294
295 $mail_data = $members !== [] ? $this->umail->appendSearchResult(array_unique($members), 'to') : $this->umail->retrieveFromStage();
296
297 $this->umail->persistToStage(
298 (int) $mail_data['user_id'],
299 $mail_data['attachments'],
300 $mail_data['rcp_to'],
301 $mail_data['rcp_cc'],
302 $mail_data['rcp_bcc'],
303 $mail_data['m_subject'],
304 $mail_data['m_message'],
305 $mail_data['use_placeholders'],
306 $mail_data['tpl_ctx_id'],
307 $mail_data['tpl_ctx_params']
308 );
309
310 $this->ctrl->redirectToURL('ilias.php?baseClass=ilMailGUI&type=search_res');
311 }
static _getAllReferences(int $id)
get all reference ids for object ID
static canSendMailToMembers(int|ilObject $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.
$ref_id
Definition: ltiauth.php:66

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 139 of file class.ilMailSearchObjectGUI.php.

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

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.

◆ $ui_factory

ILIAS UI Factory ilMailSearchObjectGUI::$ui_factory
protected

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

◆ $ui_renderer

ILIAS UI Renderer ilMailSearchObjectGUI::$ui_renderer
protected

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


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