source: extensions/PayPalShoppingCart/admin.php @ 21205

Last change on this file since 21205 was 21205, checked in by plg, 11 years ago

compatibility with Piwigo 2.5: replace functions mysql_* with pwg_db*

File size: 5.6 KB
Line 
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*/
20if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
21global $template;
22include_once(PHPWG_ROOT_PATH .'admin/include/tabsheet.class.php');
23load_language('plugin.lang', PPPPP_PATH);
24$my_base_url = get_admin_plugin_menu_link(__FILE__);
25
26// onglets
27if (!isset($_GET['tab']))
28    $page['tab'] = 'currency';
29else
30    $page['tab'] = $_GET['tab'];
31
32$tabsheet = new tabsheet();
33$tabsheet->add('currency',
34               l10n('Currency'),
35               $my_base_url.'&amp;tab=currency');
36$tabsheet->add('albums', l10n('Albums'), $my_base_url.'&amp;tab=albums');
37$tabsheet->add('size',
38               l10n('Size'),
39               $my_base_url.'&amp;tab=size');
40$tabsheet->add('shipping',
41               l10n('Shipping cost'),
42               $my_base_url.'&amp;tab=shipping');                         
43$tabsheet->select($page['tab']);
44$tabsheet->assign();
45
46switch($page['tab']){
47 case 'currency':
48  $array_currency=array(
49  'AUD'=>'Australian Dollar',
50  'BRL'=>'Brazilian Real',
51  'CAD'=>'Canadian Dollar',
52  'CZK'=>'Czech Koruna',
53  'DKK'=>'Danish Krone',
54  'EUR'=>'Euro',
55  'HKD'=>'Hong Kong Dollar',
56  'HUF'=>'Hungarian Forint',
57  'ILS'=>'Israeli New Sheqel',
58  'JPY'=>'Japanese Yen',
59  'MYR'=>'Malaysian Ringgit',
60  'MXN'=>'Mexican Peso',
61  'NOK'=>'Norwegian Krone',
62  'NZD'=>'New Zealand Dollar',
63  'PHP'=>'Philippine Peso',
64  'PLN'=>'Polish Zloty',
65  'GBP'=>'Pound Sterling',
66  'SGD'=>'Singapore Dollar',
67  'SEK'=>'Swedish Krona',
68  'CHF'=>'Swiss Franc',
69  'TWD'=>'Taiwan New Dollar',
70  'THB'=>'Thai Baht',
71  'USD'=>'U.S. Dollar'
72  );
73  if(isset($_POST['currency'])){
74   $currency=$_POST['currency'];
75   $query='UPDATE '.PPPPP_CONFIG_TABLE.' SET value = \''.$currency.'\' WHERE param = \'currency\';';
76   pwg_query($query);
77   $page['infos']=l10n('Data updated');
78   }
79 
80  $query='SELECT value FROM '.PPPPP_CONFIG_TABLE.' WHERE param = \'currency\';';
81  $result = pwg_query($query);
82  $row = pwg_db_fetch_row($result);
83  $template->assign('ppppp_currency',$row[0]);
84 
85  $template->assign('ppppp_array_currency',$array_currency);
86  break;
87
88 case 'albums' :
89
90   if (isset($_POST['apply_to_albums']) and in_array($_POST['apply_to_albums'], array('all', 'list')))
91   {
92     $conf['PayPalShoppingCart']['apply_to_albums'] = $_POST['apply_to_albums'];
93     conf_update_param('PayPalShoppingCart', serialize($conf['PayPalShoppingCart']));
94
95     if ($_POST['apply_to_albums'] == 'list')
96     {
97       check_input_parameter('albums', $_POST, true, PATTERN_ID);
98
99       if (empty($_POST['albums']))
100       {
101         $_POST['albums'][] = -1;
102       }
103       
104       $query = '
105UPDATE '.CATEGORIES_TABLE.'
106  SET paypal_active = \'false\'
107  WHERE id NOT IN ('.implode(',', $_POST['albums']).')
108;';
109       pwg_query($query);
110
111       $query = '
112UPDATE '.CATEGORIES_TABLE.'
113  SET paypal_active = \'true\'
114  WHERE id IN ('.implode(',', $_POST['albums']).')
115;';
116       pwg_query($query);
117     }
118
119     array_push(
120       $page['infos'],
121       l10n('Your configuration settings are saved')
122       );
123   }
124   
125   // associate to albums
126   $query = '
127SELECT id
128  FROM '.CATEGORIES_TABLE.'
129  WHERE paypal_active = \'true\'
130;';
131   $paypal_albums = array_from_query($query, 'id');
132
133   $query = '
134SELECT id,name,uppercats,global_rank
135  FROM '.CATEGORIES_TABLE.'
136;';
137   display_select_cat_wrapper($query, $paypal_albums, 'album_options');
138
139   $template->assign('apply_to_albums', $conf['PayPalShoppingCart']['apply_to_albums']);
140
141   break;
142 
143 
144 case 'size':
145  if(isset($_POST['delete'])and is_numeric($_POST['delete'])){
146   $delete_id=$_POST['delete'];
147   $query='DELETE FROM '.PPPPP_SIZE_TABLE.' WHERE id = '.$delete_id.';';
148   pwg_query($query);
149   $page['infos']=l10n('Data deleted');
150   }
151  else if (isset($_POST['size'])and isset($_POST['price'])and is_numeric($_POST['price'])){
152   $size=$_POST['size'];
153   $price=$_POST['price'];
154   $query='INSERT into '.PPPPP_SIZE_TABLE.' (size,price) values (\''.$size.'\',\''.$price.'\');';
155   @$res=pwg_query($query);
156   if($res==1)
157    $page['infos']=l10n('Data appened');
158   else
159    $page['errors']=l10n('Error');
160  }
161  $query='SELECT * FROM '.PPPPP_SIZE_TABLE.';';
162  $result = pwg_query($query);
163  while($row = pwg_db_fetch_assoc($result)){
164   $template->append('ppppp_array_size',$row);
165  }
166  break;
167
168 case 'shipping':
169  if(isset($_POST['fixed_shipping'])and is_numeric($_POST['fixed_shipping'])){
170   $fixed_shipping=$_POST['fixed_shipping'];
171   $query='UPDATE '.PPPPP_CONFIG_TABLE.' SET value = \''.$fixed_shipping.'\' WHERE param = \'fixed_shipping\';';
172   pwg_query($query);
173   $page['infos']=l10n('Data updated');
174   }
175  $query='SELECT value FROM '.PPPPP_CONFIG_TABLE.' WHERE param = \'fixed_shipping\';';
176  $result = pwg_query($query);
177  $row = pwg_db_fetch_row($result);
178  $template->assign('ppppp_fixed_shipping',$row[0]);
179  break;
180 }
181
182$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); 
183$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
184?>
Note: See TracBrowser for help on using the repository browser.