Пример #1
0
 function payment($module = '')
 {
     global $PHP_SELF, $language, $credit_covers, $messageStack;
     if (defined('MODULE_PAYMENT_INSTALLED') && zen_not_null(MODULE_PAYMENT_INSTALLED)) {
         $this->modules = explode(';', MODULE_PAYMENT_INSTALLED);
         $include_modules = array();
         if (zen_not_null($module) && in_array($module . '.' . substr($PHP_SELF, strrpos($PHP_SELF, '.') + 1), $this->modules)) {
             $this->selected_module = $module;
             $include_modules[] = array('class' => $module, 'file' => $module . '.php');
         } else {
             reset($this->modules);
             // Free Payment Only shows
             if (zen_get_configuration_key_value('MODULE_PAYMENT_FREECHARGER_STATUS') and ($_SESSION['cart']->show_total() == 0 and $_SESSION['shipping']['cost'] == 0)) {
                 $this->selected_module = $module;
                 if (file_exists(DIR_FS_CATALOG . DIR_WS_MODULES . '/payment/' . 'freecharger.php')) {
                     $include_modules[] = array('class' => 'freecharger', 'file' => 'freecharger.php');
                 }
             } else {
                 // All Other Payment Modules show
                 while (list(, $value) = each($this->modules)) {
                     // double check that the module really exists before adding to the array
                     if (file_exists(DIR_FS_CATALOG . DIR_WS_MODULES . '/payment/' . $value)) {
                         $class = substr($value, 0, strrpos($value, '.'));
                         // Don't show Free Payment Module
                         if ($class != 'freecharger') {
                             $include_modules[] = array('class' => $class, 'file' => $value);
                         }
                     }
                 }
             }
         }
         for ($i = 0, $n = sizeof($include_modules); $i < $n; $i++) {
             //          include(DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $include_modules[$i]['file']);
             $lang_file = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/payment/', $include_modules[$i]['file'], 'false');
             if (@file_exists($lang_file)) {
                 include_once $lang_file;
             } else {
                 if (IS_ADMIN_FLAG === false) {
                     $messageStack->add(WARNING_COULD_NOT_LOCATE_LANG_FILE . $lang_file, 'caution');
                 } else {
                     $messageStack->add_session(WARNING_COULD_NOT_LOCATE_LANG_FILE . $lang_file, 'caution');
                 }
             }
             include_once DIR_WS_MODULES . 'payment/' . $include_modules[$i]['file'];
             $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class']();
         }
         // if there is only one payment method, select it as default because in
         // checkout_confirmation.php the $payment variable is being assigned the
         // $_POST['payment'] value which will be empty (no radio button selection possible)
         if (zen_count_payment_modules() == 1 && (!isset($_SESSION['payment']) || isset($_SESSION['payment']) && !is_object($_SESSION['payment']))) {
             if (!$credit_covers) {
                 $_SESSION['payment'] = $include_modules[0]['class'];
             }
         }
         if (zen_not_null($module) && in_array($module, $this->modules) && isset($GLOBALS[$module]->form_action_url)) {
             $this->form_action_url = $GLOBALS[$module]->form_action_url;
         }
     }
 }
Пример #2
0
 function __construct($module = '')
 {
     global $payment, $gBitCustomer;
     if (defined('MODULE_PAYMENT_INSTALLED') && zen_not_null(MODULE_PAYMENT_INSTALLED)) {
         $this->modules = explode(';', MODULE_PAYMENT_INSTALLED);
         $include_modules = array();
         if (zen_not_null($module) && in_array($module . '.' . substr($_SERVER['SCRIPT_NAME'], strrpos($_SERVER['SCRIPT_NAME'], '.') + 1), $this->modules)) {
             $this->selected_module = $module;
             $include_modules[] = array('class' => $module, 'file' => $module . '.php');
         } else {
             reset($this->modules);
             // Free Payment Only shows
             if (zen_get_configuration_key_value('MODULE_PAYMENT_FREECHARGER_STATUS') and ($gBitCustomer->mCart->show_total() == 0 and $gBitCustomer->mCart->show_weight() == 0)) {
                 $this->selected_module = $module;
                 if (file_exists(DIR_FS_CATALOG . DIR_WS_MODULES . '/payment/' . 'freecharger.php')) {
                     $include_modules[] = array('class' => 'freecharger', 'file' => 'freecharger.php');
                 }
             } else {
                 // All Other Payment Modules show
                 while (list(, $value) = each($this->modules)) {
                     // double check that the module really exists before adding to the array
                     if (file_exists(DIR_FS_CATALOG . DIR_WS_MODULES . '/payment/' . $value)) {
                         $class = substr($value, 0, strrpos($value, '.'));
                         // Don't show Free Payment Module
                         if ($class != 'freecharger') {
                             $include_modules[] = array('class' => $class, 'file' => $value);
                         }
                     }
                 }
             }
         }
         for ($i = 0, $n = sizeof($include_modules); $i < $n; $i++) {
             $langFile = zen_get_file_directory(DIR_WS_LANGUAGES . $gBitCustomer->getLanguage() . '/modules/payment/', $include_modules[$i]['file'], 'false');
             if (file_exists($langFile)) {
                 include $langFile;
             }
             include DIR_WS_MODULES . 'payment/' . $include_modules[$i]['file'];
             $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class']();
         }
         // if there is only one payment method, select it as default because in
         // checkout_confirmation.php the $payment variable is being assigned the
         // $_POST['payment'] value which will be empty (no radio button selection possible)
         if (zen_count_payment_modules() == 1 && (!isset($_SESSION['payment']) || isset($_SESSION['payment']) && !is_object($_SESSION['payment']))) {
             $_SESSION['payment'] = $include_modules[0]['class'];
         }
         if (zen_not_null($module) && in_array($module, $this->modules) && isset($GLOBALS[$module]->form_action_url)) {
             $this->form_action_url = $GLOBALS[$module]->form_action_url;
         }
     }
 }