General developer forum

overriding functions in lib/filelib.php

 
6
overriding functions in lib/filelib.php
 

hi

I want to make changes the functionality of certain functions in lib/filelib.php (functions: "send_stored_file" and/or "send_file") but I don't want to do core changes to the code.

I have my own theme but I don't see a way to use renderers to override those functions.

isn't there a way without core changes?

I have moodle 3.1 installed 

 
Average of ratings: -
Picture of Darko Miletić
Re: overriding functions in lib/filelib.php
Core developersParticularly helpful Moodlers

Nope.

 
Average of ratings: -
Picture of Olumuyiwa Taiwo
Re: overriding functions in lib/filelib.php
Particularly helpful Moodlers

It might help to take a step back and ask why you need to change those functions.

There may be other ways of achieving your goals.

Beware the XY Problem smile

 
Average of ratings: -
6
Re: overriding functions in lib/filelib.php
 
what I want to achieve:

when a user tried to download a .php file that a user (him or another) upload - I want to deny this download.
to display an error message instead.

by the way I already managed to prevent users from uploading .php files in the first place.

 
Average of ratings: -
6
Re: overriding functions in lib/filelib.php
 

what I want to achieve:

when a user tries to download a .php file that a user (him or another) uploaded - I want to deny the download for security reasons and display an error message instead.

by the way I already managed to prevent users from uploading .php files in the first place.


 
Average of ratings: -
Picture of Olumuyiwa Taiwo
Re: overriding functions in lib/filelib.php
Particularly helpful Moodlers

If you're doing that in a plugin, you should implement the function MYPLUGIN_pluginfile(...) in your plugin's lib.php, and control access there. 

See https://docs.moodle.org/dev/File_API#Serving_files_to_users

 
Average of ratings: -