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 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

This file contains the profile_define_base class.

Copyright: 2007 onwards Shane Elliot {@link http://pukunui.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 653 lines (23 kb)
Included or required:0 times
Referenced: 7 times
Includes or requires: 0 files

Defines 1 class


Class: profile_define_base  - X-Ref

Class profile_define_base

define_form(&$form)   X-Ref
Prints out the form snippet for creating or editing a profile field

param: MoodleQuickForm $form instance of the moodleform class

define_form_common(&$form)   X-Ref
Prints out the form snippet for the part of creating or editing a profile field common to all data types.

param: MoodleQuickForm $form instance of the moodleform class

define_form_specific($form)   X-Ref
Prints out the form snippet for the part of creating or editing a profile field specific to the current data type.

param: MoodleQuickForm $form instance of the moodleform class

define_validate($data, $files)   X-Ref
Validate the data from the add/edit profile field form.

Generally this method should not be overwritten by child classes.

param: stdClass|array $data from the add/edit profile field form
param: array $files
return: array associative array of error messages

define_validate_common($data, $files)   X-Ref
Validate the data from the add/edit profile field form that is common to all data types.

Generally this method should not be overwritten by child classes.

param: stdClass|array $data from the add/edit profile field form
param: array $files
return: array    associative array of error messages

define_validate_specific($data, $files)   X-Ref
Validate the data from the add/edit profile field form
that is specific to the current data type

param: array $data
param: array $files
return: array    associative array of error messages

define_after_data(&$mform)   X-Ref
Alter form based on submitted or existing data

param: MoodleQuickForm $mform

define_save($data)   X-Ref
Add a new profile field or save changes to current field

param: array|stdClass $data from the add/edit profile field form

define_save_preprocess($data)   X-Ref
Preprocess data from the add/edit profile field form before it is saved.

This method is a hook for the child classes to overwrite.

param: array|stdClass $data from the add/edit profile field form
return: array|stdClass processed data object

define_editors()   X-Ref
Provides a method by which we can allow the default data in profile_define_* to use an editor

This should return an array of editor names (which will need to be formatted/cleaned)

return: array

profile_reorder_fields()   X-Ref
Reorder the profile fields within a given category starting at the field at the given startorder.


profile_reorder_categories()   X-Ref
Reorder the profile categoriess starting at the category at the given startorder.


profile_delete_category($id)   X-Ref
Delete a profile category

param: int $id of the category to be deleted
return: bool success of operation

profile_delete_field($id)   X-Ref
Deletes a profile field.

param: int $id

profile_move_field($id, $move)   X-Ref
Change the sort order of a field

param: int $id of the field
param: string $move direction of move
return: bool success of operation

profile_move_category($id, $move)   X-Ref
Change the sort order of a category.

param: int $id of the category
param: string $move direction of move
return: bool success of operation

profile_list_datatypes()   X-Ref
Retrieve a list of all the available data types

return: array   a list of the datatypes suitable to use in a select statement

profile_list_categories()   X-Ref
Retrieve a list of categories and ids suitable for use in a form

return: array

profile_save_category(stdClass $data)   X-Ref
Create or update a profile category

param: stdClass $data

profile_edit_category($id, $redirect)   X-Ref
Edit a category

param: int $id
param: string $redirect

profile_save_field(stdClass $data, array $editors)   X-Ref
Save updated field definition or create a new field

param: stdClass $data data from the form profile_field_form
param: array $editors editors for this form field type

profile_edit_field($id, $datatype, $redirect)   X-Ref
Edit a profile field.

param: int $id
param: string $datatype
param: string $redirect

profile_purge_user_fields_cache()   X-Ref
Purge the cache for the user profile fields