Fix display of priority field in queue export

Also removes the fetching of priorities separately and addresses sorting of
priorities by the ID field rather than the urgency field.
Merge pull request #451 from greezybacon/issue/priority-export

Fix display of priority field in queue export

Reviewed-By: Peter Rotich <peter@osticket.com>
forms: Fix crash if selection-field not set

If a custom list item were added to an email template, and there is no data
for the field (ie. the field is not required) when the template is rendered,
the system would crash.

toString() is required to return a string, no matter what. This patch
cascades the (string) coercion to the current value of the list field if it
is not an instance of a DynamicListItem
emails: Allow specifying how deep to recurse

Previously, the mail parsing and fetching system would recurse unbounded
searching for bodies by content-type
emails: Mail_Parse detects bounce emails
Ticket thread supports specifying `thread-type`

This allows the email system to detect something like a bounce mail and
specify that the associated message should be an internal note.
emails: Add bounce detection for mail fetching
Remove bit-rotted code
Hide close/hide dialog when esc key is pressed
Timeout after max timeout while fetching emails

Processing fetching in ASC order of the last fetch time
Remove LIMIT of 10 emails per fetch
Flush the buffer and terminate the request cleanly on autocron
forms: Fix ticket submission if already logged in

If a client is already logged into the client portal and attempts to submit
a new ticket, the ticket will be rejected if the contact-information form
has a required field other than `name` and `email`.

This patch fixes `class Client` so that the user-id is fetched from the
database and made available via the `::getUserId()` method. This was already
corrected in the `develop-next` branch for v1.8.1. The `uid` field is passed
into `Ticket::create()` so the user form validation is bypassed.

This commit should be ignored when merged into the 1.8.1 codebase.
Merge pull request #469 from greezybacon/issue/logged-in-client

forms: Fix ticket submission if already logged in

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #465 from slm4996/feature/popups

Hide close/hide dialog when esc key is pressed fixes issue #441

Reviewed-By: Jared Hancock <jared@osticket.com>
Merge pull request #468 from protich/feature/mailfetch

Timeout after max timeout while fetching emails

Reviewed-By: Jared Hancock <jared@osticket.com>
Reviewed-By: Alan Wilkes
Add Return-Path header for outbound SMTP mail
Merge pull request #461 from greezybacon/feature/handle-bounce-mails

Handle email bounce notifications

Reviewed-By: Peter Rotich <peter@osticket.com>
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