free.php (3447B)
1 <?php 2 class ControllerExtensionShippingFree extends Controller { 3 private $error = array(); 4 5 public function index() { 6 $this->load->language('extension/shipping/free'); 7 8 $this->document->setTitle($this->language->get('heading_title')); 9 10 $this->load->model('setting/setting'); 11 12 if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { 13 $this->model_setting_setting->editSetting('shipping_free', $this->request->post); 14 15 $this->session->data['success'] = $this->language->get('text_success'); 16 17 $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true)); 18 } 19 20 if (isset($this->error['warning'])) { 21 $data['error_warning'] = $this->error['warning']; 22 } else { 23 $data['error_warning'] = ''; 24 } 25 26 $data['breadcrumbs'] = array(); 27 28 $data['breadcrumbs'][] = array( 29 'text' => $this->language->get('text_home'), 30 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) 31 ); 32 33 $data['breadcrumbs'][] = array( 34 'text' => $this->language->get('text_extension'), 35 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true) 36 ); 37 38 $data['breadcrumbs'][] = array( 39 'text' => $this->language->get('heading_title'), 40 'href' => $this->url->link('extension/shipping/free', 'user_token=' . $this->session->data['user_token'], true) 41 ); 42 43 $data['action'] = $this->url->link('extension/shipping/free', 'user_token=' . $this->session->data['user_token'], true); 44 45 $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true); 46 47 if (isset($this->request->post['shipping_free_total'])) { 48 $data['shipping_free_total'] = $this->request->post['shipping_free_total']; 49 } else { 50 $data['shipping_free_total'] = $this->config->get('shipping_free_total'); 51 } 52 53 if (isset($this->request->post['shipping_free_geo_zone_id'])) { 54 $data['shipping_free_geo_zone_id'] = $this->request->post['shipping_free_geo_zone_id']; 55 } else { 56 $data['shipping_free_geo_zone_id'] = $this->config->get('shipping_free_geo_zone_id'); 57 } 58 59 $this->load->model('localisation/geo_zone'); 60 61 $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); 62 63 if (isset($this->request->post['shipping_free_status'])) { 64 $data['shipping_free_status'] = $this->request->post['shipping_free_status']; 65 } else { 66 $data['shipping_free_status'] = $this->config->get('shipping_free_status'); 67 } 68 69 if (isset($this->request->post['shipping_free_sort_order'])) { 70 $data['shipping_free_sort_order'] = $this->request->post['shipping_free_sort_order']; 71 } else { 72 $data['shipping_free_sort_order'] = $this->config->get('shipping_free_sort_order'); 73 } 74 75 $data['header'] = $this->load->controller('common/header'); 76 $data['column_left'] = $this->load->controller('common/column_left'); 77 $data['footer'] = $this->load->controller('common/footer'); 78 79 $this->response->setOutput($this->load->view('extension/shipping/free', $data)); 80 } 81 82 protected function validate() { 83 if (!$this->user->hasPermission('modify', 'extension/shipping/free')) { 84 $this->error['warning'] = $this->language->get('error_permission'); 85 } 86 87 return !$this->error; 88 } 89 }