The requesting user is not always the same as the current user. The container class now allows a different user
to be set as the requesting user. All capability checks are done against the requesting user.
Also, the $requestinguser is passed to core_calendar_provide_event_action and core_calendar_is_event_visible
callback functions. These callback functions need to be updated in all activity modules to accept a $user parameter.
This commit does few tweaks and other performance improvements to
calendar_get_allowed_event_types to be more efficient. Also some minor
queries optimizations on the event form to fetch the list of courses
without groups.
Stop loading the context in the constructor if it hasn't been provided.
There is no need to load it by default. We should lazily load it when it
is required.
All external functions must check all capabilities before returning data.
The calendar API itself does not check capabilities (I wish it did), so we must be
careful exposing these functions to webservices.
The function calendar_get_default_courses is responsible for loading all variants of calendar
course lists.
1 the list of courses that the current user will see events for in the site calendar.
2 the list of courses the current user will see when they are looking at a specific course calendar.
3 the list of course calendars the current user can create / edit events in.
Consolidate the logic for the list of courses an admin will see in the calendar.
They will see all courses if calendar_admincanseeall is enabled.
They will see only courses they are enrolled in of calendar_admincanseeall is not enabled.
They will also see the current course, if they are admin and it is not already in the list.
This applies to the course selector and the create and update event forms.
The calendar link in the navigation block has also been changed to link to the current course calendar instead of the global
one.
It's quite common to have more than 50 events in a calendar month, but
we do not want to change the default value when the API is called in
other ways.