1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* You may not change or alter any portion of this comment or credits |
4
|
|
|
* of supporting developers from this source code or any supporting source code |
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
* |
7
|
|
|
* This program is distributed in the hope that it will be useful, |
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
14
|
|
|
* @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
15
|
|
|
* @package efqdirectory |
16
|
|
|
* @since |
17
|
|
|
* @author Martijn Hertog (aka wtravel) |
18
|
|
|
* @author XOOPS Development Team, |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
require_once __DIR__ . '/admin_header.php'; |
22
|
|
|
//include __DIR__ . '/../../../include/cp_header.php'; |
|
|
|
|
23
|
|
|
|
24
|
|
|
include __DIR__ . '/../include/functions.php'; |
25
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopstree.php'; |
|
|
|
|
26
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
27
|
|
|
require_once XOOPS_ROOT_PATH . '/include/xoopscodes.php'; |
28
|
|
|
require_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php'; |
29
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
30
|
|
|
require_once __DIR__ . '/../class/class.subscription.php'; |
31
|
|
|
$myts = MyTextSanitizer::getInstance(); |
|
|
|
|
32
|
|
|
$eh = new ErrorHandler; |
|
|
|
|
33
|
|
|
$itemtypes = new XoopsTree($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes'), 'typeid', ''); |
|
|
|
|
34
|
|
|
$subscription = new efqSubscription(); |
35
|
|
|
$subscriptionhandler = new efqSubscriptionHandler(); |
36
|
|
|
|
37
|
|
|
$moddir = $xoopsModule->getVar('dirname'); |
38
|
|
|
if (isset($_GET['typeid'])) { |
39
|
|
|
$get_typeid = (int)$_GET['typeid']; |
40
|
|
|
} else { |
41
|
|
|
$get_typeid = '0'; |
42
|
|
|
if (isset($_POST['typeid'])) { |
43
|
|
|
$post_typeid = (int)$_POST['typeid']; |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
if (isset($_GET['offerid'])) { |
47
|
|
|
$get_offerid = (int)$_GET['offerid']; |
48
|
|
|
} else { |
49
|
|
|
$get_offerid = 0; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$eh = new ErrorHandler; //ErrorHandler object |
53
|
|
|
|
54
|
|
View Code Duplication |
if (isset($_GET['op'])) { |
|
|
|
|
55
|
|
|
$op = $_GET['op']; |
56
|
|
|
} elseif (isset($_POST['op'])) { |
57
|
|
|
$op = $_POST['op']; |
58
|
|
|
} else { |
59
|
|
|
$op = ''; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
//function to list subscription types |
63
|
|
|
function listoffers() |
64
|
|
|
{ |
65
|
|
|
global $xoopsDB, $eh, $xoopsUser, $subscription, $subscriptionhandler, $itemtypes, $myts, $xoopsModule; |
66
|
|
|
xoops_cp_header(); |
|
|
|
|
67
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
|
|
|
|
68
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
69
|
|
|
//adminmenu(4, _MD_MANAGE_SUBSCRIPTION_OFFERS); |
|
|
|
|
70
|
|
|
echo '<br>'; |
71
|
|
|
|
72
|
|
|
//list subscription offers |
73
|
|
|
$sql = 'SELECT o.offerid, o.typeid, o.title, o.duration, o.count, o.price, o.activeyn, o.currency, o.descr, t.typename, t.typelevel FROM ' |
74
|
|
|
. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes') |
75
|
|
|
. ' t, ' |
76
|
|
|
. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_subscr_offers') |
77
|
|
|
. ' o WHERE o.typeid=t.typeid'; |
78
|
|
|
$result = $xoopsDB->query($sql) or $eh->show('0013'); |
79
|
|
|
$numrows = $xoopsDB->getRowsNum($result); |
80
|
|
|
if ($numrows > 0) { |
81
|
|
|
echo '<h4>' . _MD_SUBSCR_OFFERS . '</h4>'; |
82
|
|
|
echo "<table width='100%' border='0' cellspacing='1' class='outer'>"; |
83
|
|
|
echo '<tr><th>' . _MD_OFFER_TITLE . '</th><th>' . _MD_OFFER_DURATION . '</th><th>' . _MD_OFFER_COUNT . '</th><th>' . _MD_OFFER_PRICE . '</th><th>' . _MD_OFFER_CURRENCY . '</th><th>' . _MD_OFFER_ACTIVE . '</th></tr>'; |
84
|
|
|
$duration_arr = $subscription->durationArray(); |
85
|
|
|
while (list($offerid, $typeid, $title, $duration, $count, $price, $activeyn, $currency, $descr, $typename, $level) = $xoopsDB->fetchRow($result)) { |
86
|
|
|
$offertitle = $myts->htmlSpecialChars($title); |
87
|
|
|
if ($activeyn == '1') { |
88
|
|
|
$activeyn = _MD_YES; |
89
|
|
|
} else { |
90
|
|
|
$activeyn = _MD_NO; |
91
|
|
|
} |
92
|
|
|
//Show offers |
93
|
|
|
echo '<tr>'; |
94
|
|
|
echo "<td class=\"even\"><a href=\"subscriptions.php?op=editoffer&offerid=$offerid\">$offertitle</a></td>"; |
95
|
|
|
echo "<td class=\"odd\">$duration_arr[$duration]</td>"; |
96
|
|
|
echo "<td class=\"even\">$count</td>"; |
97
|
|
|
echo "<td class=\"odd\">$price</td>"; |
98
|
|
|
echo "<td class=\"even\">$currency</td>"; |
99
|
|
|
echo "<td class=\"odd\">$activeyn</td>"; |
100
|
|
|
echo '</tr>'; |
101
|
|
|
} |
102
|
|
|
echo '</table>'; |
103
|
|
|
} else { |
104
|
|
|
echo '' . _MD_NORESULTS . '<br><br>'; |
105
|
|
|
} |
106
|
|
|
echo '<h4>' . _MD_ADD_SUBSCR_OFFER . '</h4>'; |
107
|
|
|
|
108
|
|
|
echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td>"; |
109
|
|
|
$form = new XoopsThemeForm(_MD_ADD_OFFER_FORM, 'newofferform', 'subscriptions.php'); |
|
|
|
|
110
|
|
|
$form->addElement(new XoopsFormText(_MD_OFFER_TITLE, 'title', 50, 100, ''), true); |
|
|
|
|
111
|
|
|
|
112
|
|
|
$itemtypes_arr = $subscriptionhandler->itemTypesArray(); |
113
|
|
|
$itemtype_select = new XoopsFormSelect(_MD_SUBSCR_ITEMTYPE, 'typeid'); |
|
|
|
|
114
|
|
|
$itemtype_select->addOptionArray($itemtypes_arr); |
115
|
|
|
$form->addElement($itemtype_select); |
116
|
|
|
|
117
|
|
|
$duration_arr = $subscription->durationArray(); |
118
|
|
|
$duration_select = new XoopsFormSelect(_MD_OFFER_DURATION, 'duration'); |
119
|
|
|
$duration_select->addOptionArray($duration_arr); |
120
|
|
|
$form->addElement($duration_select); |
121
|
|
|
|
122
|
|
|
$form->addElement(new XoopsFormText(_MD_OFFER_COUNT, 'count', 10, 50, ''), true); |
123
|
|
|
$form->addElement(new XoopsFormText(_MD_OFFER_PRICE, 'price', 20, 50, ''), true); |
124
|
|
|
|
125
|
|
|
$currency_arr = $subscription->currencyArray(); |
126
|
|
|
$currency_select = new XoopsFormSelect(_MD_OFFER_CURRENCY, 'currency'); |
127
|
|
|
$currency_select->addOptionArray($currency_arr); |
128
|
|
|
$form->addElement($currency_select); |
129
|
|
|
|
130
|
|
|
$form_active = new XoopsFormCheckBox(_MD_OFFER_ACTIVEYN, 'activeyn', 0); |
|
|
|
|
131
|
|
|
$form_active->addOption(1, _MD_YESNO); |
132
|
|
|
$form->addElement($form_active, true); |
133
|
|
|
$form->addElement(new XoopsFormDhtmlTextArea(_MD_OFFER_DESCR, 'descr', '', 5, 50, '')); |
|
|
|
|
134
|
|
|
$form->addElement(new XoopsFormButton('', 'submit', _MD_SUBMIT, 'submit')); |
|
|
|
|
135
|
|
|
$form->addElement(new XoopsFormHidden('op', 'addoffer')); |
|
|
|
|
136
|
|
|
$form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid'))); |
137
|
|
|
$form->display(); |
138
|
|
|
echo '</td></tr></table>'; |
139
|
|
|
|
140
|
|
|
//Show item types |
141
|
|
|
$sql = 'SELECT typeid, typename, typelevel FROM ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes') . ''; |
142
|
|
|
$result = $xoopsDB->query($sql) or $eh->show('0013'); |
143
|
|
|
$numrows = $xoopsDB->getRowsNum($result); |
144
|
|
|
if ($numrows > 0) { |
145
|
|
|
echo '<h4>' . _MD_ITEMTYPES . '</h4>'; |
146
|
|
|
echo "<table width='100%' border='0' cellspacing='1' class='outer'>"; |
147
|
|
|
echo '<tr><th>' . _MD_ITEMTYPE_NAME . '</th><th>' . _MD_ITEMTYPE_LEVEL . '</th><th>' . _MD_ACTION . '</th></tr>'; |
148
|
|
|
$duration_arr = $subscription->durationArray(); |
|
|
|
|
149
|
|
|
while (list($typeid, $typename, $level) = $xoopsDB->fetchRow($result)) { |
150
|
|
|
$typename = $myts->htmlSpecialChars($typename); |
151
|
|
|
$level = $myts->htmlSpecialChars($level); |
152
|
|
|
|
153
|
|
|
//Show types |
154
|
|
|
echo '<tr>'; |
155
|
|
|
echo "<td class=\"even\"><a href=\"subscriptions.php?op=edittype&typeid=$typeid\">$typename</strong></td>"; |
156
|
|
|
echo "<td class=\"odd\">$level</td>"; |
157
|
|
|
echo "<td class=\"odd\"><a href=\"subscriptions.php?op=deltype&typeid=$typeid\">" . _MD_DELETE . '</strong></td>'; |
158
|
|
|
echo '</tr>'; |
159
|
|
|
} |
160
|
|
|
echo '</table>'; |
161
|
|
|
} else { |
162
|
|
|
echo '' . _MD_NORESULTS . '<br><br>'; |
163
|
|
|
} |
164
|
|
|
echo '<h4>' . _MD_ADD_ITEMTYPE . '</h4>'; |
165
|
|
|
|
166
|
|
|
//Add item type form |
167
|
|
|
echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td>"; |
168
|
|
|
$form = new XoopsThemeForm(_MD_ADD_ITEMTYPE_FORM, 'newitemtypeform', 'subscriptions.php'); |
169
|
|
|
$form->addElement(new XoopsFormText(_MD_ITEMTYPE_NAME, 'typename', 50, 100, ''), true); |
170
|
|
|
$form->addElement(new XoopsFormText(_MD_ITEMTYPE_LEVEL, 'typelevel', 10, 50, ''), true); |
171
|
|
|
|
172
|
|
|
$form->addElement(new XoopsFormButton('', 'submit', _MD_SUBMIT, 'submit')); |
173
|
|
|
$form->addElement(new XoopsFormHidden('op', 'addtype')); |
174
|
|
|
$form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid'))); |
175
|
|
|
$form->display(); |
176
|
|
|
echo '</td></tr></table>'; |
177
|
|
|
xoops_cp_footer(); |
|
|
|
|
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
function edittype() |
181
|
|
|
{ |
182
|
|
|
global $xoopsDB, $eh, $myts, $get_typeid, $xoopsUser; |
183
|
|
|
if ($get_typeid == 0) { |
184
|
|
|
redirect_header(XOOPS_URL . "/modules/$moddir/admin/subscriptions.php", 2, _MD_INVALID_TYPEID); |
|
|
|
|
185
|
|
|
exit(); |
186
|
|
|
} |
187
|
|
|
xoops_cp_header(); |
|
|
|
|
188
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
189
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
190
|
|
|
//adminmenu(4, _MD_MANAGE_SUBSCRIPTION_OFFERS); |
|
|
|
|
191
|
|
|
echo '<br>'; |
192
|
|
|
$sql = 'SELECT typeid, typename, typelevel FROM ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes') . " WHERE typeid=$get_typeid"; |
|
|
|
|
193
|
|
|
$result = $xoopsDB->query($sql) or $eh->show('0013'); |
194
|
|
|
$numrows = $xoopsDB->getRowsNum($result); |
195
|
|
|
if ($numrows > 0) { |
196
|
|
|
//$duration_arr = $subscription->durationArray(); |
|
|
|
|
197
|
|
|
while (list($typeid, $typename, $level) = $xoopsDB->fetchRow($result)) { |
198
|
|
|
echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td>"; |
199
|
|
|
$form = new XoopsThemeForm(_MD_EDIT_ITEMTYPE_FORM, 'edititemtypeform', 'subscriptions.php'); |
200
|
|
|
$form->addElement(new XoopsFormText(_MD_ITEMTYPE_NAME, 'typename', 50, 100, $typename), true); |
201
|
|
|
$form->addElement(new XoopsFormText(_MD_ITEMTYPE_LEVEL, 'typelevel', 10, 50, $level), true); |
202
|
|
|
$form->addElement(new XoopsFormButton('', 'submit', _MD_SUBMIT, 'submit')); |
203
|
|
|
$form->addElement(new XoopsFormHidden('op', 'savetype')); |
204
|
|
|
$form->addElement(new XoopsFormHidden('typeid', "$get_typeid")); |
205
|
|
|
$form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid'))); |
206
|
|
|
$form->display(); |
207
|
|
|
echo '</td></tr></table>'; |
208
|
|
|
} |
209
|
|
|
} else { |
210
|
|
|
redirect_header(XOOPS_URL . "/modules/$moddir/admin/subscriptions.php", 2, _MD_INVALID_TYPEID); |
211
|
|
|
exit(); |
212
|
|
|
} |
213
|
|
|
xoops_cp_footer(); |
|
|
|
|
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
function editoffer() |
217
|
|
|
{ |
218
|
|
|
global $xoopsDB, $eh, $xoopsUser, $subscription, $subscriptionhandler, $get_offerid, $itemtypes; |
219
|
|
|
if ($get_offerid == 0) { |
220
|
|
|
redirect_header(XOOPS_URL . "/modules/$moddir/admin/subscriptions.php", 2, _MD_INVALID_OFFERID); |
|
|
|
|
221
|
|
|
exit(); |
222
|
|
|
} |
223
|
|
|
xoops_cp_header(); |
|
|
|
|
224
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
225
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
226
|
|
|
//adminmenu(4, _MD_MANAGE_SUBSCRIPTION_OFFERS); |
|
|
|
|
227
|
|
|
echo '<br>'; |
228
|
|
|
$sql = 'SELECT o.offerid, o.title, o.typeid, o.duration, o.count, o.price, o.activeyn, o.currency, o.descr, t.typename, t.typelevel FROM ' |
229
|
|
|
. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes') |
|
|
|
|
230
|
|
|
. ' t, ' |
231
|
|
|
. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_subscr_offers') |
232
|
|
|
. ' o WHERE o.typeid=t.typeid AND o.offerid=' |
233
|
|
|
. $get_offerid |
234
|
|
|
. ''; |
235
|
|
|
$result = $xoopsDB->query($sql) or $eh->show('0013'); |
236
|
|
|
$numrows = $xoopsDB->getRowsNum($result); |
237
|
|
|
if ($numrows > 0) { |
238
|
|
|
$duration_arr = $subscription->durationArray(); |
239
|
|
|
while (list($offerid, $offertitle, $typeid, $duration, $count, $price, $activeyn, $currency, $descr, $typename, $level) = $xoopsDB->fetchRow($result)) { |
240
|
|
|
echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td>"; |
241
|
|
|
$form = new XoopsThemeForm(_MD_ADD_OFFER_FORM, 'newofferform', 'subscriptions.php'); |
242
|
|
|
$form->addElement(new XoopsFormText(_MD_OFFER_TITLE, 'title', 50, 100, $offertitle), true); |
243
|
|
|
|
244
|
|
|
$itemtypes_arr = $subscriptionhandler->itemTypesArray(); |
245
|
|
|
$itemtype_select = new XoopsFormSelect(_MD_SUBSCR_ITEMTYPE, 'typeid', $typeid); |
246
|
|
|
$itemtype_select->addOptionArray($itemtypes_arr); |
247
|
|
|
$form->addElement($itemtype_select); |
248
|
|
|
|
249
|
|
|
//$duration_arr = $subscription->durationArray(); |
|
|
|
|
250
|
|
|
$duration_select = new XoopsFormSelect(_MD_OFFER_DURATION, 'duration', $duration); |
251
|
|
|
$duration_select->addOptionArray($duration_arr); |
252
|
|
|
$form->addElement($duration_select); |
253
|
|
|
|
254
|
|
|
$form->addElement(new XoopsFormText(_MD_OFFER_COUNT, 'count', 10, 50, $count), true); |
255
|
|
|
$form->addElement(new XoopsFormText(_MD_OFFER_PRICE, 'price', 20, 50, $price), true); |
256
|
|
|
|
257
|
|
|
$currency_arr = $subscription->currencyArray(); |
258
|
|
|
$currency_select = new XoopsFormSelect(_MD_OFFER_CURRENCY, 'currency', $currency); |
259
|
|
|
$currency_select->addOptionArray($currency_arr); |
260
|
|
|
$form->addElement($currency_select); |
261
|
|
|
|
262
|
|
|
$form_active = new XoopsFormCheckBox(_MD_OFFER_ACTIVEYN, 'activeyn', $activeyn); |
263
|
|
|
$form_active->addOption(1, _MD_YESNO); |
264
|
|
|
$form->addElement($form_active, true); |
265
|
|
|
$form->addElement(new XoopsFormDhtmlTextArea(_MD_OFFER_DESCR, 'descr', $descr, 5, 50, '')); |
266
|
|
|
$form->addElement(new XoopsFormButton('', 'submit', _MD_SUBMIT, 'submit')); |
267
|
|
|
$form->addElement(new XoopsFormHidden('op', 'saveoffer')); |
268
|
|
|
$form->addElement(new XoopsFormHidden('offerid', "$get_offerid")); |
269
|
|
|
$form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid'))); |
270
|
|
|
$form->display(); |
271
|
|
|
echo '</td></tr></table>'; |
272
|
|
|
} |
273
|
|
|
} else { |
274
|
|
|
redirect_header(XOOPS_URL . "/modules/$moddir/admin/subscriptions.php", 2, _MD_INVALID_OFFERID); |
275
|
|
|
exit(); |
276
|
|
|
} |
277
|
|
|
xoops_cp_footer(); |
|
|
|
|
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
//function to view one subscription type |
281
|
|
|
function viewtype() |
282
|
|
|
{ |
283
|
|
|
global $xoopsDB, $eh, $get_typeid; |
284
|
|
|
if (isset($get_itemid)) { |
|
|
|
|
285
|
|
|
//view type |
286
|
|
|
} |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
function addoffer() |
290
|
|
|
{ |
291
|
|
|
global $xoopsDB, $eh, $myts, $moddir; |
292
|
|
|
//Get POST variables; |
293
|
|
|
$post_title = $myts->makeTboxData4Save($_POST['title']); |
294
|
|
|
$post_typeid = (int)$_POST['typeid']; |
295
|
|
|
$post_duration = $myts->makeTboxData4Save($_POST['duration']); |
296
|
|
|
$post_currency = $myts->makeTboxData4Save($_POST['currency']); |
297
|
|
|
$post_count = (int)$_POST['count']; |
298
|
|
|
$post_price = $myts->makeTboxData4Save($_POST['price']); |
299
|
|
|
if (isset($activeyn)) { |
|
|
|
|
300
|
|
|
$post_activeyn = (int)$_POST['activeyn']; |
301
|
|
|
} else { |
302
|
|
|
$post_activeyn = 0; |
303
|
|
|
} |
304
|
|
View Code Duplication |
if (isset($_POST['descr'])) { |
|
|
|
|
305
|
|
|
$post_descr = $myts->makeTboxData4Save($_POST['descr']); |
306
|
|
|
} else { |
307
|
|
|
$post_descr = ''; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
$gen_offerid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_subscr_offers') . '_offerid_seq'); |
|
|
|
|
311
|
|
|
$sql = sprintf("INSERT INTO %s (offerid, title, typeid, duration, COUNT, price, activeyn, currency, descr) VALUES (%u, '%s', %u, %u, %u, '%s', %u, '%s', '%s')", $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_subscr_offers'), $gen_offerid, $post_title, $post_typeid, |
312
|
|
|
$post_duration, $post_count, $post_price, $post_activeyn, $post_currency, $post_descr); |
313
|
|
|
$xoopsDB->query($sql) or $eh->show('0013'); |
314
|
|
|
$gen_offerid = $xoopsDB->getInsertId(); |
315
|
|
|
redirect_header(XOOPS_URL . "/modules/$moddir/admin/subscriptions.php?offerid=" . $gen_offerid . '', 2, _MD_SAVED); |
|
|
|
|
316
|
|
|
exit(); |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
function saveoffer() |
320
|
|
|
{ |
321
|
|
|
global $xoopsDB, $eh, $myts, $moddir; |
322
|
|
|
//Get POST variables; |
323
|
|
|
$post_offerid = (int)$_POST['offerid']; |
324
|
|
|
$post_title = $myts->makeTboxData4Save($_POST['title']); |
325
|
|
|
$post_typeid = (int)$_POST['typeid']; |
326
|
|
|
$post_duration = $myts->makeTboxData4Save($_POST['duration']); |
327
|
|
|
$post_currency = $myts->makeTboxData4Save($_POST['currency']); |
328
|
|
|
$post_count = (int)$_POST['count']; |
329
|
|
|
$post_price = $myts->makeTboxData4Save($_POST['price']); |
330
|
|
|
if (isset($_POST['activeyn'])) { |
331
|
|
|
$post_activeyn = (int)$_POST['activeyn']; |
332
|
|
|
} else { |
333
|
|
|
$post_activeyn = 0; |
334
|
|
|
} |
335
|
|
View Code Duplication |
if (isset($_POST['descr'])) { |
|
|
|
|
336
|
|
|
$post_descr = $myts->makeTboxData4Save($_POST['descr']); |
337
|
|
|
} else { |
338
|
|
|
$post_descr = ''; |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
$gen_offerid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_subscr_offers') . '_offerid_seq'); |
|
|
|
|
342
|
|
|
$sql = 'UPDATE ' |
343
|
|
|
. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_subscr_offers') |
344
|
|
|
. " SET title = '$post_title', typeid = '$post_typeid', duration = '$post_duration', count = '$post_count', price = '$post_price', activeyn = '$post_activeyn', currency = '$post_currency', descr = '$post_descr' WHERE offerid='$post_offerid'"; |
345
|
|
|
$xoopsDB->query($sql) or $eh->show('0013'); |
346
|
|
|
$gen_offerid = $xoopsDB->getInsertId(); |
347
|
|
|
redirect_header(XOOPS_URL . "/modules/$moddir/admin/subscriptions.php?offerid=" . $post_offerid . '', 2, _MD_SAVED); |
|
|
|
|
348
|
|
|
exit(); |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
function addtype() |
352
|
|
|
//function to save a new item type |
353
|
|
|
{ |
354
|
|
|
global $xoopsDB, $eh, $myts, $_POST, $moddir; |
355
|
|
|
$p_typename = $myts->makeTboxData4Save($_POST['typename']); |
356
|
|
|
$p_level = $myts->makeTboxData4Save($_POST['typelevel']); |
357
|
|
|
$newid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes') . '_typeid_seq'); |
|
|
|
|
358
|
|
|
$sql = sprintf("INSERT INTO %s (typeid, typename, typelevel) VALUES (%u, '%s', '%s')", $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes'), $newid, $p_typename, $p_level); |
359
|
|
|
$xoopsDB->query($sql) or $eh->show('0013'); |
360
|
|
|
redirect_header(XOOPS_URL . "/modules/$moddir/admin/subscriptions.php", 2, _MD_SAVED); |
|
|
|
|
361
|
|
|
exit(); |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
function deltype() |
365
|
|
|
//function to delete an item type |
366
|
|
|
{ |
367
|
|
|
global $xoopsDB, $eh, $moddir, $subscriptionhandler; |
368
|
|
View Code Duplication |
if (isset($_GET['typeid'])) { |
|
|
|
|
369
|
|
|
$g_typeid = (int)$_GET['typeid']; |
370
|
|
|
} else { |
371
|
|
|
redirect_header(XOOPS_URL . "/modules/$moddir/admin/subscriptions.php", 2, _MD_ERR_ITEMTYPE_DELETE); |
|
|
|
|
372
|
|
|
exit(); |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
if ($subscriptionhandler->countSubscriptionsForType($g_typeid) > 0) { |
376
|
|
|
redirect_header(XOOPS_URL . "/modules/$moddir/admin/subscriptions.php", 3, _MD_ERR_ITEMTYPE_LINKED_TO_LISTINGS); |
|
|
|
|
377
|
|
|
exit(); |
378
|
|
|
} |
379
|
|
|
$sql = sprintf('DELETE FROM %s WHERE typeid=%u', $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes'), $g_typeid); |
|
|
|
|
380
|
|
|
$xoopsDB->queryF($sql) or $eh->show('0013'); |
381
|
|
|
redirect_header(XOOPS_URL . "/modules/$moddir/admin/subscriptions.php", 1, _MD_ITEMTYPE_DELETED); |
|
|
|
|
382
|
|
|
exit(); |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
//function to save an existing subscription type |
386
|
|
|
function savetype() |
387
|
|
|
{ |
388
|
|
|
global $xoopsDB, $eh, $post_typeid, $myts, $moddir; |
389
|
|
|
$p_typename = $myts->makeTboxData4Save($_POST['typename']); |
390
|
|
|
$p_level = (int)$_POST['typelevel']; |
391
|
|
|
$newid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes') . '_typeid_seq'); |
|
|
|
|
392
|
|
|
$sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes') . " SET typename='$p_typename', typelevel='$p_level' WHERE typeid='$post_typeid'"; |
393
|
|
|
$xoopsDB->query($sql) or $eh->show('0013'); |
394
|
|
|
redirect_header(XOOPS_URL . "/modules/$moddir/admin/subscriptions.php", 2, _MD_SAVED); |
|
|
|
|
395
|
|
|
exit(); |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
//function to delete an existing subscription type |
|
|
|
|
399
|
|
|
/*function deltype() |
400
|
|
|
{ |
401
|
|
|
global $xoopsDB, $eh, $post_typeid; |
402
|
|
|
}*/ |
403
|
|
|
|
404
|
|
|
switch ($op) { |
405
|
|
|
case 'delete': |
406
|
|
|
deltype(); |
407
|
|
|
break; |
408
|
|
|
case 'save': |
409
|
|
|
savetype(); |
410
|
|
|
break; |
411
|
|
|
case 'addtype': |
412
|
|
|
addtype(); |
413
|
|
|
break; |
414
|
|
|
case 'edittype': |
415
|
|
|
edittype(); |
416
|
|
|
break; |
417
|
|
|
case 'deltype': |
418
|
|
|
deltype(); |
419
|
|
|
break; |
420
|
|
|
case 'savetype': |
421
|
|
|
savetype(); |
422
|
|
|
break; |
423
|
|
|
case 'viewtype': |
424
|
|
|
viewtype(); |
425
|
|
|
break; |
426
|
|
|
case 'addoffer': |
427
|
|
|
addoffer(); |
428
|
|
|
break; |
429
|
|
|
case 'editoffer': |
430
|
|
|
editoffer(); |
431
|
|
|
break; |
432
|
|
|
case 'saveoffer': |
433
|
|
|
saveoffer(); |
434
|
|
|
break; |
435
|
|
|
default: |
436
|
|
|
listoffers(); |
437
|
|
|
break; |
438
|
|
|
} |
439
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.