ILIAS  trunk Revision v11.0_alpha-1871-gde1fee8db3d
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilAccountRegistrationMail Class Reference

Class ilAccountRegistrationMail. More...

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

Public Member Functions

 __construct (ilRegistrationSettings $settings, ilLanguage $lng, ilLogger $logger)
 
 getMode ()
 
 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 $senderFactory
 
- 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

ilRegistrationSettings $settings
 
ilLogger $logger
 
int $mode = self::MODE_DIRECT_REGISTRATION
 

Additional Inherited Members

- Data Fields inherited from ilMailNotification
final const 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 ( ilRegistrationSettings  $settings,
ilLanguage  $lng,
ilLogger  $logger 
)

Member Function Documentation

◆ getMode()

ilAccountRegistrationMail::getMode ( )

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

References $mode.

Referenced by sendLanguageVariableBasedAccountMail().

41  : int
42  {
43  return $this->mode;
44  }
+ Here is the caller graph for this function:

◆ isEmptyMailConfigurationData()

ilAccountRegistrationMail::isEmptyMailConfigurationData ( array  $mailData)
private

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

Referenced by trySendingUserDefinedAccountMail().

60  : bool
61  {
62  return !(
63  isset($mailData['body'], $mailData['subject']) &&
64  is_string($mailData['body']) &&
65  $mailData['body'] !== '' &&
66  is_string($mailData['subject']) &&
67  $mailData['subject'] !== ''
68  );
69  }
+ Here is the caller graph for this function:

◆ send()

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

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

References sendLanguageVariableBasedAccountMail(), and trySendingUserDefinedAccountMail().

213  : void
214  {
215  if (!$this->trySendingUserDefinedAccountMail($user, $rawPassword)) {
216  $this->sendLanguageVariableBasedAccountMail($user, $rawPassword, $usedRegistrationCode);
217  }
218  }
sendLanguageVariableBasedAccountMail(ilObjUser $user, string $rawPassword, bool $usedRegistrationCode)
trySendingUserDefinedAccountMail(ilObjUser $user, string $rawPassword)
+ Here is the call graph for this function:

◆ sendLanguageVariableBasedAccountMail()

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

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

References ilMail\_getInstallationSignature(), ilMailNotification\appendBody(), CLIENT_ID, ilObjUser\getEmail(), ilObjUser\getFullname(), ilObject\getId(), ilObjUser\getLanguage(), ilObjUser\getLogin(), getMode(), ilRegistrationSettings\IL_REG_APPROVE, ilMimeMailNotification\initLanguageByIso2Code(), ilMimeMailNotification\initMimeMail(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\logger(), ilMimeMailNotification\sendMimeMail(), ilMailNotification\setBody(), ilMimeMailNotification\setSubject(), and ILIAS\Repository\settings().

Referenced by send().

152  : void {
153  if (!$user->getEmail()) {
154  $this->logger->debug(sprintf(
155  "Missing email address, did not send account registration mail for user %s (id: %s) ...",
156  $user->getLogin(),
157  $user->getId()
158  ));
159  return;
160  }
161 
162  $this->logger->debug(sprintf(
163  "Sending language variable dependent welcome email to user %s (id: %s|language: %s) as fallback ...",
164  $user->getLogin(),
165  $user->getId(),
166  $user->getLanguage()
167  ));
168 
169  $this->initMimeMail();
170 
171  $this->initLanguageByIso2Code($user->getLanguage());
172 
173  $this->setSubject($this->language->txt('reg_mail_subject'));
174 
175  $this->setBody($this->language->txt('reg_mail_body_salutation') . ' ' . $user->getFullname() . ',');
176  $this->appendBody("\n\n");
177  $this->appendBody($this->language->txt('reg_mail_body_text1'));
178  $this->appendBody("\n\n");
179  $this->appendBody($this->language->txt('reg_mail_body_text2'));
180  $this->appendBody("\n");
181  $this->appendBody(ILIAS_HTTP_PATH . '/login.php?client_id=' . CLIENT_ID);
182  $this->appendBody("\n");
183  $this->appendBody($this->language->txt('login') . ': ' . $user->getLogin());
184  $this->appendBody("\n");
185 
186  if ($this->settings->passwordGenerationEnabled()) {
187  $this->appendBody($this->language->txt('passwd') . ': ' . $rawPassword);
188  $this->appendBody("\n");
189  }
190 
191  if ($this->getMode() === self::MODE_DIRECT_REGISTRATION) {
192  if ($this->settings->getRegistrationType() === ilRegistrationSettings::IL_REG_APPROVE && !$usedRegistrationCode) {
193  $this->appendBody("\n");
194  $this->appendBody($this->language->txt('reg_mail_body_pwd_generation'));
195  $this->appendBody("\n\n");
196  }
197  } elseif ($this->getMode() === self::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION) {
198  $this->appendBody("\n");
199  $this->appendBody($this->language->txt('reg_mail_body_forgot_password_info'));
200  $this->appendBody("\n\n");
201  }
202 
203  $this->appendBody($this->language->txt('reg_mail_body_text3'));
204  $this->appendBody("\n");
205  $this->appendBody($user->getProfileAsString($this->language));
207 
208  $this->sendMimeMail($user->getEmail());
209 
210  $this->logger->debug("Welcome email sent");
211  }
getFullname(int $a_max_strlen=0)
const CLIENT_ID
Definition: constants.php:41
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
static _getInstallationSignature()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trySendingUserDefinedAccountMail()

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

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

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

Referenced by send().

71  : bool
72  {
73  $trimStrings = static function ($value) {
74  if (is_string($value)) {
75  $value = trim($value);
76  }
77 
78  return $value;
79  };
80 
81  $this->logger->debug(sprintf(
82  "Trying to send configurable email dependent welcome email to user %s (id: %s|language: %s) ...",
83  $user->getLogin(),
84  $user->getId(),
85  $user->getLanguage()
86  ));
87 
88  $mailData = array_map($trimStrings, ilObjUserFolder::_lookupNewAccountMail($user->getLanguage()));
89 
90  if ($this->isEmptyMailConfigurationData($mailData)) {
91  $this->logger->debug(sprintf(
92  "Either subject or email missing, trying to determine email configuration via default language: %s",
93  $this->language->getDefaultLanguage()
94  ));
95 
96  $mailData = ilObjUserFolder::_lookupNewAccountMail($this->language->getDefaultLanguage());
97  if (!is_array($mailData)) {
98  $this->logger->debug(sprintf(
99  "Did not find any email configuration for language '%s' at all, skipping attempt ...",
100  $this->language->getDefaultLanguage()
101  ));
102  return false;
103  }
104 
105  $mailData = array_map($trimStrings, $mailData);
106  if ($this->isEmptyMailConfigurationData($mailData)) {
107  $this->logger->debug("Did not find any valid email configuration, skipping attempt ...");
108  return false;
109  }
110  }
111 
112  $accountMail = new ilAccountMail();
113  $accountMail->setUser($user);
114 
115  if ($this->settings->passwordGenerationEnabled()) {
116  $accountMail->setUserPassword($rawPassword);
117  }
118 
119  if (isset($mailData['att_file'])) {
121  $fs->create();
122 
123  $pathToFile = '/' . implode('/', array_map(static function (string $pathPart): string {
124  return trim($pathPart, '/');
125  }, [
126  $fs->getAbsolutePath(),
127  $mailData['lang'],
128  ]));
129 
130  $accountMail->addAttachment($pathToFile, $mailData['att_file']);
131 
132  $this->logger->debug(sprintf(
133  "Attaching '%s' as '%s' ...",
134  $pathToFile,
135  $mailData['att_file']
136  ));
137  } else {
138  $this->logger->debug("Not attachments configured for this email configuration ...");
139  }
140 
141  $accountMail->send();
142 
143  $this->logger->debug("Welcome email sent");
144 
145  return true;
146  }
const USER_FOLDER_ID
Definition: constants.php:33
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupNewAccountMail(string $a_lang)
Class ilAccountMail.
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withDirectRegistrationMode()

ilAccountRegistrationMail::withDirectRegistrationMode ( )

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

47  {
48  $clone = clone $this;
49  $clone->mode = self::MODE_DIRECT_REGISTRATION;
50  return $clone;
51  }
Class ilAccountRegistrationMail.

◆ withEmailConfirmationRegistrationMode()

ilAccountRegistrationMail::withEmailConfirmationRegistrationMode ( )

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

54  {
55  $clone = clone $this;
56  $clone->mode = self::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION;
57  return $clone;
58  }
Class ilAccountRegistrationMail.

Field Documentation

◆ $logger

ilLogger ilAccountRegistrationMail::$logger
private

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

Referenced by __construct().

◆ $mode

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

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

Referenced by getMode().

◆ $settings

ilRegistrationSettings ilAccountRegistrationMail::$settings
private

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

Referenced by __construct().

◆ MODE_DIRECT_REGISTRATION

const ilAccountRegistrationMail::MODE_DIRECT_REGISTRATION = 1
protected

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

◆ MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION

const ilAccountRegistrationMail::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION = 2
protected

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


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