General developer forum

overriding functions in lib/filelib.php

 
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: -