MDL-38493 Make mdeploy.php able to install new plugin

The patch implements the second mode of the mdeploy.php script. If
--install option is passed, the given package is downloaded, verified
and deployed to the requested location.
MDL-38493 Improve documentation of mdeploy.php
MDL-38509 Document the plugin deployment lockers in config-dist.php
MDL-38509 Implement new plugin_manager::get_plugin_types()

This new method just takes the result of the core get_plugin_types() and
re-orders the plugin types in the same way as they are displayed at the
Plugins overview screen.
MDL-38509 Implement new plugin_manager::plugintype_name()

This has exactly the same behaviour as the existing
plugintype_name_plural() method, but returns the singular form of the
plugin type (such as 'Activity module').
MDL-38509 Initial version of the new admin tool to install add-ons
MDL-38509 Mark the new installaddon admin tool as the standard plugin
MDL-38509 Check for writable plugin type location in install from ZIP form

Standard mform validation is implemented as well as progressively
enhanced AJAX version.
MDL-38509 Implement the plugin ZIP package validator

The validator code contains (modified) fragments of the
local_plugins_archive_validator class copyrighted by Marina Glancy that
is part of the local_plugins plugin. It operates over an extracted
copy of the ZIP file.
MDL-38509 Add new tool_installaddon_installer::get_plugintype_root() method
MDL-38509 Save uploaded ZIP into a temporary location and redirect to validator
MDL-38509 Add new tool_installaddon_installer::extract_installfromzip_file() method
MDL-38509 Implement the ZIP package validation page

The script validate.php expects a ZIP file stored in a temporary
location. It extracts the ZIP (optionally renaming the root directory)
and executes the validator. Then it renders the validator log messages
and continue buttons.
MDL-38509 Add strings for the new admin tool
MDL-38509 Add the script that finally deploys the validated ZIP contents
MDL-38509 Fix the communication protocol with Moodle plugins directory

Implements the behaviour currently specified at
http://docs.moodle.org/dev/On-click_add-on_installation
MDL-38509 Move the tool node in the navigation

The "Install add-ons" should appear just below Site administration >
Plugins, before the "Activity modules".
MDL-38509 Add ability to install add-ons from the remote repository

There is a new hook in the index.php file. If valid HTTP parameter
installaddonrequest is detected, the installer asks the administrator to
confirm the request.

If confirmed, the installer calls download.moodle.org/api/1.2/pluginfo.php
service to get information about the given plugin version. The essential
data are the URL of the ZIP to download and the MD5 hash of the ZIP.
These data must be fetched via HTTPS to protect against MiM attack.

If the ZIP is downloaded and the MD5 content hash is correct, the user
is redirected to the previously implemented ZIP validation page, as if
the ZIP was uploaded manually.

The valid format of the installaddonrequest is documented via the
test_decode_remote_request() unit test method.
MDL-38509 Add hook for the installaddonrequest into admin/index.php

If the user selects a plugin in Moodle plugins directory to be installed
into their site, Moodle plugins directory will redirect them into their
site's admin/index.php script, providing the installaddonrequest
parameter.

This patch makes sure that only if the user is logged-in as the admin
and the site is fully installed and up-to-date, the add-on installation
request will be dispatched to the tool_installaddon for actual
processing.

We need to store the installaddonrequest value in the $PAGE's URL so
that is is stored in $SESSION->wantsurl in case the user needs to log in
at their site. Thanks to this, the request is dispatched after the user
logs in.