Module: Messages

ver.1.0.0.11
- a reassigned ticket: the new assigned administrator gets the 'Ticket #N Was Assigned to You' email (nothing is sent when an administrator assigns the ticket to himself); a vendor (Ka Messages for Ka Multivendor) gets it only when the vendor is changed, saving the properties with the same vendor does not send it again
- the 'Last Message' column of the ticket lists (admin, customer account, vendor account) shows the date of the last message of the ticket and the lists are sorted by it (the column showed the date of the ticket, the sorting used the last change of the ticket)
- an administrator reply by email marks the ticket answered, as a reply on the ticket page
- store alerts: the new review alert used a missing setting and failed with 'E-Mail to required!', now it goes to the Admin E-Mail as the order, registration and affiliate alerts; when the Admin E-Mail is empty the alerts go to the store E-Mail as in OpenCart (they failed before)
- email templates in Russian (_ru.twig of all ticket emails, admin and catalog); a language without its own templates gets the English emails (the emails failed with 'template is not found'); the subjects 'Ticket #N Was Assigned to You' and 'Ticket #N has been closed' are translated (mail.php language files)
- emails: the 'Customer:' line of the admin emails lists the customers of the ticket, spaces after 'Customer:', 'Subject:' and 'Message:'; the greeting of the customer emails has the name of the recipient (it was empty); 'Please read this message' typo
- a ticket without an assigned administrator (Default Assigned User is not set) does not write 'assigned_user was not found' to the error log
- admin: the Split dialog button is 'Split' (it was 'Move'), 'Assigned To Vendor' without the extra colon, the New Ticket page has one breadcrumb 'New Ticket', the closed ticket alert speaks about tickets (admin and customer pages, en-gb and ru-ru), 'The ticket has been marked answered' typo; the ticket title column of the admin list is narrower and the Actions column takes the width of its buttons, so the delete button fits a 1280 px screen
- readme: the module name in readme.customer_verification.txt, versions, the documentation link; Ka Extensions page: Docs and Info links (kamod.ini)
- fixed: a customer reply to his own email of a ticket (e.g. a follow-up with an attachment) created a new ticket: the cron links an email to the ticket by In-Reply-To and, when In-Reply-To has no id of the store, by the References ids from the newest to the oldest; References ids pass the same signature check as In-Reply-To
- emails of ticket messages have a References header (the first message of the ticket and the previous messages, the oldest first; a long thread keeps the first id and the 19 newest ids, the header is not longer than 900 characters), so mail clients keep the store ids in replies
- cron: ids of the store with an invalid signature in In-Reply-To or References (e.g. after a change of the secret key) are written to the ka_messages.cron log (the message id only, without the hash)
- Ka Messages for Ka Multivendor: fixed PHP warnings on the vendor ticket page for a ticket without an assigned administrator ("Undefined array key user_id") and for a ticket or message whose author account was deleted

ver.1.0.0.10
- images can be inserted into the message text from files (admin and customer ticket pages: new ticket, reply, admin edit and split dialogs): the image dialog (several files), paste from the clipboard, drag and drop; upload progress and errors are shown under the editor, the message cannot be sent while images are uploading; insertion of images by url works as before
- JPEG, PNG, GIF and WebP images are accepted, the type is checked by the content; JPEG, PNG and WebP are saved again once with GD (EXIF and GPS data removed, orientation applied, reduced to 2560 px, a 1200 px copy for the message list); GIF is stored as is (animation is kept); WebP is stored as is when GD cannot process WebP and the image does not need to be reduced
- uploaded images are drafts of their author until the message is sent; images are shown by a protected script: drafts to their author only, images of messages by the access rules of the ticket (customers of the ticket with a verified email, administrators); safe headers (nosniff, sandbox CSP, inline, private cache, ETag)
- messages keep images as ![alt](kamsg-image:<id>), never as links with 'user_token'; only own drafts and images of the same ticket are kept in a saved message, quoted images are copied to the new message, a split message gets copies of its images, images removed by editing are deleted; image descriptions cannot add other images or links to the message
- images in the ticket messages (admin, customer and vendor) are reduced to 600 px, a click opens the full image in a popup (Magnific Popup or a Bootstrap modal)
- Ka Messages for Ka Multivendor: vendors insert images into the message text from files in the reply and new ticket forms like customers; images are shown to the vendor by the vendor image script: his drafts and images of tickets assigned to him only; uploaded images of vendors are drafts of the vendor until the message is sent
- Ka Messages for Ka Multivendor: links of images over the email limit and of attachments in vendor emails open the vendor pages (they opened the customer pages, which are not available to vendors)
- Ka Messages for Ka Multivendor: the file name of a downloaded attachment is cleaned on the vendor page (quotes and line breaks), the message error is shown in the vendor reply form
- notification emails contain the images of their message embedded in the email (Content-ID, the 1200 px copies are used), up to 5 MB of images in one email, next images are links to the image page (login is needed); images are limited to 600 px in emails; images of other messages and tickets are never added to an email, they are shown as their descriptions; the stored message is not changed
- with Ka Extensions 4.1.1.30 or newer the images are sent as inline images (image/* parts with 'Content-Disposition: inline' in multipart/related, Content-ID from Mail::generateCid(), the original file name of the image: path parts, line breaks and quotes are removed, the name is shortened to 100 characters, the extension is set by the real image type, kamsg-<id>.<ext> when there is no usable name), so mail clients do not list them as attachments; with older Ka Extensions versions (4.1.1.28 is still the minimum) they are attachments with the Content-ID kamsg-<id>.<ext> as before. After the update of Ka Extensions the kamod cache has to be rebuilt, until then the old way is used
- images of incoming emails (images pasted into the email text, cid: images of attachments and data: images) are saved as inline images of the new message with the checks of uploaded images; the image limit of a message is not applied to emails (not more than 50 images of one email are saved); rejected images are shown as their descriptions and their files are saved as attachments; images of quoted text and images of the module emails (file names and Content-IDs kamsg-*, Content-IDs ka-<md5> of Ka Extensions 4.1.1.30+) are not saved; images of the ticket sent again in replies with other Content-IDs or names (Outlook) or as attachments are found by the content (md5 of the image and of its reduced copy) and are not saved either; image placeholders written in emails are removed; other image attachments stay attachments
- fixed: an image pasted into an email reply was shown as a broken image; old messages with such images show the image description
- attached text files of incoming emails are saved as attachments instead of being added to the message text; images of multipart/related emails without Content-Disposition are found
- inline images are not listed as message attachments; they are deleted with their message or ticket
- cron deletes drafts of images older than 24 hours, temporary files and files without attachment records (once an hour, files younger than 24 hours and files outside ticket_attachments are not touched)
- new settings: maximum images in a message (10, from 1 to 50) and maximum image size (5 MB, from 1 to 50)
- the attachments table has new fields for inline images: update the extension on the Ka Extensions page to add the fields and the default settings (stored settings are kept)
- texts in en-gb and ru-ru
- cron: a reply to a deleted message or ticket creates a new ticket (customer replies with the usual new ticket notification, admin replies without notifications); invalid signatures are handled as before
- fixed: image links sometimes returned an empty response (the 304 Not Modified answer was sent without headers)

ver.1.0.0.9
- tickets have an email verification status and a source (email, form, chat, admin, customer, vendor); existing tickets stay verified, their source is 'email' (update the extension on the Ka Extensions page to add the fields)
- tickets from the contact form are not verified when the visitor is not logged in, uses another email or his email is not confirmed
- not verified tickets are not shown in the customer account (list, ticket page, attachments); an email from the ticket address to such a ticket makes it verified
- admin: the ticket list shows an exclamation icon for not verified tickets, the ticket page shows 'email not verified', the source and the 'Verified' button; admin notification emails say 'email not verified'
- tickets created by an admin have the source 'admin' (also new tickets made by moving or splitting a message, they keep the verification status of the original ticket); tickets created by a customer in his account have the source 'customer'; tickets created by a vendor for a customer (Ka Messages for Multivendor) have the source 'vendor'
- other modules can create a ticket with the 'email_verified' and 'source' values (optional fields of addTicket())

ver.1.0.0.8
- the attachments widget is a JavaScript class (KaMessagesAttachments) created in the form templates with its options, so it can be extended later
- attachment sizes in hints and errors are formatted by the Ka Extensions library (translatable size units)
- fixed: Cancel in the Unban confirmation and other buttons on the Banned Emails page submitted the ban form
- the contact form patch works when the 'private $error' line is already replaced by another module
- Ka Extensions library 4.1.1.28 or newer is required

ver.1.0.0.7
- admin ticket list: the trash button marks a ticket for deletion (the row becomes pale, the second click removes the mark), the marked tickets are deleted by the 'Update' button after a confirmation; the list opens again with the same filter, sorting and page
- tickets are deleted by administrators with the 'modify' permission only, a ticket is not deleted by a link (GET request) any more
- a deleted ticket or message also deletes the email send statuses, the attachment folders and the ticket tasks (with Ticket Tasks)
- new settings: maximum attachments in a message (5), maximum attachment size (10 MB), allowed attachment extensions
- message forms (admin, customer, vendor): one 'Add files' button instead of two file fields; it can be pressed many times to add files from different folders, the list shows the files with their sizes and a button to remove a file, the button is disabled at the limit
- the number, size and type of attached files are checked on the server, emails imported from the mailbox are not limited
- email bans: new page Customers > Banned Emails (list of rules with the comment, date and administrator, filter by email, sorting, Unban, a form to add a rule); a rule is an email or a mask with '*' (any characters), case-insensitive, masks like '*' or '*@*' are rejected; a rule for john@example.com also bans john+tag@example.com
- nothing is created for a banned sender: no tickets, messages, customers or emails; emails from banned senders are moved to the BANNED folder of the mailbox (to SKIPPED when the folder cannot be created), replies to existing tickets are blocked too, banned To/CC addresses are not added to tickets
- the contact form and the customer and vendor ticket pages tell the sender that the address is blocked
- 'Ban' button in the admin ticket list and 'Ban Sender' on the ticket page (administrators with the 'modify' permission of Banned Emails): the dialog has the sender email, a comment and options to delete the ticket and other open tickets from the address
- new table ka_ticket_bans (update the extension on the Ka Extensions page to create it and to get permissions for the new page)

ver.1.0.0.6
- the admin ticket list remembers the last filter of each administrator; the Clear button resets it
- new table ka_user_settings for values saved per administrator (reinstall the extension to create it)

ver.1.0.0.5
- messages are entered in a visual editor (Summernote) on admin, customer and vendor ticket pages, in the new ticket forms and in the admin edit and split popups; admin uses Summernote bundled with OpenCart, the storefront uses Summernote 0.8.18 bundled with the module
- the editor supports bold, italic, headings, quotes, lists, links and images by url; the html is saved as markdown
- Reply inserts the message or the selected fragment as a quote to the editor, the quote level of the fragment is kept
- messages are rendered by Parsedown in safe mode: raw html is escaped, links and images are allowed for http and https urls only

ver.1.0.0.4
- the send status of message emails (new message, new ticket) is saved for every recipient
- failed message emails are sent again by cron with increasing delays (up to 5 attempts)
- the admin ticket page shows the email send status of each message and allows to resend it to recipients who have not received it
- fixed: the 'ticket assigned' email to administrator was not sent (wrong template path)
- requires Ka Extensions with Mail::setSuppressExceptions() to detect failed emails

ver.1.0.0.3
- added Russian language for the admin area
- admin interface strings (buttons, tabs, labels, placeholders) are translatable now
- the customer can close a ticket by a POST request only (protection against closing by a link from another site)
- fixed: closing a non-existing ticket in the customer area threw an uncaught exception
- fixed: the ticket autocomplete in the admin area was filtered by a wrong customer
- fixed: SQL error when users were filtered by email; users sorting
- fixed: attachments of a deleted message were not removed
- fixed: fatal errors on missing ticket_id/message_id (wrong exception class), wrong attachments model property in the catalog
- the foreign key is removed from the ka_ticket_messages table definition (it used a hard-coded "oc_" prefix)
- removed a debug JS call in the customer ticket template
- readme: removed the license registration step

ver.1.0.0.2
- added the ability to split a message to several messages

ver.1.0.0.1
- 'customer verification' is included to the 'Customer Messages' package

ver.1.0.0.0
===========
- module released