pp_login.php (8651B)
1 <?php 2 class ControllerExtensionModulePPLogin extends Controller { 3 private $error = array(); 4 5 public function index() { 6 $this->load->language('extension/module/pp_login'); 7 8 $this->load->model('setting/setting'); 9 10 $this->document->setTitle($this->language->get('heading_title')); 11 12 if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { 13 $this->model_setting_setting->editSetting('module_pp_login', $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=module', 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 if (isset($this->error['client_id'])) { 27 $data['error_client_id'] = $this->error['client_id']; 28 } else { 29 $data['error_client_id'] = ''; 30 } 31 32 if (isset($this->error['secret'])) { 33 $data['error_secret'] = $this->error['secret']; 34 } else { 35 $data['error_secret'] = ''; 36 } 37 38 $data['breadcrumbs'] = array(); 39 40 $data['breadcrumbs'][] = array( 41 'text' => $this->language->get('text_home'), 42 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) 43 ); 44 45 $data['breadcrumbs'][] = array( 46 'text' => $this->language->get('text_extension'), 47 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true) 48 ); 49 50 $data['breadcrumbs'][] = array( 51 'text' => $this->language->get('heading_title'), 52 'href' => $this->url->link('extension/module/pp_login', 'user_token=' . $this->session->data['user_token'], true) 53 ); 54 55 $data['action'] = $this->url->link('extension/module/pp_login', 'user_token=' . $this->session->data['user_token'], true); 56 57 $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true); 58 59 if (isset($this->request->post['module_pp_login_client_id'])) { 60 $data['module_pp_login_client_id'] = $this->request->post['module_pp_login_client_id']; 61 } else { 62 $data['module_pp_login_client_id'] = $this->config->get('module_pp_login_client_id'); 63 } 64 65 if (isset($this->request->post['module_pp_login_secret'])) { 66 $data['module_pp_login_secret'] = $this->request->post['module_pp_login_secret']; 67 } else { 68 $data['module_pp_login_secret'] = $this->config->get('module_pp_login_secret'); 69 } 70 71 if (isset($this->request->post['module_pp_login_sandbox'])) { 72 $data['module_pp_login_sandbox'] = $this->request->post['module_pp_login_sandbox']; 73 } else { 74 $data['module_pp_login_sandbox'] = $this->config->get('module_pp_login_sandbox'); 75 } 76 77 if (isset($this->request->post['module_pp_login_debug'])) { 78 $data['module_pp_login_debug'] = $this->request->post['module_pp_login_debug']; 79 } else { 80 $data['module_pp_login_debug'] = $this->config->get('module_pp_login_debug'); 81 } 82 83 $this->load->model('customer/customer_group'); 84 85 $data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups(); 86 87 if (isset($this->request->post['module_pp_login_customer_group_id'])) { 88 $data['module_pp_login_customer_group_id'] = $this->request->post['module_pp_login_customer_group_id']; 89 } else { 90 $data['module_pp_login_customer_group_id'] = $this->config->get('module_pp_login_customer_group_id'); 91 } 92 93 if (isset($this->request->post['module_pp_login_button_colour'])) { 94 $data['module_pp_login_button_colour'] = $this->request->post['module_pp_login_button_colour']; 95 } elseif ($this->config->get('module_pp_login_button_colour')) { 96 $data['module_pp_login_button_colour'] = $this->config->get('module_pp_login_button_colour'); 97 } else { 98 $data['module_pp_login_button_colour'] = 'blue'; 99 } 100 101 if (isset($this->request->post['module_pp_login_seamless'])) { 102 $data['module_pp_login_seamless'] = $this->request->post['module_pp_login_seamless']; 103 } else { 104 $data['module_pp_login_seamless'] = $this->config->get('module_pp_login_seamless'); 105 } 106 107 $this->load->model('localisation/language'); 108 109 $data['languages'] = $this->model_localisation_language->getLanguages(); 110 111 $data['locales'] = array(); 112 113 $data['locales'][] = array( 114 'value' => 'en-gb', 115 'text' => 'English (Great Britain)' 116 ); 117 118 $data['locales'][] = array( 119 'value' => 'zh-cn', 120 'text' => 'Chinese (People\'s Republic of China)' 121 ); 122 123 $data['locales'][] = array( 124 'value' => 'zh-hk', 125 'text' => 'Chinese (Hong Kong)', 126 ); 127 128 $data['locales'][] = array( 129 'value' => 'zh-tw', 130 'text' => 'Chinese (Taiwan)' 131 ); 132 133 $data['locales'][] = array( 134 'value' => 'zh-xc', 135 'text' => 'Chinese (US)' 136 ); 137 138 $data['locales'][] = array( 139 'value' => 'da-dk', 140 'text' => 'Danish' 141 ); 142 143 $data['locales'][] = array( 144 'value' => 'nl-nl', 145 'text' => 'Dutch' 146 ); 147 148 $data['locales'][] = array( 149 'value' => 'en-au', 150 'text' => 'English (Australia)' 151 ); 152 153 $data['locales'][] = array( 154 'value' => 'en-us', 155 'text' => 'English (US)', 156 ); 157 158 $data['locales'][] = array( 159 'value' => 'fr-fr', 160 'text' => 'French' 161 ); 162 163 $data['locales'][] = array( 164 'value' => 'fr-ca', 165 'text' => 'French (Canada)' 166 ); 167 168 $data['locales'][] = array( 169 'value' => 'fr-xc', 170 'text' => 'French (international)' 171 ); 172 173 $data['locales'][] = array( 174 'value' => 'de-de', 175 'text' => 'German' 176 ); 177 178 $data['locales'][] = array( 179 'value' => 'he-il', 180 'text' => 'Hebrew (Israel)' 181 ); 182 183 $data['locales'][] = array( 184 'value' => 'id-id', 185 'text' => 'Indonesian' 186 ); 187 188 $data['locales'][] = array( 189 'value' => 'it-il', 190 'text' => 'Italian' 191 ); 192 193 $data['locales'][] = array( 194 'value' => 'ja-jp' , 195 'text' => 'Japanese' 196 ); 197 198 $data['locales'][] = array( 199 'value' => 'no-no', 200 'text' => 'Norwegian' 201 ); 202 203 $data['locales'][] = array( 204 'value' => 'pl-pl', 205 'text' => 'Polish'); 206 207 $data['locales'][] = array( 208 'value' => 'pt-pt', 209 'text' => 'Portuguese' 210 ); 211 212 $data['locales'][] = array( 213 'value' => 'pt-br', 214 'text' => 'Portuguese (Brazil)' 215 ); 216 217 $data['locales'][] = array( 218 'value' => 'ru-ru', 219 'text' => 'Russian' 220 ); 221 222 $data['locales'][] = array( 223 'value' => 'es-es', 224 'text' => 'Spanish' 225 ); 226 227 $data['locales'][] = array( 228 'value' => 'es-xc', 229 'text' => 'Spanish (Mexico)' 230 ); 231 232 $data['locales'][] = array( 233 'value' => 'sv-se', 234 'text' => 'Swedish' 235 ); 236 237 $data['locales'][] = array( 238 'value' => 'th-th', 239 'text' => 'Thai' 240 ); 241 242 $data['locales'][] = array( 243 'value' => 'tr-tr', 244 'text' => 'Turkish' 245 ); 246 247 if (isset($this->request->post['module_pp_login_locale'])) { 248 $data['module_pp_login_locale'] = $this->request->post['module_pp_login_locale']; 249 } else { 250 $data['module_pp_login_locale'] = $this->config->get('module_pp_login_locale'); 251 } 252 253 $data['return_url'] = HTTPS_CATALOG . 'index.php?route=extension/module/pp_login/login'; 254 255 if (isset($this->request->post['module_pp_login_status'])) { 256 $data['module_pp_login_status'] = $this->request->post['module_pp_login_status']; 257 } else { 258 $data['module_pp_login_status'] = $this->config->get('module_pp_login_status'); 259 } 260 261 $data['header'] = $this->load->controller('common/header'); 262 $data['column_left'] = $this->load->controller('common/column_left'); 263 $data['footer'] = $this->load->controller('common/footer'); 264 265 $this->response->setOutput($this->load->view('extension/module/pp_login', $data)); 266 } 267 268 protected function validate() { 269 if (!$this->user->hasPermission('modify', 'extension/module/pp_login')) { 270 $this->error['warning'] = $this->language->get('error_permission'); 271 } 272 273 if (!$this->request->post['module_pp_login_client_id']) { 274 $this->error['client_id'] = $this->language->get('error_client_id'); 275 } 276 277 if (!$this->request->post['module_pp_login_secret']) { 278 $this->error['secret'] = $this->language->get('error_secret'); 279 } 280 281 return !$this->error; 282 } 283 284 public function install() { 285 $this->load->model('marketplace/event'); 286 287 $this->model_setting_event->addEvent('pp_login', 'catalog/controller/account/logout/after', 'extension/module/pp_login/logout'); 288 } 289 290 public function uninstall() { 291 $this->load->model('marketplace/event'); 292 293 $this->model_setting_event->deleteEventByCode('pp_login'); 294 } 295 }