ILIAS
eassessment Revision 61809
◀ ilDoc Overview
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Groups
Pages
class.ilPayMethods.php
Go to the documentation of this file.
1
<?php
2
/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13
class
ilPayMethods
14
{
15
var
$pm_id
;
16
var
$pm_title
;
17
var
$pm_enabled
;
18
var
$save_usr_adr
;
19
20
21
function
ilPaymethods
($a_pm_id = 0)
22
{
23
global
$ilDB
;
24
$this->db =
$ilDB
;
25
26
if
($a_pm_id != 0)
27
{
28
$this->pm_id = $a_pm_id;
29
$this->
read
();
30
}
31
else
$this->
readAll
();
32
}
33
34
// Setter / Getter
35
function
setPmId
($a_pm_id)
36
{
37
$this->pm_id = $a_pm_id;
38
}
39
function
getPmId
()
40
{
41
return
$this->pm_id
;
42
}
43
44
function
setPmTitle
($a_pm_title)
45
{
46
$this->pm_title = $a_pm_title;
47
}
48
function
getPmTitle
()
49
{
50
return
$this->pm_title
;
51
}
52
53
function
setPmEnabled
($a_pm_enabled)
54
{
55
$this->pm_enabled = $a_pm_enabled;
56
}
57
function
getPmEnabled
()
58
{
59
return
$this->pm_enabled
;
60
}
61
62
function
setSaveUserAddress
($a_save_usr_adr)
63
{
64
$this->save_usr_adr = $a_save_usr_adr;
65
}
66
function
getSaveUserAddress
()
67
{
68
return
$this->save_usr_adr
;
69
}
70
71
static
function
countPM
()
72
{
73
global
$ilDB
;
74
75
$res
= $ilDB->query(
'SELECT count(pm_id) cnt FROM payment_paymethods'
);
76
$row
= $ilDB->fetchAssoc(
$res
);
77
78
return
$row
[
'cnt'
];
79
80
}
81
public
function
read
()
82
{
83
$res
= $this->db->queryF(
'SELECT * FROM payment_paymethods WHERE pm_id = %s'
,
84
array(
'integer'
), array($this->
getPmId
()));
85
86
87
while
(
$row
= $this->db->fetchAssoc(
$res
))
88
{
89
$this->
setPmTitle
(
$row
[
'pm_title'
]);
90
$this->
setPmEnabled
(
$row
[
'pm_enabled'
]);
91
$this->
setSaveUserAddress
(
$row
[
'save_usr_adr'
]);
92
}
93
return
true
;
94
}
95
96
public
function
readAll
()
97
{
98
$res
= $this->db->query(
'SELECT * FROM payment_paymethods'
);
99
$paymethods = array();
100
$counter = 0;
101
while
(
$row
= $this->db->fetchAssoc(
$res
))
102
{
103
$paymethods[$counter][
'pm_id'
] =
$row
[
'pm_id'
];
104
$paymethods[$counter][
'pm_title'
] =
$row
[
'pm_title'
];
105
$paymethods[$counter][
'pm_enabled'
] =
$row
[
'pm_enabled'
];
106
$paymethods[$counter][
'save_usr_adr'
] =
$row
[
'save_usr_adr'
];
107
$counter++;
108
}
109
return
$paymethods;
110
}
111
112
static
function
_PMEnabled
($a_id)
113
{
114
global
$ilDB
;
115
116
$res
= $ilDB->queryF(
'SELECT pm_enabled FROM payment_paymethods WHERE pm_id = %s'
,
117
array(
'integer'
), array($a_id));
118
119
$row
= $ilDB->fetchAssoc(
$res
);
120
121
return
(
int
)
$row
[
'pm_enabled'
];
122
123
}
124
125
static
function
_PMdisable
($a_id)
126
{
127
global
$ilDB
;
128
129
$res
= $ilDB->manipulateF(
'UPDATE payment_paymethods SET pm_enabled = 0
130
WHERE pm_id = %s'
,
131
array(
'integer'
), array($a_id));
132
}
133
134
static
function
_PMenable
($a_id)
135
{
136
global
$ilDB
;
137
138
$res
= $ilDB->manipulateF(
'UPDATE payment_paymethods SET pm_enabled = 1
139
WHERE pm_id = %s'
,
140
array(
'integer'
), array($a_id));
141
}
142
143
static
function
_PMdisableAll
()
144
{
145
global
$ilDB
;
146
147
$res
= $ilDB->manipulateF(
'UPDATE payment_paymethods SET pm_enabled = %s'
,
148
array(
'integer'
), array(
'0'
));
149
}
150
151
152
static
function
_disableSaveUserAddress
($a_id)
153
{
154
global
$ilDB
;
155
156
$res
= $ilDB->manipulateF(
'UPDATE payment_paymethods SET save_usr_adr = 0
157
WHERE pm_id = %s'
,
158
array(
'integer'
), array($a_id));
159
}
160
161
static
function
_enableSaveUserAddress
($a_id)
162
{
163
global
$ilDB
;
164
165
$res
= $ilDB->manipulateF(
'UPDATE payment_paymethods SET save_usr_adr = 1
166
WHERE pm_id = %s'
,
167
array(
'integer'
), array($a_id));
168
}
169
170
static
function
_EnabledSaveUserAddress
($a_id)
171
{
172
global
$ilDB
;
173
174
$res
= $ilDB->queryF(
'SELECT save_usr_adr FROM payment_paymethods WHERE pm_id = %s'
,
175
array(
'integer'
), array($a_id));
176
177
$row
= $ilDB->fetchAssoc(
$res
);
178
179
return
(
int
)
$row
[
'save_usr_adr'
];
180
181
}
182
static
function
_getIdByTitle
($a_pm_title)
183
{
184
global
$ilDB
;
185
186
$res
= $ilDB->queryF(
'SELECT pm_id FROM payment_paymethods WHERE pm_title = %s'
,
187
array(
'text'
), array($a_pm_title));
188
189
$row
= $ilDB->fetchAssoc(
$res
);
190
return
(
int
)
$row
[
'pm_id'
];
191
}
192
static
function
_getTitleById
($a_pm_id)
193
{
194
global
$ilDB
;
195
196
$res
= $ilDB->queryF(
'SELECT pm_title FROM payment_paymethods WHERE pm_id = %s'
,
197
array(
'integer'
), array($a_pm_id));
198
199
$row
= $ilDB->fetchAssoc(
$res
);
200
return
(
int
)
$row
[
'pm_title'
];
201
202
}
203
204
static
function
getStringByPaymethod
($a_type)
205
{
206
global
$lng
;
207
208
switch
($a_type)
209
{
210
case
'1'
:
211
case
'pm_bill'
:
212
case
'bill'
:
213
case
'PAY_METHOD_BILL'
:
return
$lng->txt(
'pays_bill'
);
214
break
;
215
216
case
'2'
:
217
case
'pm_bmf'
:
218
case
'bmf'
:
219
case
'PAY_METHOD_BMF'
:
return
$lng->txt(
'pays_bmf'
);
220
break
;
221
222
case
'3'
:
223
case
'pm_paypal'
:
224
case
'paypal'
:
225
case
'PAY_METHOD_PAYPAL'
:
return
$lng->txt(
'pays_paypal'
);
226
break
;
227
228
case
'4'
:
229
case
'pm_epay'
:
230
case
'epay'
:
231
case
'PAY_METHOD_EPAY'
:
return
$lng->txt(
'pays_epay'
);
232
break
;
233
case
'PAY_METHOD_NOT_SPECIFIED'
:
return
$lng->txt(
'paya_pay_method_not_specified'
);
234
break
;
235
default
:
236
return
$lng->txt(
'paya_pay_method_not_specified'
);
237
break
;
238
}
239
}
240
241
/*
242
* This function returns all available paymethods for SelectInputs in GUIs
243
*/
244
static
function
getPayMethodsOptions
(
$type
= 0)
245
{
246
global
$ilDB
,
$lng
;
247
248
$res
= $ilDB->query(
'SELECT * FROM payment_paymethods WHERE pm_enabled = 1'
);
249
$options = array();
250
251
//this is only for additional entries in SelectInputGUIs
252
switch
(
$type
)
253
{
254
case
'all'
:
255
$options[
'all'
] = $lng->txt(
'pay_all'
);
256
break
;
257
case
'not_specified'
:
258
$options[0] = $lng->txt(
'paya_pay_method_not_specified'
);
259
break
;
260
//default: break;
261
}
262
263
while
(
$row
= $ilDB->fetchAssoc(
$res
))
264
{
265
$options[
$row
[
'pm_id'
]] =
ilPayMethods::getStringByPaymethod
($row[
'pm_title'
]);
266
}
267
268
return
$options;
269
}
270
}
271
?>
Services
Payment
classes
class.ilPayMethods.php
Generated on Mon Apr 25 2016 19:01:38 for ILIAS by
1.8.1.2 (using
Doxyfile
)