Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
async_helper Class Reference

Helper functions for asynchronous backups and restores. More...

Public Member Functions

 __construct ($type, $id)
 Class constructor.
 
 send_message ()
 Sends a confirmation message for an aynchronous process.
 

Static Public Member Functions

static get_async_backups ($filearea, $instanceid)
 Get markup for in progress async backups, to use in backup table UI.
 
static get_async_restores ($userid)
 Get all the current in progress async restores for a user.
 
static get_backup_file_info ($filename, $filearea, $contextid)
 Get the size, url and restore url for a backup file.
 
static get_backup_record ($id)
 Given a backup id return a the record from the database.
 
static get_restore_name (\context $context)
 Get the course name of the resource being restored.
 
static get_restore_url ($backupid)
 Get the url of a restored backup item based on the backup ID.
 
static get_userdata_backup_settings (\backup_controller $backupcontroller)
 Get the user data settings for backups.
 
static is_async_enabled ()
 Check if asynchronous backup and restore mode is enabled at system level.
 
static is_async_pending ($id, $type, $operation)
 Check if there is a pending async operation for given details.
 

Protected Attributes

string $backupid
 $backupid The id of the backup or restore.
 
object $backuprec
 $backuprec The backup controller record from the database.
 
string $type = 'backup'
 $type The type of async operation.
 
object $user
 $user The user who created the backup record.
 

Detailed Description

Helper functions for asynchronous backups and restores.

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

Constructor & Destructor Documentation

◆ __construct()

async_helper::__construct ( $type,
$id )

Class constructor.

Parameters
string$typeThe type of async operation.
string$idThe id of the backup or restore.

Member Function Documentation

◆ get_async_backups()

static async_helper::get_async_backups ( $filearea,
$instanceid )
static

Get markup for in progress async backups, to use in backup table UI.

Parameters
string$fileareaThe filearea to get backup data for.
integer$instanceidThe context id to get backup data for.
Return values
array\$tabledatathe rows of table data.

◆ get_async_restores()

static async_helper::get_async_restores ( $userid)
static

Get all the current in progress async restores for a user.

Parameters
int$useridMoodle user id.
Return values
array\$restoresList of current restores in progress.

◆ get_backup_file_info()

static async_helper::get_backup_file_info ( $filename,
$filearea,
$contextid )
static

Get the size, url and restore url for a backup file.

Parameters
string$filenameThe name of the file to get info for.
string$fileareaThe file area for the file.
int$contextidThe context ID of the file.
Return values
array\$resultsThe result array containing the size, url and restore url of the file.

◆ get_backup_record()

static async_helper::get_backup_record ( $id)
static

Given a backup id return a the record from the database.

We use this method rather than 'load_controller' as the controller may not exist if this backup/restore has completed.

Parameters
int$idThe backup id to get.
Return values
object\$backuprecThe backup controller record.

◆ get_restore_name()

static async_helper::get_restore_name ( \context $context)
static

Get the course name of the resource being restored.

Parameters
context$contextThe Moodle context for the restores.
Return values
string\$coursenameThe full name of the course.

◆ get_restore_url()

static async_helper::get_restore_url ( $backupid)
static

Get the url of a restored backup item based on the backup ID.

Parameters
string$backupidThe backup ID to get the restore location url.
Return values
array\$urlarrayThe restored item URL as an array.

◆ get_userdata_backup_settings()

static async_helper::get_userdata_backup_settings ( \backup_controller $backupcontroller)
static

Get the user data settings for backups.

Parameters
backup_controller$backupcontrollerThe backup controller object.
Return values
arrayArray of user data settings.

◆ is_async_enabled()

static async_helper::is_async_enabled ( )
static

Check if asynchronous backup and restore mode is enabled at system level.

Return values
bool\$asyncTrue if async mode enabled false otherwise.

◆ is_async_pending()

static async_helper::is_async_pending ( $id,
$type,
$operation )
static

Check if there is a pending async operation for given details.

Parameters
int$idThe item id to check in the backup record.
string$typeThe type of operation: course, activity or section.
string$operationOperation backup or restore.
Return values
boolean\$asyncpedningIs there a pending async operation.

◆ send_message()

async_helper::send_message ( )

Sends a confirmation message for an aynchronous process.

Return values
int\$messageidThe id of the sent message.

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