Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
tool_moodlenet\local\import_backup_helper Class Reference

The import_backup_helper class. More...

Public Member Functions

 __construct (remote_resource $remoteresource, stdClass $user, context $context)
 Constructor for the import backup helper.
 
 get_stored_file ()
 Return a stored user draft file for processing.
 

Static Public Member Functions

static get_context_for_user (int $userid)
 Looks for a context that this user has permission to upload backup files to.
 

Protected Member Functions

 create_user_draft_stored_file (string $filename, string $path)
 Create a file in the user drafts ready for use by plugins implementing dndupload_handle().
 
 size_exceeds_upload_limit (int $sizeinbytes)
 Does the size exceed the upload limit for the current import, taking into account user and core settings.
 

Protected Attributes

context $context
 $context The context we are trying to restore this file into.
 
remote_resource $remoteresource
 $remoteresource A file resource to be restored.
 
user $user
 $user The user trying to restore a file.
 
int $useruploadlimit
 $useruploadlimit The size limit that this user can upload in this context.
 

Detailed Description

The import_backup_helper class.

The import_backup_helper objects provide a means to prepare a backup for for restoration of a course or activity backup file.

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

Constructor & Destructor Documentation

◆ __construct()

tool_moodlenet\local\import_backup_helper::__construct ( remote_resource $remoteresource,
stdClass $user,
context $context )

Constructor for the import backup helper.

Parameters
remote_resource$remoteresourceA remote file resource
stdClass$userThe user importing a file.
context$contextContext to restore into.

Member Function Documentation

◆ create_user_draft_stored_file()

tool_moodlenet\local\import_backup_helper::create_user_draft_stored_file ( string $filename,
string $path )
protected

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

Parameters
string$filenamethe name of the file on disk
string$paththe path where the file is stored on disk
Return values
stored_file

◆ get_context_for_user()

static tool_moodlenet\local\import_backup_helper::get_context_for_user ( int $userid)
static

Looks for a context that this user has permission to upload backup files to.

This gets a list of roles that the user has, checks for the restore:uploadfile capability and then sends back a context that has this permission if available.

This starts with the highest context level and moves down i.e. system -> category -> course.

Parameters
int$useridThe user ID that we are looking for a working context for.
Return values
contextA context that allows the upload of backup files.

◆ get_stored_file()

tool_moodlenet\local\import_backup_helper::get_stored_file ( )

Return a stored user draft file for processing.

Return values
stored_fileThe imported file to ultimately be restored.

◆ size_exceeds_upload_limit()

tool_moodlenet\local\import_backup_helper::size_exceeds_upload_limit ( int $sizeinbytes)
protected

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

Parameters
int$sizeinbytes
Return values
booltrue if exceeded, false otherwise.

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