postcards viewable by anonymous users

Dublin Drupaller - December 14, 2004 - 22:19
Project:Postcard
Component:Code
Category:feature request
Priority:normal
Assigned:axel
Status:closed
Description

Hi Alex,

Sorry to ask this again...but I changed the postcard.module as you advised..i.e. the new postcard_page deifinition is:

$card = db_fetch_object(db_query("SELECT p.*, i.image_path, i.thumb_path, i.width, i.height, i.filesize FROM {postcard} p INNER JOIN {image} i ON p.nid = i.nid INNER JOIN {node} n ON n.nid = p.nid WHERE p.pid = '%s'", $arg2));

But anonymous users still cn't view the postcards.

Am I forgetting/overlooking something very obvious? or is there something else I need to tweak?

Cheers

Jason

#1

Dublin Drupaller - December 15, 2004 - 12:44

*bump*

#2

axel - December 15, 2004 - 16:01
Component:Miscellaneous» Code
Assigned to:Anonymous» axel

Hm, probably I don't take into account some mechanisms for checking permissions in Drupal. Jason, I will test this feature today later and I think upload new solution today or tomorrow.

#3

Dublin Drupaller - December 15, 2004 - 16:15

Hi Alex...

Not sure if this will help..but.....I tried doing the following:

1. inserted a permission hook so I could set VIEW POSTCARDS under
ADMINISTER - USERS - CONFIGURE - PERMISSIONS..i.e.

function postcard_perm() {
  return array('administer postcards', 'send postcards', 'view postcards');
}

2. changed the line in the postcard_page function where it outputs the postcard page so it checks to see if user access has view postcards privilages...so instead of just

if {$card) {
$title = t('Postcard for you');
$output = theme('postcard_image', $card);
      }

now it reads:

if ($card && (user_access('view postcards'))) {
$title = t('Postcard for you');
$output = theme('postcard_image', $card);
      }

After implementing the above I was succesfully able to toggle the view postcards option for logged in users...but it had no effect on non-logged/anonymous in users.....

Jason

#4

Dublin Drupaller - December 15, 2004 - 16:18

addendum to previous message...

sorry.. correction...i wasn't able to toggle view postcards...

J

#5

axel - December 16, 2004 - 22:14

Jason, I test this feature on local postcard installation - this works when 'access content' disabled for all user roles. Situation even more funny: I test it on unmodified module :) Seems, you don't need SQL changes. And now I remember how me made it :) - module completely ignore 'access content', because postcards is not nodes (probably this is a bug and 'access content' permission must apply to any site content?). Any visitor may view postcard, but send postcard may only user with enabled permission 'send postcards'.

Test again, I think module must work as you want.

#6

axel - December 16, 2004 - 23:35

New version uploaded to CVS. Next set of permissions:

'view postcards' - user may view created by another user postcards

'send postcards' - user may create postcards and view created by himself postcards

'access content' still ignored, because postcard is not a node.

#7

Dublin Drupaller - December 17, 2004 - 11:05

Hi Axel,

Thanks for posting the new version. I downloaded it and installed it.

I think it's nearly there i.e. allowing anonymous users to VIEW POSTCARDS.

With the new version both SEND POSTCARDS & VIEW POSTCARDS need to be enabled for anonymous users to view postcards.

Just VIEW POSTCARDS enabled on its own under ADMINISTER - USERS - CONFIGURE - PERMISSIONS isn't enough...

Will have a look at the new module and see if I can work out a hack from there and post back up here if I find a solution..

Jason

#8

Anonymous - December 31, 2004 - 11:15
 
 

Drupal is a registered trademark of Dries Buytaert.