Commit 85a1cea7 authored by drumm's avatar drumm

#98391 by RobRoy. Don't show the file upload field if the files directory won't work.

parent 437a4982
......@@ -377,8 +377,22 @@ function upload_form_alter($form_id, &$form) {
'#prefix' => '<div id="attach-wrapper">',
'#suffix' => '</div>',
);
$form['attachments']['wrapper'] += _upload_form($node);
$form['#attributes']['enctype'] = 'multipart/form-data';
// Make sure necessary directories for upload.module exist and are
// writable before displaying the attachment form.
if (!file_check_directory(file_directory_path(), FILE_CREATE_DIRECTORY) || !file_check_directory(file_directory_temp(), FILE_CREATE_DIRECTORY)) {
$form['attachments']['#description'] = t('File attachments are disabled. The file directories have not been properly configured.');
if (user_access('administer site configuration')) {
$form['attachments']['#description'] .= ' '. t('Please visit the <a href="@admin-file-system">file system configuration page</a>.', array('@admin-file-system' => url('admin/settings/file-system')));
}
else {
$form['attachments']['#description'] .= ' '. t('Please contact the site administrator.');
}
}
else {
$form['attachments']['wrapper'] += _upload_form($node);
$form['#attributes']['enctype'] = 'multipart/form-data';
}
}
}
}
......
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