prefs: allow setting email if it was previously blank

master
Andrew Dolgov 4 years ago
parent ce9955c6ff
commit 43ea36d030

@ -231,29 +231,29 @@ class Pref_Prefs extends Handler_Protected {
if ($user) { if ($user) {
$user->full_name = clean($_POST['full_name']); $user->full_name = clean($_POST['full_name']);
if ($user->email != $new_email) if ($user->email != $new_email) {
Logger::log(E_USER_NOTICE, "Email address of user ".$user->login." has been changed to ${new_email}."); Logger::log(E_USER_NOTICE, "Email address of user ".$user->login." has been changed to ${new_email}.");
if ($user->email && $user->email != $new_email) { if ($user->email) {
$mailer = new Mailer();
$mailer = new Mailer(); $tpl = new Templator();
$tpl = new Templator();
$tpl->readTemplateFromFile("mail_change_template.txt"); $tpl->readTemplateFromFile("mail_change_template.txt");
$tpl->setVariable('LOGIN', $user->login); $tpl->setVariable('LOGIN', $user->login);
$tpl->setVariable('NEWMAIL', $new_email); $tpl->setVariable('NEWMAIL', $new_email);
$tpl->setVariable('TTRSS_HOST', Config::get(Config::SELF_URL_PATH)); $tpl->setVariable('TTRSS_HOST', Config::get(Config::SELF_URL_PATH));
$tpl->addBlock('message'); $tpl->addBlock('message');
$tpl->generateOutputToString($message); $tpl->generateOutputToString($message);
$mailer->mail(["to_name" => $user->login, $mailer->mail(["to_name" => $user->login,
"to_address" => $user->email, "to_address" => $user->email,
"subject" => "[tt-rss] Email address change notification", "subject" => "[tt-rss] Email address change notification",
"message" => $message]); "message" => $message]);
}
$user->email = $new_email; $user->email = $new_email;
} }

Loading…
Cancel
Save