Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Contains the import_strategy_file class.

Copyright: 2020 Jake Dallimore <jrhdallimore@gmail.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 170 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

import_strategy_file:: (6 methods):
  get_handlers()
  import()
  prepare_module_data()
  get_user_upload_limit()
  size_exceeds_upload_limit()
  create_user_draft_stored_file()


Class: import_strategy_file  - X-Ref

The import_strategy_file class.

The import_strategy_file objects contains the setup steps needed to prepare a resource for import as a file into Moodle. This
ensures the remote_resource is first downloaded and put in a draft file area, ready for use as a file by the handling module.

get_handlers(array $registrydata, remote_resource $resource)   X-Ref
Get an array of import_handler_info objects representing modules supporting import of this file type.

param: array $registrydata the fully populated registry.
param: remote_resource $resource the remote resource.
return: import_handler_info[] the array of import_handler_info objects.

import(remote_resource $resource, \stdClass $user, \stdClass $course, int $section)   X-Ref
Import the remote resource according to the rules of this strategy.

param: remote_resource $resource the resource to import.
param: \stdClass $user the user to import on behalf of.
param: \stdClass $course the course into which the remote_resource is being imported.
param: int $section the section into which the remote_resource is being imported.
return: \stdClass the module data.

prepare_module_data(\stdClass $course, remote_resource $resource, int $draftitemid)   X-Ref
Creates the data to pass to the dndupload_handle() hooks.

param: \stdClass $course the course record.
param: remote_resource $resource the resource being imported as a file.
param: int $draftitemid the itemid of the draft file.
return: \stdClass the data object.

get_user_upload_limit(\stdClass $user, \stdClass $course)   X-Ref
Get the max file size limit for the user in the course.

param: \stdClass $user the user to check.
param: \stdClass $course the course to check in.
return: int the file size limit, in bytes.

size_exceeds_upload_limit(int $sizeinbytes, int $useruploadlimit)   X-Ref
Does the size exceed the upload limit for the current import, taking into account user and core settings.

param: int $sizeinbytes the size, in bytes.
param: int $useruploadlimit the upload limit, in bytes.
return: bool true if exceeded, false otherwise.

create_user_draft_stored_file(\stdClass $user, string $filename, string $path)   X-Ref
Create a file in the user drafts ready for use by plugins implementing dndupload_handle().

param: \stdClass $user the user object.
param: string $filename the name of the file on disk
param: string $path the path where the file is stored on disk
return: \stored_file