1: | <?php
|
2: | namespace Opencart\Admin\Controller\Marketplace;
|
3: | |
4: | |
5: | |
6: | |
7: |
|
8: | class Api extends \Opencart\System\Engine\Controller {
|
9: | |
10: | |
11: | |
12: | |
13: |
|
14: | public function index(): void {
|
15: | $this->load->language('marketplace/api');
|
16: |
|
17: | $data['user_token'] = $this->session->data['user_token'];
|
18: |
|
19: | $this->response->setOutput($this->load->view('marketplace/api', $data));
|
20: | }
|
21: |
|
22: | |
23: | |
24: | |
25: | |
26: |
|
27: | public function save(): void {
|
28: | $this->load->language('marketplace/api');
|
29: |
|
30: | $json = [];
|
31: |
|
32: | if (!$this->user->hasPermission('modify', 'marketplace/api')) {
|
33: | $json['error']['warning'] = $this->language->get('error_permission');
|
34: | }
|
35: |
|
36: | if (!$this->request->post['opencart_username']) {
|
37: | $json['error']['username'] = $this->language->get('error_username');
|
38: | }
|
39: |
|
40: | if (!$this->request->post['opencart_secret']) {
|
41: | $json['error']['secret'] = $this->language->get('error_secret');
|
42: | }
|
43: |
|
44: | if (!$json) {
|
45: | $this->load->model('setting/setting');
|
46: |
|
47: | $this->model_setting_setting->editSetting('opencart', $this->request->post);
|
48: |
|
49: | $json['success'] = $this->language->get('text_success');
|
50: | }
|
51: |
|
52: | $this->response->addHeader('Content-Type: application/json');
|
53: | $this->response->setOutput(json_encode($json));
|
54: | }
|
55: | }
|
56: | |