Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions class/actions_attachments.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
* Copyright (C) 2025 Anthony Berton <anthony.berton@bb2a.fr>
*
* 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
Expand Down Expand Up @@ -72,7 +73,7 @@ class ActionsAttachments extends \attachments\RetroCompatCommonHookActions
, 'societe' => 'AttachmentsSociete'
, 'ecm' => 'AttachmentsTitleEcm'
, 'project_task' => 'AttachmentsTitleTask'
, 'shipping' => 'AttachmentsShipping'
, 'shipping' => 'AttachmentsShipping'
);

public $TFilePathByTitleKey = array();
Expand Down Expand Up @@ -237,17 +238,28 @@ function doActions($parameters, &$object, &$action, $hookmanager)
else{
continue;
}

// Special case for products if old path for photos is used
if ($element == 'product' && getDolGlobalString('PRODUCT_USE_OLD_PATH_FOR_PHOTO'))
{
$pdir = get_exdir($linkedObject->id, 2, 0, 0, $linkedObject, 'product') . $linkedObject->id ."/photos/";
$filedir = $conf->product->dir_output.'/'.$pdir;
}

// Scan directory
// On exclu les fichiers .meta et les preview png
$file_list=dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
if (!empty($file_list))
{
$key = $this->TTileKeyByElement[$element];
if (empty($this->TTileKeyByElement[$element])){
if(strpos($element, '_') == false){
$key = $element;
}else{
$element = explode('_', $element);
$key = $element[1];
}
}else{
$key = $this->TTileKeyByElement[$element];
}
foreach ($file_list as $file_info)
{
$fullname_md5 = md5($file_info['fullname']);
Expand Down