Add password changed email template (#7764)

* Add password changed email template

* Update user_profile.php

* Update app_defaults.php

* Update user_edit.php
This commit is contained in:
Alex
2026-02-27 12:15:35 -07:00
committed by GitHub
parent 5714fb3cd9
commit e9f1faa1b7
3 changed files with 160 additions and 0 deletions
+55
View File
@@ -547,6 +547,61 @@
$parameters['user_uuid'] = $user_uuid;
$database->execute($sql, $parameters);
unset($sql, $parameters);
//send the password changed email
if (valid_email($user_email)) {
//generate email and body variables
$domain_name = $_SESSION['domain_name'];
$domain_uuid = $_SESSION['domain_uuid'];
//get user language code, if exists
$sql = "select user_setting_value from v_user_settings ";
$sql .= "where user_uuid = :user_uuid ";
$sql .= "and domain_uuid = :domain_uuid ";
$sql .= "and user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'language' ";
$sql .= "and user_setting_name = 'code' ";
$parameters['user_uuid'] = $user_uuid;
$parameters['domain_uuid'] = $domain_uuid;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$user_language_code = $row['user_setting_value'];
}
unset($sql, $parameters, $row);
//get the email template from database
$sql = "select template_subject, template_body from v_email_templates ";
$sql .= "where template_language = :template_language ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and template_category = 'password_changed' ";
$sql .= "and template_subcategory = 'default' ";
$sql .= "and template_type = 'html' ";
$sql .= "and template_enabled = true ";
$parameters['template_language'] = $user_language_code ? $user_language_code : $settings->get('domain', 'language', 'en-us');
$parameters['domain_uuid'] = $domain_uuid;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row)) {
$email_subject = $row['template_subject'];
$email_body = $row['template_body'];
}
unset($sql, $parameters, $row);
//replace variables in email body
$email_body = str_replace('${domain}', $domain_name, $email_body);
//send the email
send_email($user_email, $email_subject, $email_body, $eml_error);
//build the user log array
$log_array['type'] = 'Password Changed';
$log_array['domain_uuid'] = $_SESSION['domain_uuid'];
$log_array['username'] = $username;
$log_array['user_uuid'] = $user_uuid;
$log_array['authorized'] = true;
//add the result to the user logs
user_logs::add($log_array);
}
}
$array['users'][$x]['user_email'] = $user_email;
$array['users'][$x]['user_status'] = $user_status;