restrict access to link

margaridacarvalho - March 10, 2009 - 10:19

Hi!
I have several images that are linked to different pdf's. What i want to do is to restrict access to anonymous users. I want them to be able to see the images but i don't want them to be able to click the image and consequently see the pdf.
Does anyone can tell how to do this?

permission..

nathanjo - March 10, 2009 - 10:31

you can do that in admi/user/permissions

sorry

margaridacarvalho - March 10, 2009 - 12:32

Thanks for your quick reply.
I'm sorry but i can't see how can i do this through user/permissions. I can restrict acess to pages but then anonymous users can't see the images, and i would like them to see them but couldn't click on them. I've tried path access module but i can't seem to put it to work right.
Could private file system and access control configuration be the answer to my problem?
Any other suggestion?

you can also do path access,

marco302008 - March 10, 2009 - 12:38

you can also do path access, so that the user ends up at an Access Denied page.

Or, alternatively, you can do it in php

<?php
if (in_array('anonymous',$GLOBALS['user']->roles)){?{>
...
html tag for link.....
<?
php }
?>

<?php
if (in_array('anonymous',$GLOBALS['user']->roles)){?{>
...
close link tag.....
<?
php }
?>

that way, the image is always produced, but the link tags are inside the php, and don't get printed for anonymous users
mark

thank's for your reply. i

margaridacarvalho - March 10, 2009 - 14:06

thank's for your reply.
i would like to try the php solution. where do i put the php code?

In the page. Use input format

HershelSR - March 22, 2009 - 14:02

In the page. Use input format PHP.

--
CiviHosting - Drupal Hosting at its Best

FYI

nathanjo - March 23, 2009 - 03:24

you need to enable first the PHP Filter under admin/build/modules

I've tried the php code but

margaridacarvalho - March 26, 2009 - 10:53

I've tried the php code but i'm getting the error "Parse error: parse error in C:\xampp\htdocs\drupal6\includes\common.inc(1648) : eval()'d code on line 4". I know that is a syntax error. The problem is that i don't know that much about php, actually i know very few...

Here is the code that i have in my page:

<p><img src="sites/default/files/imagensprodutoscatalogo/sextavados/sextavados1.png" alt="" /></p>

<?php
if (in_array('anonymous',$GLOBALS['user']->roles)){?{>
<
a href="sites/default/files/imagensprodutoscatalogo/produtospdf/din508.pdf">
<?
php }
?>


<?php
if (in_array('anonymous',$GLOBALS['user']->roles)){?{>
</
a>
<?
php }
?>

Can someone tell me where is the error?

<p><img

HershelSR - March 26, 2009 - 12:18

<p><img src="sites/default/files/imagensprodutoscatalogo/sextavados/sextavados1.png" alt="" /></p>

<?php
if (in_array('anonymous',$GLOBALS['user']->roles)){ ?>

<a href="sites/default/files/imagensprodutoscatalogo/produtospdf/din508.pdf">
<?php }
?>


<?php
if (in_array('anonymous',$GLOBALS['user']->roles)){ ?>

</a>
<?php }
?>

or even cleaner:

<p><img src="sites/default/files/imagensprodutoscatalogo/sextavados/sextavados1.png" alt="" /></p>

<?php
if (in_array('anonymous',$GLOBALS['user']->roles)) {
  echo
'<a href="sites/default/files/imagensprodutoscatalogo/produtospdf/din508.pdf"> ';
}
?>


<?php
if (in_array('anonymous',$GLOBALS['user']->roles)) {
  echo
'</a>';
}
?>

--
CiviHosting - Drupal Hosting at its Best

no link for any users

margaridacarvalho - March 26, 2009 - 12:31

thank you for the quick reply!
I've tried both code suggestions. I don't have the error anymore and the image appears but no link, whether i logged as autenticated or as anonymous user.
what may went wrong?

I just checked your syntax,

HershelSR - March 26, 2009 - 13:28

I just checked your syntax, not your logic. Try to look for

anonymous user

not just "anonymous"

--
CiviHosting - Drupal Hosting at its Best

Path Access

redben - October 14, 2009 - 13:40
 
 

Drupal is a registered trademark of Dries Buytaert.