How to trigger access denied page from hook_nodeapi
Hi Drupal friends I'd like to trigger a access denied page from my hook_nodeapi function up on $op=view. I already tried: unset($node->content); drupal_access_denied(); This gives me a strange result: two access denied pages after each other. Thanks for giving me a hand! Best Regards Ernst
On Tue, 2010-01-26 at 17:42 +0100, Ernst Plüss wrote:
Hi Drupal friends
I'd like to trigger a access denied page from my hook_nodeapi function up on $op=view.
I already tried:
unset($node->content); drupal_access_denied();
This gives me a strange result: two access denied pages after each other.
Thanks for giving me a hand! Best Regards Ernst
You'd better use hook_menu_alter() replace the 'access callback' with a custom access function for the 'node/%' menu entry. Your custom access function will do your custom tests, and if they are OK then return the node_access() function result. Pierre.
Thanks Piere! It does exactly what I wanted to do. See this blog post for more information http://www.pluess-production.ch/content/show-drupal-node-exactly-one-time Best Reagrds Ernst
Hi Ernst - I read your blog post. It seems to me that your assumption that the author is the viewer when the node is viewed one time is plausible, but not ironclad. It probably works if the data is not really important, but in a real-life situation a race condition on viewing could have someone else view it before the node creator. -Randy On Tue, Jan 26, 2010 at 1:00 PM, Ernst Plüss <ernst.pluess@gmail.com> wrote:
Thanks Piere! It does exactly what I wanted to do.
See this blog post for more information http://www.pluess-production.ch/content/show-drupal-node-exactly-one-time
Best Reagrds Ernst
-- Randy Fay Drupal Development, troubleshooting, and debugging randy@randyfay.com +1 970.462.7450
Hi Randy In general you are right. Let's say the node is automatically promoted to the start page. I think in my situation this cannot happen. The cck form is used as a more flexible replacement for a webform. Anonymous users are allowed to create new nodes. They should get the filled form exactly once in order to print it for their records. Afterwards the node goes through a work flow which is only visible for a certain user group. Best Regards Ernst
Also be sure you test any solution with cache turned on. This may require the hook_menu() approach, since hook_nodeapi() may not work as expected. On Wed, Jan 27, 2010 at 3:03 AM, Ernst Plüss <ernst.pluess@gmail.com> wrote:
Hi Randy
In general you are right. Let's say the node is automatically promoted to the start page.
I think in my situation this cannot happen. The cck form is used as a more flexible replacement for a webform. Anonymous users are allowed to create new nodes. They should get the filled form exactly once in order to print it for their records. Afterwards the node goes through a work flow which is only visible for a certain user group.
Best Regards Ernst
-- Ken Rickard agentrickard@gmail.com http://ken.therickards.com
On Tue, 2010-01-26 at 21:00 +0100, Ernst Plüss wrote:
Thanks Piere! It does exactly what I wanted to do.
See this blog post for more information http://www.pluess-production.ch/content/show-drupal-node-exactly-one-time
Ah, I forgot, using the hook_menu_alter() may interfer with others modules. Make sure that modules you are using do not alter the same menu entry, or you could have bad surprises. If you use such modules, take that into account and call each of them access callback into your, even you can do a generic callback introspection at menu_alter time to find it. Pierre.
IIRC, you can also just call exit(); after drupal_access_denied(), though I would expect the hook_menu_alter method is more efficient, if only because you avoid triggering all the other (preceding) modules hook_nodeapi('view') implementations unnecessarily. Best, Matt On Tue, Jan 26, 2010 at 8:42 AM, Ernst Plüss <ernst.pluess@gmail.com> wrote:
Hi Drupal friends
I'd like to trigger a access denied page from my hook_nodeapi function up on $op=view.
I already tried:
unset($node->content); drupal_access_denied();
This gives me a strange result: two access denied pages after each other.
Thanks for giving me a hand! Best Regards Ernst
On Tue, 2010-01-26 at 17:42 +0100, Ernst Plüss wrote:
Hi Drupal friends
I'd like to trigger a access denied page from my hook_nodeapi function up on $op=view.
Another way is working with the hook_node_grants(), but this is a total mess, I never figured out how does it work exactly. I think the guy which have implemented this one must have some brain damage. Pierre.
On Wed, Jan 27, 2010 at 8:18 AM, Pierre R. <pierre.rineau@makina-corpus.com> wrote:
Another way is working with the hook_node_grants(), but this is a total mess, I never figured out how does it work exactly. I think the guy which have implemented this one must have some brain damage.
Actually, the hook_node_grants() / hook_node_access_records() system is effective and powerful. If you can improve on it, patches are welcome. In any case, it's a bold move to insult the mental ability of someone else because you can't understand their work.... -Matt
On Jan 28, 2010, at 10:04 AM, Matt Chapman wrote:
On Wed, Jan 27, 2010 at 8:18 AM, Pierre R. <pierre.rineau@makina-corpus.com> wrote:
Another way is working with the hook_node_grants(), but this is a total mess, I never figured out how does it work exactly. I think the guy which have implemented this one must have some brain damage.
In any case, it's a bold move to insult the mental ability of someone else because you can't understand their work....
If the guy who wrote it had brain damage, and you can't understand it, what does that say about your brain?!?!! (Please note: this message not intended to be taken seriously ;) -D
On Thu, 2010-01-28 at 10:55 -0800, Domenic Santangelo wrote:
On Jan 28, 2010, at 10:04 AM, Matt Chapman wrote:
On Wed, Jan 27, 2010 at 8:18 AM, Pierre R. <pierre.rineau@makina-corpus.com> wrote:
Another way is working with the hook_node_grants(), but this is a total mess, I never figured out how does it work exactly. I think the guy which have implemented this one must have some brain damage.
In any case, it's a bold move to insult the mental ability of someone else because you can't understand their work....
If the guy who wrote it had brain damage, and you can't understand it, what does that say about your brain?!?!!
(Please note: this message not intended to be taken seriously ;)
-D
NP, I never though my brain was better than anyother's brain! Mine is pretty fucked up I'm sure:) Pierre.
On Thu, 2010-01-28 at 10:04 -0800, Matt Chapman wrote:
On Wed, Jan 27, 2010 at 8:18 AM, Pierre R. <pierre.rineau@makina-corpus.com> wrote:
Another way is working with the hook_node_grants(), but this is a total mess, I never figured out how does it work exactly. I think the guy which have implemented this one must have some brain damage.
Actually, the hook_node_grants() / hook_node_access_records() system is effective and powerful. If you can improve on it, patches are welcome. In any case, it's a bold move to insult the mental ability of someone else because you can't understand their work....
-Matt
I did that intentionnally, I indeed think it's a great API, but I think the documentation about it isn't so great, it's effective (I did use a lot of modules using it) but IMHO it's against the KISS principle (or just not well documented). I apologies to the people who did it, it's I'm pretty sure great code, but pretty hard to understand. Pierre.
participants (7)
-
Domenic Santangelo -
Ernst Plüss -
Ken Rickard -
Matt Chapman -
Pierre R. -
Pierre Rineau. -
Randy Fay