Add routing to check if a message is a bounced reply
Centralize how we check for auto replies.
Disable auto-response on a bounce.
Disable alerts to staff on auto-reply

The concern here is possible loop when an alert to staff bounces back to the
system.
Disable alerts to staff on bounces
Exclude the auto-responding email from possible alerts sent to staff
Add PK to %ticket_email_info.`id`

This patch partially reverts the previous database migration patch which
added a primary key to the table on the `thread_id` column. This column
cannot be used, because there may be multiple entries for thread_id = 0.

This also allows ticket_collaborator.isactive to be negative, as well as
adds the database portion of regex support for ticket filters.
filters: Implement regular expression matching
pipe: Use empty message token '--' if no message

Previously, the subject was duplicated, which is really confusing
pipe: Unwrap forwarded emails

If the mail received into the system has a content type of 'message/rfc822',
then unwrap the inner message and use it as the parsed email. Effectively,
assume the email was forwarded as an message/rfc822 attachment.
pipe: Honor inline bodies as valid message

Previously, if a message had a Content-Disposition header, then it could not
be considered as the body of the message.
Drop `subject` and `body` from filters

They are only available for tickets arriving via the email channel. All
other channel (including email) use the new ticket form to record the
subject and body, which are mapped to the 'Issue Summary' and 'Issue
Details' fields respectively

Structure the drop-down list for the `what` column to be future-minded
concerning custom user data matching.
Fixup isBounce detection logic
fetch: Implement parsing attached email

If the content of the message is of type `message/rfc822`, then support
downloading the body of the message and sending it off to the mail parsing
system, simulating a piped email.
Merge pull request #482 from greezybacon/issue/email-parse-issues

Fixup a few email piping issues

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #481 from greezybacon/issue/email-thread-pk

Correct the PK on %ticket_email_info

Reviewed-By: Peter Rotich <peter@osticket.com>
Use case-insensitive matching on email address

This patch addresses an issue where a client may have upper-case letters in
their email address. When visiting the client portal to check the ticket
status, previously, the exact same case would be required in the 'Email
Address' box.

This patch removes the case sensitivity for email logins.
Change from function specific static var to class var
Rename routines to make it a little clear on what they do
oops: Fix user lookup for update
Merge branch 'develop' into develop-next

Conflicts:
	include/class.usersession.php
oops: Fix finding key of existing file

If a file is attached via email and sent into the system, and a file is on
record with the same signature (hash) and size, the system will not save the
file. Instead, the key of the existing file would be found and used instead.

This patch fixes a bug in AttachmentFile::save. The key was generated for
the new file; however, if it was determined to be a duplicate, the key of
the existing file was not returned. Therefore generated key, which wasn't
saved to the database, was returned. Therefore, the wrong key was placed in
the body of the message with cid:<key> for inline images, although that key
would not exist in the database.

This patch correctly returns the existing key from the ::save() method
for de-duplicated files.
mysqli: Retry on deadlock-found error

If MySQL error #1213 (deadlock found when trying to get lock) is returned
from query, it is safe to retry the query.

This patch will retry queries up to two times for a total of three. If the
query cannot be executed without error #1213 after the third time, the error
is logged as usual, and the system continues with the failed query.