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