diff --git a/file_entity.install b/file_entity.install index e22a16d..ff7ba62 100644 --- a/file_entity.install +++ b/file_entity.install @@ -237,6 +237,9 @@ function file_entity_uninstall() { // Remove variables. variable_del('file_entity_allow_insecure_download'); + variable_del('file_entity_file_upload_wizard_skip_file_type'); + variable_del('file_entity_file_upload_wizard_skip_scheme'); + variable_del('file_entity_file_upload_wizard_skip_fields'); } /** diff --git a/file_entity.module b/file_entity.module index d59ec0a..dc37684 100644 --- a/file_entity.module +++ b/file_entity.module @@ -439,6 +439,34 @@ function file_entity_form_system_file_system_settings_alter(&$form, &$form_state '#weight' => -10, '#description' => t('Separate extensions with a space or comma and do not include the leading dot.'), ); + + $form['file_upload_wizard'] = array( + '#type' => 'fieldset', + '#title' => t('File upload wizard'), + '#weight' => -9, + '#collapsible' => TRUE, + '#collapsed' => FALSE, + '#description' => t('Configure the steps available when uploading a new file.'), + ); + + $form['file_upload_wizard']['file_entity_file_upload_wizard_skip_file_type'] = array( + '#type' => 'checkbox', + '#title' => t('Skip filetype selection.'), + '#default_value' => variable_get('file_entity_file_upload_wizard_skip_file_type', FALSE), + '#description' => t('The file type selection step is only available if the uploaded file falls into two or more file types. If this step is skipped, files with no available file type or two or more file types will not be assigned a file type.'), + ); + $form['file_upload_wizard']['file_entity_file_upload_wizard_skip_scheme'] = array( + '#type' => 'checkbox', + '#title' => t('Skip scheme selection.'), + '#default_value' => variable_get('file_entity_file_upload_wizard_skip_fields', FALSE), + '#description' => t('The scheme selection step is only available if two or more file destinations, such as public local files served by the webserver and private local files served by Drupal, are available. If this step is skipped, files will automatically be saved using the default download method.'), + ); + $form['file_upload_wizard']['file_entity_file_upload_wizard_skip_fields'] = array( + '#type' => 'checkbox', + '#title' => t('Skip available fields.'), + '#default_value' => variable_get('file_entity_file_upload_wizard_skip_fields', FALSE), + '#description' => t('The field selection step is only available if the file type the file belongs to has any available fields. If this step is skipped, any fields on the file will be left blank.'), + ); } /* diff --git a/file_entity.pages.inc b/file_entity.pages.inc index fec022a..63986d0 100644 --- a/file_entity.pages.inc +++ b/file_entity.pages.inc @@ -309,6 +309,11 @@ function file_entity_add_upload_submit($form, &$form_state) { $form['#step'] += ($trigger == 'edit-previous') ? -1 : 1; $form_state['storage']['type'] = reset($candidates_keys); } + elseif (variable_get('file_entity_file_upload_wizard_skip_file_type', FALSE)) { + // Do not assign the file a file type. + $form['#step'] += ($trigger == 'edit-previous') ? -1 : 1; + $form_state['storage']['type'] = NULL; + } } // Only one visible, writeable stream wrapper is available, check if we can @@ -321,6 +326,11 @@ function file_entity_add_upload_submit($form, &$form_state) { $form['#step'] += ($trigger == 'edit-previous') ? -1 : 1; $form_state['storage']['scheme'] = key($schemes); } + elseif (variable_get('file_entity_file_upload_wizard_skip_scheme', FALSE)) { + // Assign the file the default scheme. + $form['#step'] += ($trigger == 'edit-previous') ? -1 : 1; + $form_state['storage']['scheme'] = file_default_scheme(); + } } // We have the filetype, check if we can skip step 4. @@ -330,6 +340,10 @@ function file_entity_add_upload_submit($form, &$form_state) { // This filetype doesn't have fields, save the file. $save = TRUE; } + elseif (variable_get('file_entity_file_upload_wizard_skip_fields', FALSE)) { + // Save the file with blanks fields. + $save = TRUE; + } } switch ($trigger) {