19declare(strict_types=1);
35 private readonly ResourceStorage
$irss;
44 $this->repository_tree =
$DIC->repositoryTree();
45 $this->sender_factory =
$DIC->mail()->mime()->senderFactory();
46 $this->irss =
$DIC->resourceStorage();
47 $this->account_mail_repo =
new NewAccountMailRepository(
$DIC->database());
52 $this->lang_variables_as_fallback = $a_status;
62 $this->u_password = $a_pwd;
72 $this->
user = $a_user;
78 throw new InvalidArgumentException(
79 'Permanent link target must not be empty'
94 $this->u_password =
'';
95 $this->permanent_link_target =
null;
103 if (!isset($this->amail[$a_lang]) || !($this->amail[$a_lang] instanceof NewAccountMail)) {
104 $this->amail[$a_lang] = $this->account_mail_repo->getFor($a_lang);
107 return $this->amail[$a_lang];
120 throw new RuntimeException(
'A user instance must be passed when sending emails');
131 if (
$amail->getBody() ===
'' ||
$amail->getSubject() ===
'') {
132 $fallback_language =
'en';
134 $lang = $this->
settings->get(
'language', $fallback_language);
140 if ((
$amail->getBody() ===
'' ||
$amail->getSubject() ===
'') && $this->areLangVariablesUsedAsFallback()) {
144 $mail_subject = $tmp_lang->txt(
'reg_mail_subject');
148 $tmp_lang->loadLanguageModule(
'registration');
154 $timelimit =
"\n" . sprintf($tmp_lang->txt(
'reg_mail_body_timelimit'), $timelimit) .
"\n\n";
158 $mail_body = $tmp_lang->txt(
'reg_mail_body_salutation') .
' ' .
$user->
getFullname() .
",\n\n" .
159 $tmp_lang->txt(
'reg_mail_body_text1') .
"\n\n" .
160 $tmp_lang->txt(
'reg_mail_body_text2') .
"\n" .
161 ILIAS_HTTP_PATH .
'/login.php?client_id=' .
CLIENT_ID .
"\n";
162 $mail_body .= $tmp_lang->txt(
'login') .
': ' .
$user->
getLogin() .
"\n";
163 $mail_body .= $tmp_lang->txt(
'passwd') .
': ' . $this->u_password .
"\n";
164 $mail_body .=
"\n" . $timelimit;
165 $mail_body .= $tmp_lang->txt(
'reg_mail_body_text3') .
"\n\r";
168 $attachment =
$amail->getAttachment($this->irss);
169 if ($attachment !==
null) {
170 $mmail->Attach($attachment[0],
'',
'attachment', $attachment[1]);
178 $mmail->From($this->sender_factory->system());
179 $mmail->Subject($mail_subject,
true);
181 $mmail->Body($mail_body);
192 $mustache_factory =
$DIC->mail()->mustacheFactory();
197 $replacements[
'MAIL_SALUTATION'] = $mustache_factory->getBasicEngine()->render(
199 'f' => trim($a_amail->getSalutationFemale()),
200 'm' => trim($a_amail->getSalutationMale()),
201 default => trim($a_amail->getSalutationNoneSpecific()),
209 $replacements[
'LOGIN'] = $a_user->
getLogin();
211 $replacements[
'LAST_NAME'] = $a_user->
getLastname();
213 $replacements[
'EMAIL'] = $a_user->
getEmail();
216 $replacements[
'ILIAS_URL'] = ILIAS_HTTP_PATH .
'/login.php?client_id=' .
CLIENT_ID;
218 $replacements[
'ADMIN_MAIL'] =
$settings->
get(
'admin_email');
229 $replacements[
'TIMELIMIT'] = $timelimit;
233 $replacements[
'IF_TARGET'] =
false;
234 if ($this->permanent_link_target !==
null) {
235 $tarr = explode(
'_', $this->permanent_link_target);
236 if ($this->repository_tree->isInTree((
int) $tarr[1])) {
239 if ($type === $tarr[0]) {
246 $replacements[
'IF_TARGET'] =
true;
251 return $mustache_factory->getBasicEngine()->render($a_string, $replacements);
areLangVariablesUsedAsFallback()
useLangVariablesAsFallback(bool $a_status)
readAccountMail(string $a_lang)
readonly ilTree $repository_tree
send()
Sends the mail with its object properties as MimeMail It first tries to read the mail body,...
readonly ilSetting $settings
readonly ResourceStorage $irss
setUser(ilObjUser $a_user)
readonly ilMailMimeSenderFactory $sender_factory
string $permanent_link_target
setPermanentLinkTarget(?string $permanent_link_target)
setUserPassword(string $a_pwd)
bool $lang_variables_as_fallback
readonly NewAccountMailRepository $account_mail_repo
replacePlaceholders(string $a_string, ilObjUser $a_user, NewAccountMail $a_amail, string $a_lang)
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.
@classDescription Date and time handling
static _lookupEntry(string $a_lang_key, string $a_mod, string $a_id)
getProfileAsString(Language $language)
Get formatted mail body text of user profile data.
getFullname(int $max_strlen=0)
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
get(string $a_keyword, ?string $a_default_value=null)
get setting
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Interface GlobalHttpState.