affiliate.php (5410B)
1 <?php 2 class ControllerMailAffiliate extends Controller { 3 public function index(&$route, &$args, &$output) { 4 $this->load->language('mail/affiliate'); 5 6 $data['text_welcome'] = sprintf($this->language->get('text_welcome'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')); 7 $data['text_login'] = $this->language->get('text_login'); 8 $data['text_approval'] = $this->language->get('text_approval'); 9 $data['text_service'] = $this->language->get('text_service'); 10 $data['text_thanks'] = $this->language->get('text_thanks'); 11 12 $this->load->model('account/customer_group'); 13 14 if ($this->customer->isLogged()) { 15 $customer_group_id = $this->customer->getGroupId(); 16 } else { 17 $customer_group_id = $args[1]['customer_group_id']; 18 } 19 20 $customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id); 21 22 if ($customer_group_info) { 23 $data['approval'] = ($this->config->get('config_affiliate_approval') || $customer_group_info['approval']); 24 } else { 25 $data['approval'] = ''; 26 } 27 28 $data['login'] = $this->url->link('affiliate/login', '', true); 29 $data['store'] = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'); 30 31 $mail = new Mail($this->config->get('config_mail_engine')); 32 $mail->parameter = $this->config->get('config_mail_parameter'); 33 $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); 34 $mail->smtp_username = $this->config->get('config_mail_smtp_username'); 35 $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); 36 $mail->smtp_port = $this->config->get('config_mail_smtp_port'); 37 $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); 38 39 if ($this->customer->isLogged()) { 40 $mail->setTo($this->customer->getEmail()); 41 } else { 42 $mail->setTo($args[1]['email']); 43 } 44 45 $mail->setFrom($this->config->get('config_email')); 46 $mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')); 47 $mail->setSubject(sprintf($this->language->get('text_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'))); 48 $mail->setText($this->load->view('mail/affiliate', $data)); 49 $mail->send(); 50 } 51 52 public function alert(&$route, &$args, &$output) { 53 // Send to main admin email if new affiliate email is enabled 54 if (in_array('affiliate', (array)$this->config->get('config_mail_alert'))) { 55 $this->load->language('mail/affiliate'); 56 57 $data['text_signup'] = $this->language->get('text_signup'); 58 $data['text_website'] = $this->language->get('text_website'); 59 $data['text_firstname'] = $this->language->get('text_firstname'); 60 $data['text_lastname'] = $this->language->get('text_lastname'); 61 $data['text_customer_group'] = $this->language->get('text_customer_group'); 62 $data['text_email'] = $this->language->get('text_email'); 63 $data['text_telephone'] = $this->language->get('text_telephone'); 64 65 if ($this->customer->isLogged()) { 66 $customer_group_id = $this->customer->getGroupId(); 67 68 $data['firstname'] = $this->customer->getFirstName(); 69 $data['lastname'] = $this->customer->getLastName(); 70 $data['email'] = $this->customer->getEmail(); 71 $data['telephone'] = $this->customer->getTelephone(); 72 } else { 73 $customer_group_id = $args[1]['customer_group_id']; 74 75 $data['firstname'] = $args[1]['firstname']; 76 $data['lastname'] = $args[1]['lastname']; 77 $data['email'] = $args[1]['email']; 78 $data['telephone'] = $args[1]['telephone']; 79 } 80 81 $data['website'] = html_entity_decode($args[1]['website'], ENT_QUOTES, 'UTF-8'); 82 $data['company'] = $args[1]['company']; 83 84 $this->load->model('account/customer_group'); 85 86 $customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id); 87 88 if ($customer_group_info) { 89 $data['customer_group'] = $customer_group_info['name']; 90 } else { 91 $data['customer_group'] = ''; 92 } 93 94 $mail = new Mail($this->config->get('config_mail_engine')); 95 $mail->parameter = $this->config->get('config_mail_parameter'); 96 $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); 97 $mail->smtp_username = $this->config->get('config_mail_smtp_username'); 98 $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); 99 $mail->smtp_port = $this->config->get('config_mail_smtp_port'); 100 $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); 101 102 $mail->setTo($this->config->get('config_email')); 103 $mail->setFrom($this->config->get('config_email')); 104 $mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')); 105 $mail->setSubject(html_entity_decode($this->language->get('text_new_affiliate'), ENT_QUOTES, 'UTF-8')); 106 $mail->setText($this->load->view('mail/affiliate_alert', $data)); 107 $mail->send(); 108 109 // Send to additional alert emails if new affiliate email is enabled 110 $emails = explode(',', $this->config->get('config_mail_alert_email')); 111 112 foreach ($emails as $email) { 113 if (utf8_strlen($email) > 0 && filter_var($email, FILTER_VALIDATE_EMAIL)) { 114 $mail->setTo($email); 115 $mail->send(); 116 } 117 } 118 } 119 } 120 }