ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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_type, $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, and settings().

32  {
33  $this->settings = $settings;
34  $this->lng = $lng;
35  $this->logger = $logger;
36 
37  parent::__construct(false);
38  }
settings()
Definition: settings.php:2
+ 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.

Referenced by trySendingUserDefinedAccountMail().

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  }
+ 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 248 of file class.ilAccountRegistrationMail.php.

References sendLanguageVariableBasedAccountMail(), and trySendingUserDefinedAccountMail().

249  {
250  if (!$this->trySendingUserDefinedAccountMail($user, $rawPassword)) {
251  $this->sendLanguageVariableBasedAccountMail($user, $rawPassword, $usedRegistrationCode);
252  }
253  }
sendLanguageVariableBasedAccountMail(ilObjUser $user, $rawPassword, $usedRegistrationCode)
trySendingUserDefinedAccountMail(ilObjUser $user, $rawPassword)
+ 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.

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

Referenced by send().

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

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

Referenced by send().

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  }
getLogin()
get login / username public
getId()
get object id public
static _lookupNewAccountMail($a_lang)
settings()
Definition: settings.php:2
Class ilAccountMail.
const USER_FOLDER_ID
Class ilObjUserFolder.
getLanguage()
returns a 2char-language-string public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withDirectRegistrationMode()

ilAccountRegistrationMail::withDirectRegistrationMode ( )
Returns

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  }

◆ withEmailConfirmationRegistrationMode()

ilAccountRegistrationMail::withEmailConfirmationRegistrationMode ( )
Returns

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

63  {
64  $clone = clone $this;
65  $clone->mode = self::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION;
66 
67  return $clone;
68  }

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.

◆ MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION

const ilAccountRegistrationMail::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION = 2

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


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