Index: webform_report.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform_report/Attic/webform_report.inc,v
retrieving revision 1.1.2.27.2.8
diff -u -r1.1.2.27.2.8 webform_report.inc
--- webform_report.inc 24 Sep 2010 15:18:07 -0000 1.1.2.27.2.8
+++ webform_report.inc 24 Sep 2010 15:30:38 -0000
@@ -519,14 +519,37 @@
// handle file type
if ($type == 'file') {
- $tmp = unserialize($raw[0]);
+
$link = ' ';
- if (!empty($tmp['filename'])) {
- $link = '' .
- $tmp['filename'] . ' (' . (int) ($tmp['filesize'] / 1024) .' KB)' .
- '';
+ $text = '';
+
+ // new file handling in webforms 6.x-3.x - data is an id
+ if (is_numeric($raw[0])) {
+ // must load the webform file component handler
+ module_load_include('inc', 'webform', 'components/file');
+ $file = webform_get_file($raw[0]);
+ if (!empty($file->fid)) {
+ $text = webform_file_name($file->filepath);
+ $path = webform_file_url($file->filepath);
+ $link = '' .
+ $text . '' .
+ ' (' . (int) ($file->filesize/1024) . ' KB)';
+ }
+ }
+ // file handling for prior versions of webforms - data is serialized fileinfo
+ else {
+ $tmp = unserialize($raw[0]);
+ if (!empty($tmp['filename'])) {
+ $text = $tmp['filename'];
+ $path = base_path() . $tmp['filepath'];
+ $link = '' .
+ $text . '' .
+ ' (' . (int) ($tmp['filesize'] / 1024) .' KB)';
+ }
}
- $out = array('data' => $link, 'field' => $cid, 'sort' => $tmp['filepath']);
+
+ // output file column - save path for later
+ $out = array('data' => $link, 'field' => $cid, 'sort' => $text, 'path' => $path);
}
// handle dates
@@ -534,10 +557,18 @@
$ts = 0;
// if report date
if ($cid > 0) {
- // if date was selected
- if ($raw[0] && $raw[1]) {
- // make timestamp, dates are stored month, day, year
- $ts = strtotime($raw[0] .'/'. $raw[1] .'/'. $raw[2]);
+ // handle webforms 6.x-3.x dates
+ if (count($raw) == 1) {
+ // date is stored as yyyy-mm-dd
+ $ts = strtotime($raw[0]);
+ }
+ // handle prior webforms versions
+ else {
+ // if date was selected
+ if ($raw[0] && $raw[1]) {
+ // make timestamp, dates are stored month, day, year
+ $ts = strtotime($raw[0] .'/'. $raw[1] .'/'. $raw[2]);
+ }
}
}
// otherwise get submission timestamp
@@ -559,10 +590,18 @@
else if ($type == 'time') {
$ts = 0;
if ($cid > 0) {
+ // handle webforms 6.x-3.x time
+ if (count($raw) == 1) {
+ // date is stored as hh:mm:ss
+ $ts = strtotime($raw[0]);
+ }
+ // handle prior webforms versions
+ else {
// if time was selected
- if ($raw[0] && $raw[1]) {
- // make timestamp, times are stored hh, mm, ampm
- $ts = strtotime($raw[0] . ':' . $raw[1] . $raw[2]);
+ if ($raw[0] && $raw[1]) {
+ // make timestamp, times are stored hh, mm, ampm
+ $ts = strtotime($raw[0] . ':' . $raw[1] . $raw[2]);
+ }
}
}
else {
@@ -863,7 +902,14 @@
foreach($rows as $row) {
$tmp = array();
foreach($row as $cell) {
- $tmp[] = _webform_report_format_csv_column(strip_tags($cell['data']));
+ // special handling for file types - use entire path
+ if (array_key_exists('path', $cell)) {
+ $data = $cell['path'];
+ }
+ else {
+ $data = strip_tags($cell['data']);
+ }
+ $tmp[] = _webform_report_format_csv_column($data);
}
$output .= implode(',', $tmp) . "\n";
}
@@ -882,7 +928,7 @@
function _webform_report_format_csv_column($value) {
// if value contains a comma, it should be delimited by quotes
- if (strpos($value, ',')) {
+ if (strpos($value, ',') !== FALSE) {
// if value contains quotes, double the quotes
if (strpos($value, '"')) {
return '"' . str_replace('"', '""', $value) . '"';