Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Protected Member Functions | List of all members
tool_moodlenet\local\import_strategy_file Class Reference

The import_strategy_file class. More...

Inheritance diagram for tool_moodlenet\local\import_strategy_file:
tool_moodlenet\local\import_strategy

Public Member Functions

 get_handlers (array $registrydata, remote_resource $resource)
 Get an array of import_handler_info objects representing modules supporting import of this file type. More...
 
 import (remote_resource $resource, stdClass $user, stdClass $course, int $section)
 Import the remote resource according to the rules of this strategy. More...
 

Protected Member Functions

 create_user_draft_stored_file (\stdClass $user, string $filename, string $path)
 Create a file in the user drafts ready for use by plugins implementing dndupload_handle(). More...
 
 get_user_upload_limit (\stdClass $user, stdClass $course)
 Get the max file size limit for the user in the course. More...
 
 prepare_module_data (\stdClass $course, remote_resource $resource, int $draftitemid)
 Creates the data to pass to the dndupload_handle() hooks. More...
 
 size_exceeds_upload_limit (int $sizeinbytes, int $useruploadlimit)
 Does the size exceed the upload limit for the current import, taking into account user and core settings. More...
 

Detailed Description

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.

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

Member Function Documentation

◆ create_user_draft_stored_file()

tool_moodlenet\local\import_strategy_file::create_user_draft_stored_file ( \stdClass  $user,
string  $filename,
string  $path 
)
protected

Create a file in the user drafts ready for use by plugins implementing dndupload_handle().

Parameters
stdClass$userthe user object.
string$filenamethe name of the file on disk
string$paththe path where the file is stored on disk
Return values
stored_file

◆ get_handlers()

tool_moodlenet\local\import_strategy_file::get_handlers ( array  $registrydata,
remote_resource  $resource 
)

Get an array of import_handler_info objects representing modules supporting import of this file type.

Parameters
array$registrydatathe fully populated registry.
remote_resource$resourcethe remote resource.
Return values
import_handler_info[]the array of import_handler_info objects.

Implements tool_moodlenet\local\import_strategy.

◆ get_user_upload_limit()

tool_moodlenet\local\import_strategy_file::get_user_upload_limit ( \stdClass  $user,
stdClass  $course 
)
protected

Get the max file size limit for the user in the course.

Parameters
stdClass$userthe user to check.
stdClass$coursethe course to check in.
Return values
intthe file size limit, in bytes.

◆ import()

tool_moodlenet\local\import_strategy_file::import ( remote_resource  $resource,
stdClass  $user,
stdClass  $course,
int  $section 
)

Import the remote resource according to the rules of this strategy.

Parameters
remote_resource$resourcethe resource to import.
stdClass$userthe user to import on behalf of.
stdClass$coursethe course into which the remote_resource is being imported.
int$sectionthe section into which the remote_resource is being imported.
Return values
stdClassthe module data.
Exceptions
moodle_exceptionif the file size means the upload limit is exceeded for the user.

Implements tool_moodlenet\local\import_strategy.

◆ prepare_module_data()

tool_moodlenet\local\import_strategy_file::prepare_module_data ( \stdClass  $course,
remote_resource  $resource,
int  $draftitemid 
)
protected

Creates the data to pass to the dndupload_handle() hooks.

Parameters
stdClass$coursethe course record.
remote_resource$resourcethe resource being imported as a file.
int$draftitemidthe itemid of the draft file.
Return values
stdClassthe data object.

◆ size_exceeds_upload_limit()

tool_moodlenet\local\import_strategy_file::size_exceeds_upload_limit ( int  $sizeinbytes,
int  $useruploadlimit 
)
protected

Does the size exceed the upload limit for the current import, taking into account user and core settings.

Parameters
int$sizeinbytesthe size, in bytes.
int$useruploadlimitthe upload limit, in bytes.
Return values
booltrue if exceeded, false otherwise.
Exceptions
dml_exception

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