[development] modify permissions using hook_menu_alter()

Lluís enboig at gmail.com
Tue Apr 28 22:34:37 UTC 2009


Returning to the original post which was mine; I post what I have and
what I want to do, and then discuss the best way to do that, If lot of
people have the same needs as I do, then new drupal version "could" be
implemented to make things easy.

I have implemented a module with a functionally similar to OG, but
using $_SESSION to save the active group. After this node records and
node grants are done according to $_SESSION (and saved to a table to
allow permission rebuild).
Now I want to give a user permission to post when he have some groups
active and not for some  others, so I created a role with posting
permissions and I have to put it in $user->roles just when $_SESSION
tells me to do this.

I make it in hook_boot because another module with similar
functionality for OG was doing this way. Is this a good way to do
this? I think its better than doing this in hook_menu or
hook_menu_alter because "new" groups are available from the beginning;
but I will gladly listen to any constructive comments.


And thanks to eveyone


On Wed, Apr 29, 2009 at 12:26 AM, Earnie Boyd
<earnie at users.sourceforge.net> wrote:
> Quoting Karoly Negyesi <karoly at negyesi.net>:
>
>>> But the routing is built only when visiting some pages or after emptying
>>> the
>>> cache.
>>
>> Wrong. No matter how much cache you clear, the menu_router table won't
>> be rebuilt. This is why I stepped in: I do not want false information
>> to be spread. Indeed specific admin pages trigger a menu rebuild and
>> that's it.
>>
>
> So when is hook_menu called?  I use the devel module to ``Empty Cache'' to
> cause new items in my custom module to be generated on the menu.  The
> hook_menu isn't called until I ``Empty Cache''.  So it appears to from the
> DX perspective that emptying the cache rebuilds the menu.
>
> --
> Earnie
> -- http://r-feed.com/           -- http://for-my-kids.com/
> -- http://www.4offer.biz/       -- http://give-me-an-offer.com/
>
>
>



-- 
*La vida és com una taronja, que esperes a exprimir-la?
*Si creus que l'educació és cara, prova la ignorància.
*La vida és com una moneda, la pots gastar en el que vulguis però
només una vegada.
*Abans d'imprimir aquest missatge, pensa en el medi ambient.


More information about the development mailing list