Skip to content

Commit

Permalink
Create new system config bSendUserDeletedEmail
Browse files Browse the repository at this point in the history
Relates to #5175

When users are deleted from ChurchCRM by an admin, there's a good chance the admin does not want an email to be sent to the user informing the user that their account has been deleted.
  • Loading branch information
crossan007 committed Mar 11, 2020
1 parent 71608ac commit 8d5e1b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ChurchCRM/dto/SystemConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,15 @@ private static function buildConfigs()
"bEnable2FA" => new ConfigItem(2068,"bEnable2FA", "boolean","1",gettext("Allow users to self-enroll in 2 factor authentication")),
"bRequire2FA" => new ConfigItem(2069,"bRequire2FA", "boolean","0",gettext("Requires users to self-enroll in 2 factor authentication")),
"s2FAApplicationName" => new ConfigItem(2070,"s2FAApplicationName", "text",gettext("ChurchCRM"),gettext("Specify the application name to be displayed in authenticator app")),
"bSendUserDeletedEmail" => new ConfigItem(2071,"bSendUserDeletedEmail", "boolean","0",gettext("Send an email notifying users when their account has been deleted")),
);
}

private static function buildCategories()
{
return array (
gettext('Church Information') =>["sChurchName","sChurchAddress","sChurchCity","sChurchState","sChurchZip","sChurchCountry","sChurchPhone","sChurchEmail","sHomeAreaCode","sTimeZone","iChurchLatitude","iChurchLongitude", "sChurchWebSite","sChurchFB", "sChurchTwitter"],
gettext('User setup') => ["iMinPasswordLength","iMinPasswordChange","iMaxFailedLogins","iSessionTimeout","aDisallowedPasswords","bEnableLostPassword","bEnable2FA","bRequire2FA","s2FAApplicationName"],
gettext('User setup') => ["iMinPasswordLength","iMinPasswordChange","iMaxFailedLogins","iSessionTimeout","aDisallowedPasswords","bEnableLostPassword","bEnable2FA","bRequire2FA","s2FAApplicationName","bSendUserDeletedEmail"],
gettext('Email Setup') => ["sSMTPHost","bSMTPAuth","sSMTPUser","sSMTPPass", "iSMTPTimeout","sToEmailAddress", "bPHPMailerAutoTLS","sPHPMailerSMTPSecure"],
gettext('People Setup') => ["sDirClassifications","sDirRoleHead","sDirRoleSpouse","sDirRoleChild","sDefaultCity","sDefaultState","sDefaultCountry","bShowFamilyData","bHidePersonAddress","bHideFriendDate","bHideFamilyNewsletter","bHideWeddingDate","bHideLatLon","bForceUppercaseZip","bEnableSelfRegistration", "bAllowEmptyLastName", "iPersonNameStyle", "iProfilePictureListSize", "sNewPersonNotificationRecipientIDs", "IncludeDataInNewPersonNotifications","sGreeterCustomMsg1","sGreeterCustomMsg2"],
gettext('Enabled Features') => ["bEnabledFinance", "bEnabledSundaySchool","bEnabledEvents","bEnabledCalendar","bEnabledFundraiser","bEnabledEmail", "bEnabledMenuLinks"],
Expand Down
10 changes: 7 additions & 3 deletions src/api/routes/users/users-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Slim\Http\Request;
use Slim\Http\Response;
use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemConfig;

$app->group('/users', function () {

Expand Down Expand Up @@ -64,10 +65,13 @@
if (!is_null($userConfig)) {
$userConfig->delete();
}
$email = new AccountDeletedEmail($user);

$user->delete();
if (!$email->send()) {
$this->Logger->warn($email->getError());
if (SystemConfig::getBooleanValue("bSendUserDeletedEmail")) {
$email = new AccountDeletedEmail($user);
if (!$email->send()) {
$this->Logger->warn($email->getError());
}
}
return $response->withJson([]);
} else {
Expand Down

0 comments on commit 8d5e1b2

Please sign in to comment.