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.
forms: Fix ambiguous id / value for typeahead

If a dynamic list is displayed as a typeahead box, the value, when saved,
will be confused with the corresponding ID field for the list. MySQL
supports numeric comparison between the INT id column and the textual value
column. Therefore, if a typeahead field has the value of '01 - GooGoo', then
record will match the ListItem<id=1>, regardless of which list the item is
defined for.

This patch resolves the issue by submitting the ID number of the list
selection in the HTTP form.
Make using `realpath` safer
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.. :-(
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.
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
Ensure staff lookups are based on valid inputs

If something fishy, like an Array is received into the password reset system
or any part of the Staff management system, it should be rejected.

References:
http://osticket.com/forum/discussion/76003/sql-attack
Log password reset attempts
Double check value entered in typeahead fields

If the text does not match the value on record in the custom list, then the
value entered in the field cannot be accepted.

NOTE: This may have unintended i18n consequences, where there are varying
ways to write a letter in Unicode which may be rendered the same but will
not be correct with a string ==.
Merge pull request #435 from greezybacon/issue/log-pwreset-attempts

Log password reset attempts

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #422 from greezybacon/issue/numeric-typeahead-values

forms: Fix ambiguous id / value for typeahead

Reviewed-By: Peter Rotich <peter@osticket.com>