preventing copying files

preventing copying files

by sadaf sadafian -
Number of replies: 1
Picture of Plugin developers

Hi

How to force the user to select the "Link to the external file" (https://docs.moodle.org/404/en/File_resource_settings#Creating_an_alias/shortcut
or
https://docs.moodle.org/404/en/Working_with_files#Creating_a_link_to_a_file) option by default when he/she reselects a file from the repository?
And he/she should not be able to select "Make a copy of the file" manually

Average of ratings: -
In reply to sadaf sadafian

Re: preventing copying files

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
For every enabled repository plugin (if they support it), you can change the function supported_returntypes into
 
public function supported_returntypes() {
    return FILE_INTERNAL | FILE_EXTERNAL;
}
and the default_returntype function:

function default_returntype() {
     return FILE_EXTERNAL;
}

You also have to write (and maintain) your own documentation because the help button will continue to suggest one can make a copy of the file.
Removing functionality is never the best idea.