/*
	This is a sample hook class with every vbulletin code hook defined.  
*/
class sample_Hooks
{
	/*
		This determines the order the class is called.  If it is not defined then
		default of 10 will be used.  The class with the lowest value will be
		invoked first if multiple classes define an implementation for the 
		same hook.
	*/
	public static $order = 10;

	/*
		This hook is called immediately after the output is generated but before
		it is displayed.  This does not include the preheader portion (which may
		already have been sent to the browser at this point depending on
		configuration).
	*/
	public static function hookFrontendBeforeOutput($params)
	{
		//the style used to render the page
		//this parameter is read only
		$params['styleid'];
 
		//html from the end of the preheader to the end of the page
		//this include the the entire <body> tag
		//this parameter is editable
		$params['pageHtml']; 
	}

	/*
		This is called after the preheader is generated but before it is output to
		the browser.
	*/
	public static function hookFrontendPreheader($params)
	{
		//html from start of page to end of preheader
		//this parameter is editable
		$params['preheaderHtml']; 
	}

	/*
		This is called after a successful save of a user.
	*/
	public static function hookUserAfterSave($params)
	{
		//all parameters are read only.

		//the user id of the user
		$params['userid'];

		//if the save is being done as an administrative function
		$params['adminoverride'];

		//is this a new user?
		$params['newuser'];

		//does this user require email verification before registration is considered 
		//complete (note this may be false even if activation is required if the
		//activation is skipped such as when a user is created in the admincp).
		$params['emailVerificationRequired'];

		//does the user require moderation before registration is considered
		//complete?
		$params['userIsModerated'];
	}

	/*
		This is called before a successful activation action.  This includes when
		user is placed in the moderation queue or when an existing user is
		required to reactivate due to a change in email.
	*/
	public static function hookUserAfterActivation($params)
	{
		//all parameters are read only.

		//the user id of the user
		$params['userid'];

		//is this a new user or a reactivation?
		$params['newuser'];

		//does the user require moderation before registration is considered
		//complete?
		$params['userIsModerated'];
	}

	/*
		This is called after a user is approved in the user moderation page 
		of the admincp
	*/
	public static function hookUserModerationApproved($params)
	{
		//the user id of the user
		//this parameter is read only
		$params['userid'];
	}	

	/*
		This is called when a user is logged in (front end, or control panel)
	*/
	public static function hookProcessNewLogin($params)
	{
		// The function results array:
		//	sessionhash -- hash identifying the new session
		//	cpsessionhash -- the hash for the cp session (only present if the user is an admin or a mod)
		//	userid -- id of the user newly logged in
		//	password -- remember me token
		//	lastvisit -- the newly logged in user's last visit,
		//	lastactivity -- the newly logged in user's last activity
		$params['result']; // Editable

		// The login type
		$params['logintype']; 

		// The css prefs passed into the function
		$params['cssprefs'];

		// The userinfo array for the user logged in
		$params['userinfo']; 
	}	

	/*
		This is called when a user logs out (of the front end only, atm).
	*/
	public static function hookProcessLogout($params)
	{
		// The function results array:
		//	sessionhash -- hash identifying the new session
		//	apiaccesstoken -- the current api access token, if this is a request through MAPI

		$params['result']; // Editable

		// The userinfo array for the user logging out
		$params['userinfo'];
	}	

	/*
		Called by every page as the router decides on what route to use.
	*/
	public static function hookGetRouteMain($params)
	{
		// The pathInfo passed into the getRoute() function
		$params['pathInfo'];

		// The queryString passed into the getRoute() function
		$params['queryString']; 

		// The anchor passed into the getRoute() function
		$params['anchor'];

		// The selected route object
		$params['route']; // Editable
	}	
}
