Merge branch 'ent-12177-en-gestion-de-versiones-obsolescencia-planeada-al-subir-una-supuesta-imagen-guarda-y-se-va-al' into 'develop'

Ent 12177 en gestion de versiones obsolescencia planeada al subir una supuesta imagen guarda y se va al

See merge request artica/pandorafms!6560
This commit is contained in:
Rafael Ameijeiras 2023-11-27 11:55:29 +00:00
commit cf65c66c38
3 changed files with 49 additions and 10 deletions

View File

@ -46,7 +46,7 @@ if ($idOS > 0) {
$description = $os['description']; $description = $os['description'];
$icon = $os['icon_name']; $icon = $os['icon_name'];
} else { } else {
$name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name')))); $name = io_safe_input(strip_tags(trim(io_safe_output((string) get_parameter('name')))));
$description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description')))); $description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
$icon = get_parameter('icon', 0); $icon = get_parameter('icon', 0);
} }
@ -87,9 +87,16 @@ if ($is_management_allowed === true) {
if (in_array($file_ext, $allowed_extensions) === false) { if (in_array($file_ext, $allowed_extensions) === false) {
$message = 9; $message = 9;
} else if (exif_imagetype($file_tmp) === false && $file_ext !== 'svg') {
$message = 10;
} else { } else {
$message = 8; $message = 8;
move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name);
$file_uploaded = move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name);
if ($file_uploaded !== true) {
$message = 10;
}
} }
} }
} else { } else {
@ -108,7 +115,7 @@ if ($is_management_allowed === true) {
if ($resultOrId === false) { if ($resultOrId === false) {
$message = 2; $message = 2;
$tab = 'builder'; $tab = 'manage_os';
$actionHidden = 'save'; $actionHidden = 'save';
$textButton = __('Create'); $textButton = __('Create');
$classButton = ['icon' => 'wand']; $classButton = ['icon' => 'wand'];
@ -144,13 +151,19 @@ if ($is_management_allowed === true) {
if (in_array($file_ext, $allowed_extensions) === false) { if (in_array($file_ext, $allowed_extensions) === false) {
$message = 9; $message = 9;
} else if (exif_imagetype($file_tmp) === false) {
$message = 10;
} else { } else {
$message = 8; $message = 8;
move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name); $file_uploaded = move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name);
if ($file_uploaded !== true) {
$message = 10;
}
} }
} }
} else { } else {
$name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name')))); $name = io_safe_input(strip_tags(trim(io_safe_output((string) get_parameter('name')))));
$description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description')))); $description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
$icon = get_parameter('icon', 0); $icon = get_parameter('icon', 0);
@ -254,7 +267,7 @@ $table->class = 'databox filter-table-adv';
$table->data[0][] = html_print_label_input_block( $table->data[0][] = html_print_label_input_block(
__('Name'), __('Name'),
html_print_input_text('name', $name, __('Name'), 20, 30, true, false, false, '', 'w250px') html_print_input_text('name', $name, __('Name'), 20, 30, true, false, true, '', 'w250px')
); );
$table->data[0][] = html_print_label_input_block( $table->data[0][] = html_print_label_input_block(
@ -290,6 +303,28 @@ html_print_action_buttons(
echo '</form>'; echo '</form>';
$id_message = get_parameter('id_message', 0);
if ($id_message !== 0) {
switch ($id_message) {
case 8:
echo ui_print_success_message(__('Icon successfuly uploaded'), '', true);
break;
case 9:
echo ui_print_error_message(__('File must be of type JPG, JPEG, PNG or SVG'), '', true);
break;
case 10:
echo ui_print_error_message(__('An error ocurrered to upload icon'), '', true);
break;
default:
// Nothing to do.
break;
}
}
function get_list_os_icons_dir() function get_list_os_icons_dir()
{ {

View File

@ -162,11 +162,15 @@ if (empty($id_message) === false) {
break; break;
case 8: case 8:
echo ui_print_success_message(__('Icon successfuly uploaded'), '', true); header('Location: index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_os&action=edit&id_message=8');
break; break;
case 9: case 9:
echo ui_print_error_message(__('File must be of type JPG, JPEG, PNG or SVG'), '', true); header('Location: index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_os&action=edit&id_message=9');
break;
case 10:
header('Location: index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_os&action=edit&id_message=10');
break; break;
default: default:

View File

@ -4939,8 +4939,8 @@ function html_print_input_file($name, $return=false, $options=false, $inline_upl
$inline_upload_anchor_to_form $inline_upload_anchor_to_form
), ),
[ [
'mode' => 'link', 'class' => 'secondary',
'style' => 'min-width: initial;', 'style' => 'min-width: initial; position: relative; margin-left: 5%; ',
], ],
true, true,
); );