function _webform_analysis_file in Webform 7.4
Same name and namespace in other branches
- 6.3 components/file.inc \_webform_analysis_file()
- 7.3 components/file.inc \_webform_analysis_file()
Implements _webform_analysis_component().
File
- components/
file.inc, line 497 - Webform module file component.
Code
function _webform_analysis_file($component, $sids = array(), $single = FALSE, $join = NULL) {
$query = db_select('webform_submitted_data', 'wsd', array(
'fetch' => PDO::FETCH_ASSOC,
))
->fields('wsd', array(
'no',
'data',
))
->condition('wsd.nid', $component['nid'])
->condition('wsd.cid', $component['cid']);
if (count($sids)) {
$query
->condition('wsd.sid', $sids, 'IN');
}
if ($join) {
$query
->innerJoin($join, 'ws2_', 'wsd.sid = ws2_.sid');
}
$nonblanks = 0;
$sizetotal = 0;
$submissions = 0;
$result = $query
->execute();
foreach ($result as $data) {
$file = webform_get_file($data['data']);
if (isset($file->filesize)) {
$nonblanks++;
$sizetotal += $file->filesize;
}
$submissions++;
}
$rows[0] = array(
t('Left Blank'),
$submissions - $nonblanks,
);
$rows[1] = array(
t('User uploaded file'),
$nonblanks,
);
$other[0] = array(
t('Average uploaded file size'),
$sizetotal != 0 ? (int) ($sizetotal / $nonblanks / 1024) . ' KB' : '0',
);
return array(
'table_rows' => $rows,
'other_data' => $other,
);
}