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.php27
1 files changed, 23 insertions, 4 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 81a18c86..adb335c9 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -74,16 +74,35 @@ class Poche
74 /** 74 /**
75 * Creates a new user 75 * Creates a new user
76 */ 76 */
77 public function createNewUser($username, $password, $email = "") 77 public function createNewUser($username, $password, $email = "", $internalRegistration = false)
78 { 78 {
79 if (!empty($username) && !empty($password)){ 79 if (!empty($username) && !empty($password)){
80 $newUsername = filter_var($username, FILTER_SANITIZE_STRING); 80 $newUsername = filter_var($username, FILTER_SANITIZE_STRING);
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 Tools::logm('The new user ' . $newUsername . ' has been installed'); 84 if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) {
85 $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername)); 85 // if internal registration
86 Tools::redirect(); 86 $body_internal = "Hi,\r\n\r\nSomeone just created an account for you on " . Tools::getPocheUrl() . ".\r\nHave fun with it !";
87 // if external (public) registration
88 $body = "Hi, \r\n\r\nYou've just created an account on " . Tools::getPocheUrl() . . ".\r\nHave fun with it !";
89 $body = $internalRegistration ? $body_internal : $body;
90 $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard)
91 if (mail($email, sprintf(_('Your new wallabag account on '), Tools::getPocheUrl()), $body, 'From: {$email}')) {
92 Tools::logm('The user ' . $newUsername . ' has been emailed');
93 $this->messages->add('i', sprintf(_('The new user %1$s has been sent an email at %2$s.'), $newUsername, $email));
94
95 } else {
96 Tools::logm('A problem has been encountered while sending an email');
97 $this->messages->add('e', _('A problem has been encountered while sending an email');
98 }
99 } else {
100 Tools::logm('The user has been created, but the server did not authorize sending emails');
101 $this->messages->add('i', _('The server did not authorize sending an email');
102 }
103 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));
105 Tools::redirect();
87 } 106 }
88 else { 107 else {
89 Tools::logm('error during adding new user'); 108 Tools::logm('error during adding new user');