Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Public Attributes | Protected Attributes | List of all members
profile_field_menu Class Reference

Class profile_field_menu. More...

Inheritance diagram for profile_field_menu:
profile_field_base

Public Member Functions

 __construct ($fieldid=0, $userid=0, $fielddata=null)
 Constructor method. More...
 
 convert_external_data ($value)
 Convert external data (csv file) from value to key for processing later by edit_save_data_preprocess. 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)
 Create the code snippet for this field instance Overwrites the base class method. More...
 
 edit_field_set_default ($mform)
 Set the default value for this field instance Overwrites the base class method. 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)
 When passing the user object to the form class for the edit profile page we should load the key for the saved data. More...
 
 edit_save_data ($usernew)
 Saves the data coming from form. More...
 
 edit_save_data_preprocess ($data, $datarecord)
 The data from the form returns the key. 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. More...
 
 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
 
int $datakey
 $datakey
 
stdClass $field
 
int $fieldid
 
string $inputname
 
array $options
 $options
 
int $userid
 

Protected Attributes

string $categoryname
 name of the user profile category
 

Detailed Description

Class profile_field_menu.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

profile_field_menu::__construct (   $fieldid = 0,
  $userid = 0,
  $fielddata = null 
)

Constructor method.

Pulls out the options for the menu from the database and sets the the corresponding key for the data if it exists.

Parameters
int$fieldid
int$userid
object$fielddata

Reimplemented from profile_field_base.

Member Function Documentation

◆ convert_external_data()

profile_field_menu::convert_external_data (   $value)

Convert external data (csv file) from value to key for processing later by edit_save_data_preprocess.

Parameters
string$valueone of the values in menu options.
Return values
intoptions key for the menu

◆ display_data()

profile_field_base::display_data ( )
inherited

Display the data for this field.

Return values
string

Reimplemented in profile_field_checkbox, profile_field_datetime, profile_field_text, and profile_field_textarea.

◆ edit_after_data()

profile_field_base::edit_after_data (   $mform)
inherited

Tweaks the edit form.

Parameters
moodleform$mforminstance of the moodleform class
Return values
bool

◆ edit_field()

profile_field_base::edit_field (   $mform)
inherited

Print out the form field in the edit profile page.

Parameters
moodleform$mforminstance of the moodleform class
Return values
bool

◆ edit_field_add()

profile_field_menu::edit_field_add (   $mform)

Create the code snippet for this field instance Overwrites the base class method.

Parameters
moodleform$mformMoodle form instance

Reimplemented from profile_field_base.

◆ edit_field_set_default()

profile_field_menu::edit_field_set_default (   $mform)

Set the default value for this field instance Overwrites the base class method.

Parameters
moodleform$mformMoodle form instance

Reimplemented from profile_field_base.

◆ edit_field_set_locked()

profile_field_menu::edit_field_set_locked (   $mform)

HardFreeze the field if locked.

Parameters
moodleform$mforminstance of the moodleform class

Reimplemented from profile_field_base.

◆ edit_field_set_required()

profile_field_base::edit_field_set_required (   $mform)
inherited

Sets the required flag for the field in the form object.

Parameters
moodleform$mforminstance of the moodleform class

◆ edit_load_user_data()

profile_field_menu::edit_load_user_data (   $user)

When passing the user object to the form class for the edit profile page we should load the key for the saved data.

Overwrites the base class method.

Parameters
stdClass$userUser object.

Reimplemented from profile_field_base.

◆ edit_save_data()

profile_field_base::edit_save_data (   $usernew)
inherited

Saves the data coming from form.

Parameters
stdClass$usernewdata coming from the form
Return values
mixedreturns data id if success of db insert/update, false on fail, 0 if not permitted

◆ edit_save_data_preprocess()

profile_field_menu::edit_save_data_preprocess (   $data,
  $datarecord 
)

The data from the form returns the key.

This should be converted to the respective option string to be saved in database Overwrites base class accessor method.

Parameters
mixed$dataThe key returned from the select input in the form
stdClass$datarecordThe object that will be used to save the record
Return values
mixedData or null

Reimplemented from profile_field_base.

◆ edit_validate_field()

profile_field_base::edit_validate_field (   $usernew)
inherited

Validate the form field from profile page.

Parameters
stdClass$usernew
Return values
stringcontains error message otherwise null

◆ get_category_name()

profile_field_base::get_category_name ( )
inherited

Returns the name of the profile category where this field is.

Return values
string

◆ get_field_config_for_external()

profile_field_base::get_field_config_for_external ( )
inherited

Return the field settings suitable to be exported via an external function.

By default it return all the field settings.

Return values
arrayall the settings
Since
Moodle 3.2

◆ get_field_properties()

profile_field_menu::get_field_properties ( )

Return the field type and null properties.

This will be used for validating the data submitted by a user.

Return values
arraythe param type and null property
Since
Moodle 3.2

Reimplemented from profile_field_base.

◆ is_editable()

profile_field_base::is_editable ( )
inherited

Check if the field data is editable for the current user This method should not generally be overwritten by child classes.

Return values
bool

◆ is_empty()

profile_field_base::is_empty ( )
inherited

Check if the field data is considered empty.

Reimplemented in profile_field_datetime.

◆ is_user_object_data()

profile_field_base::is_user_object_data ( )
inherited

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.

Return values
bool

Reimplemented in profile_field_textarea.

◆ profile_field_base()

profile_field_base::profile_field_base (   $fieldid = 0,
  $userid = 0 
)
inherited

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated:
since Moodle 3.1

◆ set_category_name()

profile_field_base::set_category_name (   $categoryname)
inherited

Set the name for the profile category where this field is.

Parameters
string$categoryname

◆ set_field()

profile_field_base::set_field (   $field)
inherited

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

Parameters
stdClass$field
Exceptions
coding_exception

◆ set_user_data()

profile_field_base::set_user_data (   $data,
  $dataformat 
)
inherited

Sets user id and user data for the field.

Parameters
mixed$data
int$dataformat

The documentation for this class was generated from the following file: