Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
tool_mfa\local\factor\object_factor Interface Reference
Inheritance diagram for tool_mfa\local\factor\object_factor:
tool_mfa\local\factor\object_factor_base factor_admin\factor factor_auth\factor factor_capability\factor factor_cohort\factor factor_email\factor factor_grace\factor factor_iprange\factor factor_nosetup\factor factor_role\factor factor_sms\factor factor_token\factor factor_totp\factor factor_webauthn\factor tool_mfa\local\factor\fallback

Public Member Functions

 check_combination (array $combination)
 Checks whether the factor combination is valid based on factor behaviour.
 
 delete_factor_for_user (stdClass $user)
 Deletes all instances of a factor for user.
 
 get_active_user_factors (stdClass $user)
 Returns an array of active user factor records.
 
 get_all_user_factors (stdClass $user)
 Returns an array of all user factors of given type (both active and revoked).
 
 get_display_name ()
 Returns factor name from language string.
 
 get_info ()
 Returns factor info from language string.
 
 get_label (int $factorid)
 Retrieves label for a factorid.
 
 get_lastverified (int $factorid)
 Gets lastverified timestamp.
 
 get_no_redirect_urls ()
 Returns a list of urls to not redirect from.
 
 get_setup_string ()
 Gets the string for setup button on preferences page.
 
 get_state ()
 Returns the state of the factor check.
 
 get_summary_condition ()
 Return summary condition for passing factor.
 
 get_weight ()
 Returns configured factor weight.
 
 global_definition (\MoodleQuickForm $mform)
 Hook point for global auth form action hooks.
 
 global_definition_after_data (\MoodleQuickForm $mform)
 Hook point for global auth form action hooks.
 
 global_submit (object $data)
 Hook point for global auth form action hooks.
 
 global_validation (array $data, array $files)
 Hook point for global auth form action hooks.
 
 has_input ()
 Returns true if factor requires user input for success or failure during login.
 
 has_revoke ()
 Returns true if factor class has factor records that might be revoked.
 
 has_setup ()
 Returns true if factor needs to be setup by user and has setup_form.
 
 is_enabled ()
 Returns true if factor is enabled, otherwise false.
 
 login_form_definition (\MoodleQuickForm $mform)
 Defines login form definition page for particular factor.
 
 login_form_definition_after_data (\MoodleQuickForm $mform)
 Defines login form definition page after form data has been set.
 
 login_form_validation (array $data)
 Implements login form validation for particular factor.
 
 possible_states (stdClass $user)
 Returns all possible states for a user.
 
 post_pass_state ()
 Fires any additional actions required by the factor once the user reaches the pass state.
 
 process_cancel_action ()
 Process a cancel action from a user.
 
 revoke_user_factor (?int $factorid=null)
 Marks factor record as revoked.
 
 set_state (string $state)
 Sets the state of the factor check into the session.
 
 setup_factor_form_definition (\MoodleQuickForm $mform)
 Defines setup_factor form definition page for particular factor.
 
 setup_factor_form_definition_after_data (\MoodleQuickForm $mform)
 Defines setup_factor form definition page after form data has been set.
 
 setup_factor_form_is_cancelled (int $factorid)
 Setups in given factor when the form is cancelled.
 
 setup_factor_form_submit_button_string ()
 Setup submit button string in given factor.
 
 setup_factor_form_validation (array $data)
 Implements setup_factor form validation for particular factor.
 
 setup_user_factor (stdClass $data)
 Setups given factor and adds it to user's active factors list.
 
 show_setup_buttons ()
 If has_setup returns true, decides if the setup buttons should be shown on the preferences page.
 
 update_lastverified (?int $factorid=null)
 When validation code is correct - update lastverified field for given factor.
 

Member Function Documentation

◆ check_combination()

tool_mfa\local\factor\object_factor::check_combination ( array $combination)

Checks whether the factor combination is valid based on factor behaviour.

E.g. a combination with nosetup and another factor is not valid, as you cannot pass nosetup with another factor.

Parameters
array$combinationarray of factors that make up the combination
Return values
bool

Implemented in factor_grace\factor, factor_nosetup\factor, and tool_mfa\local\factor\object_factor_base.

◆ delete_factor_for_user()

tool_mfa\local\factor\object_factor::delete_factor_for_user ( stdClass $user)

Deletes all instances of a factor for user.

Parameters
stdClass$userthe user to delete for.
Return values
void

Implemented in tool_mfa\local\factor\object_factor_base.

◆ get_active_user_factors()

tool_mfa\local\factor\object_factor::get_active_user_factors ( stdClass $user)

Returns an array of active user factor records.

Filters get_all_user_factors() output.

Parameters
stdClass$userthe user to check against.
Return values
array

Implemented in factor_grace\factor, and tool_mfa\local\factor\object_factor_base.

◆ get_all_user_factors()

tool_mfa\local\factor\object_factor::get_all_user_factors ( stdClass $user)

Returns an array of all user factors of given type (both active and revoked).

Parameters
stdClass$userthe user to check against.
Return values
array

Implemented in factor_admin\factor, factor_auth\factor, factor_capability\factor, factor_cohort\factor, factor_email\factor, factor_grace\factor, factor_iprange\factor, factor_nosetup\factor, factor_role\factor, factor_sms\factor, factor_token\factor, factor_webauthn\factor, and tool_mfa\local\factor\object_factor_base.

◆ get_display_name()

tool_mfa\local\factor\object_factor::get_display_name ( )

Returns factor name from language string.

Return values
string
Exceptions
coding_exception

Implemented in tool_mfa\local\factor\fallback, and tool_mfa\local\factor\object_factor_base.

◆ get_info()

tool_mfa\local\factor\object_factor::get_info ( )

Returns factor info from language string.

Return values
string
Exceptions
coding_exception

Implemented in tool_mfa\local\factor\fallback, and tool_mfa\local\factor\object_factor_base.

◆ get_label()

tool_mfa\local\factor\object_factor::get_label ( int $factorid)

Retrieves label for a factorid.

Parameters
int$factorid
Return values
string|dml_exception

Implemented in tool_mfa\local\factor\object_factor_base.

◆ get_lastverified()

tool_mfa\local\factor\object_factor::get_lastverified ( int $factorid)

Gets lastverified timestamp.

Parameters
int$factorid
Return values
int|bool

Implemented in tool_mfa\local\factor\object_factor_base.

◆ get_no_redirect_urls()

tool_mfa\local\factor\object_factor::get_no_redirect_urls ( )

Returns a list of urls to not redirect from.

Return values
array

Implemented in factor_email\factor, factor_grace\factor, and tool_mfa\local\factor\object_factor_base.

◆ get_setup_string()

tool_mfa\local\factor\object_factor::get_setup_string ( )

Gets the string for setup button on preferences page.

Return values
stringthe string to display on the button.

Implemented in factor_sms\factor, factor_totp\factor, factor_webauthn\factor, and tool_mfa\local\factor\object_factor_base.

◆ get_state()

◆ get_summary_condition()

tool_mfa\local\factor\object_factor::get_summary_condition ( )

Return summary condition for passing factor.

Return values
string

Implemented in factor_auth\factor, factor_cohort\factor, factor_role\factor, and tool_mfa\local\factor\object_factor_base.

◆ get_weight()

tool_mfa\local\factor\object_factor::get_weight ( )

Returns configured factor weight.

Return values
int
Exceptions
dml_exception

Implemented in tool_mfa\local\factor\object_factor_base.

◆ global_definition()

tool_mfa\local\factor\object_factor::global_definition ( \MoodleQuickForm $mform)

Hook point for global auth form action hooks.

Parameters
MoodleQuickForm$mformForm to inject global elements into.
Return values
void

Implemented in tool_mfa\local\factor\object_factor_base.

◆ global_definition_after_data()

tool_mfa\local\factor\object_factor::global_definition_after_data ( \MoodleQuickForm $mform)

Hook point for global auth form action hooks.

Parameters
MoodleQuickForm$mformForm to inject global elements into.
Return values
void

Implemented in tool_mfa\local\factor\object_factor_base.

◆ global_submit()

tool_mfa\local\factor\object_factor::global_submit ( object $data)

Hook point for global auth form action hooks.

Parameters
object$dataData from the form.
Return values
void

Implemented in tool_mfa\local\factor\object_factor_base.

◆ global_validation()

tool_mfa\local\factor\object_factor::global_validation ( array $data,
array $files )

Hook point for global auth form action hooks.

Parameters
array$dataData from the form.
array$filesFiles form the form.
Return values
arrayof errors from validation.

Implemented in tool_mfa\local\factor\object_factor_base.

◆ has_input()

tool_mfa\local\factor\object_factor::has_input ( )

◆ has_revoke()

tool_mfa\local\factor\object_factor::has_revoke ( )

Returns true if factor class has factor records that might be revoked.

It means that user can revoke factor record from their profile.

Return values
bool

Implemented in factor_sms\factor, factor_totp\factor, factor_webauthn\factor, and tool_mfa\local\factor\object_factor_base.

◆ has_setup()

tool_mfa\local\factor\object_factor::has_setup ( )

Returns true if factor needs to be setup by user and has setup_form.

Return values
bool

Implemented in factor_sms\factor, factor_totp\factor, factor_webauthn\factor, and tool_mfa\local\factor\object_factor_base.

◆ is_enabled()

tool_mfa\local\factor\object_factor::is_enabled ( )

Returns true if factor is enabled, otherwise false.

Return values
bool
Exceptions
dml_exception

Implemented in factor_sms\factor, and tool_mfa\local\factor\object_factor_base.

◆ login_form_definition()

tool_mfa\local\factor\object_factor::login_form_definition ( \MoodleQuickForm $mform)

Defines login form definition page for particular factor.

Parameters
MoodleQuickForm$mform
Return values
MoodleQuickForm\$mform
Exceptions
coding_exception

Implemented in factor_email\factor, factor_sms\factor, factor_totp\factor, factor_webauthn\factor, and tool_mfa\local\factor\object_factor_base.

◆ login_form_definition_after_data()

tool_mfa\local\factor\object_factor::login_form_definition_after_data ( \MoodleQuickForm $mform)

Defines login form definition page after form data has been set.

Parameters
MoodleQuickForm$mform
Return values
MoodleQuickForm\$mform
Exceptions
coding_exception

Implemented in factor_email\factor, factor_sms\factor, and tool_mfa\local\factor\object_factor_base.

◆ login_form_validation()

tool_mfa\local\factor\object_factor::login_form_validation ( array $data)

Implements login form validation for particular factor.

Returns an array of errors, where array key = field id and array value = error text.

Parameters
array$data
Return values
array

Implemented in factor_email\factor, factor_sms\factor, factor_totp\factor, factor_webauthn\factor, and tool_mfa\local\factor\object_factor_base.

◆ possible_states()

tool_mfa\local\factor\object_factor::possible_states ( stdClass $user)

◆ post_pass_state()

tool_mfa\local\factor\object_factor::post_pass_state ( )

Fires any additional actions required by the factor once the user reaches the pass state.

Return values
void

Implemented in factor_email\factor, factor_grace\factor, factor_token\factor, factor_totp\factor, and tool_mfa\local\factor\object_factor_base.

◆ process_cancel_action()

tool_mfa\local\factor\object_factor::process_cancel_action ( )

Process a cancel action from a user.

Return values
void

Implemented in tool_mfa\local\factor\object_factor_base.

◆ revoke_user_factor()

tool_mfa\local\factor\object_factor::revoke_user_factor ( ?int $factorid = null)

Marks factor record as revoked.

If factorid is not provided, revoke all instances of factor.

Parameters
int | null$factorid
Return values
bool

Implemented in tool_mfa\local\factor\object_factor_base.

◆ set_state()

tool_mfa\local\factor\object_factor::set_state ( string $state)

Sets the state of the factor check into the session.

Returns whether storing the var was successful.

Parameters
string$state
Return values
bool

Implemented in factor_auth\factor, factor_capability\factor, factor_cohort\factor, factor_grace\factor, factor_iprange\factor, factor_nosetup\factor, factor_role\factor, tool_mfa\local\factor\fallback, and tool_mfa\local\factor\object_factor_base.

◆ setup_factor_form_definition()

tool_mfa\local\factor\object_factor::setup_factor_form_definition ( \MoodleQuickForm $mform)

Defines setup_factor form definition page for particular factor.

Parameters
MoodleQuickForm$mform
Return values
MoodleQuickForm\$mform
Exceptions
coding_exception

Implemented in factor_sms\factor, factor_totp\factor, factor_webauthn\factor, and tool_mfa\local\factor\object_factor_base.

◆ setup_factor_form_definition_after_data()

tool_mfa\local\factor\object_factor::setup_factor_form_definition_after_data ( \MoodleQuickForm $mform)

Defines setup_factor form definition page after form data has been set.

Parameters
MoodleQuickForm$mform
Return values
MoodleQuickForm\$mform
Exceptions
coding_exception

Implemented in factor_sms\factor, factor_totp\factor, and tool_mfa\local\factor\object_factor_base.

◆ setup_factor_form_is_cancelled()

tool_mfa\local\factor\object_factor::setup_factor_form_is_cancelled ( int $factorid)

Setups in given factor when the form is cancelled.

Parameters
int$factorid
Return values
void

Implemented in factor_sms\factor, and tool_mfa\local\factor\object_factor_base.

◆ setup_factor_form_submit_button_string()

tool_mfa\local\factor\object_factor::setup_factor_form_submit_button_string ( )

Setup submit button string in given factor.

Return values
string|null

Implemented in factor_sms\factor, and tool_mfa\local\factor\object_factor_base.

◆ setup_factor_form_validation()

tool_mfa\local\factor\object_factor::setup_factor_form_validation ( array $data)

Implements setup_factor form validation for particular factor.

Returns an array of errors, where array key = field id and array value = error text.

Parameters
array$data
Return values
array

Implemented in factor_sms\factor, factor_totp\factor, and tool_mfa\local\factor\object_factor_base.

◆ setup_user_factor()

tool_mfa\local\factor\object_factor::setup_user_factor ( stdClass $data)

Setups given factor and adds it to user's active factors list.

Returns true if factor has been successfully added, otherwise false.

Parameters
stdClass$data
Return values
stdClass|nullthe factor record, or null.

Implemented in factor_sms\factor, factor_totp\factor, and tool_mfa\local\factor\object_factor_base.

◆ show_setup_buttons()

tool_mfa\local\factor\object_factor::show_setup_buttons ( )

If has_setup returns true, decides if the setup buttons should be shown on the preferences page.

Return values
bool

Implemented in factor_sms\factor, factor_totp\factor, factor_webauthn\factor, and tool_mfa\local\factor\object_factor_base.

◆ update_lastverified()

tool_mfa\local\factor\object_factor::update_lastverified ( ?int $factorid = null)

When validation code is correct - update lastverified field for given factor.

If factor id is not provided, update all factor entries for user.

Parameters
int | null$factorid
Return values
bool|dml_exception

Implemented in tool_mfa\local\factor\object_factor_base.


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