shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

reset.php (3447B)


      1 <?php
      2 class ControllerAccountReset extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		if ($this->customer->isLogged()) {
      7 			$this->response->redirect($this->url->link('account/account', '', true));
      8 		}
      9 
     10 		if (isset($this->request->get['code'])) {
     11 			$code = $this->request->get['code'];
     12 		} else {
     13 			$code = '';
     14 		}
     15 
     16 		$this->load->model('account/customer');
     17 
     18 		$customer_info = $this->model_account_customer->getCustomerByCode($code);
     19 
     20 		if ($customer_info) {
     21 			$this->load->language('account/reset');
     22 
     23 			$this->document->setTitle($this->language->get('heading_title'));
     24 
     25 			if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
     26 				$this->model_account_customer->editPassword($customer_info['email'], $this->request->post['password']);
     27 
     28 				$this->session->data['success'] = $this->language->get('text_success');
     29 
     30 				$this->response->redirect($this->url->link('account/login', '', true));
     31 			}
     32 
     33 			$data['breadcrumbs'] = array();
     34 
     35 			$data['breadcrumbs'][] = array(
     36 				'text' => $this->language->get('text_home'),
     37 				'href' => $this->url->link('common/home')
     38 			);
     39 
     40 			$data['breadcrumbs'][] = array(
     41 				'text' => $this->language->get('text_account'),
     42 				'href' => $this->url->link('account/account', '', true)
     43 			);
     44 
     45 			$data['breadcrumbs'][] = array(
     46 				'text' => $this->language->get('heading_title'),
     47 				'href' => $this->url->link('account/reset', '', true)
     48 			);
     49 
     50 			if (isset($this->error['password'])) {
     51 				$data['error_password'] = $this->error['password'];
     52 			} else {
     53 				$data['error_password'] = '';
     54 			}
     55 
     56 			if (isset($this->error['confirm'])) {
     57 				$data['error_confirm'] = $this->error['confirm'];
     58 			} else {
     59 				$data['error_confirm'] = '';
     60 			}
     61 
     62 			$data['action'] = $this->url->link('account/reset', 'code=' . $code, true);
     63 
     64 			$data['back'] = $this->url->link('account/login', '', true);
     65 
     66 			if (isset($this->request->post['password'])) {
     67 				$data['password'] = $this->request->post['password'];
     68 			} else {
     69 				$data['password'] = '';
     70 			}
     71 
     72 			if (isset($this->request->post['confirm'])) {
     73 				$data['confirm'] = $this->request->post['confirm'];
     74 			} else {
     75 				$data['confirm'] = '';
     76 			}
     77 
     78 			$data['column_left'] = $this->load->controller('common/column_left');
     79 			$data['column_right'] = $this->load->controller('common/column_right');
     80 			$data['content_top'] = $this->load->controller('common/content_top');
     81 			$data['content_bottom'] = $this->load->controller('common/content_bottom');
     82 			$data['footer'] = $this->load->controller('common/footer');
     83 			$data['header'] = $this->load->controller('common/header');
     84 
     85 			$this->response->setOutput($this->load->view('account/reset', $data));
     86 		} else {
     87 			$this->load->language('account/reset');
     88 
     89 			$this->session->data['error'] = $this->language->get('error_code');
     90 
     91 			return new Action('account/login');
     92 		}
     93 	}
     94 
     95 	protected function validate() {
     96 		if ((utf8_strlen(html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8')) < 4) || (utf8_strlen(html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8')) > 40)) {
     97 			$this->error['password'] = $this->language->get('error_password');
     98 		}
     99 
    100 		if ($this->request->post['confirm'] != $this->request->post['password']) {
    101 			$this->error['confirm'] = $this->language->get('error_confirm');
    102 		}
    103 
    104 		return !$this->error;
    105 	}
    106 }