diff --git a/booking.studygroups_report.inc b/booking.studygroups_report.inc index c461381..cf19930 100644 --- a/booking.studygroups_report.inc +++ b/booking.studygroups_report.inc @@ -42,6 +42,13 @@ function booking_studygroups_csv_report($group_id) { WHERE m.booking_studygroup_id = :sid ORDER BY m.booking_session_id, m.booking_studygroup_role DESC, p.booking_lastname", array(':sid' => $group_id)); $session_members = $session_members_query->fetchAll(); + + // Check if we had no data added, that means there were no people in this study group + if (! $session_members) { + drupal_set_message("Error: Study group $group_id has no members assigned.", 'error', FALSE); + drupal_goto('admin/booking/studygroups'); + return ""; + } //generate the row data foreach ($session_members as $member) { @@ -70,7 +77,8 @@ function booking_studygroups_csv_report($group_id) { // Check if we had no data added, that means there were no people in this study group if (empty($data)) { - drupal_set_message("Error: Study group $group_id has no people assigned.", 'error', FALSE); + drupal_set_message("Error: Study group $group_id has no people assigned.", 'error', FALSE); + drupal_goto('admin/booking/studygroups'); return ""; }