MDL-42016 core_repository: Simplify API to sync external files

Too many functions, too different parameters, unnecessary DB queries.
All repositories developed for Moodle 2.3-2.5 will continue to work.

Also get rid of DB field files_reference.lifetime, it is absolutely unnecessary
because there is an API function for it and all repositories return constant there anyway.
MDL-42016 Properly synchronise internal references
MDL-42016 Implement new sync method in repositories
MDL-42016 Added field reference deatils