diff options
Diffstat (limited to 'modules/upload/upload.module')
-rw-r--r-- | modules/upload/upload.module | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/modules/upload/upload.module b/modules/upload/upload.module index 8237031cc..f52563d3e 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -145,11 +145,28 @@ function upload_file_download($file) { } function upload_form_alter($form_id, &$form) { - if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id) { - $form['workflow']['upload_'. $form['type']['#value']] = array( - '#type' => 'radios', '#title' => t('Attachments'), '#default_value' => variable_get('upload_'. $form['type']['#value'], 1), - '#options' => array(t('Disabled'), t('Enabled')), - ); + if (isset($form['type'])) { + if ($form['type']['#value'] .'_node_settings' == $form_id) { + $form['workflow']['upload_'. $form['type']['#value']] = array( + '#type' => 'radios', '#title' => t('Attachments'), '#default_value' => variable_get('upload_'. $form['type']['#value'], 1), + '#options' => array(t('Disabled'), t('Enabled')), + ); + } + if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) { + drupal_add_js('misc/progress.js'); + drupal_add_js('misc/upload.js'); + $form['attachments'] = array( + '#type' => 'fieldset', + '#title' => t('File attachments'), + '#collapsible' => TRUE, + '#collapsed' => empty($node->files), + '#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'), + '#prefix' => '<div class="attachments">', + '#suffix' => '</div>', + ); + $form['attachments'] += _upload_form($form['#node']); + $form['#attributes'] = array('enctype' => 'multipart/form-data'); + } } } @@ -234,13 +251,6 @@ function upload_nodeapi(&$node, $op, $arg) { } break; - case 'form': - if (variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) { - $output = upload_form($node); - $output['#attributes'] = array('enctype' => 'multipart/form-data'); - } - break; - case 'load': if (variable_get("upload_$node->type", 1) == 1) { $output['files'] = upload_load($node); @@ -401,20 +411,6 @@ function upload_delete($node) { db_query("DELETE FROM {files} WHERE nid = %d", $node->nid); } -function upload_form($node) { - drupal_add_js('misc/progress.js'); - drupal_add_js('misc/upload.js'); - - $form['attachments'] = array( - '#type' => 'fieldset', '#title' => t('File attachments'), '#collapsible' => TRUE, '#collapsed' => empty($node->files), - '#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'), - '#prefix' => '<div class="attachments">', '#suffix' => '</div>' - ); - $form['attachments'] += _upload_form($node); - - return $form; -} - function _upload_form($node) { $header = array(t('Delete'), t('List'), t('Description'), t('Size')); $rows = array(); |