MDL-38147 Performance improvements to coursecat class:

- Retrieve and cache only often-used fields of course category
- Removed function coursecat::get_all_visible() as potentially causing performance issues
- removed function coursecat::get_all_parents() as ineffective and unnecessary, replaced with get_parents()

Also some code improvements:
- rename functions starting with _ , rename arguments, etc.
MDL-38147 event-driven cache purging for course categories
MDL-38147 added event changesincourse
MDL-38147 replaced function coursecat::get_all_ids() with coursecat::get_tree()
MDL-38147 Added function coursecat::get_children() to retrieve subcategories

Caching results, sorting categories, retrieve only those that are displayed. Added tests
MDL-38147 Added function coursecat::search_courses(), get_courses()

Also search_courses_count(), get_courses_count()
- MDL-38147 attempt to preload course contacts