Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

(no description)

Copyright: 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 494 lines (20 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

backup_controller:: (33 methods):
  __construct()
  destroy()
  finish_ui()
  process_ui_event()
  set_status()
  set_execution()
  calculate_checksum()
  is_checksum_correct()
  get_backupid()
  get_type()
  get_include_files()
  get_include_files_default()
  get_operation()
  get_id()
  get_courseid()
  get_format()
  get_interactive()
  get_mode()
  get_userid()
  get_status()
  get_execution()
  get_executiontime()
  get_plan()
  debug_display_all_settings_values()
  set_kept_roles()
  execute_plan()
  get_results()
  save_controller()
  load_controller()
  calculate_backupid()
  load_plan()
  apply_defaults()
  set_include_files()

backup_controller_exception:: (1 method):
  __construct()


Class: backup_controller  - X-Ref

Class implementing the controller of any backup process

This final class is in charge of controlling all the backup architecture, for any
type of backup. Based in type, format, interactivity and target, it stores the
whole execution plan and settings that will be used later by the @backup_worker,
applies all the defaults, performs all the security contraints and is in charge
of handling the ui if necessary. Also logging strategy is defined here.

Note the class is 100% neutral and usable for *any* backup. It just stores/requests
all the needed information from other backup classes in order to have everything well
structured in order to allow the @backup_worker classes to do their job.

In other words, a mammoth class, but don't worry, practically everything is delegated/
aggregated!)

TODO: Finish phpdocs
__construct($type, $id, $format, $interactive, $mode, $userid, $releasesession = backup::RELEASESESSION_NO)   X-Ref
Constructor for the backup controller class.

param: int $type Type of the backup; One of backup::TYPE_1COURSE, TYPE_1SECTION, TYPE_1ACTIVITY
param: int $id The ID of the item to backup; e.g the course id
param: int $format The backup format to use; Most likely backup::FORMAT_MOODLE
param: bool $interactive Whether this backup will require user interaction; backup::INTERACTIVE_YES or INTERACTIVE_NO
param: int $mode One of backup::MODE_GENERAL, MODE_IMPORT, MODE_SAMESITE, MODE_HUB, MODE_AUTOMATED
param: int $userid The id of the user making the backup
param: bool $releasesession Should release the session? backup::RELEASESESSION_YES or backup::RELEASESESSION_NO

destroy()   X-Ref
Clean structures used by the backup_controller

This method clean various structures used by the backup_controller,
destroying them in an ordered way, so their memory will be gc properly
by PHP (mainly circular references).

Note that, while it's not mandatory to execute this method, it's highly
recommended to do so, specially in scripts performing multiple operations
(like the automated backups) or the system will run out of memory after
a few dozens of backups)

finish_ui()   X-Ref
No description

process_ui_event()   X-Ref
No description

set_status($status)   X-Ref
No description

set_execution($execution, $executiontime = 0)   X-Ref
No description

calculate_checksum()   X-Ref
No description

is_checksum_correct($checksum)   X-Ref
No description

get_backupid()   X-Ref
No description

get_type()   X-Ref
No description

get_include_files()   X-Ref
Returns the current value of the include_files setting.
This setting is intended to ensure that files are not included in
generated backups.

return: int Indicates whether files should be included in backups.

get_include_files_default()   X-Ref
Returns the default value for $this->includefiles before we consider any settings.

return: bool

get_operation()   X-Ref
No description

get_id()   X-Ref
No description

get_courseid()   X-Ref
No description

get_format()   X-Ref
No description

get_interactive()   X-Ref
No description

get_mode()   X-Ref
No description

get_userid()   X-Ref
No description

get_status()   X-Ref
No description

get_execution()   X-Ref
No description

get_executiontime()   X-Ref
No description

get_plan()   X-Ref

return: backup_plan

debug_display_all_settings_values()   X-Ref
For debug only. Get a simple test display of all the settings.

return: string

set_kept_roles(array $roleids)   X-Ref
Sets the user roles that should be kept in the destination course
for a course copy operation.

param: array $roleids

execute_plan()   X-Ref
Executes the backup

return: void Throws and exception of completes

get_results()   X-Ref
No description

save_controller($includeobj = true, $cleanobj = false)   X-Ref
Save controller information

param: bool $includeobj to decide if the object itself must be updated (true) or no (false)
param: bool $cleanobj to decide if the object itself must be cleaned (true) or no (false)

load_controller($backupid)   X-Ref
No description

calculate_backupid()   X-Ref
No description

load_plan()   X-Ref
No description

apply_defaults()   X-Ref
No description

set_include_files(bool $includefiles)   X-Ref
Set the initial value for the include_files setting.

param: bool $includefiles

Class: backup_controller_exception  - X-Ref

__construct($errorcode, $a=NULL, $debuginfo=null)   X-Ref
No description