Hi Gustav,
I haven't spent much time working with the calendar as a guest (that's probably why now that I logged in to check some things for this answer I got about five "I need to do this" thoughts in a row) but after having a look:
I think the existing code base will do just exactly what you describe. Are you getting different behavior, and if so, in what way? In order to do that kind of thing with calendar_get_side_blocks(), here's what needs to be done:
- Get the calendar_set_filters function call out of the first if (in fact, that's a bug waiting to happen right there... what if later, when preferences are expanded, that if doesn't execute but the next one does?)
- Give the function optional parameters with default values and alter it to use them, if present.
However, if you familiarize yourself with the code, you will see that I have intentionally made almost all layers of the calendar code take parameters for the courses, userids, groupids etc. whose events they should work on. The calendar_print_side_blocks() function is the very topmost layer, to provide an "interface" to "external" (to the calendar) parts of Moodle.
If displaying this kind of thing in the front page is going to be included in Moodle, then it would be worth to change or add a few functions like this one to provide external code with this functionality. Otherwise, I would suggest to do this programmatically for your site. It isn't difficult:
// You need to do this before the first call to any calendar_
// functions, so for the time being I call it from... everywhere.
calendar_session_vars();
// This destroys the course filtering that the user may have in
// place (if he's not a guest). A negligible inconvenience, and
// we DO have to show events from ALL courses.
$SESSION->cal_show_course = true;
// OverLib
echo calendar_overlib_html();
print_side_block_start(get_string('calendar', 'calendar'));
echo calendar_top_controls('course', array('id' => $course->id, 'm' => $_GET['cal_m'], 'y' => $_GET['cal_y']));
// The first three arguments mean: events from all courses,
// group events from all courses, and for this user only
echo calendar_get_mini(true, true, $USER->id, $_GET['cal_m'], $_GET['cal_y']);
echo calendar_filter_controls('course');
print_side_block_end();