<?php
/*
  
  osCommRes, Services Online
  http://www.oscommres.com

  Copyright (c) 2005 osCommRes

  Released under the GNU General Public License
  
  Freeway eCommerce from ZacWare
http://www.zac-ware.com/freeway

Copyright 2007 ZacWare Pty. Ltd
*/
 // Check to ensure this file is included in Freeway!
defined('_FEXEC') or die(); 

  class fulfiller {
    var $modules, $selected_module;

// class constructor
    function fulfiller($module = '') {
// BOF: WebMakers.com Added: Downloads Controller
      global $fulfiller, $language, $PHP_SELF, $cart;
// EOF: WebMakers.com Added: Downloads Controller
		if (defined('MODULE_FULFILLER_INSTALLED') && tep_not_null(MODULE_FULFILLER_INSTALLED)) {
			$installed_modules=MODULE_FULFILLER_INSTALLED;
		} else {
			$installed_modules="oneworld.php";
		}
      
        $this->modules = explode(';', $installed_modules);

        $include_modules = array();

        if ( (tep_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');
        }
        for ($i=0, $n=sizeof($include_modules); $i<$n; $i++) {
          include(DIR_WS_LANGUAGES . $language . '/modules/fulfiller/' . $include_modules[$i]['file']);
          include(DIR_WS_MODULES . 'fulfiller/' . $include_modules[$i]['file']);
          $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];
        }

		 if ( (tep_not_null($module)) && (in_array($module, $this->modules)) && (isset($GLOBALS[$module]->form_action_url)) ) {
			  $this->form_action_url = $GLOBALS[$module]->form_action_url;
			}
    }

    function process() {
      if (is_array($this->modules)) {
        //if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled)) {
		if (is_object($GLOBALS[$this->selected_module])) {
            return $GLOBALS[$this->selected_module]->process();
        }
      }
    }
	 function process_status($ord_id) {
      if (is_array($this->modules)) {
        //if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled)) {
		if (is_object($GLOBALS[$this->selected_module])) {
            return $GLOBALS[$this->selected_module]->process_status($ord_id);
        }
      }
    }
	 function process_out_of_stock() {
      if (is_array($this->modules)) {
        //if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled)) {
		if (is_object($GLOBALS[$this->selected_module])) {
            return $GLOBALS[$this->selected_module]->process_out_of_stock();
        }
      }
    }
    function get_error() {
      if (is_array($this->modules)) {
        if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
          return $GLOBALS[$this->selected_module]->get_error();
        }
      }
    }
  }
?>