1: | <?php
|
2: | namespace Opencart\Catalog\Controller\Mail;
|
3: | |
4: | |
5: | |
6: | |
7: |
|
8: | class Gdpr extends \Opencart\System\Engine\Controller {
|
9: |
|
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: |
|
19: | public function index(string &$route, array &$args, &$output): void {
|
20: |
|
21: |
|
22: |
|
23: |
|
24: | if (isset($args[0])) {
|
25: | $code = $args[0];
|
26: | } else {
|
27: | $code = '';
|
28: | }
|
29: |
|
30: | if (isset($args[1])) {
|
31: | $email = $args[1];
|
32: | } else {
|
33: | $email = '';
|
34: | }
|
35: |
|
36: | if (isset($args[2])) {
|
37: | $action = $args[2];
|
38: | } else {
|
39: | $action = '';
|
40: | }
|
41: |
|
42: | $this->load->language('mail/gdpr');
|
43: |
|
44: | $store_name = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
|
45: |
|
46: | if ($this->config->get('config_logo')) {
|
47: | $data['logo'] = $this->config->get('config_url') . 'image/' . html_entity_decode($this->config->get('config_logo'), ENT_QUOTES, 'UTF-8');
|
48: | } else {
|
49: | $data['logo'] = '';
|
50: | }
|
51: |
|
52: | $data['text_request'] = $this->language->get('text_' . $action);
|
53: |
|
54: | $data['button_confirm'] = $this->language->get('button_' . $action);
|
55: |
|
56: | $data['confirm'] = $this->url->link('information/gdpr.success', 'language=' . $this->config->get('config_language') . '&code=' . $code, true);
|
57: |
|
58: | $data['ip'] = $this->request->server['REMOTE_ADDR'];
|
59: |
|
60: | $data['store_name'] = $store_name;
|
61: | $data['store_url'] = $this->config->get('config_url');
|
62: |
|
63: | if ($this->config->get('config_mail_engine') && $email) {
|
64: | $mail_option = [
|
65: | 'parameter' => $this->config->get('config_mail_parameter'),
|
66: | 'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'),
|
67: | 'smtp_username' => $this->config->get('config_mail_smtp_username'),
|
68: | 'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'),
|
69: | 'smtp_port' => $this->config->get('config_mail_smtp_port'),
|
70: | 'smtp_timeout' => $this->config->get('config_mail_smtp_timeout')
|
71: | ];
|
72: |
|
73: | $mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option);
|
74: | $mail->setTo($email);
|
75: | $mail->setFrom($this->config->get('config_email'));
|
76: | $mail->setSender($store_name);
|
77: | $mail->setSubject(sprintf($this->language->get('text_subject'), $store_name));
|
78: | $mail->setHtml($this->load->view('mail/gdpr', $data));
|
79: | $mail->send();
|
80: | }
|
81: | }
|
82: |
|
83: |
|
84: |
|
85: | |
86: | |
87: | |
88: | |
89: | |
90: | |
91: | |
92: | |
93: | |
94: | |
95: |
|
96: | public function remove(string &$route, array &$args, &$output): void {
|
97: | if (isset($args[0])) {
|
98: | $gdpr_id = $args[0];
|
99: | } else {
|
100: | $gdpr_id = 0;
|
101: | }
|
102: |
|
103: | if (isset($args[1])) {
|
104: | $status = $args[1];
|
105: | } else {
|
106: | $status = 0;
|
107: | }
|
108: |
|
109: | $this->load->model('account/gdpr');
|
110: |
|
111: | $gdpr_info = $this->model_account_gdpr->getGdpr($gdpr_id);
|
112: |
|
113: | if ($gdpr_info && $gdpr_info['action'] == 'remove' && $status == 3) {
|
114: | $this->load->model('setting/store');
|
115: |
|
116: | $store_info = $this->model_setting_store->getStore($gdpr_info['store_id']);
|
117: |
|
118: | if ($store_info) {
|
119: | $this->load->model('setting/setting');
|
120: |
|
121: | $store_logo = html_entity_decode($this->model_setting_setting->getValue('config_logo', $store_info['store_id']), ENT_QUOTES, 'UTF-8');
|
122: | $store_name = html_entity_decode($store_info['name'], ENT_QUOTES, 'UTF-8');
|
123: | $store_url = $store_info['url'];
|
124: | } else {
|
125: | $store_logo = html_entity_decode($this->config->get('config_logo'), ENT_QUOTES, 'UTF-8');
|
126: | $store_name = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
|
127: | $store_url = HTTP_SERVER;
|
128: | }
|
129: |
|
130: |
|
131: | $this->load->model('localisation/language');
|
132: |
|
133: | $language_info = $this->model_localisation_language->getLanguage($gdpr_info['language_id']);
|
134: |
|
135: | if ($language_info) {
|
136: | $language_code = $language_info['code'];
|
137: | } else {
|
138: | $language_code = $this->config->get('config_language');
|
139: | }
|
140: |
|
141: |
|
142: | $this->load->language('default', 'mail', $language_code);
|
143: | $this->load->language('mail/gdpr_delete', 'mail', $language_code);
|
144: |
|
145: |
|
146: | $results = $this->language->all('mail');
|
147: |
|
148: | foreach ($results as $key => $value) {
|
149: | $data[$key] = $value;
|
150: | }
|
151: |
|
152: | $subject = sprintf($this->language->get('mail_text_subject'), $store_name);
|
153: |
|
154: | $this->load->model('tool/image');
|
155: |
|
156: | if (is_file(DIR_IMAGE . $store_logo)) {
|
157: | $data['logo'] = $store_url . 'image/' . $store_logo;
|
158: | } else {
|
159: | $data['logo'] = '';
|
160: | }
|
161: |
|
162: | $this->load->model('account/customer');
|
163: |
|
164: | $customer_info = $this->model_account_customer->getCustomerByEmail($gdpr_info['email']);
|
165: |
|
166: | if ($customer_info) {
|
167: | $data['text_hello'] = sprintf($this->language->get('mail_text_hello'), html_entity_decode($customer_info['firstname'], ENT_QUOTES, 'UTF-8'));
|
168: | } else {
|
169: | $data['text_hello'] = sprintf($this->language->get('mail_text_hello'), $this->language->get('mail_text_user'));
|
170: | }
|
171: |
|
172: | $data['store_name'] = $store_name;
|
173: | $data['store_url'] = $store_url;
|
174: | $data['contact'] = $store_url . 'index.php?route=information/contact';
|
175: |
|
176: | if ($this->config->get('config_mail_engine')) {
|
177: | $mail_option = [
|
178: | 'parameter' => $this->config->get('config_mail_parameter'),
|
179: | 'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'),
|
180: | 'smtp_username' => $this->config->get('config_mail_smtp_username'),
|
181: | 'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'),
|
182: | 'smtp_port' => $this->config->get('config_mail_smtp_port'),
|
183: | 'smtp_timeout' => $this->config->get('config_mail_smtp_timeout')
|
184: | ];
|
185: |
|
186: | $mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option);
|
187: | $mail->setTo($gdpr_info['email']);
|
188: | $mail->setFrom($this->config->get('config_email'));
|
189: | $mail->setSender($store_name);
|
190: | $mail->setSubject($subject);
|
191: | $mail->setHtml($this->load->view('mail/gdpr_delete', $data));
|
192: | $mail->send();
|
193: | }
|
194: | }
|
195: | }
|
196: | }
|
197: | |