vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Limit Attachment Downloads based off Posts!!! Help Please (https://vborg.vbsupport.ru/showthread.php?t=209260)

blackhatspace 03-24-2009 02:09 AM

Limit Attachment Downloads based off Posts!!! Help Please
 
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:

<!-- code corrected, see post #5 below -->
<if condition="[s]$vbulletin->userinfo['postcount'][/s] >= 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" />&nbsp;<a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;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 [DATE]1237866241[/DATE] at [TIME]1237866241[/TIME] ---------------

hey does this work with vb 3.8 because it does not seem to be working for me???? please help

--------------- Added [DATE]1237866710[/DATE] at [TIME]1237866710[/TIME] ---------------

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...

Code:

<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" />&nbsp;<a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;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

Quote:

Originally Posted by Lynne (Post 1775531)
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

Quote:

Originally Posted by Lynne (Post 1775551)
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.


All times are GMT. The time now is 11:13 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01249 seconds
  • Memory Usage 1,744KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (12)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete