<?php

class ModEss_Route_Prefix_ModEss implements XenForo_Route_Interface
{
	/**
	 * Match a specific route for an already matched prefix.
	 *
	 * @see XenForo_Route_Interface::match()
	 */
	public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
	{
		$action = $router->resolveActionWithIntegerParam($routePath, $request, 'search_id');
        if ($action == 'ban-user' || $action == 'lift-ban')
        {
            $action = $router->resolveActionWithIntegerParam($routePath, $request, 'user_id');
        }
		return $router->getRouteMatch('ModEss_ControllerPublic_ModEss', $action);
	}

	/**
	 * Method to build a link that includes the search_id
	 * @see XenForo_Route_BuilderInterface
	 */
	public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
	{
        if ($action == 'ban-user' || $action == 'lift-ban')
        {
            return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'user_id', 'title');
        }
		return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'search_id');
	}
}