From 553181a5d92a52bd3b2d22ddaac8525fc8290540 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 6 Feb 2015 21:26:41 +0100 Subject: [PATCH] Fixed: Location for file storage from tab attached files was not at same place than from tab images. --- htdocs/core/lib/product.lib.php | 14 +++++++------- htdocs/product/class/product.class.php | 25 ++++++++++++++++++++----- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 741dd98de6d..1aea8f9e37b 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -57,11 +57,6 @@ function product_prepare_head($object, $user) $h++; } - $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$object->id; - $head[$h][1] = $langs->trans("Photos"); - $head[$h][2] = 'photos'; - $h++; - // Show category tab if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { @@ -116,14 +111,19 @@ function product_prepare_head($object, $user) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'product'); - // Attachments + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$object->id; + $head[$h][1] = $langs->trans("Photos"); + $head[$h][2] = 'photos'; + $h++; + + // Attachments require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$')); $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')'; + if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>'; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ba179aef616..0778046c431 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3101,10 +3101,14 @@ class Product extends CommonObject */ function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120) { + global $conf; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $result = 0; - $dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/photos"; + + $dir = $sdir; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos"; dol_mkdir($dir); @@ -3156,8 +3160,8 @@ class Product extends CommonObject { include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; - $pdir = get_exdir($this->id,2) . $this->id ."/photos/"; - $dir = $sdir . '/'. $pdir; + $dir = $sdir; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos"; $nbphoto=0; @@ -3199,8 +3203,19 @@ class Product extends CommonObject include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; - $pdir = get_exdir($this->id,2) . $this->id ."/photos/"; - $dir = $sdir . '/'. $pdir; + $dir = $sdir . '/'; + $pdir = '/'; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $dir .= get_exdir($this->id,2) . $this->id ."/photos/"; + $pdir .= get_exdir($this->id,2) . $this->id ."/photos/"; + } + else + { + $dir .= $this->ref.'/'; + $pdir .= $this->ref.'/'; + } + $dirthumb = $dir.'thumbs/'; $pdirthumb = $pdir.'thumbs/'; -- GitLab