This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 201
/
account_newsletters.php
47 lines (33 loc) · 1.57 KB
/
account_newsletters.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2020 osCommerce
Released under the GNU General Public License
*/
require 'includes/application_top.php';
$OSCOM_Hooks->register_pipeline('loginRequired');
if (!$customer_data->has(['newsletter'])) {
tep_redirect(tep_href_link('account.php', '', 'SSL'));
}
// needs to be included earlier to set the success message in the messageStack
require "includes/languages/$language/account_newsletters.php";
$customer_data->build_read(['newsletter'], 'customers', ['id' => (int)$_SESSION['customer_id']]);
$newsletter_query = tep_db_query($customer_data->build_read(['newsletter'], 'customers', ['id' => (int)$_SESSION['customer_id']]));
$newsletter = tep_db_fetch_array($newsletter_query);
if (tep_validate_form_action_is('process')) {
if (isset($_POST['newsletter_general']) && is_numeric($_POST['newsletter_general'])) {
$newsletter_general = tep_db_prepare_input($_POST['newsletter_general']);
} else {
$newsletter_general = 0;
}
$saved_newsletter = $customer_data->get('newsletter', $newsletter);
if ($newsletter_general != $saved_newsletter) {
$customer_data->update(['newsletter' => (int)(('1' == $saved_newsletter) ? 0 : 1)], ['id' => (int)$_SESSION['customer_id']]);
}
$messageStack->add_session('account', SUCCESS_NEWSLETTER_UPDATED, 'success');
tep_redirect(tep_href_link('account.php', '', 'SSL'));
}
require $oscTemplate->map_to_template(__FILE__, 'page');
require 'includes/application_bottom.php';