Skip to content

Commit ec83c66

Browse files
committed
Correct the use of filenames. Always force a DL to the user.
1 parent d447abc commit ec83c66

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

os2web_cp_service.module

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,12 @@ function os2web_gf_service_handler($file_id) {
121121
drupal_add_http_header('Pragma', 'no-cache');
122122
}
123123

124-
// Load the title to use it as the filename.
125-
$query = new EntityFieldQuery();
126-
$result = $query
127-
->entityCondition('entity_type', 'node')
128-
->propertyCondition('type', 'os2web_cp_service_cp_document')
129-
->propertyCondition('status', 1)
130-
->fieldCondition('field_os2web_cp_service_file_id', 'value', $file_id, '=')
131-
->execute();
132-
$nids = (isset($result['node']))?array_keys($result['node']) : NULL;
133-
134-
$node = node_load(array_pop($nids));
135-
124+
$filename = str_replace('/', '_', $file_id . '.' . os2web_cp_service_get_extension_from_mime($header['content_type']));
136125
if ($node) {
126+
// If we can find the doc in DB, give it a real name.
137127
$filename = str_replace('/', '_', $node->field_os2web_cp_service_doc_id[LANGUAGE_NONE][0]['value'] . '.' . os2web_cp_service_get_extension_from_mime($header['content_type']));
138-
drupal_add_http_header('Content-Disposition', 'attachment; filename=' . $filename);
139128
}
129+
drupal_add_http_header('Content-Disposition', 'attachment; filename=' . $filename);
140130
echo $data;
141131
drupal_exit();
142132
}

0 commit comments

Comments
 (0)