Skip to content

Commit

Permalink
Remove account deletion option from unsubscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
jdarwood007 committed Oct 18, 2023
1 parent f8ffdcd commit e97dc1a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 30 deletions.
35 changes: 10 additions & 25 deletions Sources/Notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ function Unsubscribe()

// Logged in? Just delete your account.
if (!$user_info['is_guest'])
redirectexit('action=profile;area=deleteaccount');
redirectexit('action=profile;area=notification');

loadTemplate('Notify');
$context['page_title'] = $txt['unsubscribe'];
Expand All @@ -404,45 +404,30 @@ function Unsubscribe()
{
$member_info = getMemberWithToken('unsubscribe');

if (isset($_POST['delete']) || isset($_POST['notify']))
if (isset($_POST['notify']))
{
validateToken('unsubscribe');

// Approval is required to delete, but this will also stop notifications.
if (isset($_POST['delete']) && !empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum'))
{
updateMemberData($member_info['id'], array('is_activated' => 4));
updateSettings(array('unapprovedMembers' => true), true);
}
// Also check if you typed your password correctly.
elseif (isset($_POST['delete']))
{
require_once($sourcedir . '/Subs-Members.php');
deleteMembers($member_info['id']);
}
elseif (isset($_POST['notify']))
{
// Get all notifications preferences.
$notifyPrefs = getNotifyPrefs($member_info['id'], '', true);

if (!empty($notifyPrefs[$member_info['id']]))
{
// 0 = None, 1 = Alert, 2 = Email, 3 = Alert + Email
foreach ($notifyPrefs[$member_info['id']] as $pref_key => &$pref_value)
if ($pref_key != 'alert_timeout')
if ($pref_key != 'alert_timeout' && $pref_value > 0)
$pref_value = $pref_value == 2 ? 0 : 1;

setNotifyPrefs($member_info['id'], $notifyPrefs[$member_info['id']]);
}
}

if (isset($_POST['delete']) || isset($_POST['notify']))
{
$context['sub_template'] = 'unsubscribe_success';
$context['success_msg'] = $txt['unsubscribe_success_done'];
}
else
{
createToken('unsubscribe');
$context['sub_template'] = 'unsubscribe_type';
$context['sub_template'] = 'unsubscribe_confirm';
$context['token'] = $smcFunc['htmlspecialchars']($_REQUEST['token']);
$context['user_id'] = $member_info['id'];
}
Expand Down Expand Up @@ -481,16 +466,16 @@ function Unsubscribe()
$txt['unsubscribe_email_subject'],
sprintf($txt['unsubscribe_email_body'], $scripturl . '?action=unsubscribe;u=' . $user_settings['id_member'] . ';token=' . $token) . "\n\n" . sprintf($txt['regards_team'], $context['forum_name'])
);

$context['sub_template'] = 'unsubscribe_success';
$context['success_msg'] = $txt['unsubscribe_success_request'];
}

$context['sub_template'] = 'unsubscribe_success';
$context['success_msg'] = $txt['unsubscribe_success_request'];
}
else
{
// Default email address if provided with one.
$context['email_address'] = isset($_GET['email']) ? $smcFunc['htmlspecialchars'](urldecode($_GET['email'])) : '';
$context['sub_template'] = 'unsubscribe';
$context['sub_template'] = 'unsubscribe_request';
createToken('unsubscribe');
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Subs-Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ function sendmail($to, $subject, $message, $from = null, $message_id = null, $se
$subject = un_htmlspecialchars($subject);

// Add in a unsubscribe link.
$message .= "\n\n" . $txt['unsubscribe'] . ': ' . $scripturl . '?action=unsubscribe';
$message .= "\n\n" . sprintf($txt['unsubscribe_email_message'], $scripturl . '?action=unsubscribe');

// Make the message use the proper line breaks.
$message = str_replace(array("\r", "\n"), array('', $line_break), $message);
Expand Down
5 changes: 2 additions & 3 deletions Themes/default/Notify.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function template_notify_pref_changed()
/**
*
*/
function template_unsubscribe()
function template_unsubscribe_request()
{
global $context, $txt, $scripturl;

Expand Down Expand Up @@ -149,7 +149,7 @@ function template_unsubscribe_success()
/**
*
*/
function template_unsubscribe_type()
function template_unsubscribe_confirm()
{
global $txt, $scripturl, $context;

Expand All @@ -163,7 +163,6 @@ function template_unsubscribe_type()
<form method="post" accept-charset="', $context['character_set'], '" action="', $scripturl, '?action=unsubscribe">
<div class="roundframe centertext">
<p class="centertext">
<button name="delete" class="button">', $txt['unsubscribe_delete_account'], '</button>
<button name="notify" class="button">', $txt['unsubscribe_remove_notifications'], '</button>
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion Themes/default/languages/index.english.php
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@
$txt['unsubscribe_email_body'] = 'A request to unsubscribe was received. To approve this request, follow this link: %1$s.';
$txt['unsubscribe_success_request'] = 'An email has been sent with a approval link to the member if one exists.';
$txt['unsubscribe_success_done'] = 'Your rqeuest has been received and is being processed.';
$txt['unsubscribe_delete_account'] = 'Delete Account';
$txt['unsubscribe_remove_notifications'] = 'Remove all email notifications';
$txt['unsubscribe_email_message'] = 'To unsubscribe, visit %1$s';

?>

0 comments on commit e97dc1a

Please sign in to comment.