19 declare(strict_types=1);
32 private int $mode = self::MODE_DIRECT_REGISTRATION;
49 if ($permanent_link_target ===
'') {
51 'Permanent link target must not be empty' 63 $clone->mode = self::MODE_DIRECT_REGISTRATION;
70 $clone->mode = self::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION;
77 isset($mailData[
'body'], $mailData[
'subject']) &&
78 is_string($mailData[
'body']) &&
79 $mailData[
'body'] !==
'' &&
80 is_string($mailData[
'subject']) &&
81 $mailData[
'subject'] !==
'' 87 $trimStrings =
static function ($value) {
88 if (is_string($value)) {
89 $value = trim($value);
95 $this->
logger->debug(sprintf(
96 'Trying to send configurable email dependent welcome email to user %s (id: %s|language: %s) ...',
105 $this->
logger->debug(sprintf(
106 'Either subject or email missing, trying to determine email configuration via default language: %s',
107 $this->
language->getDefaultLanguage()
111 if (!is_array($mailData)) {
112 $this->
logger->debug(sprintf(
113 "Did not find any email configuration for language '%s' at all, skipping attempt ...",
114 $this->
language->getDefaultLanguage()
119 $mailData =
array_map($trimStrings, $mailData);
121 $this->
logger->debug(
'Did not find any valid email configuration, skipping attempt ...');
127 $accountMail->setUser($user);
128 $accountMail->setPermanentLinkTarget($this->permanent_link_target);
130 if ($this->
settings->passwordGenerationEnabled()) {
131 $accountMail->setUserPassword($rawPassword);
134 if (isset($mailData[
'att_file'])) {
138 $pathToFile =
'/' . implode(
'/',
array_map(
static function (
string $pathPart):
string {
139 return trim($pathPart,
'/');
141 $fs->getAbsolutePath(),
145 $accountMail->addAttachment($pathToFile, $mailData[
'att_file']);
147 $this->
logger->debug(sprintf(
148 "Attaching '%s' as '%s' ...",
150 $mailData[
'att_file']
153 $this->
logger->debug(
'Not attachments configured for this email configuration ...');
156 $accountMail->send();
158 $this->
logger->debug(
'Welcome email sent');
166 bool $usedRegistrationCode
169 $this->
logger->debug(sprintf(
170 'Missing email address, did not send account registration mail for user %s (id: %s) ...',
177 $this->
logger->debug(sprintf(
178 'Sending language variable dependent welcome email to user %s (id: %s|language: %s) as fallback ...',
201 if ($this->
settings->passwordGenerationEnabled()) {
206 if ($this->
getMode() === self::MODE_DIRECT_REGISTRATION) {
212 } elseif ($this->
getMode() === self::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION) {
220 $this->
appendBody($user->getProfileAsString($this->language));
225 $this->
logger->debug(
'Welcome email sent');
228 public function send(
ilObjUser $user,
string $rawPassword =
'',
bool $usedRegistrationCode =
false): void
ilRegistrationSettings $settings
appendBody(string $a_body)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initLanguageByIso2Code(string $a_code='')
getFullname(int $a_max_strlen=0)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class ilAccountRegistrationMail.
static _lookupNewAccountMail(string $a_lang)
sendLanguageVariableBasedAccountMail(ilObjUser $user, string $rawPassword, bool $usedRegistrationCode)
setSubject(string $a_subject)
withEmailConfirmationRegistrationMode()
const MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION
string $permanent_link_target
__construct(ilRegistrationSettings $settings, ilLanguage $lng, ilLogger $logger)
sendMimeMail(string $a_rcp)
Class ilObjAuthSettingsGUI.
withPermanentLinkTarget(string $permanent_link_target)
send(ilObjUser $user, string $rawPassword='', bool $usedRegistrationCode=false)
__construct(Container $dic, ilPlugin $plugin)
withDirectRegistrationMode()
trySendingUserDefinedAccountMail(ilObjUser $user, string $rawPassword)
language()
description: > Example for rendring a language glyph.
isEmptyMailConfigurationData(array $mailData)
const MODE_DIRECT_REGISTRATION
static _getInstallationSignature()