summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-10-09 09:04:51 +0300
committerAndrew Dolgov <[email protected]>2019-10-09 09:04:51 +0300
commitef514bc4bd13fc5a05303f4cb065abddd078250e (patch)
treea4e19c51e400bc2134cca643448585f5691b24fe /classes
parentd029e18976649c8fe928f685b9db423310f8f0f9 (diff)
add notifications for mail and password changes
update and shorten some other message templates
Diffstat (limited to 'classes')
-rw-r--r--classes/digest.php2
-rwxr-xr-xclasses/handler/public.php1
-rw-r--r--classes/pref/prefs.php36
3 files changed, 39 insertions, 0 deletions
diff --git a/classes/digest.php b/classes/digest.php
index f2533d160..c9e9f24e7 100644
--- a/classes/digest.php
+++ b/classes/digest.php
@@ -103,9 +103,11 @@ class Digest
$tpl->setVariable('CUR_DATE', date('Y/m/d', $local_ts));
$tpl->setVariable('CUR_TIME', date('G:i', $local_ts));
+ $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
$tpl_t->setVariable('CUR_DATE', date('Y/m/d', $local_ts));
$tpl_t->setVariable('CUR_TIME', date('G:i', $local_ts));
+ $tpl_t->setVariable('TTRSS_HOST', SELF_URL_PATH);
$affected_ids = array();
diff --git a/classes/handler/public.php b/classes/handler/public.php
index e2082ff1e..b81fb03b8 100755
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -996,6 +996,7 @@ class Handler_Public extends Handler {
$tpl->setVariable('LOGIN', $login);
$tpl->setVariable('RESETPASS_LINK', $resetpass_link);
+ $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
$tpl->addBlock('message');
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index e7e7a365e..dd9c2868b 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -122,6 +122,11 @@ class Pref_Prefs extends Handler_Protected {
$new_pw = clean($_POST["new_password"]);
$con_pw = clean($_POST["confirm_password"]);
+ if ($old_pw == $new_pw) {
+ print "ERROR: ".format_error("New password must be different from the old one.");
+ return;
+ }
+
if ($old_pw == "") {
print "ERROR: ".format_error("Old password cannot be blank.");
return;
@@ -194,6 +199,37 @@ class Pref_Prefs extends Handler_Protected {
$full_name = clean($_POST["full_name"]);
$active_uid = $_SESSION["uid"];
+ $sth = $this->pdo->prepare("SELECT email, login, full_name FROM ttrss_users WHERE id = ?");
+ $sth->execute([$active_uid]);
+
+ if ($row = $sth->fetch()) {
+ $old_email = $row["email"];
+
+ if ($old_email != $email) {
+ $mailer = new Mailer();
+
+ require_once "lib/MiniTemplator.class.php";
+
+ $tpl = new MiniTemplator;
+
+ $tpl->readTemplateFromFile("templates/mail_change_template.txt");
+
+ $tpl->setVariable('LOGIN', $row["login"]);
+ $tpl->setVariable('NEWMAIL', $email);
+ $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
+
+ $tpl->addBlock('message');
+
+ $tpl->generateOutputToString($message);
+
+ $mailer->mail(["to_name" => $row["login"],
+ "to_address" => $row["email"],
+ "subject" => "[tt-rss] Mail address change notification",
+ "message" => $message]);
+
+ }
+ }
+
$sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ?,
full_name = ? WHERE id = ?");
$sth->execute([$email, $full_name, $active_uid]);