affiliate.php (4512B)
1 <?php 2 class ControllerMailAffiliate extends Controller { 3 public function approve(&$route, &$args, &$output) { 4 $this->load->model('customer/customer'); 5 6 $customer_info = $this->model_customer_customer->getCustomer($args[0]); 7 8 if ($customer_info) { 9 $this->load->model('setting/store'); 10 11 $store_info = $this->model_setting_store->getStore($customer_info['store_id']); 12 13 if ($store_info) { 14 $store_name = html_entity_decode($store_info['name'], ENT_QUOTES, 'UTF-8'); 15 $store_url = $store_info['url'] . 'index.php?route=account/login'; 16 } else { 17 $store_name = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'); 18 $store_url = HTTP_CATALOG . 'index.php?route=account/login'; 19 } 20 21 $this->load->model('localisation/language'); 22 23 $language_info = $this->model_localisation_language->getLanguage($customer_info['language_id']); 24 25 if ($language_info) { 26 $language_code = $language_info['code']; 27 } else { 28 $language_code = $this->config->get('config_language'); 29 } 30 31 $language = new Language($language_code); 32 $language->load($language_code); 33 $language->load('mail/affiliate_approve'); 34 35 $subject = sprintf($language->get('text_subject'), $store_name); 36 37 $data['text_welcome'] = sprintf($language->get('text_welcome'), $store_name); 38 39 $data['login'] = $store_url . 'index.php?route=account/login'; 40 $data['store'] = $store_name; 41 42 $mail = new Mail($this->config->get('config_mail_engine')); 43 $mail->parameter = $this->config->get('config_mail_parameter'); 44 $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); 45 $mail->smtp_username = $this->config->get('config_mail_smtp_username'); 46 $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); 47 $mail->smtp_port = $this->config->get('config_mail_smtp_port'); 48 $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); 49 50 $mail->setTo($customer_info['email']); 51 $mail->setFrom($this->config->get('config_email')); 52 $mail->setSender($store_name); 53 $mail->setSubject($subject); 54 $mail->setText($this->load->view('mail/affiliate_approve', $data)); 55 $mail->send(); 56 } 57 } 58 59 public function deny(&$route, &$args, &$output) { 60 $this->load->model('customer/customer'); 61 62 $customer_info = $this->model_customer_customer->getCustomer($args[0]); 63 64 if ($customer_info) { 65 $this->load->model('setting/store'); 66 67 $store_info = $this->model_setting_store->getStore($customer_info['store_id']); 68 69 if ($store_info) { 70 $store_name = html_entity_decode($store_info['name'], ENT_QUOTES, 'UTF-8'); 71 $store_url = $store_info['url'] . 'index.php?route=account/login'; 72 } else { 73 $store_name = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'); 74 $store_url = HTTP_CATALOG . 'index.php?route=account/login'; 75 } 76 77 $this->load->model('localisation/language'); 78 79 $language_info = $this->model_localisation_language->getLanguage($customer_info['language_id']); 80 81 if ($language_info) { 82 $language_code = $language_info['code']; 83 } else { 84 $language_code = $this->config->get('config_language'); 85 } 86 87 $language = new Language($language_code); 88 $language->load($language_code); 89 $language->load('mail/affiliate_deny'); 90 91 $subject = sprintf($language->get('text_subject'), $store_name); 92 93 $data['text_welcome'] = sprintf($language->get('text_welcome'), $store_name); 94 95 $data['contact'] = $store_url . 'index.php?route=information/contact'; 96 $data['store'] = $store_name; 97 98 $mail = new Mail($this->config->get('config_mail_engine')); 99 $mail->parameter = $this->config->get('config_mail_parameter'); 100 $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); 101 $mail->smtp_username = $this->config->get('config_mail_smtp_username'); 102 $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); 103 $mail->smtp_port = $this->config->get('config_mail_smtp_port'); 104 $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); 105 106 $mail->setTo($customer_info['email']); 107 $mail->setFrom($this->config->get('config_email')); 108 $mail->setSender($store_name); 109 $mail->setSubject($subject); 110 $mail->setText($this->load->view('mail/affiliate_deny', $data)); 111 $mail->send(); 112 } 113 } 114 }