From 71cff4032ccf99092b78b72ec599e43a96a3c3db Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 18 Nov 2016 16:26:12 +0100 Subject: [PATCH] NEW : option to copy into attachement files of events, files send by mail (with auto event creation) --- htdocs/core/actions_sendmails.inc.php | 1 + .../interface_50_modAgenda_ActionsAuto.class.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 9ec3bfcb3b7..e9d65222d28 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -345,6 +345,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $object->trackid = $trackid; $object->fk_element = $object->id; $object->elementtype = $object->element; + $object->attachedfiles = $attachedfiles; // Call of triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index bce6cd02eee..437dcea9e1c 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -856,6 +856,21 @@ class InterfaceActionsAuto extends DolibarrTriggers $ret=$actioncomm->create($user); // User creating action + if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO) + { + if (is_array($object->attachedfiles) && array_key_exists('paths',$object->attachedfiles) && count($object->attachedfiles['paths'])>0) { + foreach($object->attachedfiles['paths'] as $key=>$filespath) { + $srcfile = $filespath; + $destdir = $conf->agenda->dir_output . '/' . $ret; + $destfile = $destdir . '/' . $object->attachedfiles['names'][$key]; + if (dol_mkdir($destdir) >= 0) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_copy($srcfile, $destfile); + } + } + } + } + unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. if ($ret > 0)