Allow guests to read posts but not download attachments?

Started by VE3JOC, April 18, 2020, 12:43:07 PM

Previous topic - Next topic

VE3JOC

Is there a way to allow guests to read posts in a specific forum but not be able to download attachments?  I have a tutorial forum that will have tutorials in .pdf format and I want everyone to be able to read the posts in that forum but only allow registered users to download the .pdf files.
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

Doug Heffernan

Quote from: VE3JOC on April 18, 2020, 12:43:07 PM
Is there a way to allow guests to read posts in a specific forum but not be able to download attachments?  I have a tutorial forum that will have tutorials in .pdf format and I want everyone to be able to read the posts in that forum but only allow registered users to download the .pdf files.

Yes, you can do that at the board permissions page. Untick View attachments permission set.

vbgamer45

Also I have a mod that adds a permission for downloads/view
So you can see their are attachments in the post but not allow downloads

https://custom.simplemachines.org/mods/index.php?mod=4189
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

VE3JOC

Thanks vbgamer45.  If this mod was installed, where would you go in the admin to limit the downloading of attachments?
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

vbgamer45

It is a membergroup level permissions. So under permissions for each membergroup
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

VE3JOC

Ok, I tried it.  I checked the View Attachments and unchecked the Download attachments but when I log in as a guest I cannot see any attachments.  Maybe I am not understanding how it works but my impression was that they could see that there is a file attached but not be able to download it.

Thanks
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

vbgamer45

That's what it should do. Using a custom theme or default theme?
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

VE3JOC

http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

vbgamer45

Want to double check you made the change for guest group as well?

If you did attach your display.template.php file for your theme.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

VE3JOC

The only display.template.php file that I can find is in the default theme.  I have attached it.
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

vbgamer45

Just confirming you gave the guests membergroup the "View Attachments " permission
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

VE3JOC

http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

VE3JOC

http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

VE3JOC

Can't get it to work properly so I uninstalled it.  Guess I'll have to see if I can find another way of doing this.

Thanks anyway.
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

Tonyvic

Quote from: VE3JOC on April 18, 2020, 02:09:08 PM
Ok, I tried it.  I checked the View Attachments and unchecked the Download attachments but when I log in as a guest I cannot see any attachments.  Maybe I am not understanding how it works but my impression was that they could see that there is a file attached but not be able to download it.

Thanks
I thought 'Guests' were people who were not logged in! :P

drewactual

#15
this will show the attachments, but they aren't available for download. 

Quoteedited to add:  you MUST have attachments visible to guests in your forum's permissions for this to work

first off, if you're using a custom theme or theme OTHER than default, and that theme DOES NOT have a Display.template, COPY the Display.template from your default file and paste it to the theme you are using's directory- leaving the virgin copy behind in default theme... this will retain a virgin copy of your Default.template if you choose to get rid of this code/function...

open the Display/template you just made (or the default one if you're using the default theme)

find:

echo '
<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" />&nbsp;' . $attachment['name'] . '</a> ';


it should be around or on line 530 of 2.0.17's virgin Default.template....

replace it with:

// code inject for only members able to download attachments
if ($context['user']['is_guest'])
                       echo '
                       <a href="' . $scripturl . '?action=login">Login</a> or <a href="' . $scripturl . '?action=register">Register</a> to download attachment.
                       ';
           elseif   ($context['user']['is_logged'])         
                   echo'
<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" />&nbsp;' . $attachment['name'] . ' click to download</a> <br /> ';
// end inject for members only attachments download.


that's pretty much all there is to it... it doesn't have a back-end admin control, obviously, so... the code will have to be removed to revert back... folks around here don't like their code being hacked, so don't expect this to be popular.

VE3JOC

Thanks drewactual.  I have "allow viewing of attachments" checked but having inserted the code the attachment is only visible to logged-in users.  Guests do not see that attachment.
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

drewactual

There USED to be a server side apache rpm that would open Microsoft and Adobe files on webpages... it was a resource hungry thing, but it worked.  To my knowledge and without massive amounts of coding and IF that rpm was adaptable, I still think it would be near impossible to have a working "view" documents... an image? All day long... a file? Different animal...

The code I offered will at least show there is an attachment to a guest, and will allow an image to be seen but not downloaded.

VE3JOC

Thanks drewactual.  No problem.  As long as users know that there is a tutorial that they can download if they log-in, that's great.

Thanks again.
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

Advertisement: