aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche')
-rwxr-xr-xinc/poche/Poche.class.php27
-rwxr-xr-xinc/poche/Routing.class.php2
2 files changed, 24 insertions, 5 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');
diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php
index a8d00b89..b8cab0ec 100755
--- a/inc/poche/Routing.class.php
+++ b/inc/poche/Routing.class.php
@@ -116,7 +116,7 @@ class Routing
116 // update password 116 // update password
117 $this->wallabag->updatePassword($_POST['password'], $_POST['password_repeat']); 117 $this->wallabag->updatePassword($_POST['password'], $_POST['password_repeat']);
118 } elseif (isset($_GET['newuser'])) { 118 } elseif (isset($_GET['newuser'])) {
119 $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser'], $_POST['newuseremail']); 119 $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser'], $_POST['newuseremail'], true);
120 } elseif (isset($_GET['deluser'])) { 120 } elseif (isset($_GET['deluser'])) {
121 $this->wallabag->deleteUser($_POST['password4deletinguser']); 121 $this->wallabag->deleteUser($_POST['password4deletinguser']);
122 } elseif (isset($_GET['epub'])) { 122 } elseif (isset($_GET['epub'])) {