Yet Another Award System 1.0.1  by HacNho  
Copyright (C) 2005 by HacNho, All rights reserved.

Hack Version: 1.0.1b.050329
Compatible vB version: 3.0.7. It should be compatible with all vB 3.x version, but not tested.



Version 1.0.1 - New features:
- Display awards in postbit (showthread, showpost, announcement, private)
+ UPGRADE1.txt

Version 1.0.1b:
- Display awards in postbit (showthread, showpost, announcement, private) for hybrid and threaded mode
+ UPGRADE2.txt

Version 1.0.1c:
- Optimize code in all files
+ UPGRADE3.txt

Version 1.1:
- Can Create/Edit/Remove/Reorder categories/sub-categories in ACP (with category name and description)
- Can Move one (or all) award from one category to another, or set it un-classified (not displayed in the list in public site)
- Can re-order awards (in ACP)
+ UPGRADE4.txt


Version 1.1b:
Fix awards display in showthread
+ UPGRADE4b.txt


UPGRADE INSTRUCTION

Edit showthead.php again, with the code given in awards_install_file.html or as in this file:

<edit file>
showthread.php
</edit file>

<search for>
	'pollresult',
</search for>

<replace>
	'pollresult',
	'awards_bit'
</replace>

<search for>
	if (!($forumperms & CANGETATTACHMENT))
	{
		$vboptions['viewattachedimages'] = 0;
		$vboptions['attachthumbs'] = 0;
	}

	$postcount = ($pagenumber - 1 ) * $perpage;
</search for>

<add before>
// [START HACK='Yet Another Award System' AUTHOR='HacNho']
		// Obtain list of awards for current user
			$alluserawards =  $DB_site->query("
				SELECT a.*, au.*, post.userid, post.postid 
				FROM " . TABLE_PREFIX . "post AS post
				INNER JOIN " . TABLE_PREFIX . "award_user AS au ON (au.userid=post.userid)
				INNER JOIN " . TABLE_PREFIX . "award AS a ON (a.award_id=au.award_id)
				WHERE $postids
				GROUP BY au.issue_id
				ORDER BY au.issue_time
			");
			while( $ua = $DB_site->fetch_array($alluserawards))
			{
				$userawardscache[$ua['userid']][$ua['issue_id']] = $ua;
			}
			$DB_site->free_result($alluserawards);
// [END HACK='Yet Another Award System' AUTHOR='HacNho']
</add before>

<search for>
	while ($post = $DB_site->fetch_array($posts))
	{
</search for>

<add after>
// [START HACK='Yet Another Award System' AUTHOR='HacNho']
			$post['userawards'] = '';
			$post['showuserawards'] = false;
			if (is_array($userawardscache[$post[userid]]))
			{
				foreach($userawardscache[$post['userid']] AS $award_id => $award)
				{
					eval('$post[userawards] .= "' . fetch_template('awards_bit') . '";');
					$awarduserslist .= ", <a href=\"user.php?do=edit&userid=$awardusers[userid]\">$awardusers[username]</a>";
				}
				$post['showuserawards'] = true;
			}
// [END HACK='Yet Another Award System' AUTHOR='HacNho']
</add after>

<search for>
	// re-initialise the $postarray variable
	$postarray = array();
	while ($post = $DB_site->fetch_array($cacheposts))
	{
</search for>

<replace>
// [START HACK='Yet Another Award System' AUTHOR='HacNho']
		// Obtain list of awards for current user
			$alluserawards =  $DB_site->query("
				SELECT a.*, au.*, post.userid, post.postid 
				FROM " . TABLE_PREFIX . "post AS post
				INNER JOIN " . TABLE_PREFIX . "award_user AS au ON (au.userid=post.userid)
				INNER JOIN " . TABLE_PREFIX . "award AS a ON (a.award_id=au.award_id)
				WHERE post.postid IN (" . $cache_postids . ")
				GROUP BY au.issue_id
				ORDER BY au.issue_time
			");
			while( $ua = $DB_site->fetch_array($alluserawards))
			{
				$userawardscache[$ua['userid']][$ua['issue_id']] = $ua;
			}
			$DB_site->free_result($alluserawards);
// [END HACK='Yet Another Award System' AUTHOR='HacNho']

	// re-initialise the $postarray variable
	$postarray = array();
	while ($post = $DB_site->fetch_array($cacheposts))
	{

// [START HACK='Yet Another Award System' AUTHOR='HacNho']
			$post['userawards'] = '';
			$post['showuserawards'] = false;
			if (is_array($userawardscache[$post[userid]]))
			{
				foreach($userawardscache[$post['userid']] AS $award_id => $award)
				{
					eval('$post[userawards] .= "' . fetch_template('awards_bit') . '";');
					$awarduserslist .= ", <a href=\"user.php?do=edit&userid=$awardusers[userid]\">$awardusers[username]</a>";
				}
				$post['showuserawards'] = true;
			}
// [END HACK='Yet Another Award System' AUTHOR='HacNho']
</replace>