From fb640a92bc7a7a713b298569ecefb54573f2fc34 Mon Sep 17 00:00:00 2001 From: tofulm Date: Wed, 23 Jun 2021 12:36:24 +0200 Subject: [PATCH] gere le cas des documents protected --- formulaires/gamumail.php | 11 +++++++++-- inc/envoyer_gamumail.php | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/formulaires/gamumail.php b/formulaires/gamumail.php index ae1dbc8..d257088 100644 --- a/formulaires/gamumail.php +++ b/formulaires/gamumail.php @@ -217,8 +217,15 @@ function formulaires_gamumail_traiter_dist($slug, $destinataires = 0, $Tclient = $docs_spip = ($docs_spip != '' ? explode(',', $docs_spip) : []); if (!empty($docs_spip)) { foreach ($docs_spip as $id_document) { - $Tdocument = sql_fetsel('titre,fichier,extension','spip_documents','id_document='.intval($id_document)); - $destination = _DIR_IMG.$Tdocument['fichier']; + $protected = ''; + $Tdocument = sql_fetsel('*','spip_documents','id_document='.intval($id_document)); + if ( + array_key_exists('protected', $Tdocument) + and $Tdocument['protected'] === 'oui' + ) { + $protected = 'PROTECTED/'; + } + $destination = _DIR_IMG.$protected.$Tdocument['fichier']; $extension = $Tdocument['extension']; if ($Tdocument['titre']) { $nom_fichier = $Tdocument['titre'] .".".$extension; diff --git a/inc/envoyer_gamumail.php b/inc/envoyer_gamumail.php index b38cde5..f513481 100644 --- a/inc/envoyer_gamumail.php +++ b/inc/envoyer_gamumail.php @@ -94,8 +94,16 @@ function inc_envoyer_gamumail($slug, $destinataires, $options = []) { // récup des paramètres des docs à attacher if (!empty($Tid_doc)) { foreach ($Tid_doc as $id_document) { - $Tdocument = sql_fetsel('titre,fichier,extension','spip_documents','id_document='.intval($id_document)); - $destination = _DIR_IMG.$Tdocument['fichier']; + $protected = ''; + $Tdocument = sql_fetsel('*','spip_documents','id_document='.intval($id_document)); + if ( + array_key_exists('protected', $Tdocument) + and $Tdocument['protected'] === 'oui' + ) { + $protected = 'PROTECTED/'; + } + $destination = _DIR_IMG.$protected.$Tdocument['fichier']; + $extension = $Tdocument['extension']; if ($Tdocument['titre']) { $nom_fichier = $Tdocument['titre'] .".".$extension;