This introduces a new "controlled link" file type where the file is not
stored in Moodle - but Moodle will control the access permissions on the file.
Plugins can "freeze" a filearea which means Moodle will take ownership of all the remote
files of this type.
When accessing a file, if the "filebrowser" infomation indicates the current user can write to the file, they
will be granted temporary write access.
Part of MDL-58220
The function send_content_uncached() is meant to be used when serving
content which should not be cached by browsers/proxies. You will
use this in development mode, or when the request is malformed
but you need to return some fallback content which shouldn't be stored
under the URL it was requested from.
The function file_safe_save_content() should only be used for content
not stored in the file API. Good candidates for this are resource
which fit well in the localcache. The function tries to write the
content in the most atomic way as possible to prevent incomplete
writes or concurrent writes.
This functionality was commented out in
78946b9bdb1299a21f00b88d81c73ad8700c951e for MDL-20204 back in 2009.
Since then it has been wasting cycles performing utterly pointless
preg_match and preg_replace calls.
The decision has been made to deprecate it in stables, and remove it in
3.2.
This was a complex change requiring three new functions:
file_merge_files_from_draft_area_into_filearea - To just add files from a draft area into a real one (just adding or updating, not deleting)
file_merge_draft_area_into_draft_area - To merge files from two draft areas, used by the latest for creating a draft area with all the original files plus the new ones.
file_overwrite_existing_draftfile - Required to update existing files not losing metadata or references.
The whole process is the following:
User uploads a file (upload.php)
Client gets a new draftid A containing the file only (return of upload.php)
Client requests to merge that draftid in the user's private files (core_user_add_user_private_files)
Server prepares a new UNUSED draftid B from existing area
Server merges A into B
Server saves the draft B into the final area
While strictly we should not be testing private APIs, in order
to get this backported to stables without changing visibility
we use reflection to access to such private properties and methods.
Also added one exttest to verify user agent is properly sent.
Finally, fix some wrong whitespace and changed the helper class name
to better alternative.
The format_string call used when getting file type descriptions
does not specify a context. The page context is not always
available at this point, so for consistency it should specify
the system context.