Skip to content
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
Closed

[9.2] image insertion in mail ticket notification #2869

kelior opened this issue Sep 29, 2017 · 22 comments
Assignees
Labels
Milestone

Comments

@kelior
Copy link

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
Copy link

alias59 commented Sep 29, 2017

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

@kelior
Copy link
Author

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
Copy link

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
Copy link

alias59 commented Sep 29, 2017

Check general configuration
address Web : image

@kelior
Copy link
Author

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
Copy link

as same problem. bad link image in ticket

image

@rjmontenegro
Copy link

rjmontenegro commented Oct 12, 2017

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

IE
glpi
glpi3

Chrome
glpi2

@alias59
Copy link

alias59 commented Oct 17, 2017

@kelior, Have you find solution ?

@babaymaster
Copy link

no, wait new realease,,,,

@orthagh
Copy link
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
Copy link
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 pushed a commit to orthagh/glpi that referenced this issue Nov 2, 2017
delete redondant code
depreciate Ticket::convertContentForNotification
@trasher trasher closed this as completed in 48ca89d Nov 2, 2017
trasher pushed a commit that referenced this issue Nov 2, 2017
delete redondant code
depreciate Ticket::convertContentForNotification
@dbegit
Copy link

dbegit commented Nov 20, 2017

#3154
The problem is not resolve on 9.2.1
Url of img is wrong
http://srvglpi/var/www/html/glpi/front/document.send.php?docid=6481
instead of
http://srvglpi/front/document.send.php?docid=6481

@kelior
Copy link
Author

kelior commented Nov 20, 2017

It is fixed on my end

@rjmontenegro
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

okvok commented Dec 12, 2017

Hi. Confirm. The changes work. Thank you!

@SoluNeXT
Copy link

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
Labels
Projects
None yet
Development

No branches or pull requests