New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.2] image insertion in mail ticket notification #2869

Closed
kelior opened this Issue Sep 29, 2017 · 22 comments

Comments

Projects
None yet
@kelior

kelior commented Sep 29, 2017

Since the 9.2 upgrade, when we receive a mail notification on a ticket update,
the images linked in the ticket do not appear like they used to do :

Here is the result we get on the mail :
image
It seems the link to the docid is not complete.

@alias59

This comment has been minimized.

Show comment
Hide comment
@alias59

alias59 Sep 29, 2017

Hello,
You have move the folder who containt the image after update ?
Regards

alias59 commented Sep 29, 2017

Hello,
You have move the folder who containt the image after update ?
Regards

@kelior

This comment has been minimized.

Show comment
Hide comment
@kelior

kelior Sep 29, 2017

no if I access the full url (http://10.128.6.69/glpi/front/document.send.php?docid=3488) in my browser the image is displayed correctly.

kelior commented Sep 29, 2017

no if I access the full url (http://10.128.6.69/glpi/front/document.send.php?docid=3488) in my browser the image is displayed correctly.

@alias59

This comment has been minimized.

Show comment
Hide comment
@alias59

alias59 Sep 29, 2017

Check rules the folder ( Write and Reader ) ?
In Ubuntu ( chmod -R 755 and chown -R www-data:www-data)

alias59 commented Sep 29, 2017

Check rules the folder ( Write and Reader ) ?
In Ubuntu ( chmod -R 755 and chown -R www-data:www-data)

@alias59

This comment has been minimized.

Show comment
Hide comment
@alias59

alias59 Sep 29, 2017

Check general configuration
address Web : image

alias59 commented Sep 29, 2017

Check general configuration
address Web : image

@kelior

This comment has been minimized.

Show comment
Hide comment
@kelior

kelior Sep 29, 2017

alright the problem is since version 9.2, you can insert images directly into the ticket with tinyMCE.
And it works by puttin an img tag like so
<img alt="a74e68b4-d9d62df8-59cca693a30978.38063338" height="106" width="289" src="/glpi/front/document.send.php?docid=3488">

When the notification is sent, the content of the ticket is copied in the mail with the same src.(missing the root)

kelior commented Sep 29, 2017

alright the problem is since version 9.2, you can insert images directly into the ticket with tinyMCE.
And it works by puttin an img tag like so
<img alt="a74e68b4-d9d62df8-59cca693a30978.38063338" height="106" width="289" src="/glpi/front/document.send.php?docid=3488">

When the notification is sent, the content of the ticket is copied in the mail with the same src.(missing the root)

@trasher trasher added the bug label Sep 29, 2017

@trasher trasher added this to the 9.2.1 milestone Sep 29, 2017

@babaymaster

This comment has been minimized.

Show comment
Hide comment
@babaymaster

babaymaster Oct 5, 2017

as same problem. bad link image in ticket

image

babaymaster commented Oct 5, 2017

as same problem. bad link image in ticket

image

@rjmontenegro

This comment has been minimized.

Show comment
Hide comment
@rjmontenegro

rjmontenegro Oct 12, 2017

Same on my installation 9.2 (happens on mailgate ticket creation):

IE
glpi
glpi3

Chrome
glpi2

rjmontenegro commented Oct 12, 2017

Same on my installation 9.2 (happens on mailgate ticket creation):

IE
glpi
glpi3

Chrome
glpi2

@alias59

This comment has been minimized.

Show comment
Hide comment
@alias59

alias59 Oct 17, 2017

@kelior, Have you find solution ?

alias59 commented Oct 17, 2017

@kelior, Have you find solution ?

@babaymaster

This comment has been minimized.

Show comment
Hide comment
@babaymaster

babaymaster Oct 23, 2017

no, wait new realease,,,,

babaymaster commented Oct 23, 2017

no, wait new realease,,,,

@orthagh

This comment has been minimized.

Show comment
Hide comment
@orthagh

orthagh Oct 30, 2017

Contributor

Hello guys,
We found a solution for this issue.
We embed image as attachments, the correction is #3085 and should be in 9.2.1 release.
So future mail notifications will work.

Contributor

orthagh commented Oct 30, 2017

Hello guys,
We found a solution for this issue.
We embed image as attachments, the correction is #3085 and should be in 9.2.1 release.
So future mail notifications will work.

orthagh added a commit to orthagh/glpi that referenced this issue Oct 31, 2017

@orthagh

This comment has been minimized.

Show comment
Hide comment
@orthagh

orthagh Oct 31, 2017

Contributor

And in #3092 (will be also released in 9.2.1) mail collect of inline pictures should work

Contributor

orthagh commented Oct 31, 2017

And in #3092 (will be also released in 9.2.1) mail collect of inline pictures should work

orthagh added a commit to orthagh/glpi that referenced this issue Oct 31, 2017

trasher added a commit to orthagh/glpi that referenced this issue Nov 2, 2017

mailnotification: add image inline as attachment; fix #2869
delete redondant code
depreciate Ticket::convertContentForNotification

@trasher trasher closed this in 48ca89d Nov 2, 2017

trasher added a commit that referenced this issue Nov 2, 2017

mailnotification: add image inline as attachment; fix #2869
delete redondant code
depreciate Ticket::convertContentForNotification
@dbegit

This comment has been minimized.

Show comment
Hide comment
@dbegit

dbegit commented Nov 20, 2017

@kelior

This comment has been minimized.

Show comment
Hide comment
@kelior

kelior Nov 20, 2017

It is fixed on my end

kelior commented Nov 20, 2017

It is fixed on my end

@rjmontenegro

This comment has been minimized.

Show comment
Hide comment
@rjmontenegro

rjmontenegro Nov 20, 2017

I'm still experiencing problems after upgrading to 9.2.1.

01
Ok, on notification after mailgate (new ticket).

02

Wrong, on ticket...

rjmontenegro commented Nov 20, 2017

I'm still experiencing problems after upgrading to 9.2.1.

01
Ok, on notification after mailgate (new ticket).

02

Wrong, on ticket...

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Nov 20, 2017

The problem probably comes from here :

Modify

  • inc/html.class.php:5466
    $fullpath = GLPI_DOC_DIR."/".$image['filepath'];
    to
    $fullpath = "/".$image['filepath'];

ghost commented Nov 20, 2017

The problem probably comes from here :

Modify

  • inc/html.class.php:5466
    $fullpath = GLPI_DOC_DIR."/".$image['filepath'];
    to
    $fullpath = "/".$image['filepath'];
@lekzz

This comment has been minimized.

Show comment
Hide comment
@lekzz

lekzz Nov 20, 2017

The inc/html.class.php:5466 fixes some of the issue but not all, inline mailed messages still have the wrong url, fix:

inc/html.class.php:5474

             if ($addLink) {
                $out .= '<a href="'.$CFG_GLPI['root_doc'].
                        '/front/document.send.php?docid='.$id.
                        '" target="_blank"><img alt="'.$image['tag'].
                        '" height="'.$height.'" width="'.$width.
                        '" src="'.$CFG_GLPI['root_doc'].
                   '/front/document.send.php?docid='.$id.'" /></a>';
             } else {
                $out .= '<img alt="'.$image['tag'].
                        '" height="'.$height.'" width="'.$width.
                        '" src="'.$CFG_GLPI['root_doc'].
                        '/front/document.send.php?docid='.$id.'" />';

to

             if ($addLink) {
                $out .= '<a href="/front/document.send.php?docid='.$id.
                        '" target="_blank"><img alt="'.$image['tag'].
                        '" height="'.$height.'" width="'.$width.
                        '" src="/front/document.send.php?docid='.$id.'" /></a>';
             } else {
                $out .= '<img alt="'.$image['tag'].
                        '" height="'.$height.'" width="'.$width.
                        '" src="/front/document.send.php?docid='.$id.'" />';

lekzz commented Nov 20, 2017

The inc/html.class.php:5466 fixes some of the issue but not all, inline mailed messages still have the wrong url, fix:

inc/html.class.php:5474

             if ($addLink) {
                $out .= '<a href="'.$CFG_GLPI['root_doc'].
                        '/front/document.send.php?docid='.$id.
                        '" target="_blank"><img alt="'.$image['tag'].
                        '" height="'.$height.'" width="'.$width.
                        '" src="'.$CFG_GLPI['root_doc'].
                   '/front/document.send.php?docid='.$id.'" /></a>';
             } else {
                $out .= '<img alt="'.$image['tag'].
                        '" height="'.$height.'" width="'.$width.
                        '" src="'.$CFG_GLPI['root_doc'].
                        '/front/document.send.php?docid='.$id.'" />';

to

             if ($addLink) {
                $out .= '<a href="/front/document.send.php?docid='.$id.
                        '" target="_blank"><img alt="'.$image['tag'].
                        '" height="'.$height.'" width="'.$width.
                        '" src="/front/document.send.php?docid='.$id.'" /></a>';
             } else {
                $out .= '<img alt="'.$image['tag'].
                        '" height="'.$height.'" width="'.$width.
                        '" src="/front/document.send.php?docid='.$id.'" />';
@lekzz

This comment has been minimized.

Show comment
Hide comment
@lekzz

lekzz Nov 20, 2017

Also it seems to mess up the email notifications with more then just one image.

When creating a new ticket or doing a follow up using the website with mutliple images only the first gets used in the notification.
But even funnier when doing the same using email, a preview of the 2nd image is shown in the mail. But when clicking on it you will be taken to the first image. Also the preview of the 2nd will have the dimensions of the first image.

Also it seems to want to resize/crop/whatever the first image using the website, but not the other images.

lekzz commented Nov 20, 2017

Also it seems to mess up the email notifications with more then just one image.

When creating a new ticket or doing a follow up using the website with mutliple images only the first gets used in the notification.
But even funnier when doing the same using email, a preview of the 2nd image is shown in the mail. But when clicking on it you will be taken to the first image. Also the preview of the 2nd will have the dimensions of the first image.

Also it seems to want to resize/crop/whatever the first image using the website, but not the other images.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Nov 20, 2017

It does not work even by changing / removing variables, someone to an idea? Because it's still a critical function ... 👎

ghost commented Nov 20, 2017

It does not work even by changing / removing variables, someone to an idea? Because it's still a critical function ... 👎

@lekzz

This comment has been minimized.

Show comment
Hide comment
@lekzz

lekzz Nov 22, 2017

The changes work for me but only on new uploaded images, not existing. Guess the generated tags are saved in the database.

lekzz commented Nov 22, 2017

The changes work for me but only on new uploaded images, not existing. Guess the generated tags are saved in the database.

@Claudissimo

This comment has been minimized.

Show comment
Hide comment
@Claudissimo

Claudissimo Dec 4, 2017

I have amended the inc/html.class.php file but it is still not working Under 9.2.1
We need a fix quickly guys please.

Thank you for your support

screeshot

Claudissimo commented Dec 4, 2017

I have amended the inc/html.class.php file but it is still not working Under 9.2.1
We need a fix quickly guys please.

Thank you for your support

screeshot

@okvok

This comment has been minimized.

Show comment
Hide comment
@okvok

okvok Dec 12, 2017

Hi. Confirm. The changes work. Thank you!

okvok commented Dec 12, 2017

Hi. Confirm. The changes work. Thank you!

@SoluNeXT

This comment has been minimized.

Show comment
Hide comment
@SoluNeXT

SoluNeXT Jan 31, 2018

Hi everybody
Corrected the code for images previews problem in tickets. The RegEx replacement is not working correctly. As I'm not a regex pro, i've made str_replace corrections. Here are the lines modified :

File : inc/notificationeventmailing.class.php
Line : ~157

               foreach ($document_items as $doc_i_data) {
/* ADD LINE DenisC BEGIN */
				  $doc = new Document();  
/* ADD LINE DenisC END */
                  $doc->getFromDB($doc_i_data['documents_id']);

Line : ~236

            // replace img[src] and a[href] by cid:tag in html content

            foreach ($inline_docs as $docID => $tag) {
/* REMOVED LINES DenisC BEGIN */
/*               $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'",
                  ],
                  $current->fields['body_html']);

*/
/* REMOVED LINES DenisC END */
/* ADD LINE DenisC BEGIN */
				$current->fields['body_html'] = str_replace('src="/front/document.send.php?docid='.$docID.'"','src="cid:'.$tag.'"',$current->fields['body_html']);
				$current->fields['body_html'] = str_replace('href="/front/document.send.php?docid='.$docID.'"','href="'.$CFG_GLPI['url_base'].'/front/document.send.php?docid='.$docID.'"',$current->fields['body_html']);
/* ADD LINE DenisC END */
            }

            $mmail->Body   .= $current->fields['body_html'];
            $mmail->AltBody = $current->fields['body_text'];
         }

Hope it will help some of you.
Cheers
Denis/SoluNeXT

SoluNeXT commented Jan 31, 2018

Hi everybody
Corrected the code for images previews problem in tickets. The RegEx replacement is not working correctly. As I'm not a regex pro, i've made str_replace corrections. Here are the lines modified :

File : inc/notificationeventmailing.class.php
Line : ~157

               foreach ($document_items as $doc_i_data) {
/* ADD LINE DenisC BEGIN */
				  $doc = new Document();  
/* ADD LINE DenisC END */
                  $doc->getFromDB($doc_i_data['documents_id']);

Line : ~236

            // replace img[src] and a[href] by cid:tag in html content

            foreach ($inline_docs as $docID => $tag) {
/* REMOVED LINES DenisC BEGIN */
/*               $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'",
                  ],
                  $current->fields['body_html']);

*/
/* REMOVED LINES DenisC END */
/* ADD LINE DenisC BEGIN */
				$current->fields['body_html'] = str_replace('src="/front/document.send.php?docid='.$docID.'"','src="cid:'.$tag.'"',$current->fields['body_html']);
				$current->fields['body_html'] = str_replace('href="/front/document.send.php?docid='.$docID.'"','href="'.$CFG_GLPI['url_base'].'/front/document.send.php?docid='.$docID.'"',$current->fields['body_html']);
/* ADD LINE DenisC END */
            }

            $mmail->Body   .= $current->fields['body_html'];
            $mmail->AltBody = $current->fields['body_text'];
         }

Hope it will help some of you.
Cheers
Denis/SoluNeXT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment