Fix #1654

Avoid unviewable most popular forum caching by checking them inside the
function instead of relying on a global variable available only in
stats.php (while the function is used in several places).

https://github.com/mybb/mybb/issues/1654
What about not caching it? Then when we display it, we check the permissions there.