Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Base class for the customisable profile fields. More...
Public Member Functions | |
__construct ($fieldid=0, $userid=0, $fielddata=null) | |
Constructor method. More... | |
display_data () | |
Display the data for this field. More... | |
edit_after_data ($mform) | |
Tweaks the edit form. More... | |
edit_field ($mform) | |
Print out the form field in the edit profile page. More... | |
edit_field_add ($mform) | |
Abstract method: Adds the profile field to the moodle form class @abstract The following methods must be overwritten by child classes. More... | |
edit_field_set_default ($mform) | |
Sets the default data for the field in the form object. More... | |
edit_field_set_locked ($mform) | |
HardFreeze the field if locked. More... | |
edit_field_set_required ($mform) | |
Sets the required flag for the field in the form object. More... | |
edit_load_user_data ($user) | |
Loads a user object with data for this field ready for the edit profile form. More... | |
edit_save_data ($usernew) | |
Saves the data coming from form. More... | |
edit_save_data_preprocess ($data, $datarecord) | |
Hook for child classess to process the data before it gets saved in database. More... | |
edit_validate_field ($usernew) | |
Validate the form field from profile page. More... | |
get_category_name () | |
Returns the name of the profile category where this field is. More... | |
get_field_config_for_external () | |
Return the field settings suitable to be exported via an external function. More... | |
get_field_properties () | |
Return the field type and null properties. More... | |
is_editable () | |
Check if the field data is editable for the current user This method should not generally be overwritten by child classes. More... | |
is_empty () | |
Check if the field data is considered empty. | |
is_locked () | |
Check if the field is locked on the edit profile page. | |
is_required () | |
Check if the field is required on the edit profile page. | |
is_signup_field () | |
Check if the field should appear on the signup page. | |
is_unique () | |
Check if the field data should be unique. | |
is_user_object_data () | |
Check if the field data should be loaded into the user object By default it is, but for field types where the data may be potentially large, the child class should override this and return false. More... | |
is_visible () | |
Check if the field data is visible to the current user. | |
load_data () | |
Accessor method: Load the field record and user data associated with the object's fieldid and userid. | |
profile_field_base ($fieldid=0, $userid=0) | |
Old syntax of class constructor. More... | |
set_category_name ($categoryname) | |
Set the name for the profile category where this field is. More... | |
set_field ($field) | |
Sets the field object and default data and format into $this->data and $this->dataformat. More... | |
set_fieldid ($fieldid) | |
Accessor method: set the fieldid for this instance. | |
set_user_data ($data, $dataformat) | |
Sets user id and user data for the field. More... | |
set_userid ($userid) | |
Accessor method: set the userid for this instance. | |
Public Attributes | |
mixed | $data |
string | $dataformat |
stdClass | $field |
int | $fieldid |
string | $inputname |
int | $userid |
Protected Attributes | |
string | $categoryname |
name of the user profile category | |
Base class for the customisable profile fields.
profile_field_base::__construct | ( | $fieldid = 0 , |
|
$userid = 0 , |
|||
$fielddata = null |
|||
) |
Constructor method.
int | $fieldid | id of the profile from the user_info_field table |
int | $userid | id of the user for whom we are displaying data |
object | $fielddata | optional data for the field object plus additional fields 'hasuserdata', 'data' and 'dataformat' with user data. (If $fielddata->hasuserdata is empty, user data is not available and we should use default data). If this parameter is passed, constructor will not call load_data() at all. |
Reimplemented in profile_field_menu.
profile_field_base::display_data | ( | ) |
Display the data for this field.
string |
Reimplemented in profile_field_textarea, profile_field_text, profile_field_datetime, and profile_field_checkbox.
profile_field_base::edit_after_data | ( | $mform | ) |
Tweaks the edit form.
moodleform | $mform | instance of the moodleform class |
bool |
profile_field_base::edit_field | ( | $mform | ) |
Print out the form field in the edit profile page.
moodleform | $mform | instance of the moodleform class |
bool |
profile_field_base::edit_field_add | ( | $mform | ) |
Abstract method: Adds the profile field to the moodle form class @abstract The following methods must be overwritten by child classes.
moodleform | $mform | instance of the moodleform class |
Reimplemented in profile_field_textarea, profile_field_text, profile_field_menu, profile_field_datetime, and profile_field_checkbox.
profile_field_base::edit_field_set_default | ( | $mform | ) |
Sets the default data for the field in the form object.
moodleform | $mform | instance of the moodleform class |
Reimplemented in profile_field_menu.
profile_field_base::edit_field_set_locked | ( | $mform | ) |
HardFreeze the field if locked.
moodleform | $mform | instance of the moodleform class |
Reimplemented in profile_field_menu.
profile_field_base::edit_field_set_required | ( | $mform | ) |
Sets the required flag for the field in the form object.
moodleform | $mform | instance of the moodleform class |
profile_field_base::edit_load_user_data | ( | $user | ) |
Loads a user object with data for this field ready for the edit profile form.
stdClass | $user | a user object |
Reimplemented in profile_field_textarea, and profile_field_menu.
profile_field_base::edit_save_data | ( | $usernew | ) |
Saves the data coming from form.
stdClass | $usernew | data coming from the form |
mixed | returns data id if success of db insert/update, false on fail, 0 if not permitted |
profile_field_base::edit_save_data_preprocess | ( | $data, | |
$datarecord | |||
) |
Hook for child classess to process the data before it gets saved in database.
stdClass | $data | |
stdClass | $datarecord | The object that will be used to save the record |
mixed |
Reimplemented in profile_field_datetime, profile_field_textarea, and profile_field_menu.
profile_field_base::edit_validate_field | ( | $usernew | ) |
Validate the form field from profile page.
stdClass | $usernew |
string | contains error message otherwise null |
profile_field_base::get_category_name | ( | ) |
Returns the name of the profile category where this field is.
string |
profile_field_base::get_field_config_for_external | ( | ) |
Return the field settings suitable to be exported via an external function.
By default it return all the field settings.
array | all the settings |
profile_field_base::get_field_properties | ( | ) |
Return the field type and null properties.
This will be used for validating the data submitted by a user.
array | the param type and null property |
Reimplemented in profile_field_textarea, profile_field_text, profile_field_menu, profile_field_datetime, and profile_field_checkbox.
profile_field_base::is_editable | ( | ) |
Check if the field data is editable for the current user This method should not generally be overwritten by child classes.
bool |
profile_field_base::is_user_object_data | ( | ) |
Check if the field data should be loaded into the user object By default it is, but for field types where the data may be potentially large, the child class should override this and return false.
bool |
Reimplemented in profile_field_textarea.
profile_field_base::profile_field_base | ( | $fieldid = 0 , |
|
$userid = 0 |
|||
) |
profile_field_base::set_category_name | ( | $categoryname | ) |
Set the name for the profile category where this field is.
string | $categoryname |
profile_field_base::set_field | ( | $field | ) |
Sets the field object and default data and format into $this->data and $this->dataformat.
This method should be called before self::set_user_data
stdClass | $field |
coding_exception |
profile_field_base::set_user_data | ( | $data, | |
$dataformat | |||
) |
Sets user id and user data for the field.
mixed | $data | |
int | $dataformat |