• Welcome to Simple Machines Community Forum. Please login or sign up.
January 19, 2022, 08:49:12 PM

News:

SMF 2.0.19 has been released! Please update. Read more.


Attachment Download Permission

Started by Bounda, July 23, 2006, 12:51:27 PM

Previous topic - Next topic

Bounda

July 23, 2006, 12:51:27 PM Last Edit: August 02, 2006, 01:46:23 PM by Jay The Code Monkey
When i allowed guests to view downloads, they were allowed to download them too. When i used to be on 1.0.7 it would only let them view the download, if they clicked it they were redirected to a login page. I want to be able to do this on 1.1RC2, and its really been annoying me. If i knew what file to look in, i could try to do it myself, but i have absolutely no knowledge of php. Just a quick overview.

What i want:

Guests view attachments, but when clicked, redirected to a login page.

What 1.1RC2 Has

Guests view attachments, and can download them if View Attachments is enabled through permissions. I want them to see them, but be redirected to a login page like i said before.

Please Reply Back
~Bounda

EDIT:  This is now a mod
http://mods.simplemachines.org/index.php?mod=406

JayBachatero

July 23, 2006, 07:44:06 PM #1 Last Edit: July 24, 2006, 02:25:53 PM by Jay The Code Monkey
Ok this should work.

In Display.php
Code (find) Select

if (!empty($modSettings['attachmentEnable']) && allowedTo('view_attachments'))

Replace
Code (replace) Select

if (!empty($modSettings['attachmentEnable']) && (allowedTo('view_attachments') || allowedTo('view_attachments2')))


In ManagePermissions.php
Code (find) Select

'attachment' => array(
'view_attachments' => false,
'post_attachment' => false,
)

Replace
Code (replace) Select

'attachment' => array(
'view_attachments' => false,
'view_attachments2' => false,
'post_attachment' => false,
)


In ManagePermissions.english.php
Code (find) Select

$txt['permissionname_view_attachments'] = 'View attachments';
$txt['permissionhelp_view_attachments'] = 'Attachments are files that are attached to posted messages. This feature can be enabled and configured in \'Edit Features and Options\'. Since attachments are not directly accessed, you can protect them from being downloaded by users that don\'t have this permission.';

Replace
Code (replace) Select

$txt['permissionname_view_attachments'] = 'Download attachments';
$txt['permissionhelp_view_attachments'] = 'Download Attachments';
$txt['permissionname_view_attachments2'] = 'View attachments';
$txt['permissionhelp_view_attachments2'] = 'Attachments are files that are attached to posted messages. This feature can be enabled and configured in \'Edit Features and Options\'. Since attachments are not directly accessed, you can protect them from being downloaded by users that don\'t have this permission.';
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Bounda

July 24, 2006, 12:41:52 PM #2 Last Edit: July 24, 2006, 12:57:26 PM by Bounda
im working on it right now, and if it does then i love u =D ill edit this post when finished
/edit  :'( everything else worked but when i entered the forum, i got this

Parse error: syntax error, unexpected '{' in /home/bnews/public_html/Sources/Display.php on line 716

is it because im using tinyportal?

JayBachatero

Sorry I missed a ) in the Display.php changes.

Change
(allowedTo('view_attachments') || allowedTo('view_attachments2'))
to
(allowedTo('view_attachments') || allowedTo('view_attachments2')))
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Bounda

I love u monkey  :-* lol =D it works =D

JayBachatero

Glad to hear it worked.

* Jay The Code Monkey moves this to [[tips and tricks]].
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

WifiGamer

I tried this mod on version 1.1.2 and it installed without a hitch however the problem arose when I tested it.

it created the 2 different permissions but if I allow them to view the attachment but disallow to download then if it's a picture it doesn't show up.  But if I allow them to download then it's like the mod doesn't exist.

What I wanted was to remove the download link below the picture.  Not sure if this mod is the one I need?

coffeejunkie

A related question: I have a registered-only site and need to be sure that posts and attachments are not accessible to the public.  Does the above solution prevent access to attachments even if the direct link is known?

The SMF feature list says the following on attachments (http://www.simplemachines.org/about/features.php)

QuoteAbility to restrict such that only registered members can view them (disables hotlinking, mostly.)

But this seems to suggest that someone who's not registered but knows the link can still get the attachment?

Thanks for advice and pointers!

Advertisement: