Adding $_configuration['document_if_file_exists_option']

To set default upload option see BT#9235
1.9.x
Julio Montoya 10 years ago
parent 73e3816204
commit 3bc8fd6fad
  1. 14
      main/document/upload.php
  2. 10
      main/inc/ajax/document.ajax.php
  3. 2
      main/install/configuration.dist.php

@ -284,7 +284,7 @@ if (api_get_setting('search_enabled') == 'true') {
$form->addElement('radio', 'if_exists', get_lang('UplWhatIfFileExists'), get_lang('UplDoNothing'), 'nothing');
$form->addElement('radio', 'if_exists', '', get_lang('UplOverwriteLong'), 'overwrite');
$form->addElement('radio', 'if_exists', '', get_lang('UplRenameLong'), 'rename', array('checked="checked"'));
$form->addElement('radio', 'if_exists', '', get_lang('UplRenameLong'), 'rename');
// Close the java script and avoid the footer up
$form->addElement('html', '</div>');
@ -292,7 +292,17 @@ $form->addElement('html', '</div>');
$form->addElement('style_submit_button', 'submitDocument', get_lang('SendDocument'), 'class="upload"');
$form->add_real_progress_bar('DocumentUpload', 'file');
$defaults = array('index_document' => 'checked="checked"');
$fileExistsOption = api_get_configuration_value('document_if_file_exists_option');
$defaultFileExistsOption = 'rename';
if (!empty($fileExistsOption)) {
$defaultFileExistsOption = $fileExistsOption;
}
$defaults = array(
'index_document' => 'checked="checked"',
'if_exists' => $defaultFileExistsOption
);
$form->setDefaults($defaults);

@ -25,7 +25,13 @@ switch ($action) {
exit;
}
$ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : 'overwrite';
$fileExistsOption = api_get_configuration_value('document_if_file_exists_option');
$defaultFileExistsOption = 'rename';
if (!empty($fileExistsOption)) {
$defaultFileExistsOption = $fileExistsOption;
}
//$ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : $defaultFileExistsOption;
if (!empty($_FILES)) {
require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
@ -36,7 +42,7 @@ switch ($action) {
$file['name'],
'', // comment
0,
$ifExists,
$defaultFileExistsOption,
false,
false
);

@ -276,3 +276,5 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
// Max quantity of fkceditor allowed in the exercise result page otherwise
// Textareas are used.
//$_configuration['exercise_max_fckeditors_in_page'] = 0;
// Default upload option
//$_configuration['document_if_file_exists_option'] = 'rename'; // overwrite

Loading…
Cancel
Save