ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMembershipMailGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21
22
25
32{
34 protected ilLanguage $lng;
37 protected Factory $refinery;
39
41 {
42 global $DIC;
43 $this->main_tpl = $DIC->ui()->mainTemplate();
44 $this->http = $DIC->http();
45 $this->refinery = $DIC->refinery();
46 $this->object = $object;
47 $this->ctrl = $DIC->ctrl();
48 $this->lng = $DIC->language();
49 }
50
51 public function getCurrentObject(): ilObjectGUI
52 {
53 return $this->object;
54 }
55
56 public function executeCommand(): void
57 {
58 $next_class = $this->ctrl->getNextClass($this);
59 $cmd = $this->ctrl->getCmd();
60
61 switch ($next_class) {
62 default:
63 $this->$cmd();
64 break;
65 }
66 }
67
68 protected function initRecipientsFromPost(string $name): array
69 {
70 if ($this->http->wrapper()->post()->has($name)) {
71 return $this->http->wrapper()->post()->retrieve(
72 $name,
73 $this->refinery->kindlyTo()->listOf(
74 $this->refinery->kindlyTo()->int()
75 )
76 );
77 }
78 return [];
79 }
80
81 protected function initMemberIdFromGet(): int
82 {
83 if ($this->http->wrapper()->query()->has('member_id')) {
84 return $this->http->wrapper()->query()->retrieve(
85 'member_id',
86 $this->refinery->kindlyTo()->int()
87 );
88 }
89 return 0;
90 }
91
92 public function sendMailToSelectedUsers(): void
93 {
94 if ($this->http->wrapper()->query()->has('member_id')) {
95 $particpants = [$this->initMemberIdFromGet()];
96 } else {
97 $particpants = array_unique(array_merge(
98 $this->initRecipientsFromPost('admins'),
99 $this->initRecipientsFromPost('tutors'),
100 $this->initRecipientsFromPost('members'),
101 $this->initRecipientsFromPost('roles'),
102 $this->initRecipientsFromPost('waiting'),
103 $this->initRecipientsFromPost('subscribers')
104 ));
105 }
106
107 if (!count($particpants)) {
108 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
109 $this->ctrl->returnToParent($this);
110 return;
111 }
112 $rcps = [];
113 foreach ($particpants as $usr_id) {
114 $rcps[] = ilObjUser::_lookupLogin($usr_id);
115 }
116 $this->ctrl->redirectToURL(
118 $this->getCurrentObject(),
119 'members',
120 [],
121 [
122 'type' => 'new',
123 'rcp_to' => implode(',', $rcps),
124 'sig' => $this->createMailSignature()
125 ]
126 )
127 );
128 }
129
130 protected function createMailSignature(): string
131 {
132 $this->lng->loadLanguageModule($this->getCurrentObject()->getObject()->getType());
133
134 $link = chr(13) . chr(10) . chr(13) . chr(10);
135 $link .= $this->lng->txt($this->getCurrentObject()->getObject()->getType() . '_mail_permanent_link');
136 $link .= chr(13) . chr(10) . chr(13) . chr(10);
137 $link .= ilLink::_getLink($this->getCurrentObject()->getObject()->getRefId());
138 return rawurlencode(base64_encode($link));
139 }
140}
Builds data types.
Definition: Factory.php:36
language handling
static getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
ilGlobalTemplateInterface $main_tpl
__construct(ilObjectGUI $object)
static _lookupLogin(int $a_user_id)
Class ilObjectGUI Basic methods of all Output classes.
Interface GlobalHttpState.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26