-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
executable file
·160 lines (145 loc) · 4.71 KB
/
admin.php
File metadata and controls
executable file
·160 lines (145 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
include_once ('db.php');
class plugins_paypal_admin extends plugins_paypal_db
{
public $edit, $action, $tabs;
protected $controller,$data,$template, $message, $plugins, $xml,$modelLanguage,$collectionLanguage,$header;
public $getlang, $plugin, $id, $getpage, $clientId,$clientSecret,$mode,$log;
/**
* constructeur
*/
public function __construct()
{
$this->template = new backend_model_template();
$this->plugins = new backend_controller_plugins();
$formClean = new form_inputEscape();
$this->message = new component_core_message($this->template);
$this->data = new backend_model_data($this);
$this->header = new http_header();
// Global
if (http_request::isGet('edit')) {
$this->edit = $formClean->numeric($_GET['edit']);
}
if (http_request::isGet('action')) {
$this->action = $formClean->simpleClean($_GET['action']);
} elseif (http_request::isPost('action')) {
$this->action = $formClean->simpleClean($_POST['action']);
}
if (http_request::isGet('tab')) {
$this->tab = $formClean->simpleClean($_GET['tab']);
}
if (http_request::isGet('id')) {
$this->id = (integer)$formClean->numeric($_GET['id']);
}
// POST
if (http_request::isPost('clientId')) {
$this->clientId = $formClean->simpleClean($_POST['clientId']);
}
if (http_request::isPost('clientSecret')) {
$this->clientSecret = $formClean->simpleClean($_POST['clientSecret']);
}
if (http_request::isPost('mode')) {
$this->mode = $formClean->simpleClean($_POST['mode']);
}
if (http_request::isPost('log')) {
$this->log = $formClean->simpleClean($_POST['log']);
}
}
/**
* Assign data to the defined variable or return the data
* @param string $type
* @param string|int|null $id
* @param string $context
* @param boolean $assign
* @return mixed
*/
private function getItems($type, $id = null, $context = null, $assign = true) {
return $this->data->getItems($type, $id, $context, $assign);
}
/**
* @param $data
* @throws Exception
*/
private function upd($data)
{
switch ($data['type']) {
case 'config':
parent::update(
array(
//'context' => $data['context'],
'type' => $data['type']
),
$data['data']
);
break;
}
}
/**
* Update data
* @param $data
* @throws Exception
*/
private function add($data)
{
switch ($data['type']) {
case 'newConfig':
parent::insert(
array(
//'context' => $data['context'],
'type' => $data['type']
),
$data['data']
);
break;
}
}
private function save(){
$setData = $this->getItems('root',NULL,'one',false);
if($setData['id_paypal']){
$log = !isset($this->log) ? 0 : 1;
$this->upd(
array(
'type' => 'config',
'data' => array(
'clientId' => $this->clientId,
'clientSecret' => $this->clientSecret,
'mode' => $this->mode,
'log' => $log,
'id' => $setData['id_paypal']
)
)
);
}else{
$log = !isset($this->log) ? 0 : 1;
$this->add(
array(
'type' => 'newConfig',
'data' => array(
'clientId' => $this->clientId,
'clientSecret' => $this->clientSecret,
'mode' => $this->mode,
'log' => $log
)
)
);
}
$this->message->json_post_response(true, 'update');
}
/**
* Execute plugin
*/
public function run()
{
if(isset($this->action)) {
switch ($this->action) {
case 'edit':
$this->save();
break;
}
}else{
$data = $this->getItems('root',NULL,'one',false);
$this->template->assign('paypal', $data);
$this->template->display('index.tpl');
}
}
}