1. Kayako Download customers: we will continue to develop and support Kayako Download beyond July 2017, alongside the new Kayako for existing customers.

    Find out more.

  2. The forum you are viewing relates to Kayako Classic. If you signed up or upgraded to the new Kayako (after the 4th July 2016), the information in this thread may not apply to you. You can visit the forums for the new Kayako here.

Major fix for HTML emails + breaklines!

Discussion in 'Developing, APIs and extending' started by Marvin Herbold, Feb 11, 2012.

  1. Armin.Horst

    Armin.Horst Established Member

    Hi
    I have made a further patch to the file class.SWIFT_TicketPost.php posted by Gary in Post #48 in this thread ( for 4.40.1148, based on Marvin's earlier patch )

    We did have these two errors this morning for a new ticket:
    [Warning]: Invalid argument supplied for foreach() (Ticket/class.SWIFT_TicketPost.php:865)
    [Notice]: Trying to get property of non-object (Ticket/class.SWIFT_TicketPost.php:865)
    Customer did send us a one-line email and the HTML-Part of the EMail did not contain any tags

    I did have the error before, when using the tinyMCE patch and there were no tags in the raw response text, but this was the first time I had it on an email from a customer. First workaround was to toggle the "ishtml"-flag in swticketposts, which kind of confirmed that the issue had to do with the HTML-Conversion

    long story short,
    Around line 1268 I did add an "if", so that the functions to handle the HTML are only called if there really was HTML in the EMail:
    PHP:
                if ($_firstTag !== $_rootTag)
                {
                    
    // get rid of images embedded in the email
                  
    self::RemoveEmbeddedImages($_firstTag);
     
                  
    // get rid of the trailing html whitespace (tags at the end of the html that display nothing but space)
                  
    self::TrimTrailingWhitespace($_firstTag);
     
                  
    // reconstruct document tree into valid html
                  
    $_contents self::ReconstructHtml($_firstTag);
                }
    Armin
     
  2. Gary McGrath

    Gary McGrath Staff Member

    Hi Armin,

    I actually worked on a new html processor with a smart breakline processor with some people on the forum. It worked really well, I have just not had the time to update the forge with it. ( its basically a new version of the ticket post features project )

    I have attached the file here incase it is of interest, as it will be updated with new versions of Kayako ( like it works with the latest stable release )

    Gary
     

    Attached Files:

  3. Kornflake

    Kornflake Member

    Thank you for working on the ticket post features forge project. When I installed the latest file available on our 4.51.1891 Resolve we receive the following error when attempting to view a ticket:

    I am primarily interested only in the headers feature but I'm willing to take a look at how the html features work. I look forward to hearing your advice on this error. Thanks!
     
  4. Gary McGrath

    Gary McGrath Staff Member

    Hi there,

    What webserver are you rocking? That error pretty much means your php install does not have the tidy module installed/enabled.

    Gary
     
  5. Kornflake

    Kornflake Member

    Thank you for your fast response, we installed tidy and that fixed the problem. Apache Server. You might want to mention that tidy is required within the forge?

    Now we got a different error when trying to open an old ticket. fbreak3 at line 1150 was undefined. Is it difficult to modify your code to only support the original Ticket Header purpose? It seems like two separate projects are now being combined. Thanks for your help!
     
  6. Gary McGrath

    Gary McGrath Staff Member

    hi there,

    Try this file attached here, if that does not work, I will see about skipping the new changes for you

    Gary
     

    Attached Files:

  7. Kornflake

    Kornflake Member

    The error is now: Undefined variable: fbreak3 (./__apps/tickets/models/Ticket/class.SWIFT_TicketPost.php:1185) I think this is only happening on some old tickets.
     
  8. Gary McGrath

    Gary McGrath Staff Member

    Getting there, this should fix all the errors hopefully!

    Gary
     

    Attached Files:

  9. Kornflake

    Kornflake Member

    Thank you, I am not aware of any more errors with the code!! We did notice, however, that the 'header' information is no longer left-aligning/breaking at logical points. It makes it difficult to pick out the information we are looking for. Thanks!
     
  10. Gary McGrath

    Gary McGrath Staff Member

    ah ok, I will take a look at that, it might just be that its been stripped of newline chars, but I wont have an update for that until tomorrow

    Gary
     
  11. Gary McGrath

    Gary McGrath Staff Member

    Ok, this one attached will bring back the formatting of the headers too.

    Gary
     

    Attached Files:

  12. Kornflake

    Kornflake Member

    Thank you, we have deployed your attached file into production. Looks good!
     
  13. Kornflake

    Kornflake Member

  14. Amar

    Amar New Member

  15. Gary McGrath

    Gary McGrath Staff Member

    Hi Amar,

    Out of the box they wont be, the ticketpost file will need to have both changes merged into it, I will see if I have time later on today to created a merged file for you

    Gary
     
    Amar likes this.
  16. Gary McGrath

    Gary McGrath Staff Member

    Hi Amar,

    Here is a version of ticket post features which also includes the changes needed for the tinymce post editor. ( just replace the origional with this one after you have enabled the tinymce editor )

    N.B. to others, do not use this file on its own, it will only work if you have installed the tinymce editor first.

    Gary
     

    Attached Files:

    Amar likes this.
  17. Amar

    Amar New Member

    Dear Gary,

    Thank you very much for your help.

    When I am using the file, Its showing blank page. Do you know the reason for this ?

    Thank you
     

    Attached Files:

  18. Gary McGrath

    Gary McGrath Staff Member

    Hi Amar,

    Did you follow the install text file correctly for the patch, I don't think that error is down to the mod I did, but rather an issue with the tinymce patch.

    did you make sure to upload the files, and then afterwards, upload a setup folder for your version of the helpdesk and process through an "upgrade" procedure?

    Gary
     
    Amar likes this.
  19. Amar

    Amar New Member

    Dear Gary,

    Thank you for your reply.

    Sorry It was my mistake. I didn't installed php-tidy before. We installed tidy and that fixed the problem.

    Thank you very much for your help.

    Thank you

    Amar
     
  20. Gary McGrath

    Gary McGrath Staff Member

    Hi Amar,

    Glad you got that working, happy I could help :)

    Gary
     
    Amar likes this.

Share This Page