From 4fca95b79723ce6714a9d1d42978118699af0697 Mon Sep 17 00:00:00 2001
From: Nathan Gray <nathangray.bsc@gmail.com>
Date: Wed, 30 Jan 2013 19:52:30 +0000
Subject: [PATCH] Fix fatal error in export caused by field mismatch (not
 defined)

---
 calendar/inc/class.calendar_export_csv.inc.php | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/calendar/inc/class.calendar_export_csv.inc.php b/calendar/inc/class.calendar_export_csv.inc.php
index 6dc3a6c40b..f742d30b4e 100644
--- a/calendar/inc/class.calendar_export_csv.inc.php
+++ b/calendar/inc/class.calendar_export_csv.inc.php
@@ -38,6 +38,11 @@ class calendar_export_csv implements importexport_iface_export_plugin {
 			if($key[0] == '#') $cfs[] = substr($key,1);
 		}
 
+		$query = array(
+			'cfs'		=> $cfs, // Otherwise we shouldn't get any custom fields
+			'num_rows'	=> -1,
+			'csv_export'	=> true
+		);
 		switch($options['selection'])
 		{
 			case 'criteria':
@@ -113,11 +118,6 @@ class calendar_export_csv implements importexport_iface_export_plugin {
 				}
 				break;
 			case 'filter':
-				$query = array(
-					'cfs'		=> $cfs, // Otherwise we shouldn't get any custom fields
-					'num_rows'	=> -1,
-					'csv_export'	=> true
-				);
 				$fields = importexport_helper_functions::get_filter_fields($_definition->application, $this);
 				$filter = $_definition->filter;