MDL-49583 enrol: enrol/index.php page doesn't handle direct access well
MDL-49583 enrol: enrol/index.php page doesn't handle direct access well

Before this patch if a user who is not logged in to Moodle accesses the
enrol/index.php page directly they were redirected to the Moodle front
page after login, rather than back to a page that would allow them to
self enrol, if it is enabled on the course.

This change will cause a user who directly accesses the page to be
redirected back to it after they have logged in, unless the course has guest
access enabled.

Thanks to Marina Glancy for suggesting the use of get_referer()

dilawar/moodle