Beispiel #1
0
 public function registerAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $item = $request->getPost();
         $oauth = new \Oauth\OauthService();
         $accessToken = array();
         if ($oauth->getStorage()->getAccessToken()) {
             $oauth->setServiceLocator($this->getServiceLocator());
             $oauth->initByAccessToken();
             $accessToken = $oauth->getAdapter()->getAccessToken();
         }
         $form = $accessToken ? new \User\Form\QuickRegisterForm() : new \User\Form\RegisterForm();
         $form->bind($item);
         if ($form->isValid()) {
             $callback = $this->params()->fromPost('callback');
             $callback = $callback ? $callback : '/';
             $item = $form->getData();
             $itemModel = Api::_()->getModel('User\\Model\\Register');
             $itemModel->setItem($item)->register();
             $userItem = $itemModel->getItem();
             $codeItem = $itemModel->getItem('User\\Item\\Code');
             $mail = new \Core\Mail();
             $mail->getMessage()->setSubject("Please Confirm Your Email Address")->setData(array('user' => $userItem, 'code' => $codeItem))->setTo($userItem->email, $userItem->userName)->setTemplatePath(Api::_()->getModulePath('User') . '/view/')->setTemplate('mail/active');
             $mail->send();
             $this->redirect()->toUrl($callback);
         } else {
         }
         return array('token' => $accessToken, 'form' => $form, 'item' => $item);
     } else {
         return array('item' => $this->getRequest()->getQuery());
     }
 }
Beispiel #2
0
 public function perform()
 {
     $args = $this->args;
     $itemModel = Api::_()->getModel('User\\Model\\Reset');
     $itemModel->setItem($args);
     $codeItem = $itemModel->resetRequest();
     $userItem = $itemModel->getItem();
     $mail = new \Core\Mail();
     $mail->getMessage()->setSubject("Reset Password")->setData(array('user' => $userItem, 'code' => $codeItem))->setTo($userItem->email, $userItem->userName)->setTemplatePath(EVA_MODULE_PATH . '/User/view/')->setTemplate('_admin/mail/reset');
     $mail->send();
 }
 public function resetAction()
 {
     $callback = $this->params()->fromPost('callback');
     $callback = $callback ? $callback : '/login/';
     $item = $this->getRequest()->getPost();
     $form = new Form\ResetForm();
     $form->bind($item);
     if ($form->isValid()) {
         $itemModel = Api::_()->getModel('User\\Model\\Reset');
         $itemModel->setItem($form->getData());
         $codeItem = $itemModel->resetRequest();
         $userItem = $itemModel->getItem();
         $mail = new \Core\Mail();
         $mail->getMessage()->setSubject("Reset Password")->setData(array('user' => $userItem, 'code' => $codeItem))->setTo($userItem->email, $userItem->userName)->setTemplatePath(Api::_()->getModulePath('Engine') . '/view/')->setTemplate('mail/reset');
         $mail->send();
         return $this->redirect()->toUrl($callback);
     } else {
     }
     return array('form' => $form, 'item' => $form->getData());
 }
Beispiel #4
0
 public function submit()
 {
     $this->load->language('common/contact');
     if ($this->validate()) {
         unset($this->session->data['captcha']);
         $this->language->load('common/contact');
         $mail = new \Core\Mail();
         $mail->tags = array('Contact Request');
         $mail->mandrill_key = $this->config->get('config_mandrill_key');
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_mail_smtp_hostname');
         $mail->username = $this->config->get('config_mail_smtp_username');
         $mail->password = $this->config->get('config_mail_smtp_password');
         $mail->port = $this->config->get('config_mail_smtp_port');
         $mail->timeout = $this->config->get('config_mail_smtp_timeout');
         $post = $this->request->post;
         unset($post['custom_field']);
         $mailbody = "Contact form Submission \n";
         $mailbody .= $this->language->get('entry_name') . ": " . $this->request->post['name'] . "\n";
         $mailbody .= $this->language->get('entry_email') . ": " . $this->request->post['email'] . "\n";
         $mailbody .= $this->language->get('entry_enquiry') . ": " . $this->request->post['enquiry'] . "\n";
         $fields = $this->model_account_custom_field->getCustomFields();
         foreach ($fields as $cfield) {
             if ($cfield['location'] == 'contact') {
                 $mailbody .= $cfield['name'] . ": " . $this->request->post['custom_field'][$cfield['custom_field_id']] . "\n";
                 $post['custom_field'][$cfield['name']] = $this->request->post['custom_field'][$cfield['custom_field_id']];
             }
         }
         $mailbody .= "\n\n\n------------------------------------------\n";
         $mailbody .= "" . DATE("Y-m-d h:i a") . " | " . $this->request->server['REMOTE_ADDR'];
         $this->event->trigger('contact.form.submit.body', $mailbody);
         $mailsubject = sprintf($this->language->get('email_subject'), $this->request->post['name']);
         $this->event->trigger('contact.form.submit.subject', $mailsubject);
         $this->load->model('account/contact');
         $this->model_account_contact->addContact($post);
         $mail->setTo($this->config->get('config_email'));
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($this->request->post['name']);
         $mail->setReplyTo($this->request->post['email']);
         $mail->setSubject($mailsubject);
         $mail->setText($mailbody);
         $mail->setHtml(nl2br($mailbody));
         $mail->send();
         $data['success'] = $this->language->get('text_success');
         //   $this->redirect($this->url->link('common/contact/success'));
     } else {
         $data['error'] = $this->error;
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($data));
 }
 public function contato()
 {
     if ($this->request->isPost()) {
         // instanciando a classe de email
         $email = new \Core\Mail();
         //debug($this->request->data);
         //exit;
         $default = ['from' => ['mail' => '*****@*****.**', 'title' => 'Contato site aula'], 'add' => [$this->request->data('email')], 'title' => 'Contatos site aula', 'data' => $this->request->data];
         if ($email->send($default)) {
             $this->session->setFlash('Email enviado com sucesso!', 'success');
         } else {
             $this->session->setFlash('Erro ao enviar email!', 'danger');
         }
     }
 }
Beispiel #6
0
 public function addComment($ams_page_id, $data)
 {
     //Akismet to get plugged in here! :-)
     $this->db->query("INSERT INTO #__comments SET author = '" . $this->db->escape($data['name']) . "', " . "customer_id = '" . (int) $this->customer->getId() . "', ams_page_id = '" . (int) $ams_page_id . "'," . " text = '" . $this->db->escape($data['text']) . "', " . "status = '" . (int) $this->config->get('config_comment_auto_approve') . "', date_added = NOW()");
     $comment_id = $this->db->getLastId();
     if ($this->config->get('config_review_mail')) {
         $this->language->load('mail/comment');
         $this->load->model('cms/page');
         $page_item = $this->model_cms_page->loadParent($ams_page_id);
         $subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name'));
         $message = $this->language->get('text_waiting') . "\n";
         $message .= sprintf($this->language->get('text_item'), $this->url->link($page_item->getNamespace(), 'ams_page_id=' . $ams_page_id), $this->db->escape(strip_tags($page_item->name))) . "\n";
         $message .= sprintf($this->language->get('text_reviewer'), $this->db->escape(strip_tags($data['name']))) . "\n";
         $message .= $this->language->get('text_review') . "\n";
         $message .= $this->db->escape(strip_tags($data['text'])) . "\n\n";
         $mail = new \Core\Mail();
         $mail->tags = array('Comment Notification');
         $mail->mandrill_key = $this->config->get('config_mandrill_key');
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_mail_smtp_hostname');
         $mail->username = $this->config->get('config_mail_smtp_username');
         $mail->password = $this->config->get('config_mail_smtp_password');
         $mail->port = $this->config->get('config_mail_smtp_port');
         $mail->timeout = $this->config->get('config_mail_smtp_timeout');
         $mail->setTo($this->config->get('config_email'));
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($this->config->get('config_name'));
         $mail->setSubject($subject);
         $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
         $mail->send();
         // Send to additional alert emails
         $emails = explode(',', $this->config->get('config_mail_alert'));
         $addys = array();
         foreach ($emails as $email) {
             if ($email && preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $email)) {
                 //  $mail->setTo($email);
                 $addys[] = $email;
             }
         }
         $mail->send();
     }
 }
Beispiel #7
0
 public function sendMail()
 {
     $this->language->load('sale/contact');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validateReply()) {
         //Lodge Reply:
         $this->db->query("insert into #__contact_responses set contact_id = '" . (int) $this->request->get['id'] . "', " . "subject = '" . $this->db->escape($this->request->post['subject']) . "', " . "body = '" . $this->db->escape($this->request->post['message_body']) . "', " . "user_id = '" . (int) $this->user->getId() . "', " . "date_created = now()");
         $mail = new \Core\Mail();
         $mail->mandrill_key = $this->config->get('config_mandrill_key');
         $mail->tags = array('Contact Reply');
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_smtp_host');
         $mail->username = $this->config->get('config_smtp_username');
         $mail->password = $this->config->get('config_smtp_password');
         $mail->port = $this->config->get('config_smtp_port');
         $mail->timeout = $this->config->get('config_smtp_timeout');
         $mail->setTo($this->request->post['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($this->config->get('config_name'));
         $mail->setSubject(html_entity_decode($this->request->post['subject']), ENT_QUOTES, 'UTF-8');
         $mail->setText(strip_tags(html_entity_decode($this->request->post['message_body'], ENT_QUOTES, 'UTF-8')));
         $mail->send();
         $this->session->data['success'] = $this->language->get('reply_message');
         $this->redirect($this->url->link('sale/contact', 'token=' . $this->session->data['token'], 'SSL'));
     } else {
         $this->contact_details();
     }
 }
Beispiel #8
0
 public function approve($customer_id)
 {
     $customer_info = $this->getCustomer($customer_id);
     if ($customer_info) {
         $this->db->query("UPDATE #__customer SET approved = '1' WHERE customer_id = '" . (int) $customer_id . "'");
         $this->load->language('mail/customer');
         $store_name = $this->config->get('config_name');
         $store_url = HTTP_CATALOG . 'index.php?p=account/login';
         $message = sprintf($this->language->get('text_approve_welcome'), $store_name) . "\n\n";
         $message .= $this->language->get('text_approve_login') . "\n";
         $message .= $store_url . "\n\n";
         $message .= $this->language->get('text_approve_services') . "\n\n";
         $message .= $this->language->get('text_approve_thanks') . "\n";
         $message .= $store_name;
         $mail = new \Core\Mail();
         $mail->tags = array('Customer Approve');
         $mail->mandrill_key = $this->config->get('config_mandrill_key');
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_mail_smtp_hostname');
         $mail->username = $this->config->get('config_mail_smtp_username');
         $mail->password = $this->config->get('config_mail_smtp_password');
         $mail->port = $this->config->get('config_mail_smtp_port');
         $mail->timeout = $this->config->get('config_mail_smtp_timeout');
         $mail->setTo($customer_info['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($store_name);
         $mail->setSubject(sprintf($this->language->get('text_approve_subject'), $store_name));
         $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
         $mail->send();
     }
 }
Beispiel #9
0
 public function addCustomer($data)
 {
     if (isset($data['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($data['customer_group_id'], $this->config->get('config_customer_group_display'))) {
         $customer_group_id = $data['customer_group_id'];
     } else {
         $customer_group_id = $this->config->get('config_customer_group_id');
     }
     $this->load->model('account/customer_group');
     $customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id);
     $this->db->query("INSERT INTO #__customer SET customer_group_id = '" . (int) $customer_group_id . "', " . " firstname = '" . $this->db->escape($data['firstname']) . "', " . " lastname = '" . $this->db->escape($data['lastname']) . "'," . " email = '" . $this->db->escape($data['email']) . "', " . " telephone = '" . $this->db->escape($data['telephone']) . "', " . " salt = '" . $this->db->escape($salt = substr(md5(uniqid(rand(), true)), 0, 9)) . "', " . " password = '******'password'])))) . "', " . " custom_field = '" . $this->db->escape(isset($data['custom_field']['account']) ? serialize($data['custom_field']['account']) : '') . "', " . " newsletter = '" . (isset($data['newsletter']) ? (int) $data['newsletter'] : 0) . "', " . " ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', " . " status = '1', " . " approved = '" . (int) (!$customer_group_info['approval']) . "', " . " country_id = '" . (int) $data['country_id'] . "', " . " date_added = NOW()");
     $customer_id = $this->db->getLastId();
     $this->load->language('mail/customer');
     $subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name'));
     $message = sprintf($this->language->get('text_welcome'), $this->config->get('config_name')) . "\n\n";
     if (!$customer_group_info['approval']) {
         $message .= $this->language->get('text_login') . "\n";
     } else {
         $message .= $this->language->get('text_approval') . "\n";
     }
     $message .= $this->url->link('account/login', '', 'SSL') . "\n\n";
     $message .= $this->language->get('text_services') . "\n\n";
     $message .= $this->language->get('text_thanks') . "\n";
     $message .= $this->config->get('config_name');
     $mail = new \Core\Mail();
     $mail->tags = array('Customer Registration');
     $mail->mandrill_key = $this->config->get('config_mandrill_key');
     $mail->protocol = $this->config->get('config_mail_protocol');
     $mail->parameter = $this->config->get('config_mail_parameter');
     $mail->hostname = $this->config->get('config_mail_smtp_hostname');
     $mail->username = $this->config->get('config_mail_smtp_username');
     $mail->password = $this->config->get('config_mail_smtp_password');
     $mail->port = $this->config->get('config_mail_smtp_port');
     $mail->timeout = $this->config->get('config_mail_smtp_timeout');
     $mail->setTo($data['email']);
     $mail->setFrom($this->config->get('config_email'));
     $mail->setSender($this->config->get('config_name'));
     $mail->setSubject($subject);
     $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
     $mail->send();
     // Send to main admin email if new account email is enabled
     if ($this->config->get('config_account_mail')) {
         $this->language->load('mail/customer');
         $message = $this->language->get('text_signup') . "\n\n";
         $message .= $this->language->get('text_website') . ' ' . $this->config->get('config_name') . "\n";
         $message .= $this->language->get('text_firstname') . ' ' . $data['firstname'] . "\n";
         $message .= $this->language->get('text_lastname') . ' ' . $data['lastname'] . "\n";
         $message .= $this->language->get('text_customer_group') . ' ' . $customer_group_info['name'] . "\n";
         $message .= $this->language->get('text_email') . ' ' . $data['email'] . "\n";
         $message .= $this->language->get('text_telephone') . ' ' . $data['telephone'] . "\n";
         $mail->setTo($this->config->get('config_email'));
         $mail->setSubject(html_entity_decode($this->language->get('text_new_customer'), ENT_QUOTES, 'UTF-8'));
         $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
         $mail->send();
         // Send to additional alert emails if new account email is enabled
         $emails = explode(',', $this->config->get('config_mail_alert'));
         foreach ($emails as $email) {
             if (utf8_strlen($email) > 0 && preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $email)) {
                 $mail->setTo($email);
                 $mail->send();
             }
         }
     }
     return $customer_id;
 }
Beispiel #10
0
 public function index()
 {
     $this->load->language('common/contact');
     $this->document->setTitle($this->language->get('heading_title'));
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         unset($this->session->data['captcha']);
         $this->language->load('common/contact');
         $mail = new \Core\Mail();
         $mail->tags = array('Contact Request');
         $mail->mandrill_key = $this->config->get('config_mandrill_key');
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_mail_smtp_hostname');
         $mail->username = $this->config->get('config_mail_smtp_username');
         $mail->password = $this->config->get('config_mail_smtp_password');
         $mail->port = $this->config->get('config_mail_smtp_port');
         $mail->timeout = $this->config->get('config_mail_smtp_timeout');
         $post = $this->request->post;
         unset($post['custom_field']);
         $mailbody = "Contact form Submission \n";
         $mailbody .= $this->language->get('entry_name') . ": " . $this->request->post['name'] . "\n";
         $mailbody .= $this->language->get('entry_email') . ": " . $this->request->post['email'] . "\n";
         $mailbody .= $this->language->get('entry_enquiry') . ": " . $this->request->post['enquiry'] . "\n";
         $fields = $this->model_account_custom_field->getCustomFields();
         foreach ($fields as $cfield) {
             if ($cfield['location'] == 'contact') {
                 $mailbody .= $cfield['name'] . ": " . $this->request->post['custom_field'][$cfield['custom_field_id']] . "\n";
                 $post['custom_field'][$cfield['name']] = $this->request->post['custom_field'][$cfield['custom_field_id']];
             }
         }
         $mailbody .= "\n\n\n------------------------------------------\n";
         $mailbody .= "" . DATE("Y-m-d h:i a") . " | " . $this->request->server['REMOTE_ADDR'];
         $this->event->trigger('contact.form.submit.body', $mailbody);
         $mailsubject = sprintf($this->language->get('email_subject'), $this->request->post['name']);
         $this->event->trigger('contact.form.submit.subject', $mailsubject);
         $this->load->model('account/contact');
         $this->model_account_contact->addContact($post);
         $mail->setTo($this->config->get('config_email'));
         $mail->setFrom($this->config->get('config_email'), $this->request->post['name']);
         $mail->setReplyTo($this->request->post['email']);
         $mail->setSender($this->request->post['name']);
         $mail->setSubject($mailsubject);
         $mail->setText($mailbody);
         $mail->setHtml(nl2br($mailbody));
         $mail->send();
         $this->redirect($this->url->link('common/contact/success'));
     }
     $data['breadcrumbs'] = array();
     $data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'));
     $data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('common/contact'));
     $data['heading_title'] = $this->language->get('heading_title');
     $data['text_location'] = $this->language->get('text_location');
     $data['text_store'] = $this->language->get('text_store');
     $data['text_contact'] = $this->language->get('text_contact');
     $data['text_address'] = $this->language->get('text_address');
     $data['text_telephone'] = $this->language->get('text_telephone');
     $data['text_fax'] = $this->language->get('text_fax');
     $data['text_comment'] = $this->language->get('text_comment');
     $data['entry_name'] = $this->language->get('entry_name');
     $data['entry_email'] = $this->language->get('entry_email');
     $data['entry_enquiry'] = $this->language->get('entry_enquiry');
     $data['entry_captcha'] = $this->language->get('entry_captcha');
     $data['button_map'] = $this->language->get('button_map');
     if (isset($this->error['name'])) {
         $data['error_name'] = $this->error['name'];
     } else {
         $data['error_name'] = '';
     }
     if (isset($this->error['email'])) {
         $data['error_email'] = $this->error['email'];
     } else {
         $data['error_email'] = '';
     }
     if (isset($this->error['enquiry'])) {
         $data['error_enquiry'] = $this->error['enquiry'];
     } else {
         $data['error_enquiry'] = '';
     }
     if (isset($this->error['captcha'])) {
         $data['error_captcha'] = $this->error['captcha'];
     } else {
         $data['error_captcha'] = '';
     }
     if (isset($this->error['custom_field'])) {
         $data['error_custom_field'] = $this->error['custom_field'];
     } else {
         $data['error_custom_field'] = array();
     }
     $data['button_submit'] = $this->language->get('button_submit');
     $data['action'] = $this->url->link('common/contact');
     /*
      $this->load->model('tool/image');
     
      if ($this->config->get('config_image')) {
      $data['image'] = $this->model_tool_image->resize($this->config->get('config_image'), $this->config->get('config_image_location_width'), $this->config->get('config_image_location_height'));
      } else {
      $data['image'] = false;
      }
     */
     $data['store'] = $this->config->get('config_name');
     if (isset($this->request->post['name'])) {
         $data['name'] = $this->request->post['name'];
     } else {
         $data['name'] = $this->customer->getFirstName();
     }
     if (isset($this->request->post['email'])) {
         $data['email'] = $this->request->post['email'];
     } else {
         $data['email'] = $this->customer->getEmail();
     }
     if (isset($this->request->post['enquiry'])) {
         $data['enquiry'] = $this->request->post['enquiry'];
     } else {
         $data['enquiry'] = '';
     }
     if (isset($this->request->post['captcha'])) {
         $data['captcha'] = $this->request->post['captcha'];
     } else {
         $data['captcha'] = '';
     }
     $this->load->model('account/custom_field');
     $data['custom_fields'] = $this->model_account_custom_field->getCustomFields();
     if (isset($this->request->post['custom_field'])) {
         $data['contact_custom_field'] = $this->request->post['custom_field'];
     } else {
         $data['contact_custom_field'] = array();
     }
     $this->document->addScript('view/plugins/datetimepicker/moment.js');
     $this->document->addScript('view/plugins/datetimepicker/bootstrap-datetimepicker.min.js');
     $this->document->addStyle('view/plugins/datetimepicker/bootstrap-datetimepicker.min.css');
     $this->children = array('common/column_top', 'common/column_bottom', 'common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
     $this->template = 'common/contact.phtml';
     $this->data = $data;
     $this->response->setOutput($this->render());
 }
 private function enviarEmail($pedido)
 {
     $email = new \Core\Mail();
     $default = ['from' => ['mail' => $pedido->Clientes->email, 'title' => 'Alteração pedido'], 'add' => $pedido->Clientes->email, 'title' => 'Alteração pedido', 'data' => ['nome' => $pedido->Clientes->nome, 'email' => $pedido->Clientes->email, 'assunto' => 'Alteração de status do pedido número ' . $pedido->id, 'conteudo' => 'Status alterado para ' . $pedido->status_descricao]];
     return $email->send($default);
 }
Beispiel #12
0
 public function send()
 {
     $this->load->language('marketing/contact');
     $json = array();
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         if (!$this->user->hasPermission('modify', 'marketing/contact')) {
             $json['error']['warning'] = $this->language->get('error_permission');
         }
         if (!$this->request->post['subject']) {
             $json['error']['subject'] = $this->language->get('error_subject');
         }
         if (!$this->request->post['message']) {
             $json['error']['message'] = $this->language->get('error_message');
         }
         if (!$json) {
             $store_name = $this->config->get('config_name');
             $this->load->model('marketing/subscriber');
             $this->load->model('sale/customer');
             $this->load->model('sale/customer_group');
             if (isset($this->request->get['page'])) {
                 $page = $this->request->get['page'];
             } else {
                 $page = 1;
             }
             $email_total = 0;
             $emails = array();
             $override_permission = isset($this->request->post['override_permission']) ? true : false;
             switch ($this->request->post['to']) {
                 case 'newsletter':
                     $customer_data = array('filter_opt_in' => 1, 'start' => ($page - 1) * 10, 'limit' => 10);
                     $email_total = $this->model_marketing_subscriber->getTotalSubscribers($customer_data);
                     $results = $this->model_marketing_subscriber->getSubscribers($customer_data);
                     foreach ($results as $result) {
                         $emails[] = $result['email'];
                     }
                     break;
                 case 'customer_all':
                     $customer_data = array('start' => ($page - 1) * 10, 'limit' => 10);
                     if (!$override_permission) {
                         $customer_data['filter_newsletter'] = '1';
                     }
                     $email_total = $this->model_sale_customer->getTotalCustomers($customer_data);
                     $results = $this->model_sale_customer->getCustomers($customer_data);
                     foreach ($results as $result) {
                         $emails[] = $result['email'];
                     }
                     break;
                 case 'customer_group':
                     $customer_data = array('filter_customer_group_id' => $this->request->post['customer_group_id'], 'start' => ($page - 1) * 10, 'limit' => 10);
                     if (!$override_permission) {
                         $customer_data['filter_newsletter'] = '1';
                     }
                     $email_total = $this->model_sale_customer->getTotalCustomers($customer_data);
                     $results = $this->model_sale_customer->getCustomers($customer_data);
                     foreach ($results as $result) {
                         $emails[$result['customer_id']] = $result['email'];
                     }
                     break;
                 case 'customer':
                     if (!empty($this->request->post['customer'])) {
                         foreach ($this->request->post['customer'] as $customer_id) {
                             $customer_info = $this->model_sale_customer->getCustomer($customer_id);
                             if ($customer_info && ($override_permission || $customer_info['newsletter'])) {
                                 $emails[] = $customer_info['email'];
                             }
                         }
                     }
                     break;
             }
             $json['emails'] = $emails;
             if ($emails) {
                 $start = ($page - 1) * 10;
                 $end = $start + 10;
                 if ($end < $email_total) {
                     $json['success'] = sprintf($this->language->get('text_sent'), $start, $email_total);
                 } else {
                     $json['success'] = $this->language->get('text_success');
                 }
                 if ($end < $email_total) {
                     $json['next'] = str_replace('&amp;', '&', $this->url->link('marketing/contact/send', 'token=' . $this->session->data['token'] . '&page=' . ($page + 1), 'SSL'));
                 } else {
                     $json['next'] = '';
                 }
                 $message = '<html dir="ltr" lang="en">' . "\n";
                 $message .= '  <head>' . "\n";
                 $message .= '    <title>' . $this->request->post['subject'] . '</title>' . "\n";
                 $message .= '    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
                 $message .= '  </head>' . "\n";
                 $message .= '  <body>';
                 if ($this->request->post['preheader']) {
                     $message .= '<span style="display:none;">' . $this->request->post['preheader'] . '</span>';
                 }
                 $message .= html_entity_decode($this->request->post['message'], ENT_QUOTES, 'UTF-8') . '</body>' . "\n";
                 $message .= '</html>' . "\n";
                 foreach ($emails as $email) {
                     if (preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $email)) {
                         $mail = new \Core\Mail();
                         $mail->mandrill_key = $this->config->get('config_mandrill_key');
                         $mail->protocol = $this->config->get('config_mail_protocol');
                         $mail->parameter = $this->config->get('config_mail_parameter');
                         $mail->hostname = $this->config->get('config_mail_smtp_hostname');
                         $mail->username = $this->config->get('config_mail_smtp_username');
                         $mail->password = $this->config->get('config_mail_smtp_password');
                         $mail->port = $this->config->get('config_mail_smtp_port');
                         $mail->timeout = $this->config->get('config_mail_smtp_timeout');
                         $mail->tags = array('old_newsletter');
                         $mail->setTo($email);
                         $mail->setFrom($this->config->get('config_email'));
                         $mail->setSender($store_name);
                         $mail->setSubject($this->request->post['subject']);
                         $mail->setHtml($message);
                         $mail->send();
                     }
                 }
             }
         }
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($json));
 }
Beispiel #13
0
 public function index()
 {
     if ($this->customer->isLogged()) {
         $this->redirect($this->url->link('account/account', '', 'SSL'));
     }
     $this->load->language('account/forgotten');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('account/customer');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->load->language('mail/forgotten');
         $password = substr(sha1(uniqid(mt_rand(), true)), 0, 10);
         $this->model_account_customer->editPassword($this->request->post['email'], $password);
         $subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name'));
         $message = sprintf($this->language->get('text_greeting'), $this->config->get('config_name')) . "\n\n";
         $message .= $this->language->get('text_password') . "\n\n";
         $message .= $password;
         $mail = new \Core\Mail();
         $mail->tags = array('Forgotten Password');
         $mail->mandrill_key = $this->config->get('config_mandrill_key');
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_mail_smtp_hostname');
         $mail->username = $this->config->get('config_mail_smtp_username');
         $mail->password = $this->config->get('config_mail_smtp_password');
         $mail->port = $this->config->get('config_mail_smtp_port');
         $mail->timeout = $this->config->get('config_mail_smtp_timeout');
         $mail->setTo($this->request->post['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($this->config->get('config_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');
         // Add to activity log
         $customer_info = $this->model_account_customer->getCustomerByEmail($this->request->post['email']);
         if ($customer_info) {
             $this->load->model('account/activity');
             $activity_data = array('customer_id' => $customer_info['customer_id'], 'name' => $customer_info['firstname'] . ' ' . $customer_info['lastname']);
             $this->model_account_activity->addActivity('forgotten', $activity_data);
         }
         $this->redirect($this->url->link('account/login', '', 'SSL'));
     }
     $data['breadcrumbs'] = array();
     $data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'));
     $data['breadcrumbs'][] = array('text' => $this->language->get('text_account'), 'href' => $this->url->link('account/account', '', 'SSL'));
     $data['breadcrumbs'][] = array('text' => $this->language->get('text_forgotten'), 'href' => $this->url->link('account/forgotten', '', 'SSL'));
     $data['heading_title'] = $this->language->get('heading_title');
     $data['text_your_email'] = $this->language->get('text_your_email');
     $data['text_email'] = $this->language->get('text_email');
     $data['entry_email'] = $this->language->get('entry_email');
     $data['button_continue'] = $this->language->get('button_continue');
     $data['button_back'] = $this->language->get('button_back');
     if (isset($this->error['warning'])) {
         $data['error_warning'] = $this->error['warning'];
     } else {
         $data['error_warning'] = '';
     }
     $data['action'] = $this->url->link('account/forgotten', '', 'SSL');
     $data['back'] = $this->url->link('account/login', '', 'SSL');
     $this->template = 'account/forgotten.phtml';
     $this->data = $data;
     $this->children = array('common/column_top', 'common/column_bottom', 'common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
     $this->response->setOutput($this->render());
 }
Beispiel #14
0
 public function index()
 {
     if ($this->user->isLogged()) {
         $this->user->logout();
         //  $this->redirect($this->url->link('common/home', '', 'SSL'));
     }
     $this->language->load('user/forgotten');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('user/user');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->language->load('mail/forgotten');
         $code = sha1(uniqid(mt_rand(), true));
         $this->model_user_user->editCode($this->request->post['email'], $code);
         $subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name'));
         $message = sprintf($this->language->get('text_greeting'), $this->config->get('config_name')) . "\n\n";
         $message .= sprintf($this->language->get('text_change'), $this->config->get('config_name')) . "\n\n";
         $message .= $this->url->link('user/reset', 'code=' . $code, 'SSL') . "\n\n";
         $message .= sprintf($this->language->get('text_ip'), $this->request->server['REMOTE_ADDR']) . "\n\n";
         $mail = new \Core\Mail();
         $mail->mandrill_key = $this->config->get('config_mandrill_key');
         $mail->tags = array('Forgotten Password');
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_smtp_host');
         $mail->username = $this->config->get('config_smtp_username');
         $mail->password = $this->config->get('config_smtp_password');
         $mail->port = $this->config->get('config_smtp_port');
         $mail->timeout = $this->config->get('config_smtp_timeout');
         $mail->setTo($this->request->post['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($this->config->get('config_name'));
         $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
         $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
         $mail->send();
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->url->link('user/login', '', 'SSL'));
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_forgotten'), 'href' => $this->url->link('user/forgotten', '', 'SSL'), 'separator' => $this->language->get('text_separator'));
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_your_email'] = $this->language->get('text_your_email');
     $this->data['text_email'] = $this->language->get('text_email');
     $this->data['entry_email'] = $this->language->get('entry_email');
     $this->data['button_reset'] = $this->language->get('button_reset');
     $this->data['button_cancel'] = $this->language->get('button_cancel');
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     $this->data['action'] = $this->url->link('user/forgotten', '', 'SSL');
     $this->data['cancel'] = $this->url->link('user/login', '', 'SSL');
     if (isset($this->request->post['email'])) {
         $this->data['email'] = $this->request->post['email'];
     } else {
         $this->data['email'] = '';
     }
     $this->data['title'] = $this->document->getTitle();
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         $this->data['base'] = HTTPS_SERVER;
     } else {
         $this->data['base'] = HTTP_SERVER;
     }
     $this->template = 'user/forgotten.phtml';
     $this->response->setOutput($this->render());
 }
Beispiel #15
0
 protected function send_email($to_email, $email_subject, $newsletter_html, $from_email, $from_name, $options = array())
 {
     $mail = new \Core\Mail();
     $mail->tags = array('Newsletter System');
     $mail->mandrill_key = $this->config->get('config_mandrill_key');
     $mail->protocol = $this->config->get('config_mail_protocol');
     $mail->parameter = $this->config->get('config_mail_parameter');
     $mail->hostname = $this->config->get('config_mail_smtp_hostname');
     $mail->username = $this->config->get('config_mail_smtp_username');
     $mail->password = $this->config->get('config_mail_smtp_password');
     $mail->port = $this->config->get('config_mail_smtp_port');
     $mail->timeout = $this->config->get('config_mail_smtp_timeout');
     if (!empty($options['message_id'])) {
         $mail->message_id = $options['message_id'];
     }
     $mail->setFrom($this->config->get('config_email'));
     if (!empty($options['bounce_email'])) {
         $mail->setFrom($options['bounce_email']);
     }
     $mail->setTo($to_email);
     $mail->setReplyTo($from_email, $from_name);
     $mail->setSender($from_name);
     $mail->setSubject($email_subject);
     $mail->setHtml($newsletter_html);
     try {
         $mail->send();
         return true;
     } catch (\Core\Exception $e) {
         return false;
     }
 }