From 85a1cea720b80547d430430bd27b437ba6b27d25 Mon Sep 17 00:00:00 2001 From: Neil Drumm Date: Tue, 28 Nov 2006 02:28:48 +0000 Subject: #98391 by RobRoy. Don't show the file upload field if the files directory won't work. --- modules/upload/upload.module | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/upload/upload.module b/modules/upload/upload.module index a45a0fcf3..3bf59f139 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -377,8 +377,22 @@ function upload_form_alter($form_id, &$form) { '#prefix' => '
', '#suffix' => '
', ); - $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 file system configuration page.', 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'; + } } } } -- cgit v1.2.3