|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
/************************************************************************/ |
|
3
|
|
|
/* Donations - Paypal financial management module for Xoops 2 */ |
|
4
|
|
|
/* Copyright (c) 2016 XOOPS Project */ |
|
5
|
|
|
/* http://dev.xoops.org/modules/xfmod/project/?group_id=1060 */ |
|
6
|
|
|
/* |
|
7
|
|
|
/************************************************************************/ |
|
8
|
|
|
/* */ |
|
9
|
|
|
/* Based on NukeTreasury for PHP-Nuke - by Dave Lawrence AKA Thrash */ |
|
10
|
|
|
/* NukeTreasury - Financial management for PHP-Nuke */ |
|
11
|
|
|
/* Copyright (c) 2004 by Dave Lawrence AKA Thrash */ |
|
12
|
|
|
/* [email protected] */ |
|
13
|
|
|
/* [email protected] */ |
|
14
|
|
|
/* */ |
|
15
|
|
|
/************************************************************************/ |
|
16
|
|
|
/* */ |
|
17
|
|
|
/* This program is free software; you can redistribute it and/or modify */ |
|
18
|
|
|
/* it under the terms of the GNU General Public License as published by */ |
|
19
|
|
|
/* the Free Software Foundation; either version 2 of the License. */ |
|
20
|
|
|
/* */ |
|
21
|
|
|
/* This program is distributed in the hope that it will be useful, but */ |
|
22
|
|
|
/* WITHOUT ANY WARRANTY; without even the implied warranty of */ |
|
23
|
|
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ |
|
24
|
|
|
/* General Public License for more details. */ |
|
25
|
|
|
/* */ |
|
26
|
|
|
/* You should have received a copy of the GNU General Public License */ |
|
27
|
|
|
/* along with this program; if not, write to the Free Software */ |
|
28
|
|
|
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */ |
|
29
|
|
|
/* USA */ |
|
30
|
|
|
/************************************************************************/ |
|
31
|
|
|
|
|
32
|
|
|
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
|
33
|
|
|
|
|
34
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
|
35
|
|
|
|
|
36
|
|
|
xoops_loadLanguage('main', $moduleDirName); |
|
37
|
|
|
|
|
38
|
|
|
include_once XOOPS_ROOT_PATH . "/modules/{$moduleDirName}/include/functions.php"; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param $options |
|
42
|
|
|
* @return array |
|
43
|
|
|
*/ |
|
44
|
|
|
function b_donations_donate_show($options) |
|
45
|
|
|
{ |
|
46
|
|
|
global $xoopsDB, $xoopsUser; |
|
47
|
|
|
|
|
48
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
|
49
|
|
|
$tr_config = configInfo(); |
|
50
|
|
|
$paypal_url = explode('|', $tr_config['paypal_url']); |
|
51
|
|
|
$paypal_url = $paypal_url[0]; |
|
52
|
|
|
//determine the currency |
|
53
|
|
|
$PP_CURR_CODE = explode('|', $tr_config['pp_curr_code']); // [USD,GBP,JPY,CAD,EUR] |
|
54
|
|
|
$PP_CURR_CODE = $PP_CURR_CODE[0]; |
|
55
|
|
|
$currencySign = defineCurrency($PP_CURR_CODE); |
|
56
|
|
|
|
|
57
|
|
|
$block = array(); |
|
58
|
|
|
|
|
59
|
|
|
$PP_RECEIVER_EMAIL = $tr_config['receiver_email']; |
|
60
|
|
|
$PP_ITEMNAME = $tr_config['pp_itemname']; |
|
61
|
|
|
$PP_TY_URL = $tr_config['ty_url']; |
|
62
|
|
|
$PP_CANCEL_URL = $tr_config['pp_cancel_url']; |
|
63
|
|
|
|
|
64
|
|
|
// Fill out some more template tags |
|
65
|
|
|
$DON_BUTTON_SUBMIT = $tr_config['don_button_submit']; |
|
66
|
|
|
|
|
67
|
|
|
$PP_NO_SHIP = $tr_config['pp_get_addr'] ? '0' : '1'; |
|
68
|
|
|
$PP_IMAGE_URL = $tr_config['pp_image_url']; |
|
69
|
|
|
|
|
70
|
|
|
$DON_SUB_IMG_DIMS = ''; |
|
71
|
|
|
if (is_numeric($tr_config['don_sub_img_width'])) { |
|
72
|
|
|
$DON_SUB_IMG_DIMS .= 'width=' . $tr_config['don_sub_img_width'] . ' '; |
|
73
|
|
|
} |
|
74
|
|
|
if (is_numeric($tr_config['don_sub_img_height'])) { |
|
75
|
|
|
$DON_SUB_IMG_DIMS .= 'height=' . $tr_config['don_sub_img_height'] . ' '; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name='don_amount' ORDER BY subtype"; |
|
79
|
|
|
$Recordset1 = $xoopsDB->query($sql); |
|
80
|
|
|
|
|
81
|
|
|
$DONATION_AMOUNTS = ''; |
|
82
|
|
View Code Duplication |
while (false != ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))) { |
|
83
|
|
|
if (is_numeric($row_Recordset1['value']) && $row_Recordset1['value'] > 0) { |
|
84
|
|
|
if ($row_Recordset1['subtype'] == $tr_config['don_amt_checked']) { |
|
85
|
|
|
$checked = ' selected'; |
|
86
|
|
|
$block['basedonation'] = $row_Recordset1['value']; |
|
87
|
|
|
} else { |
|
88
|
|
|
$checked = ''; |
|
89
|
|
|
} |
|
90
|
|
|
$DONATION_AMOUNTS .= '<option value="' . $row_Recordset1['value'] . '" ' . $checked . ' > ' . $currencySign . $row_Recordset1['value'] . '</option>' . "\n"; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
$DONATION_AMOUNTS .= '<option value="0"> ' . _MB_DON_OTHER_AMOUNT . ' </option>'; |
|
94
|
|
|
|
|
95
|
|
|
// Ok, output the page |
|
96
|
|
|
|
|
97
|
|
|
$uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0; |
|
98
|
|
|
$block['custom'] = $uid; |
|
99
|
|
|
$block['email'] = $PP_RECEIVER_EMAIL; |
|
100
|
|
|
$block['item'] = $PP_ITEMNAME; |
|
101
|
|
|
$block['amounts'] = $DONATION_AMOUNTS; |
|
102
|
|
|
$block['prompt'] = $tr_config['don_name_prompt']; |
|
103
|
|
|
$block['nm_yes'] = $tr_config['don_name_yes']; |
|
104
|
|
|
$block['nm_no'] = $tr_config['don_name_no']; |
|
105
|
|
|
$block['pp_noship'] = $PP_NO_SHIP; |
|
106
|
|
|
$block['pp_curr_code'] = $PP_CURR_CODE; |
|
107
|
|
|
$block['pp_cancel'] = $PP_CANCEL_URL; |
|
108
|
|
|
$block['pp_thanks'] = $PP_TY_URL; |
|
109
|
|
|
$block['pp_image'] = $PP_IMAGE_URL; |
|
110
|
|
|
$block['sub_img'] = $DON_SUB_IMG_DIMS; |
|
111
|
|
|
$block['submit_button'] = _MB_DON_SUBMIT_BUTTON; |
|
112
|
|
|
$block['paypal_url'] = $paypal_url; |
|
113
|
|
|
$block['lang_select'] = _MB_DON_SELECTAMT; |
|
114
|
|
|
$block['xdon_dir'] = $moduleDirName; |
|
115
|
|
|
|
|
116
|
|
|
return $block; |
|
117
|
|
|
} |
|
118
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.