- Posts: 11
COMMUNITY FORUM
Permissions on attachments?
- StreamAlex
- Topic Author
- Offline
- New Member
Less
More
12 years 1 month ago #102763
by StreamAlex
Permissions on attachments? was created by StreamAlex
I would like to set permissions on the attachments I add on an article. Is that possible? I don't want to hide the whole article, but just the attachments for public users.
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
12 years 1 month ago #102764
by william white
Replied by william white on topic Re: Permissions on attachments?
You will need to create an override and wrap the part of item.php that displays the attachments with a test to discover the status or the user that is logged in and either display it or not
something like this should work
<?php $user =& JFactory::getUser(); ?>
<php if($user->get('guest') ==0 ): ?>
..../*Attachment Downloads Code*/
<?php endif; ?>
something like this should work
<?php $user =& JFactory::getUser(); ?>
<php if($user->get('guest') ==0 ): ?>
..../*Attachment Downloads Code*/
<?php endif; ?>
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
12 years 1 month ago #102765
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: Permissions on attachments?
Hi. The code that William White posted should do the trick. Note however that this code only hides the attachments. If a guest user knows the download link of the attachment he can download it. In order to prevent this you need to write a K2 plugin which needs to be triggered on the "onK2BeforeDownload" event.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- StreamAlex
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
12 years 3 weeks ago #102766
by StreamAlex
Replied by StreamAlex on topic Re: Permissions on attachments?
Thank you for the answers! I have tried it and it works.
Please Log in or Create an account to join the conversation.
- navid
- Offline
- New Member
Less
More
- Posts: 15
11 years 11 months ago #102767
by navid
Replied by navid on topic Re: Permissions on attachments?
hi
where can I import this code:
<?php $user =& JFactory::getUser(); ?>
<php if($user->get('guest') ==0 ): ?>
..../*Attachment Downloads Code*/
<?php endif; ?>
what line number?
where can I import this code:
<?php $user =& JFactory::getUser(); ?>
<php if($user->get('guest') ==0 ): ?>
..../*Attachment Downloads Code*/
<?php endif; ?>
what line number?
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
11 years 11 months ago #102768
by william white
Replied by william white on topic Re: Permissions on attachments?
This depends on the k2 version you are using, attach your item.php that you are using in an attachement here and we can tell you
Please Log in or Create an account to join the conversation.
- navid
- Offline
- New Member
Less
More
- Posts: 15
11 years 11 months ago - 11 years 11 months ago #102769
by navid
Replied by navid on topic Re: Permissions on attachments?
my k2 version is 2.5.7
attached it.
too,I use alpha user point
say to me where should I import below code:
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
$aupid = AlphaUserPointsHelper::getAnyUserReferreID( $userID );
if ( $aupid ) AlphaUserPointsHelper::newpoints( 'function_name', $aupid );
}
thanks a lot
attached it.
Attachment not found
too,I use alpha user point
say to me where should I import below code:
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
$aupid = AlphaUserPointsHelper::getAnyUserReferreID( $userID );
if ( $aupid ) AlphaUserPointsHelper::newpoints( 'function_name', $aupid );
}
thanks a lot
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
11 years 11 months ago #102770
by william white
Replied by william white on topic Re: Permissions on attachments?
You seem to be working with the wrong file,
Create an override (see documentation above for info)
Use the file
YourSiteRoot/templates/YourTemplate/com_k2/templates/YourOverrideName/item.php
Create an override (see documentation above for info)
Use the file
YourSiteRoot/templates/YourTemplate/com_k2/templates/YourOverrideName/item.php
Please Log in or Create an account to join the conversation.
- navid
- Offline
- New Member
Less
More
- Posts: 15
11 years 11 months ago #102771
by navid
Replied by navid on topic Re: Permissions on attachments?
no, I dont have such directory
?!!
this file is in
components/com_k2/models
?!!
this file is in
components/com_k2/models
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
11 years 11 months ago #102772
by william white
Replied by william white on topic Re: Permissions on attachments?
Please see the documentation about k2 templates under documentation
also, see the movies in the documentation from ostraning which will walk you thru templating
before trying to make changes
also, see the movies in the documentation from ostraning which will walk you thru templating
before trying to make changes
Please Log in or Create an account to join the conversation.