[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/include/inc_module/mod_shop/inc/ -> processing.preferences.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2012 Oliver Georgi <oliver@phpwcms.de> // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // ----------------------------------------------------------------
  24  // obligate check for phpwcms constants
  25  if (!defined('PHPWCMS_ROOT')) {
  26     die("You Cannot Access This Script Directly, Have a Nice Day.");
  27  }
  28  // ----------------------------------------------------------------
  29  
  30  
  31  if($action == 'edit') {
  32  
  33      if( isset($_POST['save']) ) {
  34      
  35          $plugin['data']['shop_pref_currency']            = clean_slweg($_POST['pref_currency']);
  36          $plugin['data']['shop_pref_unit_weight']        = clean_slweg($_POST['pref_unit_weight']);
  37          
  38          $plugin['data']['shop_pref_terms']                = slweg($_POST['pref_terms']);
  39          $plugin['data']['shop_pref_terms_format']        = empty($_POST['pref_terms_format']) ? 0 : 1;
  40          
  41          $plugin['data']['shop_pref_felang']                = empty($_POST['pref_felang']) ? 0 : 1;
  42          
  43          $plugin['data']['shop_pref_id_shop']            = slweg($_POST['pref_shop_id']);
  44          $plugin['data']['shop_pref_id_cart']            = slweg($_POST['pref_cart_id']);
  45          
  46          $plugin['data']['shop_pref_vat']                = clean_slweg($_POST['pref_vat']);
  47          $plugin['data']['shop_pref_vat']                = str_replace($BLM['thousands_sep'], '', $plugin['data']['shop_pref_vat']);
  48          $plugin['data']['shop_pref_vat']                = str_replace($BLM['dec_point'], '.', $plugin['data']['shop_pref_vat']);
  49          $plugin['data']['shop_pref_vat']                = explode(LF, $plugin['data']['shop_pref_vat']);
  50          $plugin['data']['shop_pref_vat']                = array_map('roundAll', $plugin['data']['shop_pref_vat']);
  51          natsort($plugin['data']['shop_pref_vat']);
  52          $plugin['data']['shop_pref_vat']                = array_unique($plugin['data']['shop_pref_vat']);
  53          
  54          $plugin['data']['shop_pref_email_to']            = convertStringToArray( sanitize_multiple_emails( clean_slweg($_POST['pref_email_to']) ), ';');
  55          $plugin['data']['shop_pref_email_from']            = clean_slweg($_POST['pref_email_from']);
  56          $plugin['data']['shop_pref_email_paypal']        = clean_slweg($_POST['pref_email_paypal']);
  57          
  58          // check if multiple emails
  59          foreach( $plugin['data']['shop_pref_email_to'] as $key => $value ) {
  60              if(! is_valid_email($value) ) {
  61                  unset( $plugin['data']['shop_pref_email_to'][$key] );
  62              }
  63          }
  64          $plugin['data']['shop_pref_email_to']            = strtolower( implode(';', $plugin['data']['shop_pref_email_to'] ) );
  65          
  66          if(! is_valid_email($plugin['data']['shop_pref_email_from']) )        $plugin['data']['shop_pref_email_from']        = '';
  67          if(! is_valid_email($plugin['data']['shop_pref_email_paypal']) )    $plugin['data']['shop_pref_email_paypal']    = '';
  68          
  69          for( $x = 0; $x <= 4; $x++ ) {
  70          
  71              $plugin['data']['shop_pref_shipping'][$x]['weight']    = clean_slweg($_POST['pref_shipping_weight'][$x]);
  72              $plugin['data']['shop_pref_shipping'][$x]['net']    = clean_slweg($_POST['pref_shipping_net'][$x]);
  73              $plugin['data']['shop_pref_shipping'][$x]['vat']    = clean_slweg($_POST['pref_shipping_vat'][$x]);
  74              
  75              $plugin['data']['shop_pref_shipping'][$x]['weight']    = str_replace($BLM['thousands_sep'], '', $plugin['data']['shop_pref_shipping'][$x]['weight']);
  76              $plugin['data']['shop_pref_shipping'][$x]['weight']    = round(str_replace($BLM['dec_point'], '.', $plugin['data']['shop_pref_shipping'][$x]['weight']), 3);
  77              
  78              $plugin['data']['shop_pref_shipping'][$x]['net']    = str_replace($BLM['thousands_sep'], '', $plugin['data']['shop_pref_shipping'][$x]['net']);
  79              $plugin['data']['shop_pref_shipping'][$x]['net']    = round(str_replace($BLM['dec_point'], '.', $plugin['data']['shop_pref_shipping'][$x]['net']), 3);
  80              
  81              $plugin['data']['shop_pref_shipping'][$x]['vat']    = str_replace($BLM['thousands_sep'], '', $plugin['data']['shop_pref_shipping'][$x]['vat']);
  82              $plugin['data']['shop_pref_shipping'][$x]['vat']    = round(str_replace($BLM['dec_point'], '.', $plugin['data']['shop_pref_shipping'][$x]['vat']), 2);
  83          
  84          }
  85          
  86          
  87          $plugin['data']['shop_pref_payment']            = array(
  88                                                      'paypal'            => empty($_POST['pref_payment_paypal']) ? 0 : 1,
  89                                                      'prepay'            => empty($_POST['pref_payment_prepay']) ? 0 : 1,
  90                                                      'pod'                => empty($_POST['pref_payment_pod']) ? 0 : 1,
  91                                                      'onbill'            => empty($_POST['pref_payment_onbill']) ? 0 : 1,
  92                                                      'ccard'                => empty($_POST['pref_payment_ccard']) ? 0 : 1,
  93                                                      'accepted_ccard'    => ( is_array($_POST['pref_supported_ccard']) ? $_POST['pref_supported_ccard'] : array() )
  94                                                                  );
  95          
  96          // Discount Setting
  97          $plugin['data']['shop_pref_discount']            = array(
  98                                                      'discount'            => empty($_POST['pref_discount']) ? 0 : 1,
  99                                                      'percent'            => clean_slweg($_POST['pref_discount_percent'])
 100                                                                  );
 101          $plugin['data']['shop_pref_discount']['percent'] = str_replace($BLM['thousands_sep'], '', $plugin['data']['shop_pref_discount']['percent']);
 102          $plugin['data']['shop_pref_discount']['percent'] = round(str_replace($BLM['dec_point'], '.', $plugin['data']['shop_pref_discount']['percent']), 2);
 103          
 104          
 105          
 106          // Low Order
 107          $plugin['data']['shop_pref_loworder']            = array(
 108                                                      'loworder'            => empty($_POST['pref_loworder']) ? 0 : 1,
 109                                                      'under'                => clean_slweg($_POST['pref_loworder_under']),
 110                                                      'charge'            => clean_slweg($_POST['pref_loworder_charge']),
 111                                                      'vat'                => clean_slweg($_POST['pref_loworder_vat'])
 112                                                                  );
 113          $plugin['data']['shop_pref_loworder']['under']    = str_replace($BLM['thousands_sep'], '', $plugin['data']['shop_pref_loworder']['under']);
 114          $plugin['data']['shop_pref_loworder']['under']    = round(str_replace($BLM['dec_point'], '.', $plugin['data']['shop_pref_loworder']['under']), 2);
 115          $plugin['data']['shop_pref_loworder']['charge']    = str_replace($BLM['thousands_sep'], '', $plugin['data']['shop_pref_loworder']['charge']);
 116          $plugin['data']['shop_pref_loworder']['charge']    = round(str_replace($BLM['dec_point'], '.', $plugin['data']['shop_pref_loworder']['charge']), 2);
 117          $plugin['data']['shop_pref_loworder']['vat']    = str_replace($BLM['thousands_sep'], '', $plugin['data']['shop_pref_loworder']['vat']);
 118          $plugin['data']['shop_pref_loworder']['vat']    = round(str_replace($BLM['dec_point'], '.', $plugin['data']['shop_pref_loworder']['vat']), 2);
 119          
 120          if( empty($plugin['error'] )) {
 121  
 122              _setConfig('shop_pref_currency',         $plugin['data']['shop_pref_currency'],         'module_shop');
 123              _setConfig('shop_pref_unit_weight',     $plugin['data']['shop_pref_unit_weight'],     'module_shop');
 124              _setConfig('shop_pref_vat',             $plugin['data']['shop_pref_vat'],             'module_shop');
 125              _setConfig('shop_pref_email_to',         $plugin['data']['shop_pref_email_to'],         'module_shop');
 126              _setConfig('shop_pref_email_from',         $plugin['data']['shop_pref_email_from'],     'module_shop');
 127              _setConfig('shop_pref_email_paypal',     $plugin['data']['shop_pref_email_paypal'],     'module_shop');
 128              _setConfig('shop_pref_shipping',         $plugin['data']['shop_pref_shipping'],         'module_shop');
 129              _setConfig('shop_pref_payment',         $plugin['data']['shop_pref_payment'],         'module_shop');
 130              _setConfig('shop_pref_terms',             $plugin['data']['shop_pref_terms'],         'module_shop');
 131              _setConfig('shop_pref_terms_format',    $plugin['data']['shop_pref_terms_format'],    'module_shop');
 132              _setConfig('shop_pref_id_shop',            $plugin['data']['shop_pref_id_shop'],        'module_shop');
 133              _setConfig('shop_pref_id_cart',            $plugin['data']['shop_pref_id_cart'],        'module_shop');
 134              _setConfig('shop_pref_discount',        $plugin['data']['shop_pref_discount'],        'module_shop');
 135              _setConfig('shop_pref_loworder',        $plugin['data']['shop_pref_loworder'],        'module_shop');
 136              _setConfig('shop_pref_felang',            $plugin['data']['shop_pref_felang'],        'module_shop');        
 137              // save and back to listing mode
 138              headerRedirect( shop_url('controller=pref', '') );
 139              
 140          }
 141  
 142      }
 143      
 144      $_checkPref = array(
 145      
 146          'shop_pref_currency'        =>    '',
 147          'shop_pref_unit_weight'        =>    'kg',
 148          'shop_pref_vat'                =>    array( '0.00', '7.00', '19.00' ),
 149          'shop_pref_email_to'        =>    '',
 150          'shop_pref_email_from'        =>    '',
 151          'shop_pref_email_paypal'    =>    '',
 152          'shop_pref_id_shop'            =>    0,
 153          'shop_pref_id_cart'            =>    0,
 154          'shop_pref_felang'            =>    0,
 155          'shop_pref_shipping'        =>    array(    0 => array('weight'=>'50', 'net'=>0, 'vat'=>0), 
 156                                                  1 => array('weight'=>'', 'net'=>0, 'vat'=>0), 
 157                                                  2 => array('weight'=>'', 'net'=>0, 'vat'=>0),
 158                                                  3 => array('weight'=>'', 'net'=>0, 'vat'=>0),
 159                                                  4 => array('weight'=>'', 'net'=>0, 'vat'=>0)
 160                                               ),
 161          'shop_pref_payment'            =>    array(    'paypal' => 1, 
 162                                                  'prepay'=> 1, 
 163                                                  'pod' => 1, 
 164                                                  'onbill' => 1, 
 165                                                  'ccard' => 1, 
 166                                                  'accepted_ccard' => array('americanexpress', 'mastercard', 'visa')
 167                                               ),
 168          'shop_pref_terms'            =>    '',
 169          'shop_pref_terms_format'    =>  0,
 170          'shop_pref_discount'        => array('discount' => 0, 'percent' => 0),
 171          'shop_pref_loworder'        => array('loworder' => 0, 'under' => 0, 'charge' => 0, 'vat' => 0)
 172      
 173                  );
 174  
 175      // retrieve all settings
 176      foreach( $_checkPref as $key => $value ) {
 177          if( false === ( $plugin['data'][ $key ] = _getConfig( $key ) ) ) {
 178              $plugin['data'][ $key ] = $value;
 179              _setConfig( $key , $plugin['data'][ $key ], 'module_shop');
 180          }
 181      }
 182  
 183  }
 184  
 185  
 186  ?>


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1