I'm using attachment.php to display thumbnails for attachments. This is being used in a custom script which resides within the AdminCP and it's called in the same manner in which it's used in postbit to display thumbs:
http://www.mysite.com/forum/attachme...1&d=1189977330
The thumbnails display properly when any menber views their own attachments, however when they attempt to view another member's attachments, the image is not displayed (i get the box with red X in it).
You can see the result of the query which is called within the script in attached "query.gif"
The issue which i feel might be the problem is that there's no forumid passed into $attachmentinfo and therefore no $forumperms to view the attachment? I think that's the issue, but not sure because when I comment out the following block of code (taken from attachment.php) the image still doesn't show, however when i run the script to call the same exact imageid but while logged in as the user who posted the attachment, it does show.
PHP Code:
if ($attachmentinfo['postid'] == 0)
{ // Attachment that is in progress but hasn't been finalized
if ($vbulletin->userinfo['userid'] != $attachmentinfo['userid'] AND !can_moderate($attachmentinfo['forumid'], 'caneditposts'))
{ // Person viewing did not upload it
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}
// else allow user to view the attachment (from the attachment manager for example)
}
else
{
$forumperms = fetch_permissions($attachmentinfo['forumid']);
$threadinfo = array('threadid' => $attachmentinfo['threadid']); // used for session.inthread
$foruminfo = array('forumid' => $attachmentinfo['forumid']); // used for session.inforum
# Block attachments belonging to soft deleted posts and threads
if (!can_moderate($attachmentinfo['forumid']) AND ($attachmentinfo['post_visible'] == 2 OR $attachmentinfo['thread_visible'] == 2))
{
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}
# Block attachments belonging to moderated posts and threads
if (!can_moderate($attachmentinfo['forumid'], 'canmoderateposts') AND ($attachmentinfo['post_visible'] == 0 OR $attachmentinfo['thread_visible'] == 0))
{
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}
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();
}
// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($attachmentinfo['forumid'], $vbulletin->forumcache["$attachmentinfo[forumid]"]['password']);
if (!$attachmentinfo['visible'] AND !can_moderate($attachmentinfo['forumid'], 'canmoderateattachments') AND $attachmentinfo['userid'] != $vbulletin->userinfo['userid'])
{
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}
}
How can I bypass this issue? I can't seem to narrow down what the problem is really. I even tried editing the attachment.php file and adding the following just before the block above but it didnt work either:
PHP Code:
// assign a forumid in which all users have all permissions assigned
$attachmentinfo['forumid'] = 1;
Any ideas? I've been stumped on this for 2 days now.