Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
file_browser Class Reference

This class provides the main entry point for other code wishing to get information about files. More...

Public Member Functions

 get_file_info ($context=NULL, $component=NULL, $filearea=NULL, $itemid=NULL, $filepath=NULL, $filename=NULL)
 Looks up file_info instance.
 
 is_enrolled ($courseid)
 Check if user is enrolled into the course.
 

Protected Attributes

array $enrolledcourses = null
 cached list of enrolled courses.
 

Detailed Description

This class provides the main entry point for other code wishing to get information about files.

The whole file storage for a Moodle site can be seen as a huge virtual tree. The spine of the tree is the tree of contexts (system, course-categories, courses, modules, also users). Then, within each context, there may be any number of file areas, and a file area contains folders and files. The various file_info subclasses return info about the things in this tree. They should be obtained from an instance of this class.

This virtual tree is different for each user depending of his/her current permissions. Some branches such as draft areas are hidden, but accessible.

Always use this abstraction when you need to access module files from core code.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ get_file_info()

file_browser::get_file_info ( $context = NULL,
$component = NULL,
$filearea = NULL,
$itemid = NULL,
$filepath = NULL,
$filename = NULL )

Looks up file_info instance.

Parameters
stdClass$contextcontext object
string$componentcomponent
string$fileareafile area
int$itemiditem ID
string$filepathfile path
string$filenamefile name
Return values
file_info|nullfile_info instance or null if not found or access not allowed

◆ is_enrolled()

file_browser::is_enrolled ( $courseid)

Check if user is enrolled into the course.

This function keeps a cache of enrolled courses because it may be called multiple times for many courses in one request

Parameters
int$courseid
Return values
bool

Member Data Documentation

◆ $enrolledcourses

array file_browser::$enrolledcourses = null
protected

cached list of enrolled courses.



The documentation for this class was generated from the following file: