From abb1aff3787a56441bb8f50ab3d5119ae82d397a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Thu, 18 Feb 2021 16:22:28 +0000 Subject: [PATCH] allow moving images between servers, fixes #4880 --- cgi/product_image_move.pl | 12 +++++++++++- lib/ProductOpener/Images.pm | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cgi/product_image_move.pl b/cgi/product_image_move.pl index f432bc428d5eb..f2eb4a60f6f2b 100644 --- a/cgi/product_image_move.pl +++ b/cgi/product_image_move.pl @@ -47,7 +47,10 @@ my $code = normalize_code(param('code')); my $imgids = param('imgids'); my $move_to = param('move_to_override'); -if ($move_to ne 'trash') { +if ($move_to =~ /^(off|obf|opf|opff)$/) { + $move_to .= ':' . $code; +} +elsif ($move_to ne 'trash') { $move_to = normalize_code($move_to); } my $copy_data = param('copy_data_override'); @@ -189,6 +192,13 @@ } $response{url} = product_url($move_to); + + # URL on another server? + my $server = server_for_product_id($move_to); + if (defined $server) { + my $url = "https://" . $subdomain . "." . $options{other_servers}{$server}{$domain} . $response{url}; + } + $response{link} = '' . $move_to . ''; } diff --git a/lib/ProductOpener/Images.pm b/lib/ProductOpener/Images.pm index c9d7be3ceb0c6..11315a8bb7ed0 100644 --- a/lib/ProductOpener/Images.pm +++ b/lib/ProductOpener/Images.pm @@ -826,7 +826,7 @@ sub process_image_move($$$$) { my $ownerid = shift; # move images only to trash or another valid barcode (number) - if (($move_to ne 'trash') and ($move_to !~ /^\d+$/)) { + if (($move_to ne 'trash') and ($move_to !~ /^((off|obf|opf|opff):)?\d+$/)) { return "invalid barcode number: $move_to"; } @@ -877,7 +877,6 @@ sub process_image_move($$$$) { $log->info("moving source image to deleted images directory", { source_path => "$www_root/images/products/$path/$imgid.jpg", destination_path => "$data_root/deleted.images/product.$code.$imgid.jpg" }); move("$www_root/images/products/$path/$imgid.jpg", "$data_root/deleted.images/product.$code.$imgid.jpg"); - move("$www_root/images/products/$path/$imgid.json", "$data_root/deleted.images/product.$code.$imgid.json"); move("$www_root/images/products/$path/$imgid.$thumb_size.jpg", "$data_root/deleted.images/product.$code.$imgid.$thumb_size.jpg"); move("$www_root/images/products/$path/$imgid.$crop_size.jpg", "$data_root/deleted.images/product.$code.$imgid.$crop_size.jpg");