public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     $this->form = new AForm('ContactUsFrm');
     $this->form->loadFromDb('ContactUsFrm');
     $form = $this->form->getForm();
     if ($this->request->is_POST() && $this->_validate()) {
         // move all uploaded files to their directories
         $file_pathes = $this->form->processFileUploads($this->request->files);
         $mail = new AMail($this->config);
         $mail->setTo($this->config->get('store_main_email'));
         $mail->setFrom($this->request->post['email']);
         $mail->setSender($this->request->post['first_name']);
         $mail->setSubject(sprintf($this->language->get('email_subject'), $this->request->post['name']));
         $msg = $this->request->post['enquiry'] . "\r\n";
         $form_fields = $this->form->getFields();
         foreach ($form_fields as $field_name => $field_info) {
             if (has_value($this->request->post[$field_name]) && !in_array($field_name, array('first_name', 'email', 'enquiry', 'captcha'))) {
                 $field_details = $this->form->getField($field_name);
                 $msg .= "\r\n" . rtrim($field_details['name'], ':') . ":\t" . $this->request->post[$field_name];
             }
         }
         if ($file_pathes) {
             $msg .= "\r\n" . $this->language->get('entry_attached') . ": \r\n";
             foreach ($file_pathes as $file_info) {
                 $basename = pathinfo(str_replace(' ', '_', $file_info['path']), PATHINFO_BASENAME);
                 $msg .= "\t" . $file_info['display_name'] . ': ' . $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)\r\n";
                 $mail->addAttachment($file_info['path'], $basename);
             }
         }
         $mail->setText(strip_tags(html_entity_decode($msg, ENT_QUOTES, 'UTF-8')));
         $mail->send();
         //get success_page
         if ($form['success_page']) {
             $success_url = $this->html->getSecureURL($form['success_page']);
         } else {
             $success_url = $this->html->getSecureURL('content/contact/success');
         }
         $this->redirect($success_url);
     }
     if ($this->request->is_POST()) {
         foreach ($this->request->post as $name => $value) {
             $this->form->assign($name, $value);
         }
     }
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('content/contact'), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator')));
     $this->view->assign('form_output', $this->form->getFormHtml());
     $this->view->assign('action', $this->html->getURL('content/contact'));
     $this->view->assign('store', $this->config->get('store_name'));
     $this->view->assign('address', nl2br($this->config->get('config_address')));
     $this->view->assign('telephone', $this->config->get('config_telephone'));
     $this->view->assign('fax', $this->config->get('config_fax'));
     $this->processTemplate('pages/content/contact.tpl');
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Пример #2
0
 public function sendCode()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('account/customer');
     $customer_info = $this->model_account_customer->getCustomerByEmail($this->request->get['email']);
     //if can not find
     if (!$customer_info) {
         $this->redirect($this->html->getSecureURL('account/create'));
     }
     $customer_id = $customer_info['customer_id'];
     $email = $customer_info['email'];
     $this->loadLanguage('mail/account_create');
     $subject = sprintf($this->language->get('text_subject'), $this->config->get('store_name'));
     $message = sprintf($this->language->get('text_welcome'), $this->config->get('store_name')) . "\n\n";
     $code = md5(mt_rand(1, 3000));
     $this->session->data['activation'] = array('customer_id' => $customer_id, 'code' => $code, 'email' => $email);
     $message .= sprintf($this->language->get('text_activate'), "\n" . $this->html->getSecureURL('account/login', '&activation=' . $code . '&email=' . $email)) . "\n";
     $message .= $this->language->get('text_thanks') . "\n";
     $message .= $this->config->get('store_name');
     $mail = new AMail($this->config);
     $mail->setTo($email);
     $mail->setFrom($this->config->get('store_main_email'));
     $mail->setSender($this->config->get('store_name'));
     $mail->setSubject($subject);
     $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
     $mail->send();
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->redirect($this->html->getSecureURL('account/success'));
 }
Пример #3
0
 /**
  * @param int $order_id
  * @param int $order_status_id
  * @param string $comment
  * @param bool $notify
  */
 public function update($order_id, $order_status_id, $comment = '', $notify = FALSE)
 {
     $order_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t FROM `" . $this->db->table("orders") . "` o\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN " . $this->db->table("languages") . " l ON (o.language_id = l.language_id)\n\t\t\t\t\t\t\t\t\t\t WHERE o.order_id = '" . (int) $order_id . "' AND o.order_status_id > '0'");
     if ($order_query->num_rows) {
         $order_row = $this->dcrypt->decrypt_data($order_query->row, 'orders');
         $this->db->query("UPDATE `" . $this->db->table("orders") . "`\n\t\t\t\t\t\t\t\tSET order_status_id = '" . (int) $order_status_id . "',\n\t\t\t\t\t\t\t\t\tdate_modified = NOW()\n\t\t\t\t\t\t\t\tWHERE order_id = '" . (int) $order_id . "'");
         $this->db->query("INSERT INTO " . $this->db->table("order_history") . "\n\t\t\t\t\t\t\t\tSET order_id = '" . (int) $order_id . "',\n\t\t\t\t\t\t\t\t\torder_status_id = '" . (int) $order_status_id . "',\n\t\t\t\t\t\t\t\t\tnotify = '" . (int) $notify . "',\n\t\t\t\t\t\t\t\t\tcomment = '" . $this->db->escape($comment) . "',\n\t\t\t\t\t\t\t\t\tdate_added = NOW()");
         if ($notify) {
             $language = new ALanguage($this->registry, $order_row['code']);
             $language->load($order_row['filename']);
             $language->load('mail/order_update');
             $subject = sprintf($language->get('text_subject'), html_entity_decode($order_row['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
             $message = $language->get('text_order') . ' ' . $order_id . "\n";
             $message .= $language->get('text_date_added') . ' ' . dateISO2Display($order_row['date_added'], $language->get('date_format_short')) . "\n\n";
             $order_status_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("order_statuses") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE order_status_id = '" . (int) $order_status_id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND language_id = '" . (int) $order_row['language_id'] . "'");
             if ($order_status_query->num_rows) {
                 $message .= $language->get('text_order_status') . "\n\n";
                 $message .= $order_status_query->row['name'] . "\n\n";
             }
             $message .= $language->get('text_invoice') . "\n";
             $message .= $order_row['store_url'] . 'index.php?rt=account/invoice&order_id=' . $order_id . "\n\n";
             if ($comment) {
                 $message .= $language->get('text_comment') . "\n\n";
                 $message .= $comment . "\n\n";
             }
             $message .= $language->get('text_footer');
             $mail = new AMail($this->config);
             $mail->setTo($order_row['email']);
             $mail->setFrom($this->config->get('store_main_email'));
             $mail->setSender($order_row['store_name']);
             $mail->setSubject($subject);
             $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
             $mail->send();
         }
     }
 }
Пример #4
0
 public function send($to, $text)
 {
     $this->load->language('common/im');
     $to = trim($to);
     $text = trim($text);
     if (!$to || !$text) {
         return false;
     }
     $mail = new AMail($this->config);
     $mail->setTo($to);
     $mail->setFrom($this->config->get('store_main_email'));
     $mail->setSender($this->config->get('store_name'));
     $mail->setSubject($this->config->get('store_name') . ' ' . $this->language->get('im_text_notification'));
     $mail->setHtml($text);
     $mail->setText($text);
     $mail->send();
     unset($mail);
     return true;
 }
Пример #5
0
 /**
  * @param int $order_id
  * @param array $data
  * @throws AException
  */
 public function addOrderHistory($order_id, $data)
 {
     $this->db->query("UPDATE `" . $this->db->table("orders") . "`\n\t\t\t\t\t\t\tSET order_status_id = '" . (int) $data['order_status_id'] . "',\n\t\t\t\t\t\t\t\tdate_modified = NOW()\n\t\t\t\t\t\t\tWHERE order_id = '" . (int) $order_id . "'");
     if ($data['append']) {
         $this->db->query("INSERT INTO " . $this->db->table("order_history") . "\n      \t\t                    SET order_id = '" . (int) $order_id . "',\n      \t\t                        order_status_id = '" . (int) $data['order_status_id'] . "',\n      \t\t                        notify = '" . (isset($data['notify']) ? (int) $data['notify'] : 0) . "',\n      \t\t                        comment = '" . $this->db->escape(strip_tags($data['comment'])) . "',\n      \t\t                        date_added = NOW()");
     }
     if ($data['notify']) {
         $order_query = $this->db->query("SELECT *, os.name AS status\n        \t                                FROM `" . $this->db->table("orders") . "` o\n        \t                                LEFT JOIN " . $this->db->table("order_statuses") . " os ON (o.order_status_id = os.order_status_id AND os.language_id = o.language_id)\n        \t                                LEFT JOIN " . $this->db->table("languages") . " l ON (o.language_id = l.language_id)\n        \t                                WHERE o.order_id = '" . (int) $order_id . "'");
         if ($order_query->num_rows) {
             //load language specific for the order in admin section
             $language = new ALanguage(Registry::getInstance(), $order_query->row['code'], 1);
             $language->load($order_query->row['filename']);
             $language->load('mail/order');
             $this->load->model('setting/store');
             $subject = sprintf($language->get('text_subject'), $order_query->row['store_name'], $order_id);
             $message = $language->get('text_order') . ' ' . $order_id . "\n";
             $message .= $language->get('text_date_added') . ' ' . dateISO2Display($order_query->row['date_added'], $language->get('date_format_short')) . "\n\n";
             $message .= $language->get('text_order_status') . "\n\n";
             $message .= $order_query->row['status'] . "\n\n";
             $message .= $language->get('text_invoice') . "\n";
             $message .= html_entity_decode($order_query->row['store_url'] . 'index.php?rt=account/invoice&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\n\n";
             if ($data['comment']) {
                 $message .= $language->get('text_comment') . "\n\n";
                 $message .= strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "\n\n";
             }
             $message .= $language->get('text_footer');
             if ($this->dcrypt->active) {
                 $customer_email = $this->dcrypt->decrypt_field($order_query->row['email'], $order_query->row['key_id']);
             } else {
                 $customer_email = $order_query->row['email'];
             }
             $mail = new AMail($this->config);
             $mail->setTo($customer_email);
             $mail->setFrom($this->config->get('store_main_email'));
             $mail->setSender($order_query->row['store_name']);
             $mail->setSubject($subject);
             $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
             $mail->send();
         }
     }
 }
Пример #6
0
 public function loginname()
 {
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if ($this->customer->isLogged()) {
         $this->redirect($this->html->getSecureURL('account/account'));
     }
     $this->document->setTitle($this->language->get('heading_title_loginname'));
     $this->loadModel('account/customer');
     $cust_detatils = array();
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_find_customer('loginname', $cust_detatils)) {
         //extra check that we have csutomer details
         if (!empty($cust_detatils['email'])) {
             $this->loadLanguage('mail/account_forgotten_login');
             $subject = sprintf($this->language->get('text_subject'), $this->config->get('store_name'));
             $message = sprintf($this->language->get('text_greeting'), $this->config->get('store_name')) . "\n\n";
             $message .= $this->language->get('text_your_loginname') . "\n\n";
             $message .= $cust_detatils['loginname'];
             $mail = new AMail($this->config);
             $mail->setTo($cust_detatils['email']);
             $mail->setFrom($this->config->get('store_main_email'));
             $mail->setSender($this->config->get('store_name'));
             $mail->setSubject($subject);
             $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
             $mail->send();
             $this->session->data['success'] = $this->language->get('text_success_loginname');
             $this->redirect($this->html->getSecureURL('account/login'));
         }
     }
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator')));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/forgotten/loginname'), 'text' => $this->language->get('text_forgotten_loginname'), 'separator' => $this->language->get('text_separator')));
     $this->view->assign('error', $this->error['message']);
     $this->view->assign('action', $this->html->getSecureURL('account/forgotten'));
     $this->view->assign('back', $this->html->getSecureURL('account/account'));
     $form = new AForm();
     $form->setForm(array('form_name' => 'forgottenFrm'));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'forgottenFrm', 'action' => $this->html->getSecureURL('account/forgotten/loginname')));
     $this->data['help_text'] = $this->language->get('text_lastname_email');
     $this->data['heading_title'] = $this->language->get('heading_title_loginname');
     $this->data['form']['fields']['lastname'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'lastname', 'value' => $this->request->post['lastname']));
     $this->data['form']['fields']['email'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'email', 'value' => $this->request->post['email']));
     $this->data['form']['continue'] = $form->getFieldHtml(array('type' => 'submit', 'name' => $this->language->get('button_continue')));
     $this->data['form']['back'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'back', 'style' => 'button', 'text' => $this->language->get('button_back')));
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/account/forgotten.tpl');
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Пример #7
0
 public function sendNewsletter()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     // this method can process only posting.
     if ($this->request->server['REQUEST_METHOD'] != 'POST') {
         $this->redirect($this->html->getSecureURL('sale/contact'));
     }
     if (!$this->_validate()) {
         $this->main();
         return null;
     }
     $this->loadModel('sale/customer');
     $this->loadModel('setting/store');
     $store_info = $this->model_setting_store->getStore($this->request->post['store_id']);
     if ($store_info) {
         $store_name = $store_info['store_name'];
     } else {
         $store_name = $this->config->get('store_name');
     }
     $emails = array();
     // All customers by group
     if (isset($this->request->post['recipient'])) {
         $customers = $results = array();
         if ($this->request->post['recipient'] == 'all_subscribers') {
             $all_subscribers = $this->model_sale_customer->getAllSubscribers();
             $results = $this->_unify_customer_list($all_subscribers);
         } else {
             if ($this->request->post['recipient'] == 'only_subscribers') {
                 $only_subscribers = $this->model_sale_customer->getOnlyNewsletterSubscribers();
                 $results = $this->_unify_customer_list($only_subscribers);
             } else {
                 if ($this->request->post['recipient'] == 'only_customers') {
                     $only_customers = $this->model_sale_customer->getOnlyCustomers(array('status' => 1, 'approved' => 1));
                     $results = $this->_unify_customer_list($only_customers);
                 }
             }
         }
         foreach ($results as $result) {
             $customer_id = $result['customer_id'];
             $emails[$customer_id] = $customers[$customer_id] = trim($result['email']);
         }
     }
     // All customers by name/email
     if (isset($this->request->post['to']) && $this->request->post['to']) {
         foreach ($this->request->post['to'] as $customer_id) {
             $customer_info = $this->model_sale_customer->getCustomer($customer_id);
             if ($customer_info) {
                 $emails[] = trim($customer_info['email']);
             }
         }
     }
     // All customers by product
     if (isset($this->request->post['product'])) {
         foreach ($this->request->post['product'] as $product_id) {
             $results = $this->model_sale_customer->getCustomersByProduct($product_id);
             if ($customers) {
                 $emails = array();
             }
             foreach ($results as $result) {
                 if ($customers && in_array($result['email'], $customers)) {
                     $emails[] = trim($result['email']);
                 }
             }
         }
     }
     // Prevent Duplicates
     $emails = array_unique($emails);
     if ($emails) {
         $message_html = '<html dir="ltr" lang="en">' . "\n";
         $message_html .= '<head>' . "\n";
         $message_html .= '<title>' . $this->request->post['subject'] . '</title>' . "\n";
         $message_html .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
         $message_html .= '</head>' . "\n";
         $message_html .= '<body>%MESSAGEBODY%</body>' . "\n";
         $message_html .= '</html>' . "\n";
         $text_unsubscribe = $this->language->get('text_unsubscribe');
         $text_subject = $this->request->post['subject'];
         $text_message = $this->request->post['message'];
         $from = $this->config->get('store_main_email');
         foreach ($emails as $email) {
             $mail = new AMail($this->config);
             $mail->setTo($email);
             $mail->setFrom($from);
             $mail->setSender($store_name);
             $mail->setSubject($text_subject);
             $message_body = $text_message;
             if ($this->request->post['recipient'] == 'newsletter') {
                 if ($customer_id = array_search($email, $customers)) {
                     $message_body .= "\n\n<br><br>" . sprintf($text_unsubscribe, $email, $this->html->getCatalogURL('account/unsubscribe', '&email=' . $email . '&customer_id=' . $customer_id));
                 }
             }
             $message_body = html_entity_decode($message_body, ENT_QUOTES, 'UTF-8');
             $html = str_replace('%MESSAGEBODY%', $message_body, $message_html);
             $mail->setHtml($html);
             $mail->send();
             if ($mail->error) {
                 $this->error[] = 'Error: Emails does not sent! Please see error log for details.';
                 $this->main();
                 return null;
             }
             unset($mail);
         }
     }
     if (!$mail->error) {
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->html->getSecureURL('sale/contact'));
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Пример #8
0
 /**
  * @param int $id - customer_id
  */
 private function _sendMail($id)
 {
     // send email to customer
     $customer_info = $this->model_sale_customer->getCustomer($id);
     if ($customer_info) {
         $this->loadLanguage('mail/customer');
         $this->loadModel('setting/store');
         $store_info = $this->model_setting_store->getStore($customer_info['store_id']);
         if ($store_info) {
             $store_name = $store_info['store_name'];
             $store_url = $store_info['config_url'] . 'index.php?rt=account/login';
         } else {
             $store_name = $this->config->get('store_name');
             $store_url = $this->config->get('config_url') . 'index.php?rt=account/login';
         }
         $message = sprintf($this->language->get('text_welcome'), $store_name) . "\n\n";
         $message .= $this->language->get('text_login') . "\n";
         $message .= $store_url . "\n\n";
         $message .= $this->language->get('text_services') . "\n\n";
         $message .= $this->language->get('text_thanks') . "\n";
         $message .= $store_name;
         $mail = new AMail($this->config);
         $mail->setTo($customer_info['email']);
         $mail->setFrom($this->config->get('store_main_email'));
         $mail->setSender($store_name);
         $mail->setSubject(sprintf($this->language->get('text_subject'), $store_name));
         $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
         $mail->send();
     }
 }
Пример #9
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     $this->form = new AForm('ContactUsFrm');
     $this->form->loadFromDb('ContactUsFrm');
     $form = $this->form->getForm();
     if ($this->request->is_POST() && $this->_validate()) {
         // move all uploaded files to their directories
         $file_pathes = $this->form->processFileUploads($this->request->files);
         $template = new ATemplate();
         $subject = sprintf($this->language->get('email_subject'), $this->request->post['name']);
         $template->data['subject'] = $subject;
         $mail = new AMail($this->config);
         $mail->setTo($this->config->get('store_main_email'));
         $mail->setFrom($this->config->get('store_main_email'));
         $mail->setReplyTo($this->request->post['email']);
         $mail->setSender($this->request->post['first_name']);
         $mail->setSubject($subject);
         $store_logo = md5(pathinfo($this->config->get('config_logo'), PATHINFO_FILENAME)) . '.' . pathinfo($this->config->get('config_logo'), PATHINFO_EXTENSION);
         $template->data['logo'] = 'cid:' . $store_logo;
         $template->data['store_name'] = $this->config->get('store_name');
         $template->data['store_url'] = $this->config->get('config_url');
         $template->data['text_project_label'] = project_base();
         $template->data['entry_enquiry'] = $msg = $this->language->get('entry_enquiry');
         $msg .= "\r\n" . $this->request->post['enquiry'] . "\r\n";
         $template->data['enquiry'] = nl2br($this->request->post['enquiry'] . "\r\n");
         $form_fields = $this->form->getFields();
         $template->data['form_fields'] = array();
         foreach ($form_fields as $field_name => $field_info) {
             if (has_value($this->request->post[$field_name]) && !in_array($field_name, array('first_name', 'email', 'enquiry', 'captcha'))) {
                 $field_details = $this->form->getField($field_name);
                 $msg .= "\r\n" . rtrim($field_details['name'], ':') . ":\t" . $this->request->post[$field_name];
                 $template->data['form_fields'][rtrim($field_details['name'], ':')] = $this->request->post[$field_name];
             }
         }
         if ($file_pathes) {
             $msg .= "\r\n" . $this->language->get('entry_attached') . ": \r\n";
             foreach ($file_pathes as $file_info) {
                 $basename = pathinfo(str_replace(' ', '_', $file_info['path']), PATHINFO_BASENAME);
                 $msg .= "\t" . $file_info['display_name'] . ': ' . $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)\r\n";
                 $mail->addAttachment($file_info['path'], $basename);
                 $template->data['form_fields'][$file_info['display_name']] = $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)";
             }
         }
         $mail_html = $template->fetch('mail/contact.tpl');
         $mail->setHtml($mail_html);
         $mail->addAttachment(DIR_RESOURCE . $this->config->get('config_logo'), $store_logo);
         $mail->setText(strip_tags(html_entity_decode($msg, ENT_QUOTES, 'UTF-8')));
         $mail->send();
         //get success_page
         if ($form['success_page']) {
             $success_url = $this->html->getSecureURL($form['success_page']);
         } else {
             $success_url = $this->html->getSecureURL('content/contact/success');
         }
         //notify admin
         $this->loadLanguage('common/im');
         $message_arr = array(1 => array('message' => sprintf($this->language->get('im_customer_contact_admin_text'), $this->request->post['email'], $this->request->post['first_name'])));
         $this->im->send('customer_contact', $message_arr);
         $this->extensions->hk_ProcessData($this);
         $this->redirect($success_url);
     }
     if ($this->request->is_POST()) {
         foreach ($this->request->post as $name => $value) {
             $this->form->assign($name, $value);
         }
     }
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => false));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('content/contact'), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator')));
     $this->view->assign('form_output', $this->form->getFormHtml());
     $this->view->assign('action', $this->html->getURL('content/contact'));
     $this->view->assign('store', $this->config->get('store_name'));
     $this->view->assign('address', nl2br($this->config->get('config_address')));
     $this->view->assign('telephone', $this->config->get('config_telephone'));
     $this->view->assign('fax', $this->config->get('config_fax'));
     $this->processTemplate('pages/content/contact.tpl');
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Пример #10
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if ($this->customer->isLogged()) {
         $this->redirect($this->html->getSecureURL('account/account'));
     }
     $this->document->setTitle($this->language->get('heading_title'));
     $this->loadModel('account/customer');
     $request_data = $this->request->post;
     if ($this->request->is_POST()) {
         $this->errors = array_merge($this->errors, $this->model_account_customer->validateRegistrationData($request_data));
         if (!$this->errors) {
             //if allow login as email, need to set loginname = email
             if (!$this->config->get('prevent_email_as_login')) {
                 $request_data['loginname'] = $request_data['email'];
             }
             $this->data['customer_id'] = $this->model_account_customer->addCustomer($request_data);
             $this->model_account_customer->editCustomerNotifications($request_data, $this->data['customer_id']);
             unset($this->session->data['guest']);
             //login customer after create account is approvement and email activation are disabled in settings
             if (!$this->config->get('config_customer_approval') && !$this->config->get('config_customer_email_activation')) {
                 $this->customer->login($request_data['loginname'], $request_data['password']);
             }
             $template = new ATemplate();
             $this->loadLanguage('mail/account_create');
             $subject = sprintf($this->language->get('text_subject'), $this->config->get('store_name'));
             $message = sprintf($this->language->get('text_welcome'), $this->config->get('store_name')) . "\n\n";
             $template->data['text_welcome'] = $message;
             $activation = false;
             if (!$this->config->get('config_customer_approval')) {
                 //add account activation link if required
                 if ($this->config->get('config_customer_email_activation')) {
                     $activation = true;
                     // sign of activation email
                     $code = md5(mt_rand(1, 3000));
                     $email = $this->request->post['email'];
                     $this->session->data['activation'] = array('customer_id' => $this->data['customer_id'], 'code' => $code, 'email' => $email);
                     $activate_url = $this->html->getSecureURL('account/login', '&activation=' . $code . '&email=' . $email);
                     $message .= sprintf($this->language->get('text_activate'), $activate_url . "\n") . "\n";
                     $template->data['text_activate'] = sprintf($this->language->get('text_activate'), '<a href="' . $activate_url . '">' . $activate_url . '</a>');
                 } else {
                     $message .= $this->language->get('text_login') . "\n";
                     $template->data['text_login'] = $this->language->get('text_login');
                 }
             } else {
                 $message .= $this->language->get('text_approval') . "\n";
                 $template->data['text_approval'] = $this->language->get('text_approval');
             }
             if (!$activation) {
                 $login_url = $this->html->getSecureURL('account/login');
                 $message .= $login_url . "\n\n";
                 $message .= $this->language->get('text_services') . "\n\n";
                 $template->data['text_login_later'] = '<a href="' . $login_url . '">' . $login_url . '</a><br>' . $this->language->get('text_services');
             }
             $message .= $this->language->get('text_thanks') . "\n";
             $message .= $this->config->get('store_name');
             $template->data['text_thanks'] = $this->language->get('text_thanks');
             $mail = new AMail($this->config);
             $mail->setTo($this->request->post['email']);
             $mail->setFrom($this->config->get('store_main_email'));
             $mail->setSender($this->config->get('store_name'));
             $mail->setSubject($subject);
             $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
             $store_logo = md5(pathinfo($this->config->get('config_logo'), PATHINFO_FILENAME)) . '.' . pathinfo($this->config->get('config_logo'), PATHINFO_EXTENSION);
             $template->data['logo'] = 'cid:' . $store_logo;
             $template->data['store_name'] = $this->config->get('store_name');
             $template->data['store_url'] = $this->config->get('config_url');
             $template->data['text_project_label'] = project_base();
             $mail_html = $template->fetch('mail/account_create.tpl');
             $mail->addAttachment(DIR_RESOURCE . $this->config->get('config_logo'), $store_logo);
             $mail->setHtml($mail_html);
             $mail->send();
             $this->extensions->hk_UpdateData($this, __FUNCTION__);
             //set success text for non-approved customers on login page after redirect
             if ($this->config->get('config_customer_approval')) {
                 $this->loadLanguage('account/success');
                 $this->session->data['success'] = sprintf($this->language->get('text_approval', 'account/success'), $this->config->get('store_name'), $this->html->getSecureURL('content/contact'));
             }
             if ($this->config->get('config_customer_email_activation') || !$this->session->data['redirect']) {
                 $redirect_url = $this->html->getSecureURL('account/success');
             } else {
                 $redirect_url = $this->session->data['redirect'];
             }
             $this->redirect($redirect_url);
         } else {
             if (!$this->errors['warning']) {
                 $this->errors['warning'] = implode('<br>', $this->errors);
             }
         }
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => false));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator')));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/create'), 'text' => $this->language->get('text_create'), 'separator' => $this->language->get('text_separator')));
     if ($this->config->get('prevent_email_as_login')) {
         $this->data['noemaillogin'] = true;
     }
     $form = new AForm();
     $form->setForm(array('form_name' => 'AccountFrm'));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'AccountFrm', 'action' => $this->html->getSecureURL('account/create')));
     if ($this->config->get('prevent_email_as_login')) {
         // require login name
         $this->data['form']['fields']['general']['loginname'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'loginname', 'value' => $this->request->post['loginname'], 'required' => true));
     }
     $this->data['form']['fields']['general']['firstname'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'firstname', 'value' => $this->request->post['firstname'], 'required' => true));
     $this->data['form']['fields']['general']['lastname'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'lastname', 'value' => $this->request->post['lastname'], 'required' => true));
     $this->data['form']['fields']['general']['email'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'email', 'value' => $this->request->get_or_post('email'), 'required' => true));
     $this->data['form']['fields']['general']['telephone'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'telephone', 'value' => $this->request->post['telephone']));
     $this->data['form']['fields']['general']['fax'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'fax', 'value' => $this->request->post['fax'], 'required' => false));
     //get only active IM drivers
     $im_drivers = $this->im->getIMDriverObjects();
     if ($im_drivers) {
         foreach ($im_drivers as $protocol => $driver_obj) {
             if (!is_object($driver_obj) || $protocol == 'email') {
                 continue;
             }
             $fld = $driver_obj->getURIField($form, $this->request->post[$protocol]);
             $this->data['form']['fields']['general'][$protocol] = $fld;
             $this->data['entry_' . $protocol] = $fld->label_text;
         }
     }
     $this->data['form']['fields']['address']['company'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'company', 'value' => $this->request->post['company'], 'required' => false));
     $this->data['form']['fields']['address']['address_1'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'address_1', 'value' => $this->request->post['address_1'], 'required' => true));
     $this->data['form']['fields']['address']['address_2'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'address_2', 'value' => $this->request->post['address_2'], 'required' => false));
     $this->data['form']['fields']['address']['city'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'city', 'value' => $this->request->post['city'], 'required' => true));
     $this->view->assign('zone_id', $this->request->post['zone_id'], 'FALSE');
     $this->data['form']['fields']['address']['zone'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'zone_id', 'required' => true));
     $this->data['form']['fields']['address']['postcode'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'postcode', 'value' => $this->request->post['postcode'], 'required' => true));
     $this->loadModel('localisation/country');
     $countries = $this->model_localisation_country->getCountries();
     $options = array("FALSE" => $this->language->get('text_select'));
     foreach ($countries as $item) {
         $options[$item['country_id']] = $item['name'];
     }
     $this->data['form']['fields']['address']['country'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'country_id', 'options' => $options, 'value' => isset($this->request->post['country_id']) ? $this->request->post['country_id'] : $this->config->get('config_country_id'), 'required' => true));
     $this->data['form']['fields']['password']['password'] = $form->getFieldHtml(array('type' => 'password', 'name' => 'password', 'value' => $this->request->post['password'], 'required' => true));
     $this->data['form']['fields']['password']['confirm'] = $form->getFieldHtml(array('type' => 'password', 'name' => 'confirm', 'value' => $this->request->post['confirm'], 'required' => true));
     $this->data['form']['fields']['newsletter']['newsletter'] = $form->getFieldHtml(array('type' => 'radio', 'name' => 'newsletter', 'value' => !is_null($this->request->get_or_post('newsletter')) ? $this->request->get_or_post('newsletter') : -1, 'options' => array('1' => $this->language->get('text_yes'), '0' => $this->language->get('text_no'))));
     //If captcha enabled, validate
     if ($this->config->get('config_account_create_captcha')) {
         if ($this->config->get('config_recaptcha_site_key')) {
             $this->data['form']['fields']['newsletter']['captcha'] = $form->getFieldHtml(array('type' => 'recaptcha', 'name' => 'recaptcha', 'recaptcha_site_key' => $this->config->get('config_recaptcha_site_key'), 'language_code' => $this->language->getLanguageCode()));
         } else {
             $this->data['form']['fields']['newsletter']['captcha'] = $form->getFieldHtml(array('type' => 'captcha', 'name' => 'captcha', 'attr' => ''));
         }
     }
     //TODO: REMOVE THIS IN 1.3!!!
     // backward compatibility code
     $deprecated = $this->data['form']['fields'];
     foreach ($deprecated as $section => $fields) {
         foreach ($fields as $name => $fld) {
             if (in_array($name, array('country', 'zone'))) {
                 $name .= '_id';
             }
             $this->data['form'][$name] = $fld;
         }
     }
     //end of trick
     $agree = isset($this->request->post['agree']) ? $this->request->post['agree'] : false;
     $this->data['form']['agree'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'agree', 'value' => 1, 'checked' => $agree));
     $this->data['form']['continue'] = $form->getFieldHtml(array('type' => 'submit', 'name' => $this->language->get('button_continue')));
     $this->data['error_warning'] = $this->errors['warning'];
     $this->data['error_loginname'] = $this->errors['loginname'];
     $this->data['error_firstname'] = $this->errors['firstname'];
     $this->data['error_lastname'] = $this->errors['lastname'];
     $this->data['error_email'] = $this->errors['email'];
     $this->data['error_telephone'] = $this->errors['telephone'];
     $this->data['error_password'] = $this->errors['password'];
     $this->data['error_confirm'] = $this->errors['confirm'];
     $this->data['error_address_1'] = $this->errors['address_1'];
     $this->data['error_city'] = $this->errors['city'];
     $this->data['error_postcode'] = $this->errors['postcode'];
     $this->data['error_country'] = $this->errors['country'];
     $this->data['error_zone'] = $this->errors['zone'];
     $this->data['error_captcha'] = $this->errors['captcha'];
     $this->data['action'] = $this->html->getSecureURL('account/create');
     $this->data['newsletter'] = $this->request->post['newsletter'];
     if ($this->config->get('config_account_id')) {
         $this->loadModel('catalog/content');
         $content_info = $this->model_catalog_content->getContent($this->config->get('config_account_id'));
         if ($content_info) {
             $text_agree = $this->language->get('text_agree');
             $this->data['text_agree_href'] = $this->html->getURL('r/content/content/loadInfo', '&content_id=' . $this->config->get('config_account_id'));
             $this->data['text_agree_href_text'] = $content_info['title'];
         } else {
             $text_agree = '';
         }
     } else {
         $text_agree = '';
     }
     $this->data['text_agree'] = $text_agree;
     $text_account_already = sprintf($this->language->get('text_account_already'), $this->html->getSecureURL('account/login'));
     $this->data['text_account_already'] = $text_account_already;
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/account/create.tpl');
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Пример #11
0
 public function post()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     //only support post params for create account
     $request_data = $this->rest->getRequestParams();
     if ($this->customer->isLoggedWithToken($request['token'])) {
         $this->rest->setResponseData(array('error' => 'Already Logged in. Can not create new account.'));
         $this->rest->sendResponse(401);
         return null;
     }
     $this->loadModel('account/customer');
     $this->loadLanguage('account/create');
     $this->loadLanguage('account/success');
     //????? Think of way to validate and block machine registrations (non-human)
     $this->v_error = $this->model_account_customer->validateRegistrationData($request_data);
     if (!$this->v_error) {
         $this->model_account_customer->addCustomer($request_data);
         unset($this->session->data['guest']);
         $this->customer->login($request_data['email'], $request_data['password']);
         $this->loadLanguage('mail/account_create');
         $subject = sprintf($this->language->get('text_subject'), $this->config->get('store_name'));
         $message = sprintf($this->language->get('text_welcome'), $this->config->get('store_name')) . "\n\n";
         if (!$this->config->get('config_customer_approval')) {
             $message .= $this->language->get('text_login') . "\n";
         } else {
             $message .= $this->language->get('text_approval') . "\n";
         }
         $message .= $this->html->getSecureURL('account/login') . "\n\n";
         $message .= $this->language->get('text_services') . "\n\n";
         $message .= $this->language->get('text_thanks') . "\n";
         $message .= $this->config->get('store_name');
         $mail = new AMail($this->config);
         $mail->setTo($request_data['email']);
         $mail->setFrom($this->config->get('store_main_email'));
         $mail->setSender($this->config->get('store_name'));
         $mail->setSubject($subject);
         $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
         $mail->send();
         $this->data['status'] = 1;
         if (!$this->config->get('config_customer_approval')) {
             $this->data['text_message'] = sprintf($this->language->get('text_message'), '');
         } else {
             $this->data['text_message'] = sprintf($this->language->get('text_approval'), $this->config->get('store_name'), '');
         }
     } else {
         $this->data['status'] = 0;
         $this->data['errors'] = $this->v_error;
         $this->data['error_warning'] = $this->v_error['warning'];
         $this->data['error_loginname'] = $this->v_error['loginname'];
         $this->data['error_firstname'] = $this->v_error['firstname'];
         $this->data['error_lastname'] = $this->v_error['lastname'];
         $this->data['error_email'] = $this->v_error['email'];
         $this->data['error_telephone'] = $this->v_error['telephone'];
         $this->data['error_password'] = $this->v_error['password'];
         $this->data['error_confirm'] = $this->v_error['confirm'];
         $this->data['error_address_1'] = $this->v_error['address_1'];
         $this->data['error_city'] = $this->v_error['city'];
         $this->data['error_country'] = $this->v_error['country'];
         $this->data['error_zone'] = $this->v_error['zone'];
         return $this->get();
     }
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->rest->setResponseData($this->data);
     $this->rest->sendResponse(200);
 }
 public function main()
 {
     $this->loadModel('tool/forms_manager');
     $this->loadLanguage('forms_manager/forms_manager');
     $this->loadLanguage('forms_manager/default_email');
     if ($this->request->is_POST()) {
         $path = $_SERVER['HTTP_REFERER'];
         if (!isset($this->request->get['form_id'])) {
             $this->redirect($path);
             exit;
         }
         $form_id = $this->request->get['form_id'];
         $form_data = $this->model_tool_forms_manager->getForm($form_id);
         $form = new AForm($form_data['form_name']);
         $form->loadFromDb($form_data['form_name']);
         $errors = $form->validateFormData($this->request->post);
         if ($errors) {
             //save error and data to session
             $this->session->data['custom_form_' . $form_id] = $this->request->post;
             $this->session->data['custom_form_' . $form_id]['errors'] = $errors;
             $this->redirect($path);
             exit;
         } else {
             $mail = new AMail($this->config);
             $mail->setTo($this->config->get('store_main_email'));
             if (isset($this->request->post['email'])) {
                 $mail->setFrom($this->request->post['email']);
                 unset($this->request->post['email']);
             } else {
                 $sender_email = $this->config->get('forms_manager_default_sender_email');
                 $sender_email = !$sender_email ? $this->config->get('store_main_email') : $sender_email;
                 $mail->setFrom($sender_email);
             }
             if (isset($this->request->post['first_name'])) {
                 $mail->setSender($this->request->post['first_name']);
                 unset($this->request->post['first_name']);
             } else {
                 $sender_name = $this->config->get('forms_manager_default_sender_name');
                 $sender_name = !$sender_name ? $this->config->get('store_name') : $sender_name;
                 $mail->setSender($sender_name);
             }
             if (isset($this->request->post['email_subject'])) {
                 $mail->setSubject($this->request->post['email_subject']);
                 unset($this->request->post['email_subject']);
             } else {
                 $mail->setSubject($form_data['form_name']);
             }
             $msg = $this->config->get('store_name') . "\r\n" . $this->config->get('config_url') . "\r\n";
             $fields = $this->model_tool_forms_manager->getFields($form_id);
             foreach ($fields as $field) {
                 // skip files and captchas
                 if (in_array($field['element_type'], array('K', 'J', 'U'))) {
                     continue;
                 }
                 if (isset($this->request->post[$field['field_name']])) {
                     $val = $this->request->post[$field['field_name']];
                     $val = $this->_prepareValue($val);
                     //for zones
                     if ($field['element_type'] == 'Z') {
                         $msg .= $field['name'] . ': ' . $val . "";
                         $val = $this->request->post[$field['field_name'] . '_zones'];
                         $val = $this->_prepareValue($val);
                         $msg .= "\t" . $val . "\r\n";
                     } else {
                         $msg .= $field['name'] . ': ' . $val . "\r\n";
                     }
                 }
             }
             // add attachments
             $file_pathes = $form->processFileUploads($this->request->files);
             if ($file_pathes) {
                 $msg .= "\r\n" . $this->language->get('entry_attached') . ": \r\n";
                 foreach ($file_pathes as $file_info) {
                     $basename = pathinfo(str_replace(' ', '_', $file_info['path']), PATHINFO_BASENAME);
                     $msg .= "\t" . $file_info['display_name'] . ': ' . $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)\r\n";
                     $mail->addAttachment($file_info['path'], $basename);
                 }
             }
             $mail->setText(strip_tags(html_entity_decode($msg, ENT_QUOTES, 'UTF-8')));
             $mail->send();
             if (empty($mail->error)) {
                 if ($form_data['success_page']) {
                     $success_url = $this->html->getSecureURL($form_data['success_page']);
                 } else {
                     $success_url = $this->html->getSecureURL('forms_manager/default_email/success');
                 }
                 //clear form session
                 unset($this->session->data['custom_form_' . $form_id]);
                 $this->redirect($success_url);
                 exit;
             } else {
                 $this->session->data['warning'] = $mail->error;
                 $this->redirect($this->html->getSecureURL('forms_manager/default_email', '&form_id=' . $form_id));
                 exit;
             }
         }
     }
     $this->data['warning'] = $this->session->data['warning'];
     if (isset($this->session->data['warning'])) {
         unset($this->session->data['warning']);
     }
     $this->document->setTitle($this->language->get('text_default_email_title'));
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('forms_manager/default_email'), 'text' => $this->language->get('text_default_email_title'), 'separator' => $this->language->get('text_separator')));
     $this->data['continue'] = $_SERVER['HTTP_REFERER'];
     $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button', 'icon' => 'icon-arrow-right'));
     $this->data['continue_button'] = $continue;
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/default_email.tpl');
 }
 /**
  * @param array $data
  * @return bool|int
  * @throws AException
  */
 public function addCustomerTransaction($data = array())
 {
     if (!(double) $data['credit'] && !(double) $data['debit'] || !(int) $data['customer_id']) {
         return false;
     }
     $sql = "INSERT INTO " . $this->db->table("customer_transactions") . "\n                    (`customer_id`,`order_id`,`created_by`,`credit`,`debit`,`section`, `transaction_type`,`comment`,`description`,`date_added`)\n                VALUES (\n                        '" . (int) $data['customer_id'] . "',\n                        '" . (int) $data['order_id'] . "',\n                        '" . $this->user->getId() . "',\n                        '" . (double) $data['credit'] . "',\n                        '" . (double) $data['debit'] . "',\n                        '1',\n                        '" . $this->db->escape($data['transaction_type']) . "',\n                        '" . $this->db->escape($data['comment']) . "',\n                        '" . $this->db->escape($data['description']) . "',\n                        NOW()\n                        )";
     $this->db->query($sql);
     $transaction_id = $this->db->getLastId();
     if ($data['notify']) {
         $this->load->model('sale/customer');
         $customer_info = $this->model_sale_customer->getCustomer($data['customer_id']);
         if ($customer_info) {
             //detect customer's language
             $sql = "SELECT language_id\n                        FROM " . $this->db->table('orders') . "\n                        WHERE customer_id = '" . (int) $data['customer_id'] . "'\n                        ORDER BY date_added DESC";
             $result = $this->db->query($sql);
             $language_code = '';
             if ($result->row['language_id']) {
                 $lang = $this->language->getLanguageDetailsByID($result->row['language_id']);
                 $language_code = $lang['code'];
             }
             if (!$language_code) {
                 $language_code = $this->language->getDefaultLanguageCode();
             }
             //load language specific for the order in admin section
             $language = new ALanguage(Registry::getInstance(), $language_code, 1);
             $language->load('sale/customer');
             $this->load->model('setting/store');
             $store_info = $this->model_setting_store->getStore((int) $this->session->data['current_store_id']);
             $subject = sprintf($language->get('text_transaction_notification_subject'), $store_info['store_name']);
             $url = html_entity_decode($store_info['config_url'] . 'index.php?rt=account/transactions', ENT_QUOTES, 'UTF-8');
             $amount = $this->currency->format($data['credit'] - $data['debit']);
             $message = sprintf($language->get('text_transaction_notification_message'), $store_info['store_name'], $amount, $store_info['store_name']) . "\n\n";
             $message .= $url . "\n\n";
             $message .= $data['description'];
             $mail = new AMail($this->config);
             $mail->setTo($customer_info['email']);
             $mail->setFrom($store_info['store_main_email']);
             $mail->setSender($store_info['store_name']);
             $mail->setSubject($subject);
             $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
             $mail->send();
             //notify customer
             $language->load('common/im');
             $message_arr = array(0 => array('message' => sprintf($language->get('im_customer_account_update_text_to_customer'), $store_info['store_name'], $amount, $store_info['store_name'])));
             $this->im->sendToCustomer($data['customer_id'], 'customer_account_update', $message_arr);
         }
     }
     return $transaction_id;
 }
Пример #14
0
 private function _send_email($email, $data)
 {
     if (!$email || !$data) {
         $error = new AError('Error: Cannot send email. Unknown address or empty message.');
         $error->toLog()->toMessages();
         return false;
     }
     // HTML Mail
     $template = new ATemplate();
     $template->data['lang_direction'] = $this->language->get('direction');
     $template->data['lang_code'] = $this->language->get('code');
     $text_subject = $data['subject'];
     $template->data['subject'] = $text_subject;
     $text_unsubscribe = $this->language->get('text_unsubscribe');
     $text_message = $data['message'];
     $mail = new AMail($this->config);
     $mail->setTo($email);
     $mail->setFrom($data['from']);
     $mail->setSender($data['sender']);
     $mail->setSubject($text_subject);
     $message_body = $text_message;
     if ($data['subscriber']) {
         $customer_info = $this->model_sale_customer->getCustomersByEmails(array($email));
         $customer_id = $customer_info[0]['customer_id'];
         if ($customer_id) {
             $message_body .= "\n\n<br><br>" . sprintf($text_unsubscribe, $email, $this->html->getCatalogURL('account/notification', '&email=' . $email . '&customer_id=' . $customer_id));
         }
     }
     $template->data['body'] = html_entity_decode($message_body, ENT_QUOTES, 'UTF-8');
     $html = $template->fetch('mail/contact.tpl');
     $mail->setHtml($html);
     $mail->send();
     if ($mail->error) {
         return false;
     }
     return true;
 }
Пример #15
0
 public function validate()
 {
     if ($this->user->isLogged()) {
         $this->user->logout();
         unset($this->session->data['token']);
     }
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('common/forgot_password');
     $this->document->setTitle($this->language->get('heading_title'));
     if ($this->request->is_POST() && $this->_validateCaptcha()) {
         //generate password
         $password = AUser::generatePassword(8);
         $this->model_user_user->editUser($this->user_data['user_id'], array('password' => $password));
         $mail = new AMail($this->config);
         $mail->setTo($this->user_data['email']);
         $mail->setFrom($this->config->get('store_main_email'));
         $mail->setSender($this->config->get('config_owner'));
         $mail->setSubject(sprintf($this->language->get('reset_email_subject'), $this->config->get('store_name')));
         $mail->setHtml(sprintf($this->language->get('new_password_email_body'), $password));
         $mail->setText(sprintf($this->language->get('new_password_email_body'), $password));
         $mail->send();
         $this->redirect($this->html->getSecureURL('index/forgot_password/validate', '&mail=sent'));
     }
     $this->data['text_heading'] = $this->language->get('text_heading_reset');
     $this->data['login'] = $this->html->getSecureURL('index/login');
     if (isset($this->request->get['mail']) && $this->request->get['mail'] == 'sent') {
         $this->data['show_instructions'] = true;
         $this->data['text_instructions'] = $this->language->get('text_instructions_reset');
     } else {
         $this->data['error'] = $this->error;
         $this->data['action'] = $this->html->getSecureURL('index/forgot_password/validate', '&hash=' . $this->request->get['hash']);
         $this->data['update'] = '';
         $form = new AForm('ST');
         $form->setForm(array('form_name' => 'forgotFrm', 'update' => $this->data['update']));
         $this->data['form']['id'] = 'forgotFrm';
         $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'forgotFrm', 'action' => $this->data['action']));
         $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('text_please_confirm'), 'style' => 'button3'));
         $this->data['form']['fields']['username'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'username', 'value' => $this->request->post['username'], 'required' => true, 'placeholder' => $this->language->get('entry_username')));
         if ($this->config->get('config_recaptcha_site_key')) {
             $this->data['form']['fields']['captcha'] = $form->getFieldHtml(array('type' => 'recaptcha', 'name' => 'captcha', 'recaptcha_site_key' => $this->config->get('config_recaptcha_site_key'), 'language_code' => $this->language->getLanguageCode()));
         } else {
             $this->data['form']['fields']['captcha'] = $form->getFieldHtml(array('type' => 'captcha', 'name' => 'captcha', 'value' => $this->data['captcha'], 'required' => true, 'placeholder' => $this->language->get('entry_captcha')));
         }
     }
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/index/forgot_password.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if ($this->customer->isLogged()) {
         $this->redirect($this->html->getSecureURL('account/account'));
     }
     $this->document->setTitle($this->language->get('heading_title'));
     $this->loadModel('account/customer');
     $request_data = $this->request->post;
     if ($this->request->is_POST()) {
         $this->errors = array_merge($this->errors, $this->model_account_customer->validateRegistrationData($request_data));
         if (!$this->errors) {
             //if allow login as email, need to set loginname = email
             if (!$this->config->get('prevent_email_as_login')) {
                 $request_data['loginname'] = $request_data['email'];
             }
             $this->data['customer_id'] = $this->model_account_customer->addCustomer($request_data);
             unset($this->session->data['guest']);
             //login customer after create account is approvement and email activation are disabled in settings
             if (!$this->config->get('config_customer_approval') && !$this->config->get('config_customer_email_activation')) {
                 $this->customer->login($request_data['loginname'], $request_data['password']);
             }
             $this->loadLanguage('mail/account_create');
             $subject = sprintf($this->language->get('text_subject'), $this->config->get('store_name'));
             $message = sprintf($this->language->get('text_welcome'), $this->config->get('store_name')) . "\n\n";
             if (!$this->config->get('config_customer_approval')) {
                 //add account activation link if required
                 if ($this->config->get('config_customer_email_activation')) {
                     $activation = true;
                     // sign of activation email
                     $code = md5(mt_rand(1, 3000));
                     $email = $this->request->post['email'];
                     $this->session->data['activation'] = array('customer_id' => $this->data['customer_id'], 'code' => $code, 'email' => $email);
                     $message .= sprintf($this->language->get('text_activate'), "\n" . $this->html->getSecureURL('account/login', '&activation=' . $code . '&email=' . $email)) . "\n";
                 } else {
                     $message .= $this->language->get('text_login') . "\n";
                 }
             } else {
                 $message .= $this->language->get('text_approval') . "\n";
             }
             if (!$activation) {
                 $message .= $this->html->getSecureURL('account/login') . "\n\n";
                 $message .= $this->language->get('text_services') . "\n\n";
             }
             $message .= $this->language->get('text_thanks') . "\n";
             $message .= $this->config->get('store_name');
             $mail = new AMail($this->config);
             $mail->setTo($this->request->post['email']);
             $mail->setFrom($this->config->get('store_main_email'));
             $mail->setSender($this->config->get('store_name'));
             $mail->setSubject($subject);
             $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
             $mail->send();
             $this->extensions->hk_UpdateData($this, __FUNCTION__);
             if ($this->config->get('config_customer_email_activation') || !$this->session->data['redirect']) {
                 $redirect_url = $this->html->getSecureURL('account/success');
             } else {
                 $redirect_url = $this->session->data['redirect'];
             }
             $this->redirect($redirect_url);
         }
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator')));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/create'), 'text' => $this->language->get('text_create'), 'separator' => $this->language->get('text_separator')));
     if ($this->config->get('prevent_email_as_login')) {
         $this->data['noemaillogin'] = true;
     }
     $form = new AForm();
     $form->setForm(array('form_name' => 'AccountFrm'));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'AccountFrm', 'action' => $this->html->getSecureURL('account/create')));
     if ($this->config->get('prevent_email_as_login')) {
         // require login name
         $this->data['form']['loginname'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'loginname', 'value' => $this->request->post['loginname'], 'required' => true));
     }
     $this->data['form']['firstname'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'firstname', 'value' => $this->request->post['firstname'], 'required' => true));
     $this->data['form']['lastname'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'lastname', 'value' => $this->request->post['lastname'], 'required' => true));
     $this->data['form']['email'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'email', 'value' => $this->request->get_or_post('email'), 'required' => true));
     $this->data['form']['telephone'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'telephone', 'value' => $this->request->post['telephone']));
     $this->data['form']['fax'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'fax', 'value' => $this->request->post['fax'], 'required' => false));
     $this->data['form']['company'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'company', 'value' => $this->request->post['company'], 'required' => false));
     $this->data['form']['address_1'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'address_1', 'value' => $this->request->post['address_1'], 'required' => true));
     $this->data['form']['address_2'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'address_2', 'value' => $this->request->post['address_2'], 'required' => false));
     $this->data['form']['city'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'city', 'value' => $this->request->post['city'], 'required' => true));
     $this->data['form']['postcode'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'postcode', 'value' => $this->request->post['postcode'], 'required' => true));
     $this->loadModel('localisation/country');
     $countries = $this->model_localisation_country->getCountries();
     $options = array("FALSE" => $this->language->get('text_select'));
     foreach ($countries as $item) {
         $options[$item['country_id']] = $item['name'];
     }
     $this->data['form']['country_id'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'country_id', 'options' => $options, 'value' => isset($this->request->post['country_id']) ? $this->request->post['country_id'] : $this->config->get('config_country_id'), 'required' => true));
     $this->view->assign('zone_id', $this->request->post['zone_id'], 'FALSE');
     $this->data['form']['zone_id'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'zone_id', 'required' => true));
     $this->data['form']['password'] = $form->getFieldHtml(array('type' => 'password', 'name' => 'password', 'value' => $this->request->post['password'], 'required' => true));
     $this->data['form']['confirm'] = $form->getFieldHtml(array('type' => 'password', 'name' => 'confirm', 'value' => $this->request->post['confirm'], 'required' => true));
     $newsletter = '';
     $this->data['form']['newsletter'] = $form->getFieldHtml(array('type' => 'radio', 'name' => 'newsletter', 'value' => !is_null($this->request->get_or_post('newsletter')) ? $this->request->get_or_post('newsletter') : -1, 'options' => array('1' => $this->language->get('text_yes'), '0' => $this->language->get('text_no'))));
     $agree = isset($this->request->post['agree']) ? $this->request->post['agree'] : FALSE;
     $this->data['form']['agree'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'agree', 'value' => 1, 'checked' => $agree));
     $this->data['form']['continue'] = $form->getFieldHtml(array('type' => 'submit', 'name' => $this->language->get('button_continue')));
     $this->data['error_warning'] = $this->errors['warning'];
     $this->data['error_loginname'] = $this->errors['loginname'];
     $this->data['error_firstname'] = $this->errors['firstname'];
     $this->data['error_lastname'] = $this->errors['lastname'];
     $this->data['error_email'] = $this->errors['email'];
     $this->data['error_telephone'] = $this->errors['telephone'];
     $this->data['error_password'] = $this->errors['password'];
     $this->data['error_confirm'] = $this->errors['confirm'];
     $this->data['error_address_1'] = $this->errors['address_1'];
     $this->data['error_city'] = $this->errors['city'];
     $this->data['error_postcode'] = $this->errors['postcode'];
     $this->data['error_country'] = $this->errors['country'];
     $this->data['error_zone'] = $this->errors['zone'];
     $this->data['action'] = $this->html->getSecureURL('account/create');
     $this->data['newsletter'] = $this->request->post['newsletter'];
     if ($this->config->get('config_account_id')) {
         $this->loadModel('catalog/content');
         $content_info = $this->model_catalog_content->getContent($this->config->get('config_account_id'));
         if ($content_info) {
             $text_agree = $this->language->get('text_agree');
             $this->data['text_agree_href'] = $this->html->getURL('r/content/content/loadInfo', '&content_id=' . $this->config->get('config_account_id'));
             $this->data['text_agree_href_text'] = $content_info['title'];
         } else {
             $text_agree = '';
         }
     } else {
         $text_agree = '';
     }
     $this->data['text_agree'] = $text_agree;
     $text_account_already = sprintf($this->language->get('text_account_already'), $this->html->getSecureURL('account/login'));
     $this->data['text_account_already'] = $text_account_already;
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/account/create.tpl');
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Пример #17
0
 public function sendNewsletter()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     // this method can process only posting.
     if ($this->request->is_GET()) {
         $this->redirect($this->html->getSecureURL('sale/contact'));
     }
     if (!$this->_validate()) {
         $this->main();
         return null;
     }
     $this->loadModel('sale/customer');
     $this->loadModel('setting/store');
     $store_info = $this->model_setting_store->getStore($this->request->post['store_id']);
     if ($store_info) {
         $store_name = $store_info['store_name'];
     } else {
         $store_name = $this->config->get('store_name');
     }
     $emails = array();
     // All customers by group
     if (isset($this->request->post['recipient'])) {
         $customers = $results = array();
         if ($this->request->post['recipient'] == 'all_subscribers') {
             $all_subscribers = $this->model_sale_customer->getAllSubscribers();
             $results = $this->_unify_customer_list($all_subscribers);
         } else {
             if ($this->request->post['recipient'] == 'only_subscribers') {
                 $only_subscribers = $this->model_sale_customer->getOnlyNewsletterSubscribers();
                 $results = $this->_unify_customer_list($only_subscribers);
             } else {
                 if ($this->request->post['recipient'] == 'only_customers') {
                     $only_customers = $this->model_sale_customer->getOnlyCustomers(array('status' => 1, 'approved' => 1));
                     $results = $this->_unify_customer_list($only_customers);
                 }
             }
         }
         foreach ($results as $result) {
             $customer_id = $result['customer_id'];
             $emails[$customer_id] = $customers[$customer_id] = trim($result['email']);
         }
     }
     // All customers by name/email
     if (isset($this->request->post['to']) && $this->request->post['to']) {
         foreach ($this->request->post['to'] as $customer_id) {
             $customer_info = $this->model_sale_customer->getCustomer($customer_id);
             if ($customer_info) {
                 $emails[] = trim($customer_info['email']);
             }
         }
     }
     // All customers by product
     if (isset($this->request->post['product'])) {
         foreach ($this->request->post['product'] as $product_id) {
             $results = $this->model_sale_customer->getCustomersByProduct($product_id);
             if ($customers) {
                 $emails = array();
             }
             foreach ($results as $result) {
                 if ($customers && in_array($result['email'], $customers)) {
                     $emails[] = trim($result['email']);
                 }
             }
         }
     }
     // Prevent Duplicates
     $emails = array_unique($emails);
     if ($emails) {
         // HTML Mail
         $template = new ATemplate();
         $template->data['lang_direction'] = $this->language->get('direction');
         $template->data['lang_code'] = $this->language->get('code');
         $template->data['subject'] = $this->request->post['subject'];
         $text_unsubscribe = $this->language->get('text_unsubscribe');
         $text_subject = $this->request->post['subject'];
         $text_message = $this->request->post['message'];
         $from = $this->config->get('store_main_email');
         $mail = new AMail($this->config);
         foreach ($emails as $email) {
             $mail->setTo($email);
             $mail->setFrom($from);
             $mail->setSender($store_name);
             $mail->setSubject($text_subject);
             $message_body = $text_message;
             if ($this->request->post['recipient'] == 'newsletter') {
                 if ($customer_id = array_search($email, $customers)) {
                     $message_body .= "\n\n<br><br>" . sprintf($text_unsubscribe, $email, $this->html->getCatalogURL('account/unsubscribe', '&email=' . $email . '&customer_id=' . $customer_id));
                 }
             }
             $template->data['body'] = html_entity_decode($message_body, ENT_QUOTES, 'UTF-8');
             $html = $template->fetch('mail/contact.tpl');
             $mail->setHtml($html);
             $mail->send();
             if ($mail->error) {
                 $this->error[] = 'Error: Emails does not sent! Please see error log for details.';
                 $this->main();
                 return null;
             }
         }
         unset($mail);
     }
     $this->session->data['success'] = $this->language->get('text_success');
     $this->redirect($this->html->getSecureURL('sale/contact'));
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }