? .bzr ? 140932_1.patch ? 142995_4.patch ? AUTHOR ? README.txt ? formapi_file-220944-4.patch ? generate-content.php ? generate-og-users.php ? generate-og2list-mail.php ? generate-taxonomy.php ? generate-users.php ? import-taxonomy-terms.php ? import-users.php ? link ? update-teaser.php ? modules/gd ? sites/default/files ? sites/default/modules ? sites/default/settings.php Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.267 diff -u -u -r1.267 form.inc --- includes/form.inc 12 Feb 2008 13:52:32 -0000 1.267 +++ includes/form.inc 19 Feb 2008 03:17:12 -0000 @@ -1250,6 +1250,19 @@ } /** + * Helper function to determine the value for a file field element. + */ +function form_type_file_value($form, $edit = FALSE) { + if ($edit !== FALSE) { + // Retrieve the name of the file field. + $name = substr($form['#name'], 6, -1); + // Save the file and return false when it fails. + $file = file_save_upload($name, $form['#file_validators'], $form['#filepath']); + return $file === 0 ? FALSE : $file; + } +} + +/** * Helper function to determine the value for form's token value. * * @param $form Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.591 diff -u -u -r1.591 system.module --- modules/system/system.module 18 Feb 2008 19:19:47 -0000 1.591 +++ modules/system/system.module 19 Feb 2008 03:17:12 -0000 @@ -180,7 +180,7 @@ $type['select'] = array('#input' => TRUE, '#size' => 0, '#multiple' => FALSE, '#process' => array('form_expand_ahah')); $type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#process' => array('process_weight', 'form_expand_ahah')); $type['date'] = array('#input' => TRUE, '#process' => array('expand_date'), '#element_validate' => array('date_validate')); - $type['file'] = array('#input' => TRUE, '#size' => 60); + $type['file'] = array('#input' => TRUE, '#size' => 60, '#file_validators' => array(), '#filepath' => file_directory_path()); // Form structure $type['item'] = array('#value' => ''); Index: modules/upload/upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v retrieving revision 1.198 diff -u -u -r1.198 upload.module --- modules/upload/upload.module 12 Feb 2008 13:49:01 -0000 1.198 +++ modules/upload/upload.module 19 Feb 2008 03:17:12 -0000 @@ -168,15 +168,9 @@ function upload_node_form_submit($form, &$form_state) { global $user; - $limits = _upload_file_limits($user); - $validators = array( - 'file_validate_extensions' => array($limits['extensions']), - 'file_validate_image_resolution' => array($limits['resolution']), - 'file_validate_size' => array($limits['file_size'], $limits['user_size']), - ); - // Save new file uploads. - if (($user->uid != 1 || user_access('upload files')) && ($file = file_save_upload('upload', $validators, file_directory_path()))) { + if (!empty($form_state['values']['upload'])) { + $file = $form_state['values']['upload']; $file->list = variable_get('upload_list_default', 1); $file->description = $file->filename; $file->weight = 0; @@ -494,27 +488,31 @@ } } - if (user_access('upload files')) { - $limits = _upload_file_limits($user); - $form['new']['#weight'] = 10; - $form['new']['upload'] = array( - '#type' => 'file', - '#title' => t('Attach new file'), - '#size' => 40, - '#description' => ($limits['resolution'] ? t('Images are larger than %resolution will be resized. ', array('%resolution' => $limits['resolution'])) : '') . t('The maximum upload size is %filesize. Only files with the following extensions may be uploaded: %extensions. ', array('%extensions' => $limits['extensions'], '%filesize' => format_size($limits['file_size']))), - ); - $form['new']['attach'] = array( - '#type' => 'submit', - '#value' => t('Attach'), - '#name' => 'attach', - '#ahah' => array( - 'path' => 'upload/js', - 'wrapper' => 'attach-wrapper', - 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), - ), - '#submit' => array('node_form_submit_build_node'), - ); - } + $limits = _upload_file_limits($user); + $form['new']['#weight'] = 10; + $form['new']['#access'] = user_access('upload_files'); + $form['new']['upload'] = array( + '#type' => 'file', + '#title' => t('Attach new file'), + '#size' => 40, + '#description' => ($limits['resolution'] ? t('Images are larger than %resolution will be resized. ', array('%resolution' => $limits['resolution'])) : '') . t('The maximum upload size is %filesize. Only files with the following extensions may be uploaded: %extensions. ', array('%extensions' => $limits['extensions'], '%filesize' => format_size($limits['file_size']))), + '#file_validators' => array( + 'file_validate_extensions' => array($limits['extensions']), + 'file_validate_image_resolution' => array($limits['resolution']), + 'file_validate_size' => array($limits['file_size'], $limits['user_size']), + ), + ); + $form['new']['attach'] = array( + '#type' => 'submit', + '#value' => t('Attach'), + '#name' => 'attach', + '#ahah' => array( + 'path' => 'upload/js', + 'wrapper' => 'attach-wrapper', + 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), + ), + '#submit' => array('node_form_submit_build_node'), + ); // This value is used in upload_js(). $form['current']['vid'] = array('#type' => 'hidden', '#value' => isset($node->vid) ? $node->vid : 0);