Documentation for $g_allow_signup and $g_send_reset_password

Improves documentation and comments in config_defaults_inc.php, to
reflect the dependency between these 2 variables and the consequences of
having g_send_reset_password = OFF.

Fixes #6263
Documentation: Lots of minor spelling corrections

Backported from master 3081622d1c3c040cd76f9cfb1a0c25adf7fede26
Allow custom default avatar icons

Following implementation of #13992, it was no longer possible for
administrators to define a custom default avatar, as Mantis forced use
of Gravatar's 'identicon'.

This commit reintroduces that functionality, and allows use of either
one of Gravatar's default images or a custom one (identified by an URL),
through appropriate configuration of $g_show_avatar.

Fixes #14032
Maintain old behavior for default gravatar icons

This is a follow up commit for f710546a49e67cc6d014c46013269415b46a181e
that ensures installations using $g_show_avatar = ON maintain the same
behavior as before. In other words, setting the config to ON is
equivalent to 'identicon'.

Fixes #14032
Store bugnote URL replacement string in a static variable

The purpose is to make code more readable.

Follow up on fix for issue #14447.
Upgrade PHPMailer from 5.1 to 5.2.1

Version 5.2.1 (January 16, 2012)
* Closed several bugs
* Performance improvements
* MsgHTML() now returns the message as required.
* New method: GetSentMIMEMessage() (returns full copy of sent message)

Version 5.2 (July 19, 2011)
* protected MIME body and header
* better DKIM DNS Resource Record support
* better aly handling
* htmlfilter class added to extras
* moved to Apache Extras

Fixes #12562
Fix #14630: Improved logging for emails

Prior to this, several e-mail related events were not reported at all,
making troubleshooting of issues difficult. The following cases are now
logged:

 * sending of queued messages (email_send_all)
 * errors thrown by PHPMailer
 * reminder emails (email_bug_reminder) - fixes #9368
 * deletion of records from the email queue

In addition, admin/email_queue.php was modified to print a formatted
date instead of a numeric timestamp.
Fix #14631: Consistent email validation

PHPMailer uses filter_var() to check for an e-mail validity; this
function treats single-domain e-mail addresses (e.g. user@localhost) as
invalid. However, Mantis API function email_is_valid() relies on a
custom regex to validate e-mails, which does accept such addresses. As a
consequence, we accept addresses to which we are unable to send
messages.

To avoid this problem, we now rely on PHPMailer::ValidateAddress()
method to ensure that any email we store can be sent PHPMailer.
Do not skip e-mail validation if $g_login_method != LDAP

Prior to this, function email_is_valid() always returned true when
$g_use_ldap_email = ON, even if $g_login_method != LDAP.

Even though this is not an usual case (when not using LDAP, the other
LDAP-related configuration options should be left to their default
values), this causes the actual validation to be skipped which could
lead to email sending errors.

Fixes #14632
Bugnote '~' processing may produce error if bug does not exist

This error case is a bit far-fetched, and should normally not occur
unless there is some data corruption. If referencing an existing bugnote
whose parent bug is not in the database, the callback function cannot
retrieve the project_id, so error 403 is triggered.

The callback functions have also been reformatted for better readability

Fixes #12580
Localisation updates from http://translatewiki.net.
Protect $g_default_category_for_moves from deletion

When a category defined as default_category_for_moves is deleted and an
issue is subsequently moved to another project where its current
category does not exist, it gets assigned a non-existing category. This
causes application error 1502 to be triggered whenever MantisBT tries to
display the issue's Category, which can cause a system lock up.

This commit reduces the risk of this situation from happening, by
preventing users from deleting categories which are used as default
(either defined in config_inc.php or in the config table).

Fixes #14478
Localisation updates from http://translatewiki.net.
Fix #14655: Filtering of tags starting with '0' not possible
Add user_set_fields function

Affects #14673: LDAP login performs unnecessary SQL updates 
ldap_api: use only one SQL call to update user profile

Fixes #14673: LDAP login performs unnecessary SQL updates 
Localisation updates from http://translatewiki.net.
Improve comments for custom field length check

Function custom_field_get_id_from_name() contains code to check for
truncated custom fields names. This dates back to when the history
table's field_name column was only 32 chars long, whereas the custom
field's size is 64.

Even though the history's field_name size has been increased to 64 since
1.1.0a4 (see issue #8002), the check must be maintained to ensure
compatibility with upgraded legacy systems.

The fix ce3450aaabbd9d9feceb03d77d4358f195e7d966 implemented in master
branch cannot be applied here as it contains a schema update. Instead,
comments have been reworded and obsolete reference to old schema
removed.

Fixes #14650
Fix SQL error when sorting by custom field containing special char

Incorrect behavior is due to unnecessarily escaping of special chars by
calling db_prepare_string() on the custom field's name before attempting
to retrieve it's id with custom_field_get_id_from_name(). This causes a
double-escaping which prevents a match.

Even though this is not strictly necessary to fix the issue at hand,
this commit also replaces db_query() call by db_query_bound() in
custom_field_get_id_from_name().

Fixes #12170
Add optional param to columns_get_standard() to return all columns

The default behavior is to exclude the fields which are not "active" due
to config settings. The new parameter lets caller override that to
return all standard columns (ie. excluding custom fields).