Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
|
Public Member Functions | |
check_combination (array $combination) | |
Checks whether the factor combination is valid based on factor behaviour. | |
create_event_after_factor_setup (object $user) | |
Creates an event when user successfully setup a factor. | |
delete_factor_for_user (stdClass $user) | |
Deletes all instances of factor for a user. | |
get_active_user_factors (stdClass $user) | |
Returns an array of active user factor records. | |
get_additional_setup_string () | |
Gets the string for additional setup button on preferences page. | |
get_all_user_factors (stdClass $user) | |
Returns an array of all user factors of given type. | |
get_display_name () | |
Returns factor name from language string. | |
get_icon () | |
Get the icon associated with this factor. | |
get_info () | |
Returns factor help from language string. | |
get_label (int $factorid) | |
Function to retrieve the label for a factorid. | |
get_lastverified (int $factorid) | |
Gets lastverified timestamp. | |
get_login_desc () | |
Get the login description associated with this factor. | |
get_manage_info (int $factorid) | |
Returns factor help from language string when there is factor management available. | |
get_manage_string () | |
Gets the string for manage button on preferences page. | |
get_no_redirect_urls () | |
Function to get urls that should not be redirected from. | |
get_remaining_attempts () | |
Return the number of remaining attempts at this factor. | |
get_setup_string () | |
Gets the string for setup button on preferences page. | |
get_short_description () | |
Returns factor short description from language string. | |
get_state () | |
Returns the state of the factor from session information. | |
get_summary_condition () | |
Returns 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 () | |
Decides if a factor requires input from the user to verify. | |
has_replace () | |
Returns true if factor class has factor records that can be replaced. | |
has_revoke () | |
Returns true if factor class has factor records that might be revoked. | |
has_setup () | |
Decides if factor needs to be setup by user and has setup_form. | |
increment_lock_counter () | |
Increments the lock counter for a factor. | |
is_enabled () | |
Returns the information about factor availability. | |
is_lockable () | |
Returns true if a factor is able to be locked if it fails. | |
load_locked_state () | |
This loads the locked state from the DB Base class implementation. | |
login_form_definition (\MoodleQuickForm $mform) | |
Defines login form definition page for SMS 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 SMS Factor. | |
possible_states (\stdClass $user) | |
Returns all possible states for a user. | |
possible_states (stdClass $user) | |
Function to get possible states for a user from factor. | |
post_pass_state () | |
Function for factor actions in the pass state. | |
process_cancel_action () | |
Process a cancel input from a user. | |
replace_user_factor (stdClass $data, int $id) | |
Replaces a given factor and adds it to user's active factors list. | |
revoke_user_factor (?int $factorid=null) | |
Marks factor record as revoked. | |
set_state (string $state) | |
Sets the state of the factor into the session. | |
setup_factor_form_definition (\MoodleQuickForm $mform) | |
Defines setup_factor form definition page for SMS 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) | |
Reset values of the session data of the given factor. | |
setup_factor_form_submit_button_string () | |
Setup submit button string in given factor. | |
setup_factor_form_validation (array $data) | |
Returns an array of errors, where array key = field id and array value = error text. | |
setup_user_factor (stdClass $data) | |
Adds an instance of the factor for a user, from form data. | |
show_additional_setup_button () | |
Returns true if a button should be shown to add factors of the same kind on the preferences page. | |
show_setup_buttons () | |
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. | |
Public Attributes | |
string | $name |
Factor name. | |
Protected Attributes | |
string | $icon = 'fa-commenting-o' |
Factor icon. | |
tool_mfa local secret_manager | $secretmanager |
Secret manager. | |
|
inherited |
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.
array | $combination | array of factors that make up the combination |
bool |
Implements tool_mfa\local\factor\object_factor.
Reimplemented in factor_grace\factor, and factor_nosetup\factor.
|
inherited |
Creates an event when user successfully setup a factor.
object | $user |
void |
|
inherited |
Deletes all instances of factor for a user.
stdClass | $user | the user to delete for. |
void |
Implements tool_mfa\local\factor\object_factor.
|
inherited |
Returns an array of active user factor records.
Filters get_all_user_factors() output.
stdClass | $user | object to check against. |
array |
Implements tool_mfa\local\factor\object_factor.
Reimplemented in factor_grace\factor.
|
inherited |
Gets the string for additional setup button on preferences page.
If the user has the ability to set up multiple security keys.
Override in child class if necessary.
string |
Reimplemented in factor_webauthn\factor.
factor_sms\factor::get_all_user_factors | ( | stdClass | $user | ) |
Returns an array of all user factors of given type.
stdClass | $user | the user to check against. |
array |
Reimplemented from tool_mfa\local\factor\object_factor_base.
|
inherited |
Returns factor name from language string.
Base class implementation.
string |
coding_exception |
Implements tool_mfa\local\factor\object_factor.
Reimplemented in tool_mfa\local\factor\fallback.
|
inherited |
Get the icon associated with this factor.
string | the icon name. |
|
inherited |
Returns factor help from language string.
Base class implementation.
string |
coding_exception |
Implements tool_mfa\local\factor\object_factor.
Reimplemented in tool_mfa\local\factor\fallback.
|
inherited |
Function to retrieve the label for a factorid.
int | $factorid |
string|dml_exception |
Implements tool_mfa\local\factor\object_factor.
|
inherited |
Gets lastverified timestamp.
int | $factorid |
int|bool | the lastverified timestamp, or false if not found. |
Implements tool_mfa\local\factor\object_factor.
factor_sms\factor::get_login_desc | ( | ) |
Get the login description associated with this factor.
Override for factors that have a user input.
string | The login option. |
Reimplemented from tool_mfa\local\factor\object_factor_base.
|
inherited |
Returns factor help from language string when there is factor management available.
Base class implementation.
int | $factorid | The factor we want manage info for. |
string |
coding_exception |
factor_sms\factor::get_manage_string | ( | ) |
Gets the string for manage button on preferences page.
string |
Reimplemented from tool_mfa\local\factor\object_factor_base.
|
inherited |
Function to get urls that should not be redirected from.
array |
Implements tool_mfa\local\factor\object_factor.
Reimplemented in factor_email\factor, and factor_grace\factor.
|
inherited |
Return the number of remaining attempts at this factor.
int | the number of attempts at this factor remaining. |
factor_sms\factor::get_setup_string | ( | ) |
Gets the string for setup button on preferences page.
string |
Reimplemented from tool_mfa\local\factor\object_factor_base.
|
inherited |
Returns factor short description from language string.
Base class implementation.
string |
coding_exception |
|
inherited |
Returns the state of the factor from session information.
Implementation for factors that require input. Should be overridden in child classes with no input.
mixed |
Implements tool_mfa\local\factor\object_factor.
Reimplemented in factor_admin\factor, factor_auth\factor, factor_capability\factor, factor_cohort\factor, factor_email\factor, factor_iprange\factor, factor_nosetup\factor, factor_role\factor, factor_token\factor, factor_totp\factor, factor_webauthn\factor, and tool_mfa\local\factor\fallback.
|
inherited |
Returns condition for passing factor.
Implementation for basic conditions. Override for complex conditions such as auth type.
string |
Implements tool_mfa\local\factor\object_factor.
Reimplemented in factor_auth\factor, factor_cohort\factor, and factor_role\factor.
|
inherited |
Returns configured factor weight.
Base class implementation.
int |
dml_exception |
Implements tool_mfa\local\factor\object_factor.
|
inherited |
Hook point for global auth form action hooks.
MoodleQuickForm | $mform | Form to inject global elements into. |
void |
Implements tool_mfa\local\factor\object_factor.
|
inherited |
Hook point for global auth form action hooks.
MoodleQuickForm | $mform | Form to inject global elements into. |
void |
Implements tool_mfa\local\factor\object_factor.
|
inherited |
Hook point for global auth form action hooks.
object | $data | Data from the form. |
void |
Implements tool_mfa\local\factor\object_factor.
|
inherited |
Hook point for global auth form action hooks.
array | $data | Data from the form. |
array | $files | Files form the form. |
array | of errors from validation. |
Implements tool_mfa\local\factor\object_factor.
factor_sms\factor::has_input | ( | ) |
Decides if a factor requires input from the user to verify.
bool |
Reimplemented from tool_mfa\local\factor\object_factor_base.
|
inherited |
Returns true if factor class has factor records that can be replaced.
Override in child class if necessary.
bool |
Reimplemented in factor_totp\factor, and factor_webauthn\factor.
factor_sms\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.
bool |
Reimplemented from tool_mfa\local\factor\object_factor_base.
factor_sms\factor::has_setup | ( | ) |
Decides if factor needs to be setup by user and has setup_form.
bool |
Reimplemented from tool_mfa\local\factor\object_factor_base.
|
inherited |
Increments the lock counter for a factor.
void |
factor_sms\factor::is_enabled | ( | ) |
Returns the information about factor availability.
bool |
Reimplemented from tool_mfa\local\factor\object_factor_base.
|
inherited |
Returns true if a factor is able to be locked if it fails.
Generally only input factors are lockable. Override in child class if necessary
bool |
|
inherited |
factor_sms\factor::login_form_definition | ( | \MoodleQuickForm | $mform | ) |
Defines login form definition page for SMS Factor.
MoodleQuickForm | $mform |
MoodleQuickForm#$mform |
Reimplemented from tool_mfa\local\factor\object_factor_base.
factor_sms\factor::login_form_definition_after_data | ( | \MoodleQuickForm | $mform | ) |
Defines login form definition page after form data has been set.
MoodleQuickForm | $mform | Form to inject global elements into. |
MoodleQuickForm#$mform |
Reimplemented from tool_mfa\local\factor\object_factor_base.
factor_sms\factor::login_form_validation | ( | array | $data | ) |
Implements login form validation for SMS Factor.
array | $data |
array |
Reimplemented from tool_mfa\local\factor\object_factor_base.
factor_sms\factor::possible_states | ( | \stdClass | $user | ) |
Returns all possible states for a user.
stdClass | $user |
|
inherited |
Function to get possible states for a user from factor.
Implementation where state is based on deterministic user data. This should be overridden in factors where state is non-deterministic. E.g. IP changes based on whether a user is using a VPN.
stdClass | $user |
array |
Implements tool_mfa\local\factor\object_factor.
Reimplemented in factor_capability\factor, factor_cohort\factor, factor_email\factor, factor_grace\factor, factor_iprange\factor, factor_nosetup\factor, factor_role\factor, factor_token\factor, factor_totp\factor, and factor_webauthn\factor.
|
inherited |
Function for factor actions in the pass state.
Override in child class if necessary.
void |
Implements tool_mfa\local\factor\object_factor.
Reimplemented in factor_email\factor, factor_grace\factor, factor_token\factor, and factor_totp\factor.
|
inherited |
Process a cancel input from a user.
void |
Implements tool_mfa\local\factor\object_factor.
|
inherited |
Replaces a given factor and adds it to user's active factors list.
Returns the new factor if it has been successfully replaced.
Dummy implementation. Should be overridden in child class.
stdClass | $data | The new factor data. |
int | $id | The id of the factor to replace. |
stdClass|null | the record if created, or null. |
Reimplemented in factor_totp\factor, and factor_webauthn\factor.
|
inherited |
Marks factor record as revoked.
If factorid is not provided, revoke all instances of factor.
int | null | $factorid |
bool |
coding_exception | |
dml_exception |
Implements tool_mfa\local\factor\object_factor.
|
inherited |
Sets the state of the factor into the session.
Implementation for factors that require input. Should be overridden in child classes with no input.
string | $state | the state constant to set. |
bool |
Implements tool_mfa\local\factor\object_factor.
Reimplemented in factor_auth\factor, factor_capability\factor, factor_cohort\factor, factor_grace\factor, factor_iprange\factor, factor_nosetup\factor, factor_role\factor, and tool_mfa\local\factor\fallback.
factor_sms\factor::setup_factor_form_definition | ( | \MoodleQuickForm | $mform | ) |
Defines setup_factor form definition page for SMS Factor.
MoodleQuickForm | $mform |
MoodleQuickForm#$mform |
Reimplemented from tool_mfa\local\factor\object_factor_base.
factor_sms\factor::setup_factor_form_definition_after_data | ( | \MoodleQuickForm | $mform | ) |
Defines setup_factor form definition page after form data has been set.
MoodleQuickForm | $mform |
MoodleQuickForm#$mform |
Reimplemented from tool_mfa\local\factor\object_factor_base.
factor_sms\factor::setup_factor_form_is_cancelled | ( | int | $factorid | ) |
Reset values of the session data of the given factor.
int | $factorid |
void |
Reimplemented from tool_mfa\local\factor\object_factor_base.
factor_sms\factor::setup_factor_form_submit_button_string | ( | ) |
Setup submit button string in given factor.
string|null |
Reimplemented from tool_mfa\local\factor\object_factor_base.
factor_sms\factor::setup_factor_form_validation | ( | array | $data | ) |
Returns an array of errors, where array key = field id and array value = error text.
array | $data |
array |
Reimplemented from tool_mfa\local\factor\object_factor_base.
factor_sms\factor::setup_user_factor | ( | stdClass | $data | ) |
Adds an instance of the factor for a user, from form data.
stdClass | $data |
stdClass|null | the factor record, or null. |
Reimplemented from tool_mfa\local\factor\object_factor_base.
|
inherited |
Returns true if a button should be shown to add factors of the same kind on the preferences page.
For example, give user's the ability to set up multiple security keys.
Override in child class if necessary.
bool |
Reimplemented in factor_webauthn\factor.
factor_sms\factor::show_setup_buttons | ( | ) |
Decides if the setup buttons should be shown on the preferences page.
bool |
Reimplemented from tool_mfa\local\factor\object_factor_base.
|
inherited |
When validation code is correct - update lastverified field for given factor.
If factor id is not provided, update all factor entries for user.
int | null | $factorid |
bool|dml_exception |
dml_exception |
Implements tool_mfa\local\factor\object_factor.