gere le cas des documents protected

This commit is contained in:
Christophe 2021-06-23 12:36:24 +02:00
parent 9e3e8e59ad
commit fb640a92bc
2 changed files with 19 additions and 4 deletions

View file

@ -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;

View file

@ -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;