<?php
// FrontController.php
include_once('core/base/Controller.php');

/**
 *
 */
class FrontController extends Controller
{
	// the currently executing module controller
	var $mod;
	
	/**
	 * Constructor.
	 *
	 * @param $data_access DataAccess
	 * @param $timer StopWatch
	 * @access public
	 */
	function FrontController(& $data_access, & $session, & $timer)
	{
		global $__CS; 
		$__CS->EnterMethod("FrontController");
		$__CS->SendObject($data_access,"DataAccess");
		$__CS->SendObject($session,"Session");
		$__CS->SendObject($timer,"StopWatch");
		
		parent::Controller(& $data_access, & $session, & $timer);
		$this->mod = NULL;
		
		$__CS->ExitMethod("FrontController");
	}
	
	
	/**
	 * Processes a request.
	 *
	 * @param $request Request
	 * @access public
	 */
	function processRequest(& $request)
	{
		global $__CS; 
		$__CS->EnterMethod("processRequest");
		$__CS->SendObject($request,"Request");
		
		$this->request 	=& $request;
		$module 		= $this->request->get(__MODULE);
		if(!$module) { $module = __MEMBER;
		$request->set(__ACTION,__MEMBER_SEARCH); }
		switch($module) {
			case __DEED:
				include_once('core/deeds/DeedController.php');
				$this->mod =& new DeedController(& $this->da, & $this->sess, & $this->timer, & $this);
				break;
			case __RESPON:
				include_once('core/responsibilities/ResponsibilityController.php');
				$this->mod =& new ResponsibilityController(& $this->da, & $this->sess, & $this->timer, & $this);
				break;
			case __MEMBER:
				include_once('core/members/MemberController.php');
				$this->mod =& new MemberController(& $this->da, & $this->sess, & $this->timer, & $this);
				break;
			case __RANK:
				include_once('core/ranks/RankController.php');
				$this->mod =& new RankController(& $this->da, & $this->sess, & $this->timer, & $this);
				break;
		}
		if( !($this->mod == NULL) ) {
			$this->mod->processRequest(& $this->request);
		}
		else {
			trigger_error(__ERROR."Module controller not set to handle request ".__MODULE."=".$module);
		}
		$__CS->ExitMethod("processRequest");
	}
}
?>