Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403]

Defines various element classes used in specific areas

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: 290 lines (12 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 7 classes

anonymizer_final_element:: (1 method):
  set_value()

mnethosturl_final_element:: (1 method):
  set_value()

base64_encode_final_element:: (1 method):
  set_value()

encrypted_final_element:: (4 methods):
  __construct()
  set_key()
  set_value()
  generate_encryption_random_key()

file_nested_element:: (2 methods):
  process()
  fill_values()

backup_plugin_element:: (0 methods):

backup_subplugin_element:: (0 methods):


Class: anonymizer_final_element  - X-Ref

Implementation of backup_final_element that provides one interceptor for anonymization of data

This class overwrites the standard set_value() method, in order to get (by name)
functions from backup_anonymizer_helper executed, producing anonymization of information
to happen in a clean way

TODO: Finish phpdocs
set_value($value)   X-Ref
No description

Class: mnethosturl_final_element  - X-Ref

Implementation of backup_final_element that provides special handling of mnethosturl

This class overwrites the standard set_value() method, in order to decide,
based on various config options, what to do with the field.

TODO: Finish phpdocs
set_value($value)   X-Ref
No description

Class: base64_encode_final_element  - X-Ref

Implementation of {@link backup_final_element} that provides base64 encoding.

This final element transparently encodes with base64_encode() contents that
normally are not safe for being stored in utf-8 xml files (binaries, serialized
data...).
set_value($value)   X-Ref
Set the value for the final element, encoding it as utf-8/xml safe base64.

param: string $value Original value coming from backup step source, usually db.

Class: encrypted_final_element  - X-Ref

Implementation of {@link backup_final_element} that provides symmetric-key AES-256 encryption of contents.

This final element transparently encrypts, for secure storage and transport, any content
that shouldn't be shown normally in plain text. Usually, passwords or keys that cannot use
hashing algorithms, although potentially can encrypt any content. All information is encoded
using base64.

Features:
- requires openssl extension to work. Without it contents are completely omitted.
- automatically creates an appropriate default key for the site and stores it into backup_encryptkey config (bas64 encoded).
- uses a different appropriate init vector for every operation, which is transmited with the encrypted contents.
- all generated data is base64 encoded for safe transmission.
- automatically adds "encrypted" attribute for easier detection.
- implements HMAC for providing integrity.

__construct($name, $attributes = null)   X-Ref
Constructor - instantiates a encrypted_final_element, specifying its basic info.

Overridden to automatically add the 'encrypted' attribute if missing.

param: string $name name of the element
param: array  $attributes attributes this element will handle (optional, defaults to null)

set_key($key)   X-Ref
Set the encryption key manually, overriding default backup_encryptkey config.

param: string $key key to be used for encrypting. Required to be 256-bit key.

set_value($value)   X-Ref
Set the value of the field.

This method sets the value of the element, encrypted using the specified key for it,
defaulting to (and generating) backup_encryptkey config. HMAC is used for integrity.

param: string $value plain-text content the will be stored encrypted and encoded.

generate_encryption_random_key($bytes)   X-Ref
Generate an appropiate random key to be used for encrypting backup information.

Normally used as site default encryption key (backup_encryptkey config) and also
for calculating the init vectors.

Note that until PHP 5.6.12 openssl_random_pseudo_bytes() did NOT
use a "cryptographically strong algorithm" {@link https://bugs.php.net/bug.php?id=70014}
But it's beyond my crypto-knowledge when it's worth finding a *real* better alternative.

param: int $bytes Number of bytes to determine the key length expected.

Class: file_nested_element  - X-Ref

Implementation of backup_nested_element that provides special handling of files

This class overwrites the standard fill_values() method, so it gets intercepted
for each file record being set to xml, in order to copy, at the same file, the
physical file from moodle file storage to backup file storage

TODO: Finish phpdocs
process($processor)   X-Ref
No description

fill_values($values)   X-Ref
No description

Class: backup_plugin_element  - X-Ref

Implementation of backup_optigroup_element to be used by plugins stuff.
Split just for better separation and future specialisation

Class: backup_subplugin_element  - X-Ref

Implementation of backup_optigroup_element to be used by subplugins stuff.
Split just for better separation and future specialisation