MDL-25500 lock: New locking framework.

This locking system is designed to be used everywhere requiring
locking in Moodle. Each use of the locking system can be configured
to use a different type of locking (or the same type with a different
configuration).

The first supported lock types are memcache, memcached, file (flock),
db (specific handlers for pg, mysql and mariadb).
MDL-42928 JavaScript: Create a module to handle page scroll locking
MDL-42928 JavaScript: Add LockScroll to all modal dialogues
MDL-42928 JavaScript: Disable lockScroll for small chooserdialogues
MDL-34055 add bulk DB->insert_records() method

This patch was inspired by patch by Simon Coggins from Totara.
MDL-40909 mod_forum: removed duplicated test (duplicated in enrol/meta/tests/plugin_test.php)
MDL-40909 core_enrol: removed 'unenrol' add_to_log calls

Before each of these calls a call to unenrol_user() is made, which
triggers the event 'user_enrolment_deleted'. Nothing more is needed.
MDL-40909 core_enrol: removed 'enrol' add_to_log calls

Before each of these calls a call to enrol_user() is made, which
triggers the event 'user_enrolment_created'. Nothing more is needed.
MDL-40909 enrol_imsenterprise: removed 'new' add_to_log call

Here we are replacing the unnecessary code used to create a course with
a call to create_course(), which triggers the event 'course_created'.
Nothing more is needed.
Merge branch 'w04_MDL-34055_m27_insertrecords' of https://github.com/skodak/moodle
Merge branch 'MDL-42928-master' of git://github.com/andrewnicols/moodle

Conflicts:
	theme/bootstrapbase/style/moodle.css
MDL-25500 Lock: Do not use file locking if $CFG->preventfilelocking is set

(And file_lock_dir is not prefixed with the dataroot).
Merge branch 'MDL-40909_master' of https://github.com/markn86/moodle
MDL-43040 Replace $module with $plugin in all mod/*/version.php

Conflicts:
	mod/quiz/version.php
Merge branch 'MDL-25500-master-squashed' of git://github.com/damyon/moodle
MDL-25500 lock: post integration trivial cleanup

* A couple of misc comment typo's
* Added missing $CFG required global in file_lock_factory::is_available
* Removed unused $CFG global from file_lock_factory::get_lock
* A couple of trivial phpdoc tweaks
* Removed unused $DB global from postgres_lock_factory::get_index_from_key
* Added global namespace \ to exceptions in get_index_from_key (tested and found they didn't resolve)
MDL-43040 Note the deprecation and add some TODOs
Merge branch 'MDL-43040'
MDL-43736 Events: event->contextinstanceid should be used where possible

While restoring event context might not be present (deleted)
So before using context api's check context or use event properties
MDL-43736 Events: Updated unit test to test context not used in event