Try the following...
Code:
Product: vBulletin
Hook Location: attachment_start
Title: Closed Attachments
Plugin PHP Code: code is below
Plugin is Active: Yes
// start Closed Attachments code
/*************************************************************
SET THESE VALUES
*************************************************************/
$forums_closed_to_guest_attach_views = array(1,2,3,4,5);
$user_ids_whose_attaches_are_closed = array(1);
$user_groups_allowed_to_see_attaches = array(5,6,7);
/************************************************************/
if (!$attachmentinfo_check = $db->query_first("
SELECT attachment.userid, thread.forumid
FROM " . TABLE_PREFIX . "attachment AS attachment
LEFT JOIN " . TABLE_PREFIX . "attachmenttype AS attachmenttype ON (attachmenttype.extension = attachment.extension)
LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = attachment.postid)
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)
WHERE " . ($vbulletin->GPC['postid'] ? "attachment.postid = " . $vbulletin->GPC['postid'] : "attachmentid = " . $vbulletin->GPC['attachmentid']) . "
"))
{
eval(standard_error(fetch_error('invalidid', $vbphrase['attachment'], $vbulletin->options['contactuslink'])));
}
$user_groups_allowed_for_attachments = array();
if ($vbulletin->userinfo['userid'] > 0 && $vbulletin->userinfo['membergroupids'])
{
$user_groups_allowed_for_attachments = explode(",",str_replace(" ","",$vbulletin->userinfo['membergroupids']));
}
$user_groups_allowed_results = array_intersect($user_groups_allowed_to_see_attaches, $user_groups_allowed_for_attachments);
if (
in_array($attachmentinfo_check['forumid'], $forums_closed_to_guest_attach_views)
&&
in_array($attachmentinfo_check['userid'], $user_ids_whose_attaches_are_closed)
&&
!in_array($vbulletin->userinfo['usergroupid'], $user_groups_allowed_to_see_attaches)
&&
empty($user_groups_allowed_results)
)
{
print_no_permission();
}
// end Closed Attachments code