function track_da_files_export_user_datas_csv in Track da files 7
User specific csv export function.
1 call to track_da_files_export_user_datas_csv()
- track_da_files_table_export_user_report in includes/
track_da_files.admin.inc - Exports the track da files table in csv for a specific user.
File
- includes/
track_da_files.admin.inc, line 1040 - Administrative page callbacks for Track da files module.
Code
function track_da_files_export_user_datas_csv($variables, $uid) {
// We strip html for before exporting into csv file.
foreach ($variables['rows'] as $key => $record) {
foreach ($record as $key2 => $row) {
$rows[$key][$key2] = strip_tags($row);
}
}
$variables['rows'] = $rows;
drupal_add_http_header('Content-Type', 'text/csv; utf-8');
$user = user_load($uid);
if (!empty($user->name)) {
$username = check_plain($user->name);
drupal_add_http_header('Content-Disposition', 'attachment; filename=' . $username . '-' . date('Ymd-his') . '-uid' . $uid);
}
else {
drupal_add_http_header('Content-Disposition', 'attachment; filename=anonymous-users-' . date('Ymd-his') . '-uid' . $uid);
}
$output = '';
$keys = array();
foreach ($variables['header'] as $key => $value) {
$keys[] = $value['data'];
}
if ($keys) {
$output .= implode("\t", $keys) . "\n";
}
foreach ($variables['rows'] as $value) {
$output .= implode("\t", $value) . "\n";
}
print $output;
exit;
}