/admin/controller/module/affiliate.php

https://github.com/sansanwawa/e-commerse · PHP · 102 lines · 77 code · 25 blank · 0 comment · 9 complexity · a45293285b27f356aff1f780e4136c89 MD5 · raw file

  1. <?php
  2. class ControllerModuleAffiliate extends Controller {
  3. private $error = array();
  4. public function index() {
  5. $this->load->language('module/affiliate');
  6. $this->document->setTitle($this->language->get('heading_title'));
  7. $this->load->model('setting/setting');
  8. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
  9. $this->model_setting_setting->editSetting('affiliate', $this->request->post);
  10. $this->session->data['success'] = $this->language->get('text_success');
  11. $this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
  12. }
  13. $this->data['heading_title'] = $this->language->get('heading_title');
  14. $this->data['text_enabled'] = $this->language->get('text_enabled');
  15. $this->data['text_disabled'] = $this->language->get('text_disabled');
  16. $this->data['text_content_top'] = $this->language->get('text_content_top');
  17. $this->data['text_content_bottom'] = $this->language->get('text_content_bottom');
  18. $this->data['text_column_left'] = $this->language->get('text_column_left');
  19. $this->data['text_column_right'] = $this->language->get('text_column_right');
  20. $this->data['entry_layout'] = $this->language->get('entry_layout');
  21. $this->data['entry_position'] = $this->language->get('entry_position');
  22. $this->data['entry_status'] = $this->language->get('entry_status');
  23. $this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
  24. $this->data['button_save'] = $this->language->get('button_save');
  25. $this->data['button_cancel'] = $this->language->get('button_cancel');
  26. $this->data['button_add_module'] = $this->language->get('button_add_module');
  27. $this->data['button_remove'] = $this->language->get('button_remove');
  28. if (isset($this->error['warning'])) {
  29. $this->data['error_warning'] = $this->error['warning'];
  30. } else {
  31. $this->data['error_warning'] = '';
  32. }
  33. $this->data['breadcrumbs'] = array();
  34. $this->data['breadcrumbs'][] = array(
  35. 'text' => $this->language->get('text_home'),
  36. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
  37. 'separator' => false
  38. );
  39. $this->data['breadcrumbs'][] = array(
  40. 'text' => $this->language->get('text_module'),
  41. 'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'),
  42. 'separator' => ' :: '
  43. );
  44. $this->data['breadcrumbs'][] = array(
  45. 'text' => $this->language->get('heading_title'),
  46. 'href' => $this->url->link('module/affiliate', 'token=' . $this->session->data['token'], 'SSL'),
  47. 'separator' => ' :: '
  48. );
  49. $this->data['action'] = $this->url->link('module/affiliate', 'token=' . $this->session->data['token'], 'SSL');
  50. $this->data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
  51. $this->data['modules'] = array();
  52. if (isset($this->request->post['affiliate_module'])) {
  53. $this->data['modules'] = $this->request->post['affiliate_module'];
  54. } elseif ($this->config->get('affiliate_module')) {
  55. $this->data['modules'] = $this->config->get('affiliate_module');
  56. }
  57. $this->load->model('design/layout');
  58. $this->data['layouts'] = $this->model_design_layout->getLayouts();
  59. $this->template = 'module/affiliate.tpl';
  60. $this->children = array(
  61. 'common/header',
  62. 'common/footer',
  63. );
  64. $this->response->setOutput($this->render());
  65. }
  66. private function validate() {
  67. if (!$this->user->hasPermission('modify', 'module/affiliate')) {
  68. $this->error['warning'] = $this->language->get('error_permission');
  69. }
  70. if (!$this->error) {
  71. return true;
  72. } else {
  73. return false;
  74. }
  75. }
  76. }
  77. ?>