Commit 0b168c78 authored by quicksketch's avatar quicksketch

#756658: Fix Preview with Private File system.

parent d510b348
......@@ -154,8 +154,10 @@ function filefield_file_download($file) {
}
}
}
// If no file field item is involved with this file, we don't care about it.
if (empty($cck_files)) {
// If no file field item is involved with this file, we don't care about it,
// unless it's a newly uploaded image that isn't yet associated with a field.
if (empty($cck_files) && !($file->status == 0 && isset($_SESSION['filefield_access']) && in_array($file->fid, $_SESSION['filefield_access']))) {
return;
}
......@@ -292,8 +294,12 @@ function filefield_widget_settings($op, $widget) {
* Implementation of hook_widget().
*/
function filefield_widget(&$form, &$form_state, $field, $items, $delta = 0) {
if (module_exists('devel_themer') && (user_access('access devel theme information') || user_access('access devel information'))) {
drupal_set_message(t('Files may not be uploaded while the Theme Developer tool is enabled. It is highly recommended to <a href="!url">disable this module</a> unless it is actively being used.', array('!url' => url('admin/build/modules'))), 'error');
}
// CCK doesn't give a validate callback at the field level...
// and FAPI's #require is naieve to complex structures...
// and FAPI's #require is naive to complex structures...
// we validate at the field level ourselves.
if (empty($form['#validate']) || !in_array('filefield_node_form_validate', $form['#validate'])) {
$form['#validate'][] = 'filefield_node_form_validate';
......
......@@ -360,6 +360,11 @@ function filefield_widget_process($element, $edit, &$form_state, $form) {
);
}
// Grant access to temporary files.
if ($item['fid'] && isset($item['status']) && $item['status'] == 0 && variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
$_SESSION['filefield_access'][] = $item['fid'];
}
// placeholder.. will be serialized into the data column. this is a place for widgets
// to put additional data.
$element['data'] = array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment