Setup:
I have a main module (called public) and several sub-modules that extend the support offered by the public module.
A sub-module (let's call it sub) functions can be accesed only by users with the role that that sub-module creates (guess what, called sub).
Some of the pages defined in public_menu() are extended by the pages defined by sub_menu().
For example, if the public module declares:
$pages["public/asl/info"] = array('page callback'=>'public_asl_info', ...);
the sub module declares:
$pages["sub/asl/info"] = array('page callback'=>'sub_asl_info', ...);
also, consider that sub_asl_info() extend public_asl_info() like this:
function sub_asl_info( $id)
{
$public_page = public_asl_info( $id);
$dip_page = sub_asl_dip_info( $id);
$page = $public_page.$dip_page;
return $page;
}
there are more complex cases, but this is enough to explain the setup :)
How i solved it (wrongly) so far:
function sub_menu_alter( &$item)
{
if( !has_role( 'sub'))
return;
$item['public/asl/info'] = $item['sub/asl/info'];
$item["public/operatori/info"] = $item["sub/operatori/info"];
$item["public/ospiti/info"] = $item["sub/schedario"];
$item["public/query"] = $item["sub/query"];
$item["public/tassonomia"] = $item["sub/tassonomia"];
$item["public/comunicazioni"] = $item["sub/comunicazioni"];
}
The redirects are hard saved inside the menu_router table, so with more than one user logged it doesn't work.
I came to this solution based on how i solved the same problem but for blocks, however, using _block_view_alter() doesn't hit the same wall.
How do i solve this (programmatically)?
Possibly without using yet-another-module, unless really neccessary.