HTML Code:
$postLikes = $db->query_read('SELECT DISTINCT `live_dbtech_thanks_entry`.*, `live_user`.`username`, `live_user`.`displaygroupid` FROM `live_dbtech_thanks_entry` JOIN `live_user` ON (`live_user`.`userid` = `live_dbtech_thanks_entry` .`userid`) WHERE `contentid` = \'' . $post['postid'] . '\'');
name="dbtech_thanks_button" data-postid="{$post[postid]}" data-button="{$button[varname]}
$data = array('likes' => array(), 'dislikes' => array(), 'STFU' => array());
$has = array('likes' => 0, 'dislikes' => 0, 'STFU' => 0);
while( ( $fetch = $db->fetch_array( $postLikes ) ) != false )
{
$member = array(
'userid' => $fetch['userid'],
'username' => $fetch['username'],
'displaygroupid' => $fetch['displaygroupid']
);
$data[ strtolower( $button['varname'] ) ][ $fetch['userid'] ] = fetch_musername( $member );
if( $fetch['userid'] == $vbulletin->userinfo['userid'] )
{
$has[ strtolower( $button['varname'] ) ] = 1;
}
}
$post['hasLiked'] = $has['likes'];
$post['hasDisliked'] = $has['dislikes'];
$post['hasSTFU'] = $has['STFU'];
$post['likes'] = count( $data['likes'] );
$post['dislikes'] = count( $data['dislikes'] );
$post['STFU'] = count( $data['STFU'] );
$likesHTML = '';
$dislikesHTML = '';
$STFUHTML = '';
if( $post['likes'] > 0 )
{
$likesHTML = ( ( $has['likes'] == 1 ) ? '<span class="you">You' . ( $post['likes'] > 2 ? ',' : ' ' ) . ' </span> ' : '<span class="you"></span> ' );
$i = 0;
$extraHTML = '';
$extra = 0;
foreach( $data['likes'] as $key => $value )
{
if( ( ( $post['likes'] == 1 && $has['likes'] == 0 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$likesHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i < 10 && ( $i < ( $post['likes'] - 1 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$likesHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i >= 10 && ( $i < $post['likes'] ) && $key != $vbulletin->userinfo['userid'] )
{
$extraHTML .= trim( strip_tags( $value ) ) . ', ';
++$extra;
}
++$i;
}
$lastUser = end( $data['likes'] );
$lastUserID = key( $data['likes'] );
$likesHTML = substr( $likesHTML, 0, -2 ) . ( ( ( ( $post['likes'] > 1 && $extra == 0 && $has['like'] == 0 ) || ( $post['likes'] > 2 && $extra == 0 && $has['like'] == 1 ) ) && $lastUserID != $vbulletin->userinfo['userid'] ) ? ' and <a href="member.php?u=' . $lastUserID . '">' . $lastUser . '</a>' : ( ( $post['likes'] > 1 && $extra > 0 ) ? ' and <a href="#" class="tooltip" title=\'' . substr( $extraHTML, 0, -2 ) . '\'>' . $extra . ' others</a>' : '') ) . ' ' . ( ( $has['likes'] == 0 && $post['likes'] > 1 ) ? 'like' : ( ( $has['likes'] == 0 && $post['likes'] == 1 ) ? 'likes' : 'like' ) ) . ' this';
}
if( $post['dislikes'] > 0 )
{
$dislikesHTML = ( ( $has['dislikes'] == 1 ) ? '<span class="you">You' . ( $post['dislikes'] > 2 ? ',' : ' ' ) . ' </span> ' : '<span class="you"></span> ' );
$i = 0;
$extraHTML = '';
$extra = 0;
foreach( $data['dislikes'] as $key => $value )
{
if( ( ( $post['dislikes'] == 1 && $has['dislikes'] == 0 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$dislikesHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i < 10 && ( $i < ( $post['dislikes'] - 1 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$dislikesHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i >= 10 && ( $i < $post['dislikes'] ) && $key != $vbulletin->userinfo['userid'] )
{
$extraHTML .= trim( strip_tags( $value ) ) . ', ';
++$extra;
}
++$i;
}
$lastUser = end( $data['dislikes'] );
$lastUserID = key( $data['dislikes'] );
$dislikesHTML = substr( $dislikesHTML, 0, -2 ) . ( ( ( ( $post['dislikes'] > 1 && $extra == 0 && $has['like'] == 0 ) || ( $post['dislikes'] > 2 && $extra == 0 && $has['like'] == 1 ) ) && $lastUserID != $vbulletin->userinfo['userid'] ) ? ' and <a href="member.php?u=' . $lastUserID . '">' . $lastUser . '</a>' : ( ( $post['dislikes'] > 1 && $extra > 0 ) ? ' and <a href="#" class="tooltip" title=\'' . substr( $extraHTML, 0, -2 ) . '\'>' . $extra . ' others</a>' : '') ) . ' ' . ( ( $has['dislikes'] == 0 && $post['dislikes'] > 1 ) ? 'dislike' : ( ( $has['dislikes'] == 0 && $post['dislikes'] == 1 ) ? 'dislikes' : 'dislike' ) ) . ' this';
}
if( $post['STFU'] > 0 )
{
$STFUHTML = ( ( $has['STFU'] == 1 ) ? '<span class="you">You' . ( $post['STFU'] > 2 ? ',' : ' ' ) . ' </span> ' : '<span class="you"></span> ' );
$i = 0;
$extraHTML = '';
$extra = 0;
foreach( $data['STFU'] as $key => $value )
{
if( ( ( $post['STFU'] == 1 && $has['STFU'] == 0 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$STFUHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i < 10 && ( $i < ( $post['STFU'] - 1 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$STFUHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i >= 10 && ( $i < $post['STFU'] ) && $key != $vbulletin->userinfo['userid'] )
{
$extraHTML .= trim( strip_tags( $value ) ) . ', ';
++$extra;
}
++$i;
}
$lastUser = end( $data['STFU'] );
$lastUserID = key( $data['STFU'] );
$STFUHTML = substr( $STFUHTML, 0, -2 ) . ( ( $post['STFU'] > 1 && $extra == 0 && $lastUserID != $vbulletin->userinfo['userid'] ) ? ' and <a href="member.php?u=' . $lastUserID . '">' . $lastUser . '</a>' : ( ( $post['STFU'] > 1 && $extra > 0 ) ? ' and <a href="#" class="tooltip" title="' . substr( $extraHTML, 0, -2 ) . '">' . $extra . ' others</a>' : '') ) . ' ' . ( ( $has['STFU'] == 0 && $post['STFU'] > 1 ) ? 'said' : ( ( $has['STFU'] == 0 && $post['STFU'] == 1 ) ? 'says' : 'say' ) ) . ' STFU';
}
$post['likeshtml'] = $likesHTML;
$post['dislikeshtml'] = $dislikesHTML;
$post['STFUhtml'] = $STFUHTML;
$post['systemhtml'] = '
<script>var admin = ' . ( ( $vbulletin->userinfo['displaygroupid'] == 6 ) ? 'true' : 'false' ) . '</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js"></script>
<script src="/assets/tipsy.js"></script>
<script src="/assets/global.js"></script>
<script src="clientscript/vbulletin_ajax_reputation.js?v=387" type="text/javascript" ></script>
<style>@import url( /assets/likes.css );</style>';