From fb59029be1032fae9a14b3374c4899777e6b74c4 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 17 Jun 2018 09:15:10 +1000 Subject: [PATCH] add some error handling for studygroup csv report --- booking.studygroups_report.inc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/booking.studygroups_report.inc b/booking.studygroups_report.inc index ddac8e4..c461381 100644 --- a/booking.studygroups_report.inc +++ b/booking.studygroups_report.inc @@ -19,8 +19,7 @@ function booking_studygroups_csv_report($group_id) { array(':eid' => $event->eid, ':sid' => $group_id)) ->fetchObject(); - if (! $group) - { + if (! $group) { drupal_set_message("Error: Could not find matching study group ID. Unable to view group membership.", 'error', FALSE); drupal_goto('admin/booking/studygroups'); return ""; @@ -66,9 +65,14 @@ function booking_studygroups_csv_report($group_id) { } //add the spaces and put this element in the right array $data[$member->booking_session_id][] = implode(' ', $text); - } //watchdog('booking_debug', "
Study Group CSV Report\n@info
", array('@info' => print_r( $data_array, true))); + + // 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); + return ""; + } //calculate the CSV layout $header_array = array_keys($data);