Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

This file contains the form add/update a data purpose.

Copyright: 2018 David Monllao
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 577 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: purpose  - X-Ref

Data purpose form.

definition()   X-Ref
Define the form - called by parent constructor


add_field(\stdClass $data)   X-Ref
Add a fieldset to the current form.

param: \stdClass   $data

add_override_fields()   X-Ref
Handle addition of relevant repeated element fields for role overrides.


filter_data_for_persistent($data)   X-Ref
Converts fields.

param: \stdClass $data
return: \stdClass

get_role_override_id(string $prefix = '')   X-Ref
Get the field for the role name.

param: string  $prefix The prefix to apply to the field
return: \stdClass

get_role_field(string $prefix = '')   X-Ref
Get the field for the role name.

param: string  $prefix The prefix to apply to the field
return: \stdClass

get_lawful_base_field(string $prefix = '')   X-Ref
Get the mform field for lawful bases.

param: string  $prefix The prefix to apply to the field
return: \stdClass

get_sensitive_base_field(string $prefix = '')   X-Ref
Get the mform field for sensitive bases.

param: string  $prefix The prefix to apply to the field
return: \stdClass

get_retention_period_fields(string $prefix = '')   X-Ref
Get the retention period fields.

param: string  $prefix The name of the main field, and prefix for the subfields.
return: \stdClass

get_protected_field(string $prefix = '')   X-Ref
Get the mform field for the protected flag.

param: string  $prefix The prefix to apply to the field
return: \stdClass

convert_fields(\stdClass $data)   X-Ref
Converts data to data suitable for storage.

param: \stdClass $data
return: \stdClass

get_default_data()   X-Ref
Get the default data.

return: \stdClass

convert_existing_data_to_values(\stdClass $data)   X-Ref
Normalise any values stored in existing data.

param: \stdClass $data
return: \stdClass

get_role_overrides_from_data(\stdClass $data)   X-Ref
Fetch the role override data from the list of submitted data.

param: \stdClass   $data The complete set of processed data
return: \stdClass[] The list of overrides

extra_validation($data, $files, array &$errors)   X-Ref
Define extra validation mechanims.

param: stdClass $data Data to validate.
param: array $files Array of files.
param: array $errors Currently reported errors.
return: array of additional errors, or overridden errors.

set_data($data)   X-Ref
Load in existing data as form defaults. Usually new entry defaults are stored directly in
form definition (new entry form); this function is used to load in data where values
already exist and data is being edited (edit entry form).

param: stdClass $data