View Full Version : Limit Attachment Downloads based off Posts!!! Help Please
blackhatspace
03-24-2009, 02:09 AM
Does anyone know how to limit downloading of forum attachments based off post count?
TigerC10
03-24-2009, 02:27 AM
You can modify the template attachmentbit.
<!-- code corrected, see post #5 below -->
<if condition="$vbulletin->userinfo['postcount'] >= 50">
<tr>
<td class="$bgclass">
<img class="inlineimg" src="$stylevar[imgdir_attach]/$attachment[attachmentextension].gif" alt="<phrase 1="$attachment[attachmentextension]">$vbphrase[file_type_x]</phrase>" width="16" height="16" border="0" style="vertical-align:middle" /> <a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&d=$attachment[dateline]" target="_blank">$attachment[filename]</a>
</td>
<td class="$bgclass">
$attachment[filesize]
</td>
<td class="$bgclass" align="center">
$attachment[counter]
</td>
</tr>
<else />
<tr>
<td class="$bgclass" colspan="3" align="center">You do not have enough posts to download attachments.</td>
</tr>
</if>
Change the 50 to whatever post count you want it to be. If you want to make it more advanced than that, you should post a mod request.
blackhatspace
03-24-2009, 02:29 AM
Thank you sir!
--------------- Added 1237866241 at 1237866241 ---------------
hey does this work with vb 3.8 because it does not seem to be working for me???? please help
--------------- Added 1237866710 at 1237866710 ---------------
It's still allowing downloads & i copied your code word for word!
Lynne
03-24-2009, 02:53 AM
Templates should use $bbuserinfo instead of $vbulletin->userinfo. Also, postcount may be the post number at the location - maybe spit it out and see (like this is post #4)
TigerC10
03-24-2009, 02:58 AM
Ah, I just kinda wrote it without thinking. Yeah, I agree $bbuserinfo is a much better way to go about it. I think it would then be...
<if condition="$bbuserinfo['posts'] >= 10">
<tr>
<td class="$bgclass">
<img class="inlineimg" src="$stylevar[imgdir_attach]/$attachment[attachmentextension].gif" alt="<phrase 1="$attachment[attachmentextension]">$vbphrase[file_type_x]</phrase>" width="16" height="16" border="0" style="vertical-align:middle" /> <a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&d=$attachment[dateline]" target="_blank">$attachment[filename]</a>
</td>
<td class="$bgclass">
$attachment[filesize]
</td>
<td class="$bgclass" align="center">
$attachment[counter]
</td>
</tr>
<else />
<tr>
<td class="$bgclass" colspan="3" align="center">You do not have enough posts to download attachments.</td>
</tr>
</if>
blackhatspace
03-24-2009, 02:59 AM
Templates should use $bbuserinfo instead of $vbulletin->userinfo. Also, postcount may be the post number at the location - maybe spit it out and see (like this is post #4)
hmmm that doesn't seem to work either, it seems like vbulletin is ignoring the if statements and still letting them download.
TigerC10
03-24-2009, 03:04 AM
Keep in mind that there is such a thing as browser caching, and post caching. When testing this, make sure you're clearing your brower's cache.
How to clear the cache for the page you're viewing
For Firefox: hold SHIFT and click the refresh button on the toolbar
For Internet Explorer: hold CTRL and click the refresh button on the toolbar
Lynne
03-24-2009, 03:22 AM
I am pretty sure ['posts] won't work if a user has more than 1,000 posts because of the comma. That variable $post['posts'] gets formatted prior to use in the postbit templates. I think you need to write a plugin to get the 'real' unformatted posts to use in a condition.
blackhatspace
03-24-2009, 03:25 AM
Ok. I've tried your updated code, Cleared my browsers chache & cookies and It's still not working on the forum. I think Lynne may be right that some of the variables are incorrect.
Thanks.
Lynne
03-24-2009, 03:31 AM
It's not that the variable is wrong, it's just that you can't use it in a condition since it's formatted. You need to write a plugin, maybe using postbit_display_start?, to grab the posts number *before* it gets formatted.
blackhatspace
03-24-2009, 03:32 AM
It's not that the variable is wrong, it's just that you can't use it in a condition since it's formatted. You need to write a plugin, maybe using postbit_display_start?, to grab the posts number *before* it gets formatted.
That makes sense. Too bad i can't program... (HINT: TigerC10 )
TigerC10
03-24-2009, 03:52 AM
Is that so? I was under the impression that PHP operated like Perl in that it would convert the string to a number for comparison - but perhaps the number is converted to a string for comparison instead...
If that's the case... Then yes... We'd have to collect the post count before the template runs. I... Don't really know if I want to take this mod on. You should post a mod request (https://vborg.vbsupport.ru/forumdisplay.php?f=112).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.