// Create time filter options form.
$customdata = array('cmid' => $cm->id, 'individual' => $curindividual, 'group' => $groupid, 'startyear' => $course->startdate, 'params' => array('tab' => $tab));
$timefilter = new oublog_participation_timefilter_form(null, $customdata);
$start = $end = 0;
// If data has been received from this form.
if ($submitted = $timefilter->get_data()) {
    if ($submitted->start) {
        $start = strtotime('00:00:00', $submitted->start);
    }
    if ($submitted->end) {
        $end = strtotime('23:59:59', $submitted->end);
    }
} else {
    // Recieved via post back for tab useage.
    if ($start = optional_param('start', null, PARAM_INT)) {
        $timefilter->set_data(array('start' => $start));
        $start = strtotime('00:00:00', $start);
    }
    if ($end = optional_param('end', null, PARAM_INT)) {
        $timefilter->set_data(array('end' => $end));
        $end = strtotime('23:59:59', $end);
    }
}
// Customise data sought based on current tab.
switch ($tab) {
    case 1:
        $getposts = false;
        $getcomments = true;
        break;
    case 2:
        $getposts = false;