The code which is creating the thumbnails is as follows:
PHP Code:
while ($attachment = $db->fetch_array($attachments))
{
if (!$attachment['build_thumbnail'])
{
$attachment['hasthumbnail'] = false;
}
$feedback['attachments']["$attachment[attachmentid]"] = $attachment;
if ($attachment['hasthumbnail'])
{
$thumbcount++;
if ($vbulletin->options['attachrow'] AND $thumbcount >= $vbulletin->options['attachrow'])
{
$thumbcount = 0;
$show['br'] = true;
}
else
{
$show['br'] = false;
}
// ... define transparency for attachments with visible = 0
if ($attachment['visible'])
{
$transparency = '';
}
else
{
$transparency = '-moz-opacity:0.2; filter:alpha(opacity=20)';
}
// ... display each thumbnail
$thumbs .=
'<a href="../attachment.php?' . $vbulletin->session->vars['sessionurl'] . "attachmentid=$attachment[attachmentid]&stc=1&d=$attachment[thumbnail_dateline]\" target=\"_blank\"><img src=\"../attachment.php?" . $vbulletin->session->vars['sessionurl'] . "attachmentid=$attachment[attachmentid]&thumb=1&d=$attachment[dateline]\" border=\"0\" style=\"$transparency\" class=\"thumbnail\" alt=\"Attachment id: $attachment[attachmentid]\" /></a><a href=\"attachment.php" . $vbulletin->session->vars['sessionurl'] . "?do=edit&attachmentid=$attachment[attachmentid]\" target=\"_blank\"><img src=\"../images/statusicon/icon_editimage.gif\" border=\"0\" alt=\"Edit Image\" /></a>
" . iif($show['br'], "<br /><br />") . "
";
$show['thumbnailattachment'] = true;
}
}
I don't think that's the issue as it works just fine for generating thumbs for attachments posted by myself, the problem occurrs when viewing thumbs for any other member.
It's probably relevant that these thumbnails for attachments are NOT associated with posts, threads or forums. they are associated with Feedback reports. Therefore the query which gathers the attachment data from the database returns no forumid. (please see attached "
query_result_attachment-php.gif" ).
I thought since there's no forumid returned, the following code in attachment.php is unable to generate the $forumperms needed and it's the reason for the error:
PHP Code:
$forumperms = fetch_permissions($attachmentinfo['forumid']);
$threadinfo = array('threadid' => $attachmentinfo['threadid']); // used for session.inthread
$foruminfo = array('forumid' => $attachmentinfo['forumid']); // used for session.inforum
But that can't be it, since there's no forum id returned either when viewing my own attachment thumbnail.
If the thumb is clisked on to view the attachment in a full size window, I get a NO PERMISSION error. Now the interesting thing is, the no permission error ( print_no_permission(); ) is only located in the following part of the attachment.php script:
PHP Code:
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment']) OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($attachmentinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0)))
{
print_no_permission();
}
But if i comment that part out in attachment php, the thumbnail still doesn't display, and i still get the nopermission error when opening the full wondow.
It baffles my mind. Please anyone help, i will be eternally grateful.