You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2017-11-30 20:21:33

sarsen
Member
Registered: 2015-03-03
Posts: 13

9.2.1 - Mail attachments for notification attaches all documents

I just installed version 9.2.1 on my test server and tested the document attachment option in the notification email.  It now works, a technician can now attach a document in a follow up and it is going to be sent to the Requester in the notification email.  The problem is, it doesn't just attach the document that was selected in the followup, it will attach ALL documents pertaining to that ticket.  Example : if i do 3 followups with each of them having 1 file, the first followup will attach 1 file, the second will attach the first followup file and the current one, the third one will attach the first, second and current.

And it will even attach a document that was placed in a private followup.  As you can probably guess this will just confuse the requesters plus it's inflating mailboxes with unnecessary documents.  Is it possible to revise this to only place in the notification only the document attached to the followup in question?


GLPI 9.2.1 | Wampserver 3.1.0 | Apache 2.4.27 | PHP 7.1.9 | MySQL 5.7.19

Offline

#2 2017-12-01 19:58:47

jpsbatista
Member
Registered: 2017-11-30
Posts: 8

Re: 9.2.1 - Mail attachments for notification attaches all documents

I have same problem on same version.

Offline

#3 2019-09-24 16:31:51

marcosbarbosabr
Member
Registered: 2019-09-23
Posts: 4

Re: 9.2.1 - Mail attachments for notification attaches all documents

Hi all

Have you already resolved this problem?

Can you share , please?

I have the same problem with the version 9.4.3

Tks

Offline

#4 2021-06-28 21:36:00

alexey_zhuravlev
Member
Registered: 2021-03-11
Posts: 4

Re: 9.2.1 - Mail attachments for notification attaches all documents

I have same problem on 9.5.3 and 9.5.5
Way of sending emails: PHP or SMTP + SSL
Any followup notification contains all attachments from ticket.

Last edited by alexey_zhuravlev (2021-06-28 21:42:10)

Offline

#5 2021-09-30 09:19:26

cillox
Member
Registered: 2017-08-18
Posts: 14

Re: 9.2.1 - Mail attachments for notification attaches all documents

Hi,

anyone can get the resolve this issue?

Offline

#6 2022-06-28 10:22:48

chch18
Member
Registered: 2022-06-28
Posts: 2

Re: 9.2.1 - Mail attachments for notification attaches all documents

Hello!
If still relevant))
I tried to do this to change the logic of working with attachments:
In class notificationeventmailing.class.php around line 268
replace
foreach ($inline_docs as $docID => $tag) {
               $current->fields['body_html'] = preg_replace([
                     '/src=["\'][^"\']*document\.send\.php\?docid='.$docID.'(&[^"\']+)?["\']/',
                     '/href=["\'][^"\']*document\.send\.php\?docid='.$docID.'(&[^"\']+)?["\']/',
                  ], [
                     'src="cid:' . $tag . '"',
                     'href="' . $CFG_GLPI['url_base'] . '/front/document.send.php?docid=' . $docID . '$1"',
                  ],
                  $current->fields['body_html']);
            }

            $mmail->Body    = GLPIMailer::normalizeBreaks($current->fields['body_html']);
            $mmail->AltBody = GLPIMailer::normalizeBreaks($current->fields['body_text']);
         }

         self::attachDocuments($mmail, $documents_to_attach);
to
foreach ($inline_docs as $docID => $tag) {
               $current->fields['body_html'] = preg_replace([
                     '/src=["\'][^"\']*document\.send\.php\?docid='.$docID.'(&[^"\']+)?["\']/',
                     '/href=["\'][^"\']*document\.send\.php\?docid='.$docID.'(&[^"\']+)?["\']/',
                  ], [
                     'src="cid:' . $tag . '"',
                     'href="' . $CFG_GLPI['url_base'] . '/front/document.send.php?docid=' . $docID . '$1"',
                  ],
                  $current->fields['body_html']);
            }

            $mmail->Body    = GLPIMailer::normalizeBreaks($current->fields['body_html']);
            $mmail->AltBody = GLPIMailer::normalizeBreaks($current->fields['body_text']);
         }

<------> //patch -  attach docs from documents fields of queuednotifications
         if($current->fields["documents"]){
             $documents_to_attach = [];
             $documents_to_attach = importArrayFromDB($current->fields["documents"]);
<------>     self::attachDocuments($mmail, $documents_to_attach);
         }

In class notificationevent.class.php around line 182
replace
if (class_exists($eventclass)) {
               $eventclass::raise(
                  $event,
                  $item,
                  $options,
                  $label,
                  $data,
                  $notificationtarget->setEvent($eventclass),
                  $template,
                  $notify_me,
                  $emitter
               );
            }
to
if (class_exists($eventclass)) {
<------><------>//attach docs added with followups or tasks
<------><------>if(array_key_exists('followup_id',$options)||array_key_exists('task_id',$options)){
                    $id_docs_array = [];
                    if(array_key_exists('followup_id',$options)){
                        $doc_crit[] = [
                            'timeline_position'  => ['>', CommonITILObject::NO_TIMELINE],
                            'items_id'=>$options['followup_id']
                        ];
                    }
                    if(array_key_exists('task_id',$options)){
                        $doc_crit[] = [
                            'timeline_position'  => ['>', CommonITILObject::NO_TIMELINE],
                            'items_id'=>$options['task_id']
                        ];
                    }

                    $query = [
                        'SELECT'=>'documents_id',
                        'FROM'=>'glpi_documents_items',
                        'WHERE'=> $doc_crit
                    ];
                    $docs_ids = $DB->request($query);
                    foreach($docs_ids as $d_id){
                        $id_docs_array[] = $d_id['documents_id'];
                    }
                    $options['documents'] = $id_docs_array;
                }
<------><------>//end of patch attach docs added with followups or tasks
               $eventclass::raise(
                  $event,
                  $item,
                  $options,
                  $label,
                  $data,
                  $notificationtarget->setEvent($eventclass),
                  $template,
                  $notify_me,
                  $emitter
               );
            }
           
In class notificationeventabstract.class.php around line 140

//Send notification to the user
                        if ($label == '') {
                           $send_data = $template->getDataToSend(
                              $notificationtarget,
                              $tid,
                              $key,
                              $users_infos,
                              $options
                           );
                           $send_data['_notificationtemplates_id'] = $data['notificationtemplates_id'];
                           $send_data['_itemtype']                 = $item->getType();
                           $send_data['_items_id']                 = method_exists($item, "getID")
                              ? $item->getID()
                              : 0;
                           $send_data['_entities_id']              = $entity;
                           $send_data['mode']                      = $data['mode'];
                           //ADD
                           $send_data['documents']                 = $options['documents'];
I only tested this for  followup and tasks.
If you have a test environment, you can try testing.

Offline

#7 2023-05-09 08:19:50

vlcek_vratko
Member
Registered: 2023-05-09
Posts: 4

Re: 9.2.1 - Mail attachments for notification attaches all documents

Hi guys,


I know it's been a while, but this problem still exists, have you found any other solution?

Thanks a lot.

V.

Offline

#8 2023-07-19 09:52:22

Cristian98
Member
Registered: 2019-06-04
Posts: 9

Re: 9.2.1 - Mail attachments for notification attaches all documents

Hi everyone,
have we got any news about this?
Is there a way to avoid that for every notification we have all ticket's documents attached?

Thanks!
Cris

Offline

#9 2023-09-22 11:32:49

Changemanager
Member
Registered: 2023-02-21
Posts: 38

Re: 9.2.1 - Mail attachments for notification attaches all documents

same problem...

Offline

#10 2023-09-22 14:00:52

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,335
Website

Re: 9.2.1 - Mail attachments for notification attaches all documents

Please don't resurrect topics from ancient GLPI versions.
Please find or start a new topic for a supported version of GLPI (10.0.X).


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

Board footer

Powered by FluxBB