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