diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index d096de914..8ade91b48 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -74,16 +74,50 @@ class Poche /** * Creates a new user */ - public function createNewUser($username, $password, $email = "") + public function createNewUser($username, $password, $email = "", $internalRegistration = false) { if (!empty($username) && !empty($password)){ $newUsername = filter_var($username, FILTER_SANITIZE_STRING); $email = filter_var($email, FILTER_SANITIZE_STRING); if (!$this->store->userExists($newUsername)){ if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername), $email)) { - Tools::logm('The new user ' . $newUsername . ' has been installed'); - $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to logout ?'), $newUsername)); - Tools::redirect(); + if ($email != "") { // if email is filled + if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) { + + // if internal registration + $body_internal = _('Hi,') . "\r\n\r\n" . sprintf(_('Someone just created a wallabag account for you on %1$s.'), Tools::getPocheUrl()) . + "\r\n\r\n" . sprintf(_('Your login is %1$s.'), $newUsername) ."\r\n\r\n" . + _('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" . + _('Have fun with it !') . "\r\n\r\n" . + _('This is an automatically generated message, no one will answer if you respond to it.'); + + // if external (public) registration + $body = "Hi, " . $newUsername . "\r\n\r\nYou've just created a wallabag account on " . Tools::getPocheUrl() . ".\r\nHave fun with it !"; + $body = $internalRegistration ? $body_internal : $body; + + $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard) + if (mail($email, sprintf(_('Your new wallabag account on %1$s'), Tools::getPocheUrl()), $body, + 'X-Mailer: PHP/' . phpversion() . "\r\n" . + 'Content-type: text/plain; charset=UTF-8' . "\r\n" . + "From: " . $newUsername . "@" . gethostname() . "\r\n")) { + Tools::logm('The user ' . $newUsername . ' has been emailed'); + $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)); + + } else { + Tools::logm('A problem has been encountered while sending an email'); + $this->messages->add('e', _('A problem has been encountered while sending an email')); + } + } else { + Tools::logm('The user has been created, but the server did not authorize sending emails'); + $this->messages->add('i', _('The server did not authorize sending a confirmation email')); + } + } else { + Tools::logm('The user has been created, but no email was saved, so no confimation email was sent'); + $this->messages->add('i', _('The user was created, but no email was sent because email was not filled in')); + } + Tools::logm('The new user ' . $newUsername . ' has been installed'); + $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to logout ?'), $newUsername)); + Tools::redirect(); } else { Tools::logm('error during adding new user'); diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php index 709831d50..82ff20d67 100755 --- a/inc/poche/Routing.class.php +++ b/inc/poche/Routing.class.php @@ -117,7 +117,7 @@ class Routing // update password $this->wallabag->updatePassword($_POST['password'], $_POST['password_repeat']); } elseif (isset($_GET['newuser'])) { - $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser'], $_POST['newuseremail']); + $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser'], $_POST['newuseremail'], true); } elseif (isset($_GET['deluser'])) { $this->wallabag->deleteUser($_POST['password4deletinguser']); } elseif (isset($_GET['epub'])) { diff --git a/inc/poche/config.inc.default.php b/inc/poche/config.inc.default.php index 91b50c244..fbf4ae9a5 100755 --- a/inc/poche/config.inc.default.php +++ b/inc/poche/config.inc.default.php @@ -59,6 +59,9 @@ @define ('MOBI', FALSE); @define ('PDF', FALSE); +// registration +@define ('SEND_CONFIRMATION_EMAIL', TRUE); + // display or not print link in article view @define ('SHOW_PRINTLINK', '1'); // display or not percent of read in article view. Affects only default theme. diff --git a/locale/en_US.utf8/LC_MESSAGES/en_US.utf8.mo b/locale/en_US.utf8/LC_MESSAGES/en_US.utf8.mo index 77dee0708..025231250 100644 Binary files a/locale/en_US.utf8/LC_MESSAGES/en_US.utf8.mo and b/locale/en_US.utf8/LC_MESSAGES/en_US.utf8.mo differ diff --git a/locale/en_US.utf8/LC_MESSAGES/en_US.utf8.po b/locale/en_US.utf8/LC_MESSAGES/en_US.utf8.po index 579d1acad..75dad661e 100644 --- a/locale/en_US.utf8/LC_MESSAGES/en_US.utf8.po +++ b/locale/en_US.utf8/LC_MESSAGES/en_US.utf8.po @@ -663,6 +663,56 @@ msgstr "Download the articles from this search in an EPUB" msgid "Download the articles from this category in an epub" msgstr "Download the articles from this category in an EPUB" +# registration +msgid "Hi," +msgstr "Hi," + +msgid "Hi, %1$s" +msgstr "Hi, %1$s" + +msgid "Someone just created a wallabag account for you on %1$s." +msgstr "Someone just created a wallabag account for you on %1$s." + +msgid "Your login is %1$s." +msgstr "Your login is %1$s." + +msgid "Have fun with it !" +msgstr "Have fun with it !" + +msgid "" +"This is an automatically generated message, no one will answer if you " +"respond to it." +msgstr "" +"This is an automatically generated message, no one will answer if you " +"respond to it." + +msgid "" +"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" +msgstr "" +"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" + +msgid "" +"The new user %1$s has been sent an email at %2$s. You may have to check spam " +"folder." +msgstr "" +"The new user %1$s has been sent an email at %2$s. You may have to check spam " +"folder." + +msgid "A problem has been encountered while sending the confirmation email" +msgstr "A problem has been encountered while sending an confirmation email" + +msgid "The server did not authorize sending a confirmation email" +msgstr "The server did not authorize sending a confirmation email" + +msgid "" +"The user was created, but no email was sent because email was not filled in" +msgstr "" +"The user was created, but no email was sent because email was not filled in" + #~ msgid "poche it!" #~ msgstr "poche it!" diff --git a/locale/fr_FR.utf8/LC_MESSAGES/fr_FR.utf8.mo b/locale/fr_FR.utf8/LC_MESSAGES/fr_FR.utf8.mo index 83f397a05..b3b2f6fed 100644 Binary files a/locale/fr_FR.utf8/LC_MESSAGES/fr_FR.utf8.mo and b/locale/fr_FR.utf8/LC_MESSAGES/fr_FR.utf8.mo differ diff --git a/locale/fr_FR.utf8/LC_MESSAGES/fr_FR.utf8.po b/locale/fr_FR.utf8/LC_MESSAGES/fr_FR.utf8.po index fef312083..948a83564 100644 --- a/locale/fr_FR.utf8/LC_MESSAGES/fr_FR.utf8.po +++ b/locale/fr_FR.utf8/LC_MESSAGES/fr_FR.utf8.po @@ -789,6 +789,58 @@ msgstr "" msgid "Produced by wallabag with PHPMobi" msgstr "Produit par wallabag avec PHPMobi" +# registration +msgid "Hi," +msgstr "Salut," + +msgid "Hi, %1$s" +msgstr "Salut, %1$s" + +msgid "Someone just created a wallabag account for you on %1$s." +msgstr "" +"Quelqu'un vient juste de créer un compte wallabag pour vous à l'adresse %1$s." + +msgid "Your login is %1$s." +msgstr "Votre identifiant is %1$s." + +msgid "Have fun with it !" +msgstr "Amusez-vous bien !" + +msgid "" +"This is an automatically generated message, no one will answer if you " +"respond to it." +msgstr "" +"Ceci est un message généré automatiquement, personne ne vous répondra si " +"vous y répondez." + +msgid "" +"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" +msgstr "" +"Note : Votre mot de passe a été défini par la personne ayant créé votre " +"compte. Vous devriez entrer en contact avec cette personne pour connaître " +"votre mot de passe et le changer dès que possible" + +msgid "" +"The new user %1$s has been sent an email at %2$s. You may have to check spam " +"folder." +msgstr "" +"Un email a été envoyé au nouvel utiliateur %1$s à l'adresse %2$s. Il peut " +"être nécessaire de vérifier le dossier des spams." + +msgid "A problem has been encountered while sending the confirmation email" +msgstr "Un problème a été rencontré lors de l'envoi de l'email de confirmation" + +msgid "The server did not authorize sending a confirmation email" +msgstr "Le serveur n'autorise pas l'envoi d'un email de confirmation" + +msgid "" +"The user was created, but no email was sent because email was not filled in" +msgstr "" +"L'utilisateur a été créé, mais aucun mail n'a été envoyé car l'email n'était " +"pas renseigné" + msgid "Mail function is disabled. You can't send emails from your server" msgstr "" "La fonction mail est désactivée. Vous ne pouvez pas envoyer d'E-mails depuis "