Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 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

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

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()}

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

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

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

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

param: file_info $fileinfo
return: array

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

param: file_info $fileinfo
return: array

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.

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

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

return: bool