Search moodle.org's
Developer Documentation

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
  • /repository/ -> lib.php (source)

    Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 37 and 311] [Versions 38 and 311] [Versions 39 and 311]

    This file contains classes used to manage the repository plugins in Moodle

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

    Defines 6 classes

    repository_type:: (16 methods):
      get_contextvisibility()
      __construct()
      get_typename()
      get_readablename()
      get_options()
      get_visible()
      get_sortorder()
      create()
      update_options()
      update_visible()
      update_sortorder()
      move_order()
      update_visibility()
      delete()
      prepare_to_cache()
      wake_from_cache()

    repository:: (3 methods):
      __construct()
      get_repository_by_id()
      get_typename()

    name:: (80 methods):
      get_type_by_typename()
      get_type_by_id()
      get_types()
      check_capability()
      draftfile_exists()
      get_moodle_file()
      file_is_accessible()
      copy_to_area()
      get_unused_filename()
      append_suffix()
      get_editable_types()
      get_instances()
      get_instance()
      static_function()
      antivir_scan_file()
      send_file()
      get_reference_details()
      cache_file_by_reference()
      reference_file_selected()
      get_file_source_info()
      move_to_filepool()
      build_tree()
      display_instances_list()
      get_file_reference()
      prepare_file()
      has_moodle_files()
      get_link()
      get_file()
      import_external_file_contents()
      get_file_size()
      is_visible()
      can_be_edited_by_user()
      get_name()
      contains_private_data()
      supported_filetypes()
      supported_returntypes()
      default_returntype()
      get_meta()
      create()
      delete()
      delete_all_for_context()
      hide()
      set_option()
      get_option()
      filter()
      get_listing()
      prepare_breadcrumb()
      prepare_list()
      prepare_listing()
      search()
      logout()
      check_login()
      print_login()
      print_search()
      callback()
      global_search()
      cron()
      plugin_init()
      type_config_form()
      type_form_validation()
      instance_config_form()
      get_type_option_names()
      get_instance_option_names()
      instance_form_validation()
      get_short_filename()
      overwrite_existing_draftfile()
      update_draftfile()
      delete_tempfile_from_draft()
      convert_references_to_local()
      remove_files()
      reset_caches()
      sync_external_file()
      sync_reference()
      build_source_field()
      prepare_to_cache()
      wake_from_cache()
      send_relative_file()
      supports_relative_file()
      uses_post_requests()
      get_secret_key()

    repository_exception:: (0 methods):

    repository_instance_form:: (3 methods):
      add_defaults()
      definition()
      validation()

    repository_type_form:: (5 methods):
      definition()
      validation()
      initialise_filepicker()
      repository_delete_selected_files()
      repository_download_selected_files()


    Class: repository_type  - X-Ref

    This class is used to manage repository plugins

    A repository_type is a repository plug-in. It can be Box.net, Flick-r, ...
    A repository type can be edited, sorted and hidden. It is mandatory for an
    administrator to create a repository type in order to be able to create
    some instances of this type.
    Coding note:
    - a repository_type object is mapped to the "repository" database table
    - "typename" attibut maps the "type" database field. It is unique.
    - general "options" for a repository type are saved in the config_plugin table
    - when you delete a repository, all instances are deleted, and general
    options are also deleted from database
    - When you create a type for a plugin that can't have multiple instances, a
    instance is automatically created.

    get_contextvisibility($context)   X-Ref
    Return if the instance is visible in a context

    param: stdClass $context context
    return: bool

    __construct($typename = '', $typeoptions = array()   X-Ref
    repository_type constructor

    param: int $typename
    param: array $typeoptions
    param: bool $visible
    param: int $sortorder (don't really need set, it will be during create() call)

    get_typename()   X-Ref
    Get the type name (no whitespace)
    For a human readable name, use get_readablename()

    return: string the type name

    get_readablename()   X-Ref
    Return a human readable and user-friendly type name

    return: string user-friendly type name

    get_options()   X-Ref
    Return general options

    return: array the general options

    get_visible()   X-Ref
    Return visibility

    return: bool

    get_sortorder()   X-Ref
    Return order / position of display in the file picker

    return: int

    create($silent = false)   X-Ref
    Create a repository type (the type name must not already exist)

    param: bool $silent throw exception?
    return: mixed return int if create successfully, return false if

    update_options($options = null)   X-Ref
    Update plugin options into the config_plugin table

    param: array $options
    return: bool

    update_visible($visible = null)   X-Ref
    Update visible database field with the value given as parameter
    or with the visible value of this object
    This function is private.
    For public access, have a look to switch_and_update_visibility()

    param: bool $visible
    return: bool

    update_sortorder($sortorder = null)   X-Ref
    Update database sortorder field with the value given as parameter
    or with the sortorder value of this object
    This function is private.
    For public access, have a look to move_order()

    param: int $sortorder
    return: bool

    move_order($move)   X-Ref
    Change order of the type with its adjacent upper or downer type
    (database fields are updated)
    Algorithm details:
    1. retrieve all types in an array. This array is sorted by sortorder,
    and the array keys start from 0 to X (incremented by 1)
    2. switch sortorder values of this type and its adjacent type

    param: string $move "up" or "down"

    update_visibility($visible = null)   X-Ref
    1. Change visibility to the value chosen
    2. Update the type

    param: bool $visible
    return: bool

    delete($downloadcontents = false)   X-Ref
    Delete a repository_type (general options are removed from config_plugin
    table, and all instances are deleted)

    param: bool $downloadcontents download external contents if exist
    return: bool

    prepare_to_cache()   X-Ref
    Prepares the repository type to be cached. Implements method from cacheable_object interface.

    return: array

    wake_from_cache($data)   X-Ref
    Restores repository type from cache. Implements method from cacheable_object interface.

    return: array

    Class: repository  - X-Ref

    This is the base class of the repository class.

    To create repository plugin, see: {@link http://docs.moodle.org/dev/Repository_plugins}
    See an example: {@link repository_boxnet}

    __construct($repositoryid, $context = SYSCONTEXTID, $options = array()   X-Ref
    Constructor

    param: int $repositoryid repository instance id
    param: int|stdClass $context a context id or context object
    param: array $options repository options
    param: int $readonly indicate this repo is readonly or not

    get_repository_by_id($repositoryid, $context, $options = array()   X-Ref
    Get repository instance using repository id

    Note that this function does not check permission to access repository contents

    param: int $repositoryid repository instance ID
    param: context|int $context context instance or context ID where this repository will be used
    param: array $options additional repository options
    return: repository

    get_typename()   X-Ref
    Returns the type name of the repository.

    return: string type name of the repository.

    Class: name  - X-Ref

    get_type_by_typename($typename)   X-Ref
    Get a repository type object by a given type name.

    param: string $typename the repository type name
    return: repository_type|bool

    get_type_by_id($id)   X-Ref
    Get the repository type by a given repository type id.

    param: int $id the type id
    return: object

    get_types($visible=null)   X-Ref
    Return all repository types ordered by sortorder field
    first repository type in returnedarray[0], second repository type in returnedarray[1], ...

    param: bool $visible can return types by visiblity, return all types if null
    return: array Repository types

    check_capability()   X-Ref
    Checks if user has a capability to view the current repository.

    return: bool true when the user can, otherwise throws an exception.

    draftfile_exists($itemid, $filepath, $filename)   X-Ref
    Check if file already exists in draft area.

    param: int $itemid of the draft area.
    param: string $filepath path to the file.
    param: string $filename file name.
    return: bool

    get_moodle_file($reference)   X-Ref
    Parses the moodle file reference and returns an instance of stored_file

    param: string $reference reference to the moodle internal file as retruned by
    return: stored_file|null

    file_is_accessible($source)   X-Ref
    Repository method to make sure that user can access particular file.

    This is checked when user tries to pick the file from repository to deal with
    potential parameter substitutions is request

    param: string $source source of the file, returned by repository as 'source' and received back from user (not cleaned)
    return: bool whether the file is accessible by current user

    copy_to_area($source, $filerecord, $maxbytes = -1, $areamaxbytes = FILE_AREA_MAX_BYTES_UNLIMITED)   X-Ref
    This function is used to copy a moodle file to draft area.

    It DOES NOT check if the user is allowed to access this file because the actual file
    can be located in the area where user does not have access to but there is an alias
    to this file in the area where user CAN access it.
    {@link file_is_accessible} should be called for alias location before calling this function.

    param: string $source The metainfo of file, it is base64 encoded php serialized data
    param: stdClass|array $filerecord contains itemid, filepath, filename and optionally other
    param: int $maxbytes maximum allowed size of file, -1 if unlimited. If size of file exceeds
    param: int $areamaxbytes the maximum size of the area. A file_exception is thrown if the
    return: array The information about the created file

    get_unused_filename($itemid, $filepath, $filename)   X-Ref
    Get an unused filename from the current draft area.

    Will check if the file ends with ([0-9]) and increase the number.

    param: int $itemid draft item ID.
    param: string $filepath path to the file.
    param: string $filename name of the file.
    return: string an unused file name.

    append_suffix($filename)   X-Ref
    Append a suffix to filename.

    param: string $filename
    return: string

    get_editable_types($context = null)   X-Ref
    Return all types that you a user can create/edit and which are also visible
    Note: Mostly used in order to know if at least one editable type can be set

    param: stdClass $context the context for which we want the editable types
    return: array types

    get_instances($args = array()   X-Ref
    Return repository instances

    param: array $args Array containing the following keys:
    return: array repository instances

    get_instance($id)   X-Ref
    Get single repository instance for administrative actions

    Do not use this function to access repository contents, because it
    does not set the current context

    param: integer $id repository instance id
    return: repository

    static_function($plugin, $function)   X-Ref
    Call a static function. Any additional arguments than plugin and function will be passed through.

    param: string $plugin repository plugin name
    param: string $function function name
    return: mixed

    antivir_scan_file($thefile, $filename, $deleteinfected)   X-Ref
    Scan file, throws exception in case of infected file.

    Please note that the scanning engine must be able to access the file,
    permissions of the file are not modified here!

    param: string $thefile
    param: string $filename name of the file
    param: bool $deleteinfected

    send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null)   X-Ref
    Repository method to serve the referenced file

    param: stored_file $storedfile the file that contains the reference
    param: int $lifetime Number of seconds before the file should expire from caches (null means $CFG->filelifetime)
    param: int $filter 0 (default)=no filtering, 1=all files, 2=html files only
    param: bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin
    param: array $options additional options affecting the file serving

    get_reference_details($reference, $filestatus = 0)   X-Ref
    Return human readable reference information

    param: string $reference value of DB field files_reference.reference
    param: int $filestatus status of the file, 0 - ok, 666 - source missing
    return: string

    cache_file_by_reference($reference, $storedfile)   X-Ref
    Cache file from external repository by reference
    {@link repository::get_file_reference()}
    {@link repository::get_file()}
    Invoked at MOODLE/repository/repository_ajax.php

    param: string $reference this reference is generated by
    param: stored_file $storedfile created file reference

    reference_file_selected($reference, $context, $component, $filearea, $itemid)   X-Ref
    reference_file_selected

    This function is called when a controlled link file is selected in a file picker and the form is
    saved. The expected behaviour for repositories supporting controlled links is to
    - copy the file to the moodle system account
    - put it in a folder that reflects the context it is being used
    - make sure the sharing permissions are correct (read-only with the link)
    - return a new reference string pointing to the newly copied file.

    param: string $reference this reference is generated by
    param: context $context the target context for this new file.
    param: string $component the target component for this new file.
    param: string $filearea the target filearea for this new file.
    param: string $itemid the target itemid for this new file.
    return: string updated reference (final one before it's saved to db).

    get_file_source_info($source)   X-Ref
    Return the source information

    The result of the function is stored in files.source field. It may be analysed
    when the source file is lost or repository may use it to display human-readable
    location of reference original.

    This method is called when file is picked for the first time only. When file
    (either copy or a reference) is already in moodle and it is being picked
    again to another file area (also as a copy or as a reference), the value of
    files.source is copied.

    param: string $source source of the file, returned by repository as 'source' and received back from user (not cleaned)
    return: string|null

    move_to_filepool($thefile, $record)   X-Ref
    Move file from download folder to file pool using FILE API

    param: string $thefile file path in download folder
    param: stdClass $record
    return: array containing the following keys:

    build_tree($fileinfo, $search, $dynamicmode, &$list)   X-Ref
    Builds a tree of files This function is then called recursively.

    param: file_info $fileinfo an object returned by file_browser::get_file_info()
    param: string $search searched string
    param: bool $dynamicmode no recursive call is done when in dynamic mode
    param: array $list the array containing the files under the passed $fileinfo
    return: int the number of files found

    display_instances_list($context, $typename = null)   X-Ref
    Display a repository instance list (with edit/delete/create links)

    param: stdClass $context the context for which we display the instance
    param: string $typename if set, we display only one type of instance

    get_file_reference($source)   X-Ref
    Prepare file reference information

    param: string $source source of the file, returned by repository as 'source' and received back from user (not cleaned)
    return: string file reference, ready to be stored

    prepare_file($filename)   X-Ref
    Get a unique file path in which to save the file.

    The filename returned will be removed at the end of the request and
    should not be relied upon to exist in subsequent requests.

    param: string $filename file name
    return: file path

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

    return: bool

    get_link($url)   X-Ref
    Return file URL, for most plugins, the parameter is the original
    url, but some plugins use a file id, so we need this function to
    convert file id to original url.

    param: string $url the url of file
    return: string

    get_file($url, $filename = '')   X-Ref
    Downloads a file from external repository and saves it in temp dir

    Function get_file() must be implemented by repositories that support returntypes
    FILE_INTERNAL or FILE_REFERENCE. It is invoked to pick up the file and copy it
    to moodle. This function is not called for moodle repositories, the function
    {@link repository::copy_to_area()} is used instead.

    This function can be overridden by subclass if the files.reference field contains
    not just URL or if request should be done differently.

    param: string $url the content of files.reference field, in this implementaion
    param: string $filename filename (without path) to save the downloaded file in the
    return: array with elements:

    import_external_file_contents(stored_file $file, $maxbytes = 0)   X-Ref
    Downloads the file from external repository and saves it in moodle filepool.
    This function is different from {@link repository::sync_reference()} because it has
    bigger request timeout and always downloads the content.

    This function is invoked when we try to unlink the file from the source and convert
    a reference into a true copy.

    param: stored_file $file
    param: int $maxbytes throw an exception if file size is bigger than $maxbytes (0 means no limit)

    get_file_size($source)   X-Ref
    Return size of a file in bytes.

    param: string $source encoded and serialized data of file
    return: int file size in bytes

    is_visible()   X-Ref
    Return is the instance is visible
    (is the type visible ? is the context enable ?)

    return: bool

    can_be_edited_by_user()   X-Ref
    Can the instance be edited by the current user?

    The property $readonly must not be used within this method because
    it only controls if the options from self::get_instance_option_names()
    can be edited.

    return: bool true if the user can edit the instance.

    get_name()   X-Ref
    Return the name of this instance, can be overridden.

    return: string

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

    This function should return true for the repositories which access external private
    data from a user. This is the case for repositories such as Dropbox, Google Docs or Box.net
    which authenticate the user and then store the auth token.

    Of course, many repositories store 'private data', but we only want to set
    contains_private_data() to repositories which are external to Moodle and shouldn't be accessed
    to by the users having the capability to 'login as' someone else. For instance, the repository
    'Private files' is not considered as private because it's part of Moodle.

    You should not set contains_private_data() to true on repositories which allow different types
    of instances as the levels other than 'user' are, by definition, not private. Also
    the user instances will be protected when they need to.

    return: boolean True when the repository accesses private external data.

    supported_filetypes()   X-Ref
    What kind of files will be in this repository?

    return: array return '*' means this repository support any files, otherwise

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

    Maximum value is FILE_INTERNAL | FILE_EXTERNAL | FILE_REFERENCE

    return: int

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

    Maximum value is FILE_INTERNAL | FILE_EXTERNAL | FILE_REFERENCE

    return: int

    get_meta()   X-Ref
    Provide repository instance information for Ajax

    return: stdClass

    create($type, $userid, $context, $params, $readonly=0)   X-Ref
    Create an instance for this plug-in

    param: string $type the type of the repository
    param: int $userid the user id
    param: stdClass $context the context
    param: array $params the options for this instance
    param: int $readonly whether to create it readonly or not (defaults to not)
    return: mixed

    delete($downloadcontents = false)   X-Ref
    delete a repository instance

    param: bool $downloadcontents
    return: bool

    delete_all_for_context($contextid, $downloadcontents = true)   X-Ref
    Delete all the instances associated to a context.

    This method is intended to be a callback when deleting
    a course or a user to delete all the instances associated
    to their context. The usual way to delete a single instance
    is to use {@link self::delete()}.

    param: int $contextid context ID.
    param: boolean $downloadcontents true to convert references to hard copies.
    return: void

    hide($hide = 'toggle')   X-Ref
    Hide/Show a repository

    param: string $hide
    return: bool

    set_option($options = array()   X-Ref
    Save settings for repository instance
    $repo->set_option(array('api_key'=>'f2188bde132', 'name'=>'dongsheng'));

    param: array $options settings
    return: bool

    get_option($config = '')   X-Ref
    Get settings for repository instance.

    param: string $config a specific option to get.
    return: mixed returns an array of options. If $config is not empty, then it returns that option,

    filter($value)   X-Ref
    Filter file listing to display specific types

    param: array $value
    return: bool

    get_listing($path = '', $page = '')   X-Ref
    Given a path, and perhaps a search, get a list of files.

    See details on {@link http://docs.moodle.org/dev/Repository_plugins}

    param: string $path this parameter can a folder name, or a identification of folder
    param: string $page the page number of file list
    return: array the list of files, including meta infomation, containing the following keys

    prepare_breadcrumb($breadcrumb)   X-Ref
    Prepare the breadcrumb.

    param: array $breadcrumb contains each element of the breadcrumb.
    return: array of breadcrumb elements.

    prepare_list($list)   X-Ref
    Prepare the file/folder listing.

    param: array $list of files and folders.
    return: array of files and folders.

    prepare_listing($listing)   X-Ref
    Prepares list of files before passing it to AJAX, makes sure data is in the correct
    format and stores formatted values.

    param: array|stdClass $listing result of get_listing() or search() or file_get_drafarea_files()
    return: array

    search($search_text, $page = 0)   X-Ref
    Search files in repository
    When doing global search, $search_text will be used as
    keyword.

    param: string $search_text search key word
    param: int $page page
    return: mixed see {@link repository::get_listing()}

    logout()   X-Ref
    Logout from repository instance
    By default, this function will return a login form

    return: string

    check_login()   X-Ref
    To check whether the user is logged in.

    return: bool

    print_login()   X-Ref
    Show the login screen, if required

    return: string

    print_search()   X-Ref
    Show the search screen, if required

    return: string

    callback()   X-Ref
    For oauth like external authentication, when external repository direct user back to moodle,
    this function will be called to set up token and token_secret


    global_search()   X-Ref
    is it possible to do glboal search?

    return: bool

    cron()   X-Ref
    Defines operations that happen occasionally on cron

    return: bool

    plugin_init()   X-Ref
    function which is run when the type is created (moodle administrator add the plugin)

    return: bool success or fail?

    type_config_form($mform, $classname = 'repository')   X-Ref
    Edit/Create Admin Settings Moodle form

    param: moodleform $mform Moodle form (passed by reference)
    param: string $classname repository class name

    type_form_validation($mform, $data, $errors)   X-Ref
    Validate Admin Settings Moodle form

    param: moodleform $mform Moodle form (passed by reference)
    param: array $data array of ("fieldname"=>value) of submitted data
    param: array $errors array of ("fieldname"=>errormessage) of errors
    return: array array of errors

    instance_config_form($mform)   X-Ref
    Edit/Create Instance Settings Moodle form

    param: moodleform $mform Moodle form (passed by reference)

    get_type_option_names()   X-Ref
    Return names of the general options.
    By default: no general option name

    return: array

    get_instance_option_names()   X-Ref
    Return names of the instance options.
    By default: no instance option name

    return: array

    instance_form_validation($mform, $data, $errors)   X-Ref
    Validate repository plugin instance form

    param: moodleform $mform moodle form
    param: array $data form data
    param: array $errors errors
    return: array errors

    get_short_filename($str, $maxlength)   X-Ref
    Create a shorten filename

    param: string $str filename
    param: int $maxlength max file name length
    return: string short filename

    overwrite_existing_draftfile($itemid, $filepath, $filename, $newfilepath, $newfilename)   X-Ref
    Overwrite an existing file

    param: int $itemid
    param: string $filepath
    param: string $filename
    param: string $newfilepath
    param: string $newfilename
    return: bool

    update_draftfile($draftid, $filepath, $filename, $updatedata)   X-Ref
    Updates a file in draft filearea.

    This function can only update fields filepath, filename, author, license.
    If anything (except filepath) is updated, timemodified is set to current time.
    If filename or filepath is updated the file unconnects from it's origin
    and therefore all references to it will be converted to copies when
    filearea is saved.

    param: int $draftid
    param: string $filepath path to the directory containing the file, or full path in case of directory
    param: string $filename name of the file, or '.' in case of directory
    param: array $updatedata array of fields to change (only filename, filepath, license and/or author can be updated)

    delete_tempfile_from_draft($draftitemid, $filepath, $filename)   X-Ref
    Delete a temp file from draft area

    param: int $draftitemid
    param: string $filepath
    param: string $filename
    return: bool

    convert_references_to_local()   X-Ref
    Find all external files in this repo and import them


    remove_files()   X-Ref
    Find all external files linked to this repository and delete them.


    reset_caches()   X-Ref
    Function repository::reset_caches() is deprecated, cache is handled by MUC now.


    sync_external_file($file, $resetsynchistory = false)   X-Ref
    Function repository::sync_external_file() is deprecated. Use repository::sync_reference instead


    sync_reference(stored_file $file)   X-Ref
    Performs synchronisation of an external file if the previous one has expired.

    This function must be implemented for external repositories supporting
    FILE_REFERENCE, it is called for existing aliases when their filesize,
    contenthash or timemodified are requested. It is not called for internal
    repositories (see {@link repository::has_moodle_files()}), references to
    internal files are updated immediately when source is modified.

    Referenced files may optionally keep their content in Moodle filepool (for
    thumbnail generation or to be able to serve cached copy). In this
    case both contenthash and filesize need to be synchronized. Otherwise repositories
    should use contenthash of empty file and correct filesize in bytes.

    Note that this function may be run for EACH file that needs to be synchronised at the
    moment. If anything is being downloaded or requested from external sources there
    should be a small timeout. The synchronisation is performed to update the size of
    the file and/or to update image and re-generated image preview. There is nothing
    fatal if syncronisation fails but it is fatal if syncronisation takes too long
    and hangs the script generating a page.

    Note: If you wish to call $file->get_filesize(), $file->get_contenthash() or
    $file->get_timemodified() make sure that recursion does not happen.

    Called from {@link stored_file::sync_external_file()}

    param: stored_file $file
    return: bool false when file does not need synchronisation, true if it was synchronised

    build_source_field($source)   X-Ref
    Build draft file's source field

    {@link file_restore_source_field_from_draft_file()}
    XXX: This is a hack for file manager (MDL-28666)
    For newly created  draft files we have to construct
    source filed in php serialized data format.
    File manager needs to know the original file information before copying
    to draft area, so we append these information in mdl_files.source field

    param: string $source
    return: string serialised source field

    prepare_to_cache()   X-Ref
    Prepares the repository to be cached. Implements method from cacheable_object interface.

    return: array

    wake_from_cache($data)   X-Ref
    Restores the repository from cache. Implements method from cacheable_object interface.

    return: array

    send_relative_file(stored_file $mainfile, $relativepath)   X-Ref
    Gets a file relative to this file in the repository and sends it to the browser.
    Used to allow relative file linking within a repository without creating file records
    for linked files

    Repositories that overwrite this must be very careful - see filesystem repository for example.

    param: stored_file $mainfile The main file we are trying to access relative files for.
    param: string $relativepath the relative path to the file we are trying to access.

    supports_relative_file()   X-Ref
    helper function to check if the repository supports send_relative_file.

    return: true|false

    uses_post_requests()   X-Ref
    Helper function to indicate if this repository uses post requests for uploading files.

    return: bool

    get_secret_key()   X-Ref
    Generate a secret key to be used for passing sensitive information around.

    return: string repository secret key.

    Class: repository_exception  - X-Ref

    Exception class for repository api

    Class: repository_instance_form  - X-Ref

    This is a class used to define a repository instance form

    add_defaults()   X-Ref
    Added defaults to moodle form


    definition()   X-Ref
    Define moodle form elements


    validation($data, $files)   X-Ref
    Validate moodle form data

    param: array $data form data
    param: array $files files in form
    return: array errors

    Class: repository_type_form  - X-Ref

    This is a class used to define a repository type setting form

    definition()   X-Ref
    Definition of the moodleform


    validation($data, $files)   X-Ref
    Validate moodle form data

    param: array $data moodle form data
    param: array $files
    return: array errors

    initialise_filepicker($args)   X-Ref
    Generate all options needed by filepicker

    param: array $args including following keys
    return: array the list of repository instances, including meta infomation, containing the following keys

    repository_delete_selected_files($context, string $component, string $filearea, $itemid, array $files)   X-Ref
    Convenience function to handle deletion of files.

    param: object $context The context where the delete is called
    param: string $component component
    param: string $filearea filearea
    param: int $itemid the item id
    param: array $files Array of files object with each item having filename/filepath as values
    return: array $return Array of strings matching up to the parent directory of the deleted files

    repository_download_selected_files($context, string $component, string $filearea, $itemid, array $files)   X-Ref
    Convenience function to handle deletion of files.

    param: object $context The context where the delete is called
    param: string $component component
    param: string $filearea filearea
    param: int $itemid the item id
    param: array $files Array of files object with each item having filename/filepath as values
    return: array $return Array of strings matching up to the parent directory of the deleted files