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.
Fetch thread before deleting ticket
Ensure a ROOT_PATH is defined for CLI apps
Disambiguate `status` field on ticket queue view
Make using `realpath` safer
filters: Unpack the user information before filter

If a user is created / selected before opening a ticket (very likely the
case in the SCP), the email address and name should be unpacked into the
$vars dictionary prior to creating and processing ticket filters
Adds missing argument for Ticket::lookup for ajax.

Couldn't find the rebase to this.. actually, I didn't look, I'm still struggling with git and eclipse, would probably have been easier with vim! Anyway, rewrote changes for 1.7.
Update ajax.tickets.php

Missed one.. :-(
Merge pull request #425 from greezybacon/issue/filter-deny-scp

filters: Unpack the user information before filter

Reviewed-By: Peter Rotich <peter@osticket.com>
forms: Allow decl of promt and default for choices

Allow the administrator to enter a prompt to be shown in the choices
drop-down for choice fields. Also add the option of selecting a default
value from the list initially rather than displaying a prompt.
Merge pull request #421 from greezybacon/issue/420

Ensure a ROOT_PATH is defined for CLI apps

Reviewed-By: Peter Rotich <peter@osticket.com>
mysql: Retire old mysql constants

Required for PHP 5.5 compatibility
Merge pull request #878 from greezybacon/issue/ticket-lock-lookup

Fix parameter count to TicketLock::lookup

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #427 from greezybacon/feature/choice-field-prompt

forms: Allow decl of prompt and default for choices

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #417 from greezybacon/feature/revisit-template-layout

Revisit template management page

Reviewed-By: Peter Rotich <peter@osticket.com>
Allow staff to cancel user lookup popup when creating a new ticket

The change will allows staff to open a new ticket without going through the
"forced" user lookup popup. On cancel the staff is presented with a
simplified user info form with email and name being the only fields
required.
Merge pull request #424 from greezybacon/issue/361

Make using `realpath` safer

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #434 from protich/feature/new-ticket-revisited

Allow staff to cancel user lookup popup when creating a new ticket

Reviewed-By: Jared Hancock <jared@osticket.com>
Don't refer to class Misc in deploy scripts
Merge remote branch 'upstream-1.7/develop' into develop

Conflicts:
	include/mysqli.php