Merge branch 'ent-11078-quitar-las-opciones-de-crear-ficheros-y-directorios-en-el-mib-uploader' into 'develop'

Ent 11078 quitar las opciones de crear ficheros y directorios en el mib uploader

See merge request artica/pandorafms!5826
This commit is contained in:
Rafael Ameijeiras 2023-05-31 11:23:50 +00:00
commit d44eb102e7
2 changed files with 78 additions and 52 deletions

View File

@ -485,6 +485,11 @@ function filemanager_file_explorer(
// Options. // Options.
$allowZipFiles = (isset($options['all']) === true) || ((isset($options['allowZipFiles']) === true) && ($options['allowZipFiles'] === true)); $allowZipFiles = (isset($options['all']) === true) || ((isset($options['allowZipFiles']) === true) && ($options['allowZipFiles'] === true));
$allowCreateText = (isset($options['all']) === true) || ((isset($options['allowCreateText']) === true) && ($options['allowCreateText'] === true)); $allowCreateText = (isset($options['all']) === true) || ((isset($options['allowCreateText']) === true) && ($options['allowCreateText'] === true));
$allowCreateFolder = (isset($options['allowCreateFolder'])) ? false : true;
if ($options['denyCreateText'] === true) {
$allowCreateText = false;
}
if ($homedir_filemanager === false) { if ($homedir_filemanager === false) {
$homedir_filemanager = $config['homedir']; $homedir_filemanager = $config['homedir'];
@ -494,11 +499,14 @@ function filemanager_file_explorer(
?> ?>
<script type="text/javascript"> <script type="text/javascript">
<?php if ($allowCreateFolder === true) : ?>
function show_form_create_folder() { function show_form_create_folder() {
actions_dialog('create_folder'); actions_dialog('create_folder');
$("#create_folder").css("display", "block"); $("#create_folder").css("display", "block");
check_opened_dialog('create_folder'); check_opened_dialog('create_folder');
} }
<?php endif ?>
<?php if ($allowCreateText === true) : ?> <?php if ($allowCreateText === true) : ?>
function show_create_text_file() { function show_create_text_file() {
actions_dialog('create_text_file'); actions_dialog('create_text_file');
@ -514,11 +522,14 @@ function filemanager_file_explorer(
} }
function check_opened_dialog(check_opened) { function check_opened_dialog(check_opened) {
if (check_opened !== 'create_folder') { <?php if ($allowCreateFolder === true) : ?>
if (($("#create_folder").hasClass("ui-dialog-content") && $('#create_folder').dialog('isOpen') === true)) { if (check_opened !== 'create_folder') {
$('#create_folder').dialog('close'); if (($("#create_folder").hasClass("ui-dialog-content") && $('#create_folder').dialog('isOpen') === true)) {
$('#create_folder').dialog('close');
}
} }
} <?php endif ?>
<?php if ($allowCreateText === true) : ?> <?php if ($allowCreateText === true) : ?>
if (check_opened !== 'create_text_file') { if (check_opened !== 'create_text_file') {
if (($("#create_text_file").hasClass("ui-dialog-content") && $('#create_text_file').dialog('isOpen') === true)) { if (($("#create_text_file").hasClass("ui-dialog-content") && $('#create_text_file').dialog('isOpen') === true)) {
@ -537,14 +548,18 @@ function filemanager_file_explorer(
$('.' + action).addClass('file_table_modal_active'); $('.' + action).addClass('file_table_modal_active');
var title_action = ''; var title_action = '';
switch (action) { switch (action) {
case 'create_folder': <?php if ($allowCreateFolder === true) : ?>
title_action = "<?php echo __('Create a Directory'); ?>"; case 'create_folder':
break; title_action = "<?php echo __('Create a Directory'); ?>";
<?php if ($allowCreateText === true) : ?>
case 'create_text_file':
title_action = "<?php echo __('Create File'); ?>";
break; break;
<?php endif ?> <?php endif ?>
<?php if ($allowCreateText === true) : ?>
case 'create_text_file':
title_action = "<?php echo __('Create File'); ?>";
break;
<?php endif ?>
case 'upload_file': case 'upload_file':
title_action = "<?php echo __('Upload Files'); ?>"; title_action = "<?php echo __('Upload Files'); ?>";
break; break;
@ -809,18 +824,21 @@ function filemanager_file_explorer(
if ($readOnly === false) { if ($readOnly === false) {
if (is_writable($real_directory) === true) { if (is_writable($real_directory) === true) {
// The buttons to make actions. // The buttons to make actions.
$tabs_dialog = '<ul id="file_table_modal"> $tabs_dialog = '<ul id="file_table_modal">';
<li class="create_folder"> if ($allowCreateFolder === true) {
<a href="javascript: show_form_create_folder();">'.html_print_image( $tabs_dialog .= '
'images/create_directory.png', <li class="create_folder">
true, <a href="javascript: show_form_create_folder();">'.html_print_image(
[ 'images/create_directory.png',
'title' => __('Create directory'), true,
'class' => 'invert_filter', [
] 'title' => __('Create directory'),
).'<span>'.__('Create a Directory').'</span> 'class' => 'invert_filter',
</a> ]
</li>'; ).'<span>'.__('Create a Directory').'</span>
</a>
</li>';
}
if ($allowCreateText === true) { if ($allowCreateText === true) {
$tabs_dialog .= ' $tabs_dialog .= '
@ -853,23 +871,25 @@ function filemanager_file_explorer(
$tabs_dialog .= '</ul>'; $tabs_dialog .= '</ul>';
// Create folder section. // Create folder section.
$createFolderElements = $tabs_dialog; if ($allowCreateFolder === true) {
$createFolderElements .= sprintf('<form method="POST" action="%s">', $url); $createFolderElements = $tabs_dialog;
$createFolderElements .= html_print_input_text('dirname', '', '', 30, 255, true); $createFolderElements .= sprintf('<form method="POST" action="%s">', $url);
$createFolderElements .= html_print_submit_button(__('Create'), 'crt', false, [ 'class' => 'submitButton', 'style' => 'float:right', 'icon' => 'next'], true); $createFolderElements .= html_print_input_text('dirname', '', '', 30, 255, true);
$createFolderElements .= html_print_input_hidden('directory', $relative_directory, true); $createFolderElements .= html_print_submit_button(__('Create'), 'crt', false, [ 'class' => 'submitButton', 'style' => 'float:right', 'icon' => 'next'], true);
$createFolderElements .= html_print_input_hidden('create_dir', 1, true); $createFolderElements .= html_print_input_hidden('directory', $relative_directory, true);
$createFolderElements .= html_print_input_hidden('hash', md5($relative_directory.$config['server_unique_identifier']), true); $createFolderElements .= html_print_input_hidden('create_dir', 1, true);
$createFolderElements .= html_print_input_hidden('hash2', md5($relative_directory.$config['server_unique_identifier']), true); $createFolderElements .= html_print_input_hidden('hash', md5($relative_directory.$config['server_unique_identifier']), true);
$createFolderElements .= '</form>'; $createFolderElements .= html_print_input_hidden('hash2', md5($relative_directory.$config['server_unique_identifier']), true);
$createFolderElements .= '</form>';
html_print_div( html_print_div(
[ [
'id' => 'create_folder', 'id' => 'create_folder',
'class' => 'invisible', 'class' => 'invisible',
'content' => $createFolderElements, 'content' => $createFolderElements,
] ]
); );
}
// Upload file section. // Upload file section.
$uploadFileElements = $tabs_dialog; $uploadFileElements = $tabs_dialog;
@ -936,18 +956,20 @@ function filemanager_file_explorer(
echo "<div style='width: ".$table->width.";' class='file_table_buttons'>"; echo "<div style='width: ".$table->width.";' class='file_table_buttons'>";
$buttons[] = html_print_button( if ($allowCreateFolder === true) {
__('Create directory'), $buttons[] = html_print_button(
'create_directory', __('Create directory'),
false, 'create_directory',
'show_form_create_folder()', false,
[ 'show_form_create_folder()',
'class' => 'margin-right-2 invert_filter secondary', [
'icon' => 'create_directory', 'class' => 'margin-right-2 invert_filter secondary',
], 'icon' => 'create_directory',
true, ],
false true,
); false
);
}
if ($allowCreateText === true) { if ($allowCreateText === true) {
$buttons[] = html_print_button( $buttons[] = html_print_button(

View File

@ -109,5 +109,9 @@ filemanager_file_explorer(
false, false,
'', '',
false, false,
['all' => true] [
'all' => true,
'denyCreateText' => true,
'allowCreateFolder' => true,
]
); );