1: | <?php
2: | namespace Opencart\Catalog\Controller\Mail;
3: | /**
4: | * Class Register
5: | *
6: | * @package Opencart\Catalog\Controller\Mail
7: | */
8: | class Register extends \Opencart\System\Engine\Controller {
9: | // catalog/model/account/customer/addCustomer/after
10: | /**
11: | * @param string $route
12: | * @param array<int, mixed> $args
13: | * @param mixed $output
14: | *
15: | * @throws \Exception
16: | *
17: | * @return void
18: | */
19: | public function index(string &$route, array &$args, &$output): void {
20: | $this->load->language('mail/register');
21: |
22: | $store_name = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
23: |
24: | $subject = sprintf($this->language->get('text_subject'), $store_name);
25: |
26: | $data['text_welcome'] = sprintf($this->language->get('text_welcome'), $store_name);
27: |
28: | $this->load->model('account/customer_group');
29: |
30: | if (isset($args[0]['customer_group_id'])) {
31: | $customer_group_id = (int)$args[0]['customer_group_id'];
32: | } else {
33: | $customer_group_id = (int)$this->config->get('config_customer_group_id');
34: | }
35: |
36: | $customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id);
37: |
38: | if ($customer_group_info) {
39: | $data['approval'] = $customer_group_info['approval'];
40: | } else {
41: | $data['approval'] = '';
42: | }
43: |
44: | $data['login'] = $this->url->link('account/login', 'language=' . $this->config->get('config_language'), true);
45: |
46: | $data['store'] = $store_name;
47: | $data['store_url'] = $this->config->get('config_url');
48: |
49: | if ($this->config->get('config_mail_engine')) {
50: | $mail_option = [
51: | 'parameter' => $this->config->get('config_mail_parameter'),
52: | 'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'),
53: | 'smtp_username' => $this->config->get('config_mail_smtp_username'),
54: | 'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'),
55: | 'smtp_port' => $this->config->get('config_mail_smtp_port'),
56: | 'smtp_timeout' => $this->config->get('config_mail_smtp_timeout')
57: | ];
58: |
59: | $mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option);
60: | $mail->setTo($args[0]['email']);
61: | $mail->setFrom($this->config->get('config_email'));
62: | $mail->setSender($store_name);
63: | $mail->setSubject($subject);
64: | $mail->setHtml($this->load->view('mail/register', $data));
65: | $mail->send();
66: | }
67: | }
68: |
69: | // catalog/model/account/customer/addCustomer/after
70: |
71: | /**
72: | * Alert
73: | *
74: | * @param string $route
75: | * @param array<int, mixed> $args
76: | * @param mixed $output
77: | *
78: | * @throws \Exception
79: | *
80: | * @return void
81: | */
82: | public function alert(string &$route, array &$args, &$output): void {
83: | // Send to main admin email if new account email is enabled
84: | if (in_array('account', (array)$this->config->get('config_mail_alert'))) {
85: | $this->load->language('mail/register');
86: |
87: | $store_name = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
88: |
89: | $subject = $this->language->get('text_new_customer');
90: |
91: | $data['firstname'] = $args[0]['firstname'];
92: | $data['lastname'] = $args[0]['lastname'];
93: |
94: | $data['login'] = $this->url->link('account/login', 'language=' . $this->config->get('config_language'), true);
95: |
96: | $this->load->model('account/customer_group');
97: |
98: | if (isset($args[0]['customer_group_id'])) {
99: | $customer_group_id = (int)$args[0]['customer_group_id'];
100: | } else {
101: | $customer_group_id = (int)$this->config->get('config_customer_group_id');
102: | }
103: |
104: | $customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id);
105: |
106: | if ($customer_group_info) {
107: | $data['customer_group'] = $customer_group_info['name'];
108: | } else {
109: | $data['customer_group'] = '';
110: | }
111: |
112: | $data['email'] = $args[0]['email'];
113: | $data['telephone'] = $args[0]['telephone'];
114: |
115: | $data['store'] = $store_name;
116: | $data['store_url'] = $this->config->get('config_url');
117: |
118: | if ($this->config->get('config_mail_engine')) {
119: | $mail_option = [
120: | 'parameter' => $this->config->get('config_mail_parameter'),
121: | 'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'),
122: | 'smtp_username' => $this->config->get('config_mail_smtp_username'),
123: | 'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'),
124: | 'smtp_port' => $this->config->get('config_mail_smtp_port'),
125: | 'smtp_timeout' => $this->config->get('config_mail_smtp_timeout')
126: | ];
127: |
128: | $mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option);
129: | $mail->setTo($this->config->get('config_email'));
130: | $mail->setFrom($this->config->get('config_email'));
131: | $mail->setSender($store_name);
132: | $mail->setSubject($subject);
133: | $mail->setHtml($this->load->view('mail/register_alert', $data));
134: | $mail->send();
135: |
136: | // Send to additional alert emails if new account email is enabled
137: | $emails = explode(',', (string)$this->config->get('config_mail_alert_email'));
138: |
139: | foreach ($emails as $email) {
140: | if (oc_strlen($email) > 0 && filter_var($email, FILTER_VALIDATE_EMAIL)) {
141: | $mail->setTo(trim($email));
142: | $mail->send();
143: | }
144: | }
145: | }
146: | }
147: | }
148: | }
149: |

OpenCart API API documentation generated by ApiGen dev-master