1 | <?php |
---|
2 | /* |
---|
3 | Plugin Panier PayPal Pour Piwigo |
---|
4 | Copyright (C) 2011 www.queguineur.fr — Tous droits réservés. |
---|
5 | |
---|
6 | Ce programme est un logiciel libre ; vous pouvez le redistribuer ou le |
---|
7 | modifier suivant les termes de la “GNU General Public License” telle que |
---|
8 | publiée par la Free Software Foundation : soit la version 3 de cette |
---|
9 | licence, soit (à votre gré) toute version ultérieure. |
---|
10 | |
---|
11 | Ce programme est distribué dans l’espoir qu’il vous sera utile, mais SANS |
---|
12 | AUCUNE GARANTIE : sans même la garantie implicite de COMMERCIALISABILITÉ |
---|
13 | ni d’ADÉQUATION À UN OBJECTIF PARTICULIER. Consultez la Licence Générale |
---|
14 | Publique GNU pour plus de détails. |
---|
15 | |
---|
16 | Vous devriez avoir reçu une copie de la Licence Générale Publique GNU avec |
---|
17 | ce programme ; si ce n’est pas le cas, consultez : |
---|
18 | <http://www.gnu.org/licenses/>. |
---|
19 | */ |
---|
20 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
21 | global $template; |
---|
22 | include_once(PHPWG_ROOT_PATH .'admin/include/tabsheet.class.php'); |
---|
23 | load_language('plugin.lang', PPPPP_PATH); |
---|
24 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
25 | |
---|
26 | // onglets |
---|
27 | if (!isset($_GET['tab'])) |
---|
28 | $page['tab'] = 'currency'; |
---|
29 | else |
---|
30 | $page['tab'] = $_GET['tab']; |
---|
31 | |
---|
32 | $tabsheet = new tabsheet(); |
---|
33 | $tabsheet->add('currency', |
---|
34 | l10n('Currency'), |
---|
35 | $my_base_url.'&tab=currency'); |
---|
36 | $tabsheet->add('albums', l10n('Albums'), $my_base_url.'&tab=albums'); |
---|
37 | $tabsheet->add('size', |
---|
38 | l10n('Size'), |
---|
39 | $my_base_url.'&tab=size'); |
---|
40 | $tabsheet->add('shipping', |
---|
41 | l10n('Shipping cost'), |
---|
42 | $my_base_url.'&tab=shipping'); |
---|
43 | $tabsheet->select($page['tab']); |
---|
44 | $tabsheet->assign(); |
---|
45 | |
---|
46 | switch($page['tab']) |
---|
47 | { |
---|
48 | case 'currency': |
---|
49 | |
---|
50 | $array_currency = array( |
---|
51 | 'AUD'=>'Australian Dollar', |
---|
52 | 'BRL'=>'Brazilian Real', |
---|
53 | 'CAD'=>'Canadian Dollar', |
---|
54 | 'CZK'=>'Czech Koruna', |
---|
55 | 'DKK'=>'Danish Krone', |
---|
56 | 'EUR'=>'Euro', |
---|
57 | 'HKD'=>'Hong Kong Dollar', |
---|
58 | 'HUF'=>'Hungarian Forint', |
---|
59 | 'ILS'=>'Israeli New Sheqel', |
---|
60 | 'JPY'=>'Japanese Yen', |
---|
61 | 'MYR'=>'Malaysian Ringgit', |
---|
62 | 'MXN'=>'Mexican Peso', |
---|
63 | 'NOK'=>'Norwegian Krone', |
---|
64 | 'NZD'=>'New Zealand Dollar', |
---|
65 | 'PHP'=>'Philippine Peso', |
---|
66 | 'PLN'=>'Polish Zloty', |
---|
67 | 'GBP'=>'Pound Sterling', |
---|
68 | 'SGD'=>'Singapore Dollar', |
---|
69 | 'SEK'=>'Swedish Krona', |
---|
70 | 'CHF'=>'Swiss Franc', |
---|
71 | 'TWD'=>'Taiwan New Dollar', |
---|
72 | 'THB'=>'Thai Baht', |
---|
73 | 'USD'=>'U.S. Dollar' |
---|
74 | ); |
---|
75 | |
---|
76 | if(isset($_POST['currency']) and isset($array_currency[ $_POST['currency'] ])) |
---|
77 | { |
---|
78 | $conf['PayPalShoppingCart']['currency'] = $_POST['currency']; |
---|
79 | conf_update_param('PayPalShoppingCart', $conf['PayPalShoppingCart']); |
---|
80 | |
---|
81 | $page['infos'][] = l10n('Your configuration settings are saved'); |
---|
82 | } |
---|
83 | |
---|
84 | $template->assign( |
---|
85 | array( |
---|
86 | 'ppppp_currency' => $conf['PayPalShoppingCart']['currency'], |
---|
87 | 'ppppp_array_currency' => $array_currency, |
---|
88 | ) |
---|
89 | ); |
---|
90 | |
---|
91 | break; |
---|
92 | |
---|
93 | case 'albums' : |
---|
94 | |
---|
95 | if (isset($_POST['apply_to_albums']) and in_array($_POST['apply_to_albums'], array('all', 'list'))) |
---|
96 | { |
---|
97 | $conf['PayPalShoppingCart']['apply_to_albums'] = $_POST['apply_to_albums']; |
---|
98 | conf_update_param('PayPalShoppingCart', $conf['PayPalShoppingCart']); |
---|
99 | |
---|
100 | if ($_POST['apply_to_albums'] == 'list') |
---|
101 | { |
---|
102 | check_input_parameter('albums', $_POST, true, PATTERN_ID); |
---|
103 | |
---|
104 | if (empty($_POST['albums'])) |
---|
105 | { |
---|
106 | $_POST['albums'][] = -1; |
---|
107 | } |
---|
108 | |
---|
109 | $query = ' |
---|
110 | UPDATE '.CATEGORIES_TABLE.' |
---|
111 | SET paypal_active = \'false\' |
---|
112 | WHERE id NOT IN ('.implode(',', $_POST['albums']).') |
---|
113 | ;'; |
---|
114 | pwg_query($query); |
---|
115 | |
---|
116 | $query = ' |
---|
117 | UPDATE '.CATEGORIES_TABLE.' |
---|
118 | SET paypal_active = \'true\' |
---|
119 | WHERE id IN ('.implode(',', $_POST['albums']).') |
---|
120 | ;'; |
---|
121 | pwg_query($query); |
---|
122 | } |
---|
123 | |
---|
124 | $page['infos'][] = l10n('Your configuration settings are saved'); |
---|
125 | } |
---|
126 | |
---|
127 | // associate to albums |
---|
128 | $query = ' |
---|
129 | SELECT id |
---|
130 | FROM '.CATEGORIES_TABLE.' |
---|
131 | WHERE paypal_active = \'true\' |
---|
132 | ;'; |
---|
133 | $paypal_albums = array_from_query($query, 'id'); |
---|
134 | |
---|
135 | $query = ' |
---|
136 | SELECT id,name,uppercats,global_rank |
---|
137 | FROM '.CATEGORIES_TABLE.' |
---|
138 | ;'; |
---|
139 | display_select_cat_wrapper($query, $paypal_albums, 'album_options'); |
---|
140 | |
---|
141 | $template->assign('apply_to_albums', $conf['PayPalShoppingCart']['apply_to_albums']); |
---|
142 | |
---|
143 | break; |
---|
144 | |
---|
145 | |
---|
146 | case 'size': |
---|
147 | |
---|
148 | if (isset($_POST['delete'])) |
---|
149 | { |
---|
150 | check_input_parameter('delete', $_POST, false, PATTERN_ID); |
---|
151 | |
---|
152 | pwg_query('DELETE FROM '.PPPPP_SIZE_TABLE.' WHERE id = '.$_POST['delete'].';'); |
---|
153 | |
---|
154 | $page['infos'][] = l10n('Your configuration settings are saved'); |
---|
155 | } |
---|
156 | else if (isset($_POST['size']) and isset($_POST['price'])) |
---|
157 | { |
---|
158 | single_insert( |
---|
159 | PPPPP_SIZE_TABLE, |
---|
160 | array( |
---|
161 | 'size' => pwg_db_real_escape_string($_POST['size']), |
---|
162 | 'price' => pwg_db_real_escape_string($_POST['price']), |
---|
163 | ) |
---|
164 | ); |
---|
165 | |
---|
166 | $page['infos'][] = l10n('Your configuration settings are saved'); |
---|
167 | } |
---|
168 | |
---|
169 | $query='SELECT * FROM '.PPPPP_SIZE_TABLE.';'; |
---|
170 | $result = pwg_query($query); |
---|
171 | while($row = pwg_db_fetch_assoc($result)) |
---|
172 | { |
---|
173 | $template->append('ppppp_array_size',$row); |
---|
174 | } |
---|
175 | |
---|
176 | break; |
---|
177 | |
---|
178 | case 'shipping': |
---|
179 | |
---|
180 | if (isset($_POST['fixed_shipping'])and is_numeric($_POST['fixed_shipping'])) |
---|
181 | { |
---|
182 | $conf['PayPalShoppingCart']['fixed_shipping'] = $_POST['fixed_shipping']; |
---|
183 | conf_update_param('PayPalShoppingCart', $conf['PayPalShoppingCart']); |
---|
184 | |
---|
185 | $page['infos'][] = l10n('Your configuration settings are saved'); |
---|
186 | } |
---|
187 | |
---|
188 | $template->assign('ppppp_fixed_shipping', $conf['PayPalShoppingCart']['fixed_shipping']); |
---|
189 | break; |
---|
190 | } |
---|
191 | |
---|
192 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
193 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
194 | ?> |
---|