FIX #7379: Compatibility with PRODUCT_USE_OLD_PATH_FOR_PHOTO varieable

This commit is contained in:
Ferran Marcet 2017-12-07 18:44:33 +01:00
parent 924cf871a7
commit bfc476a118
3 changed files with 8 additions and 7 deletions

View File

@ -6,7 +6,7 @@
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com> * Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2016-2017 Ferran Marcet <fmarcet@2byte.es>
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -938,9 +938,9 @@ class FormFile
if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.'; if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.';
} }
// For backward compatiblity, we detect file is stored into an old path // For backward compatiblity, we detect file is stored into an old path
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $file['level1name'] == 'photos') if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos')
{ {
$relativepath=preg_replace('/^.*\/produit\//','',$file['path']).'/'; $relativepath=preg_replace('/^.*\/produit\//','',$filearray[0]['path']).'/';
} }
// Defined relative dir to DOL_DATA_ROOT // Defined relative dir to DOL_DATA_ROOT
$relativedir = ''; $relativedir = '';

View File

@ -3997,8 +3997,8 @@ class Product extends CommonObject
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{ {
$dirold .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; $dir = $sdir . '/'. get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/";
$pdirold .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; $pdir = '/' . get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/";
} }
// Defined relative dir to DOL_DATA_ROOT // Defined relative dir to DOL_DATA_ROOT

View File

@ -6,6 +6,7 @@
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -75,8 +76,8 @@ if ($id > 0 || ! empty($ref))
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs
{ {
if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos";
else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; else $upload_dir = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos";
} }
} }
$modulepart='produit'; $modulepart='produit';