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_notifications.php
66 lines (49 loc) · 2.49 KB
/
account_notifications.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/*
$Id$
CE Phoenix, E-Commerce made Easy
https://phoenixcart.org
Copyright (c) 2021 Phoenix Cart
Released under the GNU General Public License
*/
require 'includes/application_top.php';
$OSCOM_Hooks->register_pipeline('loginRequired');
// needs to be included earlier to set the success message in the messageStack
require language::map_to_translation('account_notifications.php');
$global_query = tep_db_query("SELECT global_product_notifications FROM customers_info WHERE customers_info_id = " . (int)$_SESSION['customer_id']);
$global = $global_query->fetch_assoc();
if (tep_validate_form_action_is('process')) {
if (isset($_POST['product_global']) && is_numeric($_POST['product_global'])) {
$product_global = Text::input($_POST['product_global']);
} else {
$product_global = '0';
}
if ($product_global != $global['global_product_notifications']) {
$product_global = (($global['global_product_notifications'] == '1') ? '0' : '1');
tep_db_query("UPDATE customers_info SET global_product_notifications = '" . (int)$product_global . "' WHERE customers_info_id = " . (int)$_SESSION['customer_id']);
} elseif (!empty($_POST['products'])) {
$products_parsed = [];
foreach ((array)$_POST['products'] as $value) {
if (is_numeric($value)) {
$products_parsed[] = $value;
}
}
if (count($products_parsed) > 0) {
$check_query = tep_db_query("SELECT COUNT(*) AS total FROM products_notifications WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id NOT IN (" . implode(',', $products_parsed) . ")");
$check = $check_query->fetch_assoc();
if ($check['total'] > 0) {
tep_db_query("DELETE FROM products_notifications WHERE customers_id = " . (int)$_SESSION['customer_id'] . " AND products_id NOT IN (" . implode(',', $products_parsed) . ")");
}
}
} else {
$check_query = tep_db_query("SELECT COUNT(*) AS total FROM products_notifications WHERE customers_id = " . (int)$_SESSION['customer_id']);
$check = $check_query->fetch_assoc();
if ($check['total'] > 0) {
tep_db_query("DELETE FROM products_notifications WHERE customers_id = " . (int)$_SESSION['customer_id']);
}
}
$messageStack->add_session('account', SUCCESS_NOTIFICATIONS_UPDATED, 'success');
tep_redirect(tep_href_link('account.php'));
}
require $oscTemplate->map_to_template(__FILE__, 'page');
require 'includes/application_bottom.php';