[development] Blocks and page context
merlin at logrus.com
Sat Apr 24 00:27:03 UTC 2010
E.J. Zufelt wrote:
> Good evening,
> Thanks for this.
> I took a look at user_access() but wasn't sure that it would do what I
> needed. I have to admit to being a newbie as far as Drupal
> development goes. I normally work on cor accessibility.
> As far as user_access() I see that it can accept a user object, but
> that it also needs me to pass a permission to check. What permission
> would I be checking to see if the current system path can be accessed?
> This is why menu_get_item() seemed more appropriate. It would be
> nice if there was a function like menu_get_item() that accepted the
> user object like user_access() does. Perhaps I'll ad an issue as a
> feature request for d8 if this doesn't already exist in some hidden
> corner of d6.
Context is a major weakness in Drupal right now and there is currently a
lot of discussion on what to do about that in D8. As for what you can do
right now, your global $user hack is probably the only thing you can
actually do. it's not elegant at all, but in a contrib module...be very
very careful you don't change the $user identity once you're done (so
make sure all possible failure scenarios are covered).
More information about the development