Jaxel
01-06-2009, 09:40 AM
For the comments on one of my mods, I am using the following code to pull avatars from comment bits... (they should really make the code width boxes bigger)
$comments = $db->query_read("
SELECT comment.*, IF(NOT ISNULL(user.userid), user.username, comment.postusername) AS username,
user.avatarrevision AS avatarrevision, avatar.avatarpath AS avatarpath, NOT ISNULL(customavatar.userid) AS hascustom,
customavatar.dateline AS avatardateline, customavatar.width_thumb AS width_thumb, customavatar.height_thumb AS height_thumb
FROM " . TABLE_PREFIX . "videocomment AS comment
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = comment.postuserid)
LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid)
LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)
WHERE comment.videoid = '" . $videoinfo['videoid'] . "' AND comment.state = 'visible'
ORDER BY comment.dateline DESC
LIMIT " . ($limitlower - 1) . ", $perpage
");
$bbcode_parser_comment =& new vB_BbcodeParser($vbulletin, fetch_tag_list());
$thumb = true;
while ($comment = $db->fetch_array($comments))
{
$comment['message'] = $bbcode_parser_comment->parse($comment['message'], 'videodirectory_reply');
$comment['date'] = vbdate($vbulletin->options['dateformat'], $comment['dateline']);
$comment['time'] = vbdate($vbulletin->options['timeformat'], $comment['dateline']);
$show['deletionlink'] = ($permissions['videodirectorypermissions'] & $vbulletin->bf_ugp_videodirectorypermissions['canmoderate']);
fetch_musername($comment);
if (!empty($comment['avatarpath']))
{
$comment['avatar'] = array($comment['avatarpath']);
}
else if ($comment['hascustom'])
{
$avatarurl = array('hascustom' => 1);
if ($vbulletin->options['usefileavatar'])
{
$comment['avatarurl'] = $vbulletin->options['avatarurl'] . ($thumb ? '/thumbs' : '') . "/avatar{$comment['postuserid']}_{$comment['avatarrevision']}.gif";
}
else
{
$comment['avatarurl'] = "image.php?u=$comment[postuserid]&dateline=$comment[avatardateline]" . ($thumb ? '&type=thumb' : '') ;
}
}
if ($thumb)
{
if ($comment['width_thumb'] AND $comment['height_thumb'])
{
$avatarwidth = $comment['width_thumb'];
$avatarheight = $comment['height_thumb'];
}
}
if (empty($comment['avatarurl']))
{
$comment['avatarurl'] = $stylevar['imgdir_misc'] . '/unknown.gif';
}
eval('$commentbits .= "' . fetch_template('video_commentbit') . '";');
}
It pulls the avatars from the file system no problem... but when pulling from the database, it gives a blank avatar. I dont mean the "unknown.gif"; I mean an empty avatar with nothing on it. You can see what I mean here: http://www.waltdisneyboards.com/videos/walt-disney-2/jack-benny-visits-walt-disney-rare-footage-12.html The first comment has the unknown avatar, while the second comment has a blank avatar. Looking at the source code of that page, you will see that it clearly finds the avatar with the following code:
<img src="http://www.waltdisneyboards.com/avatars/wdbarnyvee.gif?dateline=1228446000&type=thumb" class="alt2 avatar" border="0" alt="WDBArnyVee" />http://www.waltdisneyboards.com/avatars/wdbarnyvee.gif?dateline=1228446000&type=thumb
However, its just not displaying it on that page. Is there something I am missing? Do I need to give this script permission to display avatars from the database or something?
$comments = $db->query_read("
SELECT comment.*, IF(NOT ISNULL(user.userid), user.username, comment.postusername) AS username,
user.avatarrevision AS avatarrevision, avatar.avatarpath AS avatarpath, NOT ISNULL(customavatar.userid) AS hascustom,
customavatar.dateline AS avatardateline, customavatar.width_thumb AS width_thumb, customavatar.height_thumb AS height_thumb
FROM " . TABLE_PREFIX . "videocomment AS comment
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = comment.postuserid)
LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid)
LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)
WHERE comment.videoid = '" . $videoinfo['videoid'] . "' AND comment.state = 'visible'
ORDER BY comment.dateline DESC
LIMIT " . ($limitlower - 1) . ", $perpage
");
$bbcode_parser_comment =& new vB_BbcodeParser($vbulletin, fetch_tag_list());
$thumb = true;
while ($comment = $db->fetch_array($comments))
{
$comment['message'] = $bbcode_parser_comment->parse($comment['message'], 'videodirectory_reply');
$comment['date'] = vbdate($vbulletin->options['dateformat'], $comment['dateline']);
$comment['time'] = vbdate($vbulletin->options['timeformat'], $comment['dateline']);
$show['deletionlink'] = ($permissions['videodirectorypermissions'] & $vbulletin->bf_ugp_videodirectorypermissions['canmoderate']);
fetch_musername($comment);
if (!empty($comment['avatarpath']))
{
$comment['avatar'] = array($comment['avatarpath']);
}
else if ($comment['hascustom'])
{
$avatarurl = array('hascustom' => 1);
if ($vbulletin->options['usefileavatar'])
{
$comment['avatarurl'] = $vbulletin->options['avatarurl'] . ($thumb ? '/thumbs' : '') . "/avatar{$comment['postuserid']}_{$comment['avatarrevision']}.gif";
}
else
{
$comment['avatarurl'] = "image.php?u=$comment[postuserid]&dateline=$comment[avatardateline]" . ($thumb ? '&type=thumb' : '') ;
}
}
if ($thumb)
{
if ($comment['width_thumb'] AND $comment['height_thumb'])
{
$avatarwidth = $comment['width_thumb'];
$avatarheight = $comment['height_thumb'];
}
}
if (empty($comment['avatarurl']))
{
$comment['avatarurl'] = $stylevar['imgdir_misc'] . '/unknown.gif';
}
eval('$commentbits .= "' . fetch_template('video_commentbit') . '";');
}
It pulls the avatars from the file system no problem... but when pulling from the database, it gives a blank avatar. I dont mean the "unknown.gif"; I mean an empty avatar with nothing on it. You can see what I mean here: http://www.waltdisneyboards.com/videos/walt-disney-2/jack-benny-visits-walt-disney-rare-footage-12.html The first comment has the unknown avatar, while the second comment has a blank avatar. Looking at the source code of that page, you will see that it clearly finds the avatar with the following code:
<img src="http://www.waltdisneyboards.com/avatars/wdbarnyvee.gif?dateline=1228446000&type=thumb" class="alt2 avatar" border="0" alt="WDBArnyVee" />http://www.waltdisneyboards.com/avatars/wdbarnyvee.gif?dateline=1228446000&type=thumb
However, its just not displaying it on that page. Is there something I am missing? Do I need to give this script permission to display avatars from the database or something?