diff options
Diffstat (limited to 'inc/poche/Poche.class.php')
-rwxr-xr-x | inc/poche/Poche.class.php | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index b26826f1..8ade91b4 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -81,25 +81,40 @@ class Poche | |||
81 | $email = filter_var($email, FILTER_SANITIZE_STRING); | 81 | $email = filter_var($email, FILTER_SANITIZE_STRING); |
82 | if (!$this->store->userExists($newUsername)){ | 82 | if (!$this->store->userExists($newUsername)){ |
83 | if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername), $email)) { | 83 | if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername), $email)) { |
84 | if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) { | 84 | if ($email != "") { // if email is filled |
85 | // if internal registration | 85 | if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) { |
86 | $body_internal = "Hi,\r\n\r\nSomeone just created an account for you on " . Tools::getPocheUrl() . ".\r\nHave fun with it !"; | 86 | |
87 | // if external (public) registration | 87 | // if internal registration |
88 | $body = "Hi, \r\n\r\nYou've just created an account on " . Tools::getPocheUrl() . ".\r\nHave fun with it !"; | 88 | $body_internal = _('Hi,') . "\r\n\r\n" . sprintf(_('Someone just created a wallabag account for you on %1$s.'), Tools::getPocheUrl()) . |
89 | $body = $internalRegistration ? $body_internal : $body; | 89 | "\r\n\r\n" . sprintf(_('Your login is %1$s.'), $newUsername) ."\r\n\r\n" . |
90 | $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard) | 90 | _('Note : The password has been chosen by the person who created your account. Get in touch with that person to know your password and change it as soon as possible') . "\r\n\r\n" . |
91 | if (mail($email, sprintf(_('Your new wallabag account on '), Tools::getPocheUrl()), $body, 'X-Mailer: PHP/' . phpversion())) { | 91 | _('Have fun with it !') . "\r\n\r\n" . |
92 | Tools::logm('The user ' . $newUsername . ' has been emailed'); | 92 | _('This is an automatically generated message, no one will answer if you respond to it.'); |
93 | $this->messages->add('i', sprintf(_('The new user %1$s has been sent an email at %2$s.'), $newUsername, $email)); | ||
94 | 93 | ||
94 | // if external (public) registration | ||
95 | $body = "Hi, " . $newUsername . "\r\n\r\nYou've just created a wallabag account on " . Tools::getPocheUrl() . ".\r\nHave fun with it !"; | ||
96 | $body = $internalRegistration ? $body_internal : $body; | ||
97 | |||
98 | $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard) | ||
99 | if (mail($email, sprintf(_('Your new wallabag account on %1$s'), Tools::getPocheUrl()), $body, | ||
100 | 'X-Mailer: PHP/' . phpversion() . "\r\n" . | ||
101 | 'Content-type: text/plain; charset=UTF-8' . "\r\n" . | ||
102 | "From: " . $newUsername . "@" . gethostname() . "\r\n")) { | ||
103 | Tools::logm('The user ' . $newUsername . ' has been emailed'); | ||
104 | $this->messages->add('i', sprintf(_('The new user %1$s has been sent an email at %2$s. You may have to check spam folder.'), $newUsername, $email)); | ||
105 | |||
106 | } else { | ||
107 | Tools::logm('A problem has been encountered while sending an email'); | ||
108 | $this->messages->add('e', _('A problem has been encountered while sending an email')); | ||
109 | } | ||
95 | } else { | 110 | } else { |
96 | Tools::logm('A problem has been encountered while sending an email'); | 111 | Tools::logm('The user has been created, but the server did not authorize sending emails'); |
97 | $this->messages->add('e', _('A problem has been encountered while sending an email')); | 112 | $this->messages->add('i', _('The server did not authorize sending a confirmation email')); |
98 | } | 113 | } |
99 | } else { | 114 | } else { |
100 | Tools::logm('The user has been created, but the server did not authorize sending emails'); | 115 | Tools::logm('The user has been created, but no email was saved, so no confimation email was sent'); |
101 | $this->messages->add('i', _('The server did not authorize sending an email')); | 116 | $this->messages->add('i', _('The user was created, but no email was sent because email was not filled in')); |
102 | } | 117 | } |
103 | Tools::logm('The new user ' . $newUsername . ' has been installed'); | 118 | Tools::logm('The new user ' . $newUsername . ' has been installed'); |
104 | $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername)); | 119 | $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername)); |
105 | Tools::redirect(); | 120 | Tools::redirect(); |