add some error handling for studygroup csv report

This commit is contained in:
Nathan Coad
2018-06-17 09:15:10 +10:00
parent f672e32ba0
commit fb59029be1

View File

@@ -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', "<pre>Study Group CSV Report\n@info</pre>", 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);