Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
Helper functions for asynchronous backups and restores.
Copyright: | 2019 Matt Porritt <mattp@catalyst-au.net> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 381 lines (13 kb) |
Included or required: | 0 times |
Referenced: | 1 time |
Includes or requires: | 0 files |
async_helper:: (13 methods):
__construct()
get_backup_record()
get_user()
lookup_message_variables()
get_resource_link()
send_message()
is_async_enabled()
is_async_pending()
get_backup_file_info()
get_restore_url()
get_async_backups()
get_restore_name()
get_async_restores()
Class: async_helper - X-Ref
Helper functions for asynchronous backups and restores.__construct($type, $id) X-Ref |
Class constructor. param: string $type The type of async operation. param: string $id The id of the backup or restore. |
get_backup_record($id) X-Ref |
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. param: int $id The backup id to get. return: object $backuprec The backup controller record. |
get_user() X-Ref |
Given a user id return a user object. return: object $user The limited user record. |
lookup_message_variables($matches) X-Ref |
Callback for preg_replace_callback. Replaces message placeholders with real values. param: array $matches The match array from from preg_replace_callback. return: string $match The replaced string. |
get_resource_link() X-Ref |
Get the link to the resource that is being backuped or restored. return: moodle_url $url The link to the resource. |
send_message() X-Ref |
Sends a confirmation message for an aynchronous process. return: int $messageid The id of the sent message. |
is_async_enabled() X-Ref |
Check if asynchronous backup and restore mode is enabled at system level. return: bool $async True if async mode enabled false otherwise. |
is_async_pending($id, $type, $operation) X-Ref |
Check if there is a pending async operation for given details. param: int $id The item id to check in the backup record. param: string $type The type of operation: course, activity or section. param: string $operation Operation backup or restore. return: boolean $asyncpedning Is there a pending async operation. |
get_backup_file_info($filename, $filearea, $contextid) X-Ref |
Get the size, url and restore url for a backup file. param: string $filename The name of the file to get info for. param: string $filearea The file area for the file. param: int $contextid The context ID of the file. return: array $results The result array containing the size, url and restore url of the file. |
get_restore_url($backupid) X-Ref |
Get the url of a restored backup item based on the backup ID. param: string $backupid The backup ID to get the restore location url. return: array $urlarray The restored item URL as an array. |
get_async_backups($renderer, $instanceid) X-Ref |
Get markup for in progress async backups, to use in backup table UI. param: \core_backup_renderer $renderer The backup renderer object. param: integer $instanceid The context id to get backup data for. return: array $tabledata the rows of table data. |
get_restore_name(\context $context) X-Ref |
Get the course name of the resource being restored. param: \context $context The Moodle context for the restores. return: string $coursename The full name of the course. |
get_async_restores($userid) X-Ref |
Get all the current in progress async restores for a user. param: int $userid Moodle user id. return: array $restores List of current restores in progress. |