source: extensions/PayPalShoppingCart/admin.php @ 30191

Last change on this file since 30191 was 30179, checked in by plg, 10 years ago

compatibility 2.7 and better use of core config

File size: 5.8 KB
RevLine 
[9239]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');
[19464]36$tabsheet->add('albums', l10n('Albums'), $my_base_url.'&amp;tab=albums');
[9239]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
[30179]46switch($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    }
[9239]83 
[30179]84    $template->assign(
85      array(
86        'ppppp_currency' => $conf['PayPalShoppingCart']['currency'],
87        'ppppp_array_currency' => $array_currency,
88        )
89      );
90   
91    break;
[19464]92
[30179]93   case 'albums' :
[19464]94
[30179]95     if (isset($_POST['apply_to_albums']) and in_array($_POST['apply_to_albums'], array('all', 'list')))
[19464]96     {
[30179]97       $conf['PayPalShoppingCart']['apply_to_albums'] = $_POST['apply_to_albums'];
98       conf_update_param('PayPalShoppingCart', $conf['PayPalShoppingCart']);
[19464]99
[30179]100       if ($_POST['apply_to_albums'] == 'list')
[19464]101       {
[30179]102         check_input_parameter('albums', $_POST, true, PATTERN_ID);
103
104         if (empty($_POST['albums']))
105         {
106           $_POST['albums'][] = -1;
107         }
[19464]108       
[30179]109         $query = '
[19464]110UPDATE '.CATEGORIES_TABLE.'
111  SET paypal_active = \'false\'
112  WHERE id NOT IN ('.implode(',', $_POST['albums']).')
113;';
[30179]114         pwg_query($query);
[19464]115
[30179]116         $query = '
[19464]117UPDATE '.CATEGORIES_TABLE.'
118  SET paypal_active = \'true\'
119  WHERE id IN ('.implode(',', $_POST['albums']).')
120;';
[30179]121         pwg_query($query);
122       }
123
124       $page['infos'][] = l10n('Your configuration settings are saved');
[19464]125     }
126   
[30179]127     // associate to albums
128     $query = '
[19464]129SELECT id
130  FROM '.CATEGORIES_TABLE.'
131  WHERE paypal_active = \'true\'
132;';
[30179]133     $paypal_albums = array_from_query($query, 'id');
[19464]134
[30179]135     $query = '
[19464]136SELECT id,name,uppercats,global_rank
137  FROM '.CATEGORIES_TABLE.'
138;';
[30179]139     display_select_cat_wrapper($query, $paypal_albums, 'album_options');
[19464]140
[30179]141     $template->assign('apply_to_albums', $conf['PayPalShoppingCart']['apply_to_albums']);
[19464]142
[30179]143     break;
[19464]144 
[9239]145 
[30179]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'].';');
[9239]153
[30179]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        );
[9239]165
[30179]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
[9239]192$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); 
193$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
194?>
Note: See TracBrowser for help on using the repository browser.