Some recursive functions call get_categories() repeatedly to get all of the
child categories of the current one.
This commit create a lazily-initialized cache of all of the categories so
that the database is only queried once to retrieve all of the categories.
It speeds up the both the homepage and the course edit page (where the
categories are displayed in combo boxes).