<?php
global $vbulletin, $vbphrase, $template_hook;

if (VBSIGNATURES::$permissions['canview'])
{
	if (THIS_SCRIPT == 'vbsignatures')
	{
		$vbulletin->options['selectednavtab'] = 'dbtech_vbsignatures';
	}
	
	if (intval($vbulletin->versionnumber) == 3 AND !class_exists('vB_Template'))
	{
		// We need the template class
		require_once(DIR . '/dbtech/vbsignatures/includes/class_template.php');
	}	
	
	if (intval($vbulletin->versionnumber) > 3 AND (defined('CMS_SCRIPT') OR defined('VBA_SCRIPT')) AND !defined('VBSIGNATURES_NAV_LOOPED') AND THIS_SCRIPT != 'vbsignatures')
	{
		// vB4 have an awkward design quirk with the Suite, we'll fire the plugin elsewhere
		define('VBSIGNATURES_NAV_LOOPED', true);
		$vbulletin->pluginlist['process_templates_complete'] .= "\r\nrequire(DIR . '/dbtech/vbsignatures/hooks/process_templates_complete.php');";
		vBulletinHook::set_pluginlist($vbulletin->pluginlist);
	}
	else
	{
		if ($vbulletin->options['dbtech_vbsignatures_integration'] & 1)
		{
			$template_hook['navbar_quick_links_menu_pos4'] .= vB_Template::create('dbtech_vbsignatures_quicklinks_link')->render();
		}
		if ($vbulletin->options['dbtech_vbsignatures_integration'] & 2)
		{
			$template_hook['navbar_community_menu_end'] .= vB_Template::create('dbtech_vbsignatures_quicklinks_link')->render();
		}
		
		if ($vbulletin->options['dbtech_vbsignatures_navbar'])
		{
			if (intval($vbulletin->versionnumber) == 3)
			{
				$template_hook['navbar_buttons_right'] .= vB_Template::create('dbtech_vbsignatures_navbar_link')->render();
			}
			else
			{
				// Hook into nav tab
				$template_hook['navtab_middle'] .= vB_Template::create('dbtech_vbsignatures_navbar_link')->render();
			}
		}
	}
}
?>