<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="fquick_autogaragelink" active="1">
	<title>FQuick Garage Plugin</title>
	<description>Allows forum members to link to their FQuick garage in posts and their member profiles.</description>
	<version>3.61</version>
	<url>http://www.fquick.com/promote/</url>
	<versioncheckurl />
	<dependencies>
	</dependencies>
	<codes>
		<code version="1.00">
			<installcode><![CDATA[$db->query_write("ALTER TABLE " . TABLE_PREFIX . "user ADD fquick VARCHAR( 250 )");]]></installcode>
			<uninstallcode><![CDATA[$db->query_write("ALTER TABLE " . TABLE_PREFIX . "user DROP fquick");]]></uninstallcode>
		</code>
	</codes>
	<templates>
		<template name="fquick" templatetype="template" date="1200097251" username="admin" version="1.00"><![CDATA[<fieldset class="fieldset">
	<legend>FQuick ID</legend>
		<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0" width="100%">
			<tr>
					<td colspan="2">Enter your <a href="http://www.fquick.com" target="_blank">FQuick.com</a> username in the box below to be displayed in your Posts.</td>
			</tr>
			<tr>
					<td>FQuick Username<br />
					<img src="$stylevar[imgdir_misc]/fquickmini.gif" alt="" />
					<input type="text" class="bginput" name="fquick" value="$bbuserinfo[fquick]" size="25" maxlength="50" /><br />Username must be exactly how it shows on FQuick for this forums banner to show on your homepage on FQuick.<br />(Please note: this forums banner will not show on your FQuick account for up to 24 hours)</td>
			</tr>
		</table>
</fieldset>]]></template>
	</templates>
	<plugins>
		<plugin active="1">
			<title>Setup XML Output for FQuick Statistics</title>
			<hookname>forumhome_start</hookname>
			<phpcode><![CDATA[if ($_REQUEST['do'] == "fquickstats" AND md5($_REQUEST['access']) === '91f60de111db77a03c96963d619ee88d'){
	$fquick = $db->query_read("
        SELECT user.username, user.fquick, user.posts, user.usertitle, usergroup.title AS ugtitle
        FROM " . TABLE_PREFIX . "user AS user
        LEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup ON(usergroup.usergroupid = user.usergroupid)
        WHERE fquick <> ''
    ");

    $fquickstat = $db->query_read("
        SELECT plugin.title AS pluginTitle, plugin.active AS pluginState, product.version as productVersion
        FROM " . TABLE_PREFIX . "plugin AS plugin
        LEFT JOIN " . TABLE_PREFIX . "product AS product ON(product.productid = plugin.product)
        WHERE product = 'fquick_autogaragelink'
    ");
    
	$userCount = $db->query_first("
		SELECT COUNT(*) AS userCount FROM " . TABLE_PREFIX . "user
	");
	
	$forumStat = $db->query_first("
		SELECT COUNT(*) AS threadCount, SUM(replycount) AS postCount
		FROM " . TABLE_PREFIX . "thread AS thread
		WHERE visible = 1
	");
	$forumStat['postCount'] = $forumStat['threadCount'] + $forumStat['postCount'];
	
    while ($fquickstats = $db->fetch_array($fquickstat)){
         $fquickstatus[] = array($fquickstats['pluginState'], $fquickstats['pluginTitle']);
         $fquickversion[] = array($fquickstats['productVersion']);
    }
    while ($fquicks = $db->fetch_array($fquick)){
		$fquicknum[] = array($fquicks['username'], $fquicks['fquick'], $fquicks['posts'], $fquicks['usertitle'], $fquicks['ugtitle']);
	}
	
    $fquickreturn = $db->num_rows($fquickstat);
    $fquickstatret = $db->num_rows($fquick);
    $db->free_result($fquick);
    $db->free_result($fquickstat);
    
    $vBversion = $vbulletin->versionnumber;
    $productVersion = $fquickversion['0']['0'];
	  
    header("Content-Type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>
        <data>
        <activeUsers>$fquickstatret</activeUsers>
        <forumStats>
        	<vBVersion>$vBversion</vBVersion>
        	<forumMembers>$userCount[userCount]</forumMembers>
        	<forumThreads>$forumStat[threadCount]</forumThreads>
        	<forumPosts>$forumStat[postCount]</forumPosts>
			<productVersion>$productVersion</productVersion>
		</forumStats>";
		
		echo "<members>";
		
		for ($foobah = 0; $foobah < $fquickstatret; $foobah++)
		{
			echo "<user>";
			echo "<forumUsername>«![CDATA[" . $fquicknum[$foobah][0] . "]]»</forumUsername>";
			echo "<fquickUsername>«![CDATA[" . $fquicknum[$foobah][1] . "]]»</fquickUsername>";
			echo "<postCount>" . $fquicknum[$foobah][2] . "</postCount>";
			echo "<userTitle>«![CDATA[" . $fquicknum[$foobah][3] . "]]»</userTitle>";
			echo "<userGroup>«![CDATA[" . $fquicknum[$foobah][4] . "]]»</userGroup>";
			echo "</user>";
		}
		
		echo "</members>";
		echo "<pluginStates>";
		
		for ($foo = 0; $foo < $fquickreturn; $foo++)
		{
		    $fquickstatus[$foo][0] = iif($fquickstatus[$foo][0] == 1, "Enabled", "Disabled");
		    echo "<plugin>";
		    echo "<title>" . $fquickstatus[$foo][1] . "</title>";
		    echo "<status>" . $fquickstatus[$foo][0] . "</status>";
		    echo "</plugin>";
		}
		
	echo "</pluginStates>
		</data>";
    exit;
}]]></phpcode>
		</plugin>
		<plugin active="1">
			<title>Add to Memberlist</title>
			<hookname>memberlist_complete</hookname>
			<phpcode><![CDATA[global $vbulletin;

$ifstart = '".((';
$ifend = ') ? ("';

$totalcols++;
$find = $ifstart . '$show[\'agecol\']' . $ifend;
$replace = '<td class=\'thead\' nowrap=\'nowrap\' width=\'15%\'>$vbphrase[fquick_garage]</td>';
$vbulletin->templatecache['memberlist'] = str_replace($find, $replace.$find, $vbulletin->templatecache['memberlist']);]]></phpcode>
		</plugin>
		<plugin active="1">
			<title>Add to Memberlist</title>
			<hookname>memberlist_start</hookname>
			<phpcode><![CDATA[global $vbulletin;

$endif = '") : (""))."';
$ifstart = '".((';
$ifend = ') ? ("';

$rvbg = iif($bgclass == 'alt2', 'alt1', 'alt2');

$find = $ifstart . '$show[\'agecol\'] AND exec_switch_bg()' . $ifend;
$replace = '<td class=\'$rvbg\'>' . $ifstart . '$userinfo[\'fquick\']' . $ifend . '<a href=\'http://www.fquick.com/$userinfo[fquick]\' target=\'_blank\'>
<img src=\'images/misc/fquick.gif\' title=\'View My FQuick Garage\' alt=\'View My FQuick Garage\' border=\'0\'></a>' . $endif . '</td>';
$vbulletin->templatecache['memberlist_resultsbit'] = str_replace($find, $replace.$find, $vbulletin->templatecache['memberlist_resultsbit']);]]></phpcode>
		</plugin>
		<plugin active="1">
			<title>Add to Profile</title>
			<hookname>member_start</hookname>
			<phpcode><![CDATA[global $vbulletin;

$endif = '") : (""))."';
$ifstart = '".((';
$ifend = ') ? ("';
$newline = chr(13) . chr(10);
$tab = chr(9);

$find = $tab . $tab . $tab . $tab . '</table>' . $newline . $tab . $tab . $tab . '</fieldset>' . $newline . $tab . $tab . $tab . $endif;
$replace = $ifstart . '$userinfo[\'fquick\']' . $ifend . '<a href=\'http://www.fquick.com/$userinfo[fquick]\' target=\'_blank\'>
<img src=\'images/misc/fquick.gif\' title=\'View My FQuick Garage\' alt=\'View My FQuick Garage\' border=\'0\'></a>' . $endif;
$vbulletin->templatecache['MEMBERINFO'] = str_replace($find, $find.$replace, $vbulletin->templatecache['MEMBERINFO']);]]></phpcode>
		</plugin>
		<plugin active="1">
			<title>Add User Setting</title>
			<hookname>profile_start</hookname>
			<phpcode><![CDATA[$endif = '") : (""))."';
$ifstart = '".((';
$ifend = ') ? ("';

$find = $ifstart . '$customfields[\'regular\']' . $ifend;
$replace = '<!-- Placeholder -->';
$vbulletin->templatecache['modifyprofile'] = str_replace($find, $replace.$find, $vbulletin->templatecache['modifyprofile']);
$vbulletin->templatecache['modifyprofile'] = str_replace($replace, fetch_template('fquick'),$vbulletin->templatecache['modifyprofile']);]]></phpcode>
		</plugin>
		<plugin active="1">
			<title>Add User Setting</title>
			<hookname>profile_updateprofile</hookname>
			<phpcode><![CDATA[$vbulletin->input->clean_gpc('p', 'fquick', TYPE_STR); 
$userdata->set('fquick', $vbulletin->GPC['fquick']);]]></phpcode>
		</plugin>
		<plugin active="1">
			<title>Add to Postbit</title>
			<hookname>showthread_start</hookname>
			<phpcode><![CDATA[global $vbulletin;

$endif = '") : (""))."';
$ifstart = '".((';
$ifend = ') ? ("';

$find = $ifstart . '$show[\'reputation\']' . $ifend;
$replacement = $ifstart . '$post[\'fquick\']' . $ifend . '<div style=\'margin:5px 0px 5px 0px\'><a href=\'http://www.fquick.com/$post[fquick]\' target=\'_blank\'>
<img src=\'images/misc/fquick.gif\' title=\'View My FQuick Garage\' border=\'0\'></a></div>' . $endif;
$vbulletin->templatecache['postbit_legacy'] = str_replace($find, $replacement.$find,$vbulletin->templatecache['postbit_legacy']);
$vbulletin->templatecache['postbit'] = str_replace($find, $replacement.$find,$vbulletin->templatecache['postbit']);]]></phpcode>
		</plugin>
		<plugin active="1">
			<title>Add to AdminCP</title>
			<hookname>useradmin_edit_column1</hookname>
			<phpcode><![CDATA[print_input_row('FQuick Username', 'user[fquick]', $user['fquick']);]]></phpcode>
		</plugin>
		<plugin active="1">
			<title>Add to Dataman</title>
			<hookname>userdata_start</hookname>
			<phpcode><![CDATA[$this->validfields['fquick'] = array(TYPE_STR, REQ_NO);]]></phpcode>
		</plugin>
	</plugins>
	<phrases>
		<phrasetype name="GLOBAL" fieldname="global">
			<phrase name="fquick_enter_username" date="0" username="" version=""><![CDATA[Enter your FQuick Username below to have it displayed in your Posts.]]></phrase>
			<phrase name="fquick_garage" date="0" username="" version=""><![CDATA[FQuick Garage]]></phrase>
			<phrase name="fquick_username" date="0" username="" version=""><![CDATA[FQuick Username]]></phrase>
		</phrasetype>
	</phrases>
	<options>
	</options>
	<helptopics>
	</helptopics>
	<cronentries>
	</cronentries>
	<faqentries>
	</faqentries>
</product>
