you want to completely reload the capabilities for the current user.
Basically it will deal nicely with the default site-wide permissions
depending on the current user.
More background in the comments on MDL-6963
Merged from stable
All the page headers work correctly also on the site course.
On the site page the modules don't require login unless necessary or required by $CFG->forcelogin.