Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 403]

This plugin is used to access local files

Copyright: 2010 Dongsheng Cai {@link http://dongsheng.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 361 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

repository_local:: (9 methods):
  get_listing()
  supported_returntypes()
  has_moodle_files()
  get_non_empty_children()
  can_skip()
  get_node()
  get_node_path()
  search()
  contains_private_data()


Class: repository_local  - X-Ref

repository_local class is used to browse moodle files

get_listing($encodedpath = '', $page = '')   X-Ref
Get file listing

return: mixed
param: string $encodedpath
param: string $page no paging is used in repository_local

supported_returntypes()   X-Ref
Tells how the file can be picked from this repository

return: int

has_moodle_files()   X-Ref
Does this repository used to browse moodle files?

return: boolean

get_non_empty_children(file_info $fileinfo, $extensions)   X-Ref
Returns all children elements that have one of the specified extensions

This function may skip subfolders and recursively add their children
{@link repository_local::can_skip()}

return: array array of file_info elements
param: file_info $fileinfo
param: string|array $extensions, for example '*' or array('.gif','.jpg')

can_skip(file_info $fileinfo, $extensions, $parent = -1)   X-Ref
Whether this folder may be skipped in folder hierarchy

1. Skip the name of a single filearea in a module
2. Skip course categories for non-admins who do not have navshowmycoursecategories setting

return: bool
param: file_info $fileinfo
param: string|array $extensions, for example '*' or array('.gif','.jpg')
param: file_info|int $parent specify parent here if we know it to avoid creating extra objects

get_node(file_info $fileinfo)   X-Ref
Converts file_info object to element of repository return list

return: array
param: file_info $fileinfo

get_node_path(file_info $fileinfo)   X-Ref
Converts file_info object to element of repository return path

return: array
param: file_info $fileinfo

search($q, $page = 1)   X-Ref
Search through all the files.

This method will do a raw search through the database, then will try
to match with files that a user can access. A maximum of 50 files will be
returned at a time, excluding possible duplicates found along the way.

Queries are done in chunk of 100 files to prevent too many records to be fetched
at once. When too many files are not included, or a maximum of 10 queries are
performed we consider that this was the last page.

return: array of results.
param: String  $q    The query string.
param: integer $page The page number.

contains_private_data()   X-Ref
Is this repository accessing private data?

return: bool