<?php
/**
 *
 * @package    SearchModuleRedirecter
 * @author     Hidehito NOZAWA aka Suin <http://suin.asia/>
 * @copyright  2009 Hidehito NOZAWA
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU GPL v2.0
 *
 */

if ( !defined('XOOPS_ROOT_PATH') ) exit;

class SearchModuleRedirecter extends XCube_ActionFilter
{
	var $searchDirname = 'search';

	function preBlockFilter()
	{
		$this->mRoot->mDelegateManager->add('Legacypage.Search.Access', array($this, 'redirect'), XCUBE_DELEGATE_PRIORITY_FIRST);
	}

	function redirect()
	{
		if ( file_exists(XOOPS_ROOT_PATH.'/modules/'.$this->searchDirname.'/index.php') )
		{
			$moduleHandler =& xoops_gethandler('module');
			$moduleObj =& $moduleHandler->getByDirname($this->searchDirname);
			if ( $moduleObj->getVar('isactive') == 1 )
			{
				header('Location: '.XOOPS_URL.'/modules/'.$this->searchDirnam.'/index.php?'.$_SERVER['QUERY_STRING']);
				die;
			}
		}
	}
}

?>
