ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAccountRegistrationMail Class Reference

Class ilAccountRegistrationMail. More...

+ Inheritance diagram for ilAccountRegistrationMail:
+ Collaboration diagram for ilAccountRegistrationMail:

Public Member Functions

 __construct (private readonly ilRegistrationSettings $settings, private readonly ilLogger $logger, private readonly NewAccountMailRepository $account_mail_repository)
 
 getMode ()
 
 withPermanentLinkTarget (string $permanent_link_target)
 
 withDirectRegistrationMode ()
 
 withEmailConfirmationRegistrationMode ()
 
 send (ilObjUser $user, string $rawPassword='', bool $usedRegistrationCode=false)
 
- Public Member Functions inherited from ilMimeMailNotification
 __construct (bool $a_is_personal_workspace=false)
 
 sendMimeMail (string $a_rcp)
 
 setCurrentRecipient (string $current_recipient)
 
 getCurrentRecipient ()
 
 setMimeMail (ilMimeMail $mime_mail)
 
 getMimeMail ()
 
- Public Member Functions inherited from ilMailNotification
 __construct (protected bool $is_in_wsp=false)
 
 setType (int $a_type)
 
 getType ()
 
 setSender (int $a_usr_id)
 
 getSender ()
 
 setRecipients (array $a_rcp)
 
 getRecipients ()
 
 setAttachments (array $a_att)
 
 getAttachments ()
 
 setLangModules (array $a_modules)
 
 getUserLanguage (int $a_usr_id)
 
 setRefId (int $a_id)
 
 getRefId ()
 
 getObjId ()
 
 setObjId (int $a_obj_id)
 
 getObjType ()
 
 setAdditionalInformation (array $a_info)
 
 getAdditionalInformation ()
 
 sendMail (array $a_rcp, bool $a_parse_recipients=true)
 
 getBlockBorder ()
 

Protected Attributes

const MODE_DIRECT_REGISTRATION = 1
 
const MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION = 2
 
- Protected Attributes inherited from ilMimeMailNotification
ilMimeMail $mime_mail
 
string $current_recipient
 
ilMailMimeSenderFactory $sender_factory
 
- Protected Attributes inherited from ilMailNotification
int $type
 
int $sender
 
ilMail $mail = null
 
string $subject = ''
 
string $body = ''
 
array $attachments = []
 
ilLanguage $language
 
array $lang_modules = []
 
array $recipients = []
 
int $ref_id
 
int $obj_id = 0
 
string $obj_type = ''
 
array $additional_info = []
 
ilWorkspaceTree $wsp_tree
 
ilWorkspaceAccessHandler $wsp_access_handler
 

Private Member Functions

 isEmptyMailConfigurationData (array $mailData)
 
 trySendingUserDefinedAccountMail (ilObjUser $user, string $rawPassword)
 
 sendLanguageVariableBasedAccountMail (ilObjUser $user, string $rawPassword, bool $usedRegistrationCode)
 

Private Attributes

int $mode = self::MODE_DIRECT_REGISTRATION
 
string $permanent_link_target = null
 

Additional Inherited Members

- Data Fields inherited from ilMailNotification
final const int SUBJECT_TITLE_LENGTH = 60
 
- Protected Member Functions inherited from ilMimeMailNotification
 setSubject (string $a_subject)
 
 initMimeMail ()
 
 initLanguageByIso2Code (string $a_code='')
 
 initLanguage (int $a_usr_id)
 
- Protected Member Functions inherited from ilMailNotification
 setSubject (string $a_subject)
 
 getSubject ()
 
 setBody (string $a_body)
 
 appendBody (string $a_body)
 
 getBody ()
 
 initLanguage (int $a_usr_id)
 
 initLanguageByIso2Code (string $a_code='')
 
 setLanguage (ilLanguage $a_language)
 
 getLanguage ()
 
 getLanguageText (string $a_keyword)
 
 getObjectTitle (bool $a_shorten=false)
 
 initMail ()
 
 getMail ()
 
 createPermanentLink (array $a_params=[], string $a_append='')
 
 userToString (int $a_usr_id)
 
 isRefIdAccessible (int $a_user_id, int $a_ref_id, string $a_permission='read')
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAccountRegistrationMail::__construct ( private readonly ilRegistrationSettings  $settings,
private readonly ilLogger  $logger,
private readonly NewAccountMailRepository  $account_mail_repository 
)

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

39 {
41 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ getMode()

ilAccountRegistrationMail::getMode ( )

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

43 : int
44 {
45 return $this->mode;
46 }

References $mode.

◆ isEmptyMailConfigurationData()

ilAccountRegistrationMail::isEmptyMailConfigurationData ( array  $mailData)
private

Definition at line 75 of file class.ilAccountRegistrationMail.php.

75 : bool
76 {
77 return !(
78 isset($mailData['body'], $mailData['subject']) &&
79 is_string($mailData['body']) &&
80 $mailData['body'] !== '' &&
81 is_string($mailData['subject']) &&
82 $mailData['subject'] !== ''
83 );
84 }

◆ send()

ilAccountRegistrationMail::send ( ilObjUser  $user,
string  $rawPassword = '',
bool  $usedRegistrationCode = false 
)

Definition at line 191 of file class.ilAccountRegistrationMail.php.

191 : void
192 {
193 if (!$this->trySendingUserDefinedAccountMail($user, $rawPassword)) {
194 $this->sendLanguageVariableBasedAccountMail($user, $rawPassword, $usedRegistrationCode);
195 }
196 }
trySendingUserDefinedAccountMail(ilObjUser $user, string $rawPassword)
sendLanguageVariableBasedAccountMail(ilObjUser $user, string $rawPassword, bool $usedRegistrationCode)

◆ sendLanguageVariableBasedAccountMail()

ilAccountRegistrationMail::sendLanguageVariableBasedAccountMail ( ilObjUser  $user,
string  $rawPassword,
bool  $usedRegistrationCode 
)
private

Definition at line 126 of file class.ilAccountRegistrationMail.php.

130 : void {
131 if (!$user->getEmail()) {
132 $this->logger->debug(sprintf(
133 'Missing email address, did not send account registration mail for user %s (id: %s) ...',
134 $user->getLogin(),
135 $user->getId()
136 ));
137 return;
138 }
139
140 $this->logger->debug(sprintf(
141 'Sending language variable dependent welcome email to user %s (id: %s|language: %s) as fallback ...',
142 $user->getLogin(),
143 $user->getId(),
144 $user->getLanguage()
145 ));
146
147 $this->initMimeMail();
148
149 $this->initLanguageByIso2Code($user->getLanguage());
150
151 $this->setSubject($this->language->txt('reg_mail_subject'));
152
153 $this->setBody($this->language->txt('reg_mail_body_salutation') . ' ' . $user->getFullname() . ',');
154 $this->appendBody("\n\n");
155 $this->appendBody($this->language->txt('reg_mail_body_text1'));
156 $this->appendBody("\n\n");
157 $this->appendBody($this->language->txt('reg_mail_body_text2'));
158 $this->appendBody("\n");
159 $this->appendBody(ILIAS_HTTP_PATH . '/login.php?client_id=' . CLIENT_ID);
160 $this->appendBody("\n");
161 $this->appendBody($this->language->txt('login') . ': ' . $user->getLogin());
162 $this->appendBody("\n");
163
164 if ($this->settings->passwordGenerationEnabled()) {
165 $this->appendBody($this->language->txt('passwd') . ': ' . $rawPassword);
166 $this->appendBody("\n");
167 }
168
169 if ($this->getMode() === self::MODE_DIRECT_REGISTRATION) {
170 if ($this->settings->getRegistrationType() === ilRegistrationSettings::IL_REG_APPROVE && !$usedRegistrationCode) {
171 $this->appendBody("\n");
172 $this->appendBody($this->language->txt('reg_mail_body_pwd_generation'));
173 $this->appendBody("\n\n");
174 }
175 } elseif ($this->getMode() === self::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION) {
176 $this->appendBody("\n");
177 $this->appendBody($this->language->txt('reg_mail_body_forgot_password_info'));
178 $this->appendBody("\n\n");
179 }
180
181 $this->appendBody($this->language->txt('reg_mail_body_text3'));
182 $this->appendBody("\n");
183 $this->appendBody($user->getProfileAsString($this->language));
185
186 $this->sendMimeMail($user->getEmail());
187
188 $this->logger->debug('Welcome email sent');
189 }
static _getInstallationSignature()
getProfileAsString(Language $language)
Get formatted mail body text of user profile data.
getFullname(int $max_strlen=0)
const CLIENT_ID
Definition: constants.php:41

References ilObject\getId(), ilObjUser\getLogin(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ trySendingUserDefinedAccountMail()

ilAccountRegistrationMail::trySendingUserDefinedAccountMail ( ilObjUser  $user,
string  $rawPassword 
)
private

Definition at line 86 of file class.ilAccountRegistrationMail.php.

86 : bool
87 {
88 $this->logger->debug(sprintf(
89 'Trying to send configurable email dependent welcome email to user %s (id: %s|language: %s) ...',
90 $user->getLogin(),
91 $user->getId(),
92 $user->getLanguage()
93 ));
94
95 $mailData = $this->account_mail_repository->getFor($user->getLanguage());
96
97 if ($mailData->getBody() === '' && $mailData->getSubject() === '') {
98 $this->logger->debug(sprintf(
99 'Either subject or email missing, trying to determine email configuration via default language: %s',
100 $this->language->getDefaultLanguage()
101 ));
102
103 $mailData = $this->account_mail_repository->getFor($this->language->getDefaultLanguage());
104
105 if ($mailData->getBody() === '' && $mailData->getSubject() === '') {
106 $this->logger->debug('Did not find any valid email configuration, skipping attempt ...');
107 return false;
108 }
109 }
110
111 $accountMail = new ilAccountMail();
112 $accountMail->setUser($user);
113 $accountMail->setPermanentLinkTarget($this->permanent_link_target);
114
115 if ($this->settings->passwordGenerationEnabled()) {
116 $accountMail->setUserPassword($rawPassword);
117 }
118
119 $accountMail->send();
120
121 $this->logger->debug('Welcome email sent');
122
123 return true;
124 }

References ilObject\getId(), ilObjUser\getLanguage(), ilObjUser\getLogin(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\logger(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ withDirectRegistrationMode()

ilAccountRegistrationMail::withDirectRegistrationMode ( )

Definition at line 61 of file class.ilAccountRegistrationMail.php.

62 {
63 $clone = clone $this;
64 $clone->mode = self::MODE_DIRECT_REGISTRATION;
65 return $clone;
66 }
Class ilAccountRegistrationMail.

References MODE_DIRECT_REGISTRATION.

◆ withEmailConfirmationRegistrationMode()

ilAccountRegistrationMail::withEmailConfirmationRegistrationMode ( )

Definition at line 68 of file class.ilAccountRegistrationMail.php.

69 {
70 $clone = clone $this;
72 return $clone;
73 }

References MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION.

◆ withPermanentLinkTarget()

ilAccountRegistrationMail::withPermanentLinkTarget ( string  $permanent_link_target)

Definition at line 48 of file class.ilAccountRegistrationMail.php.

48 : self
49 {
50 if ($permanent_link_target === '') {
51 throw new InvalidArgumentException(
52 'Permanent link target must not be empty'
53 );
54 }
55
56 $clone = clone $this;
57 $clone->permanent_link_target = $permanent_link_target;
58 return $clone;
59 }

References $permanent_link_target.

Field Documentation

◆ $mode

int ilAccountRegistrationMail::$mode = self::MODE_DIRECT_REGISTRATION
private

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

Referenced by getMode().

◆ $permanent_link_target

string ilAccountRegistrationMail::$permanent_link_target = null
private

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

Referenced by withPermanentLinkTarget().

◆ MODE_DIRECT_REGISTRATION

const ilAccountRegistrationMail::MODE_DIRECT_REGISTRATION = 1
protected

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

Referenced by withDirectRegistrationMode().

◆ MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION

const ilAccountRegistrationMail::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION = 2
protected

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