ILIAS  release_7 Revision v7.30-3-g800a261c036
ilAccountRegistrationMail Class Reference

Class ilAccountRegistrationMail. More...

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

Public Member Functions

 __construct (ilRegistrationSettings $settings, ilLanguage $lng, ilLogger $logger)
 ilAccountRegistrationMail constructor. More...
 
 getMode ()
 
 withDirectRegistrationMode ()
 
 withEmailConfirmationRegistrationMode ()
 
 send (ilObjUser $user, $rawPassword='', $usedRegistrationCode=false)
 
- Public Member Functions inherited from ilMimeMailNotification
 sendMimeMail ($a_rcp)
 
 setCurrentRecipient ($current_recipient)
 
 getCurrentRecipient ()
 
 setMimeMail ($mime_mail)
 
 getMimeMail ()
 
- Public Member Functions inherited from ilMailNotification
 __construct ($a_is_personal_workspace=false)
 
 setType ($a_type)
 Set notification type. More...
 
 getType ()
 Get notification type. More...
 
 setSender ($a_usr_id)
 Set sender of mail. More...
 
 getSender ()
 get sender of mail More...
 
 setRecipients (array $a_rcp)
 
 getRecipients ()
 get array of recipients More...
 
 setAttachments ($a_att)
 Set attachments. More...
 
 getAttachments ()
 Get attachments. More...
 
 setLangModules (array $a_modules)
 Set lang modules. More...
 
 getUserLanguage ($a_usr_id)
 Get user language. More...
 
 setRefId ($a_id)
 
 getRefId ()
 
 getObjId ()
 
 setObjId ($a_obj_id)
 
 getObjType ()
 Get object type. More...
 
 setAdditionalInformation (array $a_info)
 Additional information for creating notification mails. More...
 
 getAdditionalInformation ()
 
 sendMail (array $a_rcp, $a_parse_recipients=true)
 
 getBlockBorder ()
 Get (ascii) block border. More...
 

Data Fields

const MODE_DIRECT_REGISTRATION = 1
 
const MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION = 2
 
- Data Fields inherited from ilMailNotification
const SUBJECT_TITLE_LENGTH = 60
 

Private Member Functions

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

Private Attributes

 $settings
 
 $lng
 
 $logger
 
 $mode = self::MODE_DIRECT_REGISTRATION
 

Additional Inherited Members

- Protected Member Functions inherited from ilMimeMailNotification
 initLanguageByIso2Code ($a_code='')
 
 initLanguage ($a_usr_id)
 
- Protected Member Functions inherited from ilMailNotification
 setSubject ($a_subject)
 
 getSubject ()
 
 setBody ($a_body)
 
 appendBody ($a_body)
 Append body text. More...
 
 getBody ()
 
 initLanguage ($a_usr_id)
 Init language. More...
 
 initLanguageByIso2Code ($a_code='')
 Init language by ISO2 code. More...
 
 setLanguage ($a_language)
 
 getLanguage ()
 
 getLanguageText ($a_keyword)
 
 getObjectTitle ($a_shorten=false)
 
 initMail ()
 
 getMail ()
 
 createPermanentLink ($a_params=array(), $a_append='')
 
 userToString ($a_usr_id)
 
 isRefIdAccessible ($a_user_id, $a_ref_id, $a_permission="read")
 Check if ref id is accessible for user. More...
 
- Protected Attributes inherited from ilMimeMailNotification
 $mime_mail
 
 $current_recipient
 
- Protected Attributes inherited from ilMailNotification
 $type = null
 
 $sender = null
 
 $mail = null
 
 $subject = ''
 
 $body = ''
 
 $attachments = array()
 
 $language = null
 
 $lang_modules = array()
 
 $recipients = array()
 
 $ref_id = null
 
 $obj_id = null
 
 $obj_type = null
 
 $additional_info = array()
 
 $is_in_wsp
 
 $wsp_tree
 
 $wsp_access_handler
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAccountRegistrationMail::__construct ( ilRegistrationSettings  $settings,
ilLanguage  $lng,
ilLogger  $logger 
)

ilAccountRegistrationMail constructor.

Parameters
ilRegistrationSettings$settings
ilLanguage$lng
ilLogger$logger

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

References $lng, $logger, $settings, ILIAS\GlobalScreen\Provider\__construct(), and settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ getMode()

ilAccountRegistrationMail::getMode ( )
Returns
int

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

References $mode.

Referenced by sendLanguageVariableBasedAccountMail().

+ Here is the caller graph for this function:

◆ isEmptyMailConfigurationData()

ilAccountRegistrationMail::isEmptyMailConfigurationData (   $mailData)
private
Parameters
$mailData
Returns
bool

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

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

Referenced by trySendingUserDefinedAccountMail().

+ Here is the caller graph for this function:

◆ send()

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

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

258 {
259 if (!$this->trySendingUserDefinedAccountMail($user, $rawPassword)) {
260 $this->sendLanguageVariableBasedAccountMail($user, $rawPassword, $usedRegistrationCode);
261 }
262 }
sendLanguageVariableBasedAccountMail(ilObjUser $user, $rawPassword, $usedRegistrationCode)
trySendingUserDefinedAccountMail(ilObjUser $user, $rawPassword)

References sendLanguageVariableBasedAccountMail(), and trySendingUserDefinedAccountMail().

+ Here is the call graph for this function:

◆ sendLanguageVariableBasedAccountMail()

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

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

189 {
190 if (!$user->getEmail()) {
191 $this->logger->debug(sprintf(
192 "Missing email address, did not send account registration mail for user %s (id: %s) ...",
193 $user->getLogin(),
194 $user->getId()
195 ));
196 return;
197 }
198
199 $this->logger->debug(sprintf(
200 "Sending language variable dependent welcome email to user %s (id: %s|language: %s) as fallback ...",
201 $user->getLogin(),
202 $user->getId(),
203 $user->getLanguage()
204 ));
205
206 $this->initMimeMail();
207
208 $this->initLanguageByIso2Code($user->getLanguage());
209
210 $this->setSubject($this->language->txt('reg_mail_subject'));
211
212 $this->setBody($this->language->txt('reg_mail_body_salutation') . ' ' . $user->getFullname() . ',');
213 $this->appendBody("\n\n");
214 $this->appendBody($this->language->txt('reg_mail_body_text1'));
215 $this->appendBody("\n\n");
216 $this->appendBody($this->language->txt('reg_mail_body_text2'));
217 $this->appendBody("\n");
218 $this->appendBody(ILIAS_HTTP_PATH . '/login.php?client_id=' . CLIENT_ID);
219 $this->appendBody("\n");
220 $this->appendBody($this->language->txt('login') . ': ' . $user->getLogin());
221 $this->appendBody("\n");
222
223 if ($this->settings->passwordGenerationEnabled()) {
224 $this->appendBody($this->language->txt('passwd') . ': ' . $rawPassword);
225 $this->appendBody("\n");
226 }
227
228 if ($this->getMode() === self::MODE_DIRECT_REGISTRATION) {
229 if ($this->settings->getRegistrationType() == IL_REG_APPROVE && !$usedRegistrationCode) {
230 $this->appendBody("\n");
231 $this->appendBody($this->language->txt('reg_mail_body_pwd_generation'));
232 $this->appendBody("\n\n");
233 }
234 } elseif ($this->getMode() === self::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION) {
235 $this->appendBody("\n");
236 $this->appendBody($this->language->txt('reg_mail_body_forgot_password_info'));
237 $this->appendBody("\n\n");
238 }
239
240 $this->appendBody($this->language->txt('reg_mail_body_text3'));
241 $this->appendBody("\n");
242 $this->appendBody($user->getProfileAsString($this->language));
244
245 $this->sendMimeMail($user->getEmail());
246
247 $this->logger->debug(sprintf(
248 "Welcome email sent"
249 ));
250 }
appendBody($a_body)
Append body text.
static _getInstallationSignature()
getEmail()
get email address @access public
getLogin()
get login / username @access public
getFullname($a_max_strlen=0)
get fullname @access public
getLanguage()
returns a 2char-language-string @access public
getId()
get object id @access public
const CLIENT_ID
Definition: constants.php:39
language()
Definition: language.php:2

References ilMail\_getInstallationSignature(), ilMailNotification\appendBody(), CLIENT_ID, ilObjUser\getEmail(), ilObjUser\getFullname(), ilObject\getId(), ilObjUser\getLanguage(), ilObjUser\getLogin(), getMode(), IL_REG_APPROVE, ilMimeMailNotification\initLanguageByIso2Code(), language(), ilMimeMailNotification\sendMimeMail(), ilMailNotification\setBody(), ilMailNotification\setSubject(), and settings().

Referenced by send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trySendingUserDefinedAccountMail()

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

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

92 {
93 $trimStrings = function ($value) {
94 if (is_string($value)) {
95 $value = trim($value);
96 }
97
98 return $value;
99 };
100
101 $this->logger->debug(sprintf(
102 "Trying to send configurable email dependent welcome email to user %s (id: %s|language: %s) ...",
103 $user->getLogin(),
104 $user->getId(),
105 $user->getLanguage()
106 ));
107
109 if (!is_array($mailData)) {
110 $this->logger->debug(sprintf(
111 "Did not find any email configuration for language '%s' at all, skipping attempt ...",
112 $user->getLanguage()
113 ));
114 return false;
115 }
116
117 $mailData = array_map($trimStrings, $mailData);
118
119 if ($this->isEmptyMailConfigurationData($mailData)) {
120 $this->logger->debug(sprintf(
121 "Either subject or email missing, trying to determine email configuration via default language: %s",
122 $this->language->getDefaultLanguage()
123 ));
124
125 $mailData = ilObjUserFolder::_lookupNewAccountMail($this->language->getDefaultLanguage());
126 if (!is_array($mailData)) {
127 $this->logger->debug(sprintf(
128 "Did not find any email configuration for language '%s' at all, skipping attempt ...",
129 $this->language->getDefaultLanguage()
130 ));
131 return false;
132 }
133
134 $mailData = array_map($trimStrings, $mailData);
135 if ($this->isEmptyMailConfigurationData($mailData)) {
136 $this->logger->debug(sprintf(
137 "Did not find any valid email configuration, skipping attempt ..."
138 ));
139 return false;
140 }
141 }
142
143 $accountMail = new ilAccountMail();
144 $accountMail->setUser($user);
145
146 if ($this->settings->passwordGenerationEnabled()) {
147 $accountMail->setUserPassword($rawPassword);
148 }
149
150 if (isset($mailData['att_file'])) {
152 $fs->create();
153
154 $pathToFile = '/' . implode('/', array_map(function ($pathPart) {
155 return trim($pathPart, '/');
156 }, [
157 $fs->getAbsolutePath(),
158 $mailData['lang'],
159 ]));
160
161 $accountMail->addAttachment($pathToFile, $mailData['att_file']);
162
163 $this->logger->debug(sprintf(
164 "Attaching '%s' as '%s' ...",
165 $pathToFile,
166 $mailData['att_file']
167 ));
168 } else {
169 $this->logger->debug(sprintf(
170 "Not attachments configured for this email configuration ..."
171 ));
172 }
173
174 $accountMail->send();
175
176 $this->logger->debug(sprintf(
177 "Welcome email sent"
178 ));
179
180 return true;
181 }
Class ilAccountMail.
static _lookupNewAccountMail($a_lang)
const USER_FOLDER_ID
Definition: constants.php:31

References ilObjUserFolder\_lookupNewAccountMail(), ilObject\getId(), ilObjUser\getLanguage(), ilObjUser\getLogin(), isEmptyMailConfigurationData(), language(), settings(), and USER_FOLDER_ID.

Referenced by send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withDirectRegistrationMode()

ilAccountRegistrationMail::withDirectRegistrationMode ( )
Returns
\ilAccountRegistrationMail

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

52 {
53 $clone = clone $this;
54 $clone->mode = self::MODE_DIRECT_REGISTRATION;
55
56 return $clone;
57 }

References MODE_DIRECT_REGISTRATION.

◆ withEmailConfirmationRegistrationMode()

ilAccountRegistrationMail::withEmailConfirmationRegistrationMode ( )
Returns
\ilAccountRegistrationMail

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

63 {
64 $clone = clone $this;
66
67 return $clone;
68 }

References MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION.

Field Documentation

◆ $lng

ilAccountRegistrationMail::$lng
private

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

Referenced by __construct().

◆ $logger

ilAccountRegistrationMail::$logger
private

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

Referenced by __construct().

◆ $mode

ilAccountRegistrationMail::$mode = self::MODE_DIRECT_REGISTRATION
private

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

Referenced by getMode().

◆ $settings

ilAccountRegistrationMail::$settings
private

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

Referenced by __construct().

◆ MODE_DIRECT_REGISTRATION

const ilAccountRegistrationMail::MODE_DIRECT_REGISTRATION = 1

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

Referenced by withDirectRegistrationMode().

◆ MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION

const ilAccountRegistrationMail::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION = 2

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