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 310 and 311] [Versions 311 and 403]

restore user interface stages This file contains the classes required to manage the stages that make up the restore user interface. These will be primarily operated a {@link restore_ui} instance.

Copyright: 2010 Sam Hemelryk
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1172 lines (41 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 9 classes

restore_ui_stage:: (6 methods):
  __construct()
  get_restoreid()
  is_independent()
  has_sub_stages()
  get_name()
  is_first_stage()

restore_ui_independent_stage:: (5 methods):
  get_progress_reporter()
  set_progress_reporter()
  get_progress_bar()
  is_independent()
  destroy()

restore_ui_stage_confirm:: (7 methods):
  __construct()
  process()
  extract_file_to_dir()
  progress()
  display()
  get_stage_name()
  get_stage()

restore_ui_stage_destination:: (8 methods):
  __construct()
  process()
  display()
  get_stage_name()
  get_filepath()
  get_course_id()
  get_stage()
  get_target()

restore_ui_stage_settings:: (3 methods):
  __construct()
  process()
  initialise_stage_form()

restore_ui_stage_schema:: (3 methods):
  __construct()
  process()
  initialise_stage_form()

restore_ui_stage_review:: (3 methods):
  __construct()
  process()
  initialise_stage_form()

restore_ui_stage_process:: (5 methods):
  __construct()
  process()
  initialise_stage_form()
  display()
  has_sub_stages()

restore_ui_stage_complete:: (2 methods):
  __construct()
  display()


Class: restore_ui_stage  - X-Ref

Abstract stage class

This class should be extended by all restore stages (a requirement of many restore ui functions).
Each stage must then define two abstract methods
- process : To process the stage
- initialise_stage_form : To get a restore_moodleform instance for the stage

__construct(restore_ui $ui, array $params = null)   X-Ref
Constructor

param: restore_ui $ui
param: array $params

get_restoreid()   X-Ref
The restore id from the restore controller

return: string

is_independent()   X-Ref
This is an independent stage

return: int

has_sub_stages()   X-Ref
No sub stages for this stage

return: false

get_name()   X-Ref
The name of this stage

return: string

is_first_stage()   X-Ref
Returns true if this is the settings stage

return: bool

Class: restore_ui_independent_stage  - X-Ref

Abstract class used to represent a restore stage that is indenependent.

An independent stage is a judged to be so because it doesn't require, and has
no use for the restore controller.

get_progress_reporter()   X-Ref
Gets the progress reporter object in use for this restore UI stage.

IMPORTANT: This progress reporter is used only for UI progress that is
outside the restore controller. The restore controller has its own
progress reporter which is used for progress during the main restore.
Use the restore controller's progress reporter to report progress during
a restore operation, not this one.

This extra reporter is necessary because on some restore UI screens,
there are long-running tasks even though there is no restore controller
in use. There is a similar function in restore_ui. but that class is not
used on some stages.

return: \core\progress\none

set_progress_reporter(\core\progress\base $progressreporter)   X-Ref
Sets the progress reporter that will be returned by get_progress_reporter.

param: \core\progress\base $progressreporter Progress reporter

get_progress_bar()   X-Ref
Gets an array of progress bar items that can be displayed through the restore renderer.

return: array Array of items for the progress bar

is_independent()   X-Ref
Obviously true

return: true

destroy()   X-Ref
Handles the destruction of this object.


Class: restore_ui_stage_confirm  - X-Ref

The confirmation stage.

This is the first stage, it is independent.

__construct($contextid)   X-Ref
Constructor

param: int $contextid

process()   X-Ref
Processes this restore stage

return: bool

extract_file_to_dir($source)   X-Ref
Extracts the file.

param: string|stored_file $source Archive file to extract
return: bool

progress($progress = file_progress::INDETERMINATE, $max = file_progress::INDETERMINATE)   X-Ref
Implementation for file_progress interface to display unzip progress.

param: int $progress Current progress
param: int $max Max value

display(core_backup_renderer $renderer)   X-Ref
Renders the confirmation stage screen

param: core_backup_renderer $renderer renderer instance to use
return: string HTML code

get_stage_name()   X-Ref
The restore stage name.

return: string

get_stage()   X-Ref
The restore stage this class is for.

return: int

Class: restore_ui_stage_destination  - X-Ref

This is the destination stage.

This stage is the second stage and is also independent

__construct($contextid)   X-Ref
Constructs the destination stage.

param: int $contextid

process()   X-Ref
Processes the destination stage.

return: bool

display(core_backup_renderer $renderer)   X-Ref
Renders the destination stage screen

param: core_backup_renderer $renderer renderer instance to use
return: string HTML code

get_stage_name()   X-Ref
Returns the stage name.

return: string

get_filepath()   X-Ref
Returns the backup file path

return: mixed|null

get_course_id()   X-Ref
Returns the course id.

return: null

get_stage()   X-Ref
Returns the current restore stage

return: int

get_target()   X-Ref
Returns the target for this restore.
One of backup::TARGET_*

return: int

Class: restore_ui_stage_settings  - X-Ref

This stage is the settings stage.

This stage is the third stage, it is dependent on a restore controller and
is the first stage as such.

__construct(restore_ui $ui, array $params = null)   X-Ref
Initial restore stage constructor

param: restore_ui $ui
param: array $params

process(base_moodleform $form = null)   X-Ref
Process the settings stage.

param: base_moodleform $form
return: bool|int

initialise_stage_form()   X-Ref
Initialise the stage form.

return: backup_moodleform|base_moodleform|restore_settings_form

Class: restore_ui_stage_schema  - X-Ref

Schema stage of backup process

During the schema stage the user is required to set the settings that relate
to the area that they are backing up as well as its children.

__construct(restore_ui $ui, array $params = null)   X-Ref
Schema stage constructor

param: restore_ui $ui
param: array $params

process(base_moodleform $form = null)   X-Ref
Processes the schema stage

param: base_moodleform $form
return: int The number of changes the user made

initialise_stage_form()   X-Ref
Creates the backup_schema_form instance for this stage

return: backup_schema_form

Class: restore_ui_stage_review  - X-Ref

Confirmation stage

On this stage the user reviews the setting for the backup and can change the filename
of the file that will be generated.

__construct($ui, array $params = null)   X-Ref
Constructs the stage

param: restore_ui $ui
param: array $params

process(base_moodleform $form = null)   X-Ref
Processes the confirmation stage

param: base_moodleform $form
return: int The number of changes the user made

initialise_stage_form()   X-Ref
Creates the backup_confirmation_form instance this stage requires

return: backup_confirmation_form

Class: restore_ui_stage_process  - X-Ref

Final stage of backup

This stage is special in that it is does not make use of a form. The reason for
this is the order of procession of backup at this stage.
The processesion is:
1. The final stage will be intialise.
2. The confirmation stage will be processed.
3. The backup will be executed
4. The complete stage will be loaded by execution
5. The complete stage will be displayed

This highlights that we neither need a form nor a display method for this stage
we simply need to process.

__construct(base_ui $ui, array $params = null)   X-Ref
Constructs the final stage

param: base_ui $ui
param: array $params

process(base_moodleform $form = null)   X-Ref
Processes the final stage.

In this case it checks to see if there is a sub stage that we need to display
before execution, if there is we gear up to display the subpage, otherwise
we return true which will lead to execution of the restore and the loading
of the completed stage.

param: base_moodleform $form

initialise_stage_form()   X-Ref
should NEVER be called... throws an exception


display(core_backup_renderer $renderer)   X-Ref
Renders the process stage screen

param: core_backup_renderer $renderer renderer instance to use
return: string HTML code

has_sub_stages()   X-Ref
Returns true if this stage can have sub-stages.

return: bool|false

Class: restore_ui_stage_complete  - X-Ref

This is the completed stage.

Once this is displayed there is nothing more to do.

__construct(restore_ui $ui, array $params = null, array $results = null)   X-Ref
Constructs the complete backup stage

param: restore_ui $ui
param: array $params
param: array $results

display(core_backup_renderer $renderer)   X-Ref
Displays the completed backup stage.

Currently this just envolves redirecting to the file browser with an
appropriate message.

param: core_backup_renderer $renderer
return: string HTML code to echo