aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Poche.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche/Poche.class.php')
-rwxr-xr-xinc/poche/Poche.class.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 8ade91b4..6d4ce137 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -76,6 +76,7 @@ class Poche
76 */ 76 */
77 public function createNewUser($username, $password, $email = "", $internalRegistration = false) 77 public function createNewUser($username, $password, $email = "", $internalRegistration = false)
78 { 78 {
79 Tools::logm('Trying to create a new user...');
79 if (!empty($username) && !empty($password)){ 80 if (!empty($username) && !empty($password)){
80 $newUsername = filter_var($username, FILTER_SANITIZE_STRING); 81 $newUsername = filter_var($username, FILTER_SANITIZE_STRING);
81 $email = filter_var($email, FILTER_SANITIZE_STRING); 82 $email = filter_var($email, FILTER_SANITIZE_STRING);
@@ -84,7 +85,7 @@ class Poche
84 if ($email != "") { // if email is filled 85 if ($email != "") { // if email is filled
85 if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) { 86 if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) {
86 87
87 // if internal registration 88 // if internal registration from config screen
88 $body_internal = _('Hi,') . "\r\n\r\n" . sprintf(_('Someone just created a wallabag account for you on %1$s.'), Tools::getPocheUrl()) . 89 $body_internal = _('Hi,') . "\r\n\r\n" . sprintf(_('Someone just created a wallabag account for you on %1$s.'), Tools::getPocheUrl()) .
89 "\r\n\r\n" . sprintf(_('Your login is %1$s.'), $newUsername) ."\r\n\r\n" . 90 "\r\n\r\n" . sprintf(_('Your login is %1$s.'), $newUsername) ."\r\n\r\n" .
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 _('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" .
@@ -92,7 +93,10 @@ class Poche
92 _('This is an automatically generated message, no one will answer if you respond to it.'); 93 _('This is an automatically generated message, no one will answer if you respond to it.');
93 94
94 // if external (public) registration 95 // 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 = sprintf(_('Hi, %1$s'), $newUsername) . "\r\n\r\n" .
97 sprintf(_('You\'ve just created a wallabag account on %1$s.'), Tools::getPocheUrl()) .
98 "\r\n\r\n" . _("Have fun with it !");
99
96 $body = $internalRegistration ? $body_internal : $body; 100 $body = $internalRegistration ? $body_internal : $body;
97 101
98 $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard) 102 $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard)
@@ -102,6 +106,7 @@ class Poche
102 "From: " . $newUsername . "@" . gethostname() . "\r\n")) { 106 "From: " . $newUsername . "@" . gethostname() . "\r\n")) {
103 Tools::logm('The user ' . $newUsername . ' has been emailed'); 107 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)); 108 $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));
109 Tools::redirect('?');
105 110
106 } else { 111 } else {
107 Tools::logm('A problem has been encountered while sending an email'); 112 Tools::logm('A problem has been encountered while sending an email');
@@ -109,14 +114,16 @@ class Poche
109 } 114 }
110 } else { 115 } else {
111 Tools::logm('The user has been created, but the server did not authorize sending emails'); 116 Tools::logm('The user has been created, but the server did not authorize sending emails');
112 $this->messages->add('i', _('The server did not authorize sending a confirmation email')); 117 $this->messages->add('i', _('The server did not authorize sending a confirmation email, but the user was created.'));
113 } 118 }
114 } else { 119 } else {
115 Tools::logm('The user has been created, but no email was saved, so no confimation email was sent'); 120 Tools::logm('The user has been created, but no email was saved, so no confimation email was sent');
116 $this->messages->add('i', _('The user was created, but no email was sent because email was not filled in')); 121 $this->messages->add('i', _('The user was created, but no email was sent because email was not filled in'));
117 } 122 }
118 Tools::logm('The new user ' . $newUsername . ' has been installed'); 123 Tools::logm('The new user ' . $newUsername . ' has been installed');
119 $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername)); 124 if (\Session::isLogged()) {
125 $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername));
126 }
120 Tools::redirect(); 127 Tools::redirect();
121 } 128 }
122 else { 129 else {
@@ -130,6 +137,9 @@ class Poche
130 Tools::redirect(); 137 Tools::redirect();
131 } 138 }
132 } 139 }
140 else {
141 Tools::logm('Password or username were empty');
142 }
133 } 143 }
134 144
135 /** 145 /**