MDL-40854 fix mod/...:view capabilities

Prior to the fix, if you did not have a capability like mod/page:view,
then you woulds still see the link to the Page activity in the course
section, but when you clicked on it, you would run into a
require_capability error.

It is a principle that we never show users a link to a page they are not
allowed to access, therefore, when users do not have mod/...:view, they
should not see the link on the course page.

This patch implements this in the cm_info class, in a similar way to how
access restrictions by groups works.

It does not assume that the mod/...:view capability exists. If the
capability does not exist, then users are not prevented from seeing the
link.