Show extra forms for help topic first

Extra forms associated with the help topic are now shown above the ticket
details form on both the staff and client interfaces.
Allow autocomplete on email address
Fix ticket queue counts for limited users
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 remove the case sensitivity for email logins.
Fix subject ticket number matcher (again)
Merge pull request #876 from greezybacon/issue/875

Use case-insensitive matching on email address

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #877 from greezybacon/issue/subject-ticket-number

Fix subject ticket number matcher (again)

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #398 from greezybacon/issue/render-extra-form-first

Show extra forms for help topic first

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #401 from greezybacon/issue/allow-autocomplete-on-client

Allow autocomplete on email address

Reviewed-By: Peter Rotich <peter@osticket.com>
Make priority field type NOT changeable

This is necessary because the system depends ticket priority to sort and
display ticket data.
Merge remote branch 'upstream-1.7/develop' into develop
Revisit template management page

Arrange templates in a group by their respective use in the system:

  * System Management Templates
  * Staff Ticket Templates (Alerts and Notices)
  * End-User Ticket Templates (Autoresponder)

This provides an interface to sort the templates and make them easier to
find and provides a nice place for new templates to be added without making
it increasingly more difficult to locate templates in the list.

This patch also fixes the missing templates in the drop-down list when
editing an implemented template.
Use config URL instead of THISPAGE

THISPAGE is unreliable for CLI cron calls. It was historically used so the
admin could figure out which file/page generated the error. But with
backtrace support we no longer need it.
Merge pull request #412 from protich/issue/baseurl

Use config URL instead of THISPAGE

Reviewed-By: Jared Hancock <jared@osticket.com>
Drop the cdata table on field type change

If a field on the ticket details form changes type, recreate the cdata table
Merge pull request #413 from greezybacon/issue/drop-cdata-on-type-change

Drop the data table on field type change

Reviewed-By: Peter Rotich <peter@osticket.com>
Don't update the session unless it changes

And deadband session token updates to 1 per 30 seconds
Don't fetch ticket thread unless necessary
Don't generate staff statistics for AJAX requests
Periodically optimize core tables

This is instead of optimizing the lock table for every cron run, which
wastes a lot of db server io