| Línea 25... |
Línea 25... |
| 25 |
|
25 |
|
| Línea 26... |
Línea 26... |
| 26 |
defined('MOODLE_INTERNAL') || die();
|
26 |
defined('MOODLE_INTERNAL') || die();
|
| Línea -... |
Línea 27... |
| - |
|
27 |
|
| - |
|
28 |
global $OUTPUT;
|
| - |
|
29 |
|
| - |
|
30 |
if ($ADMIN->fulltree) {
|
| - |
|
31 |
$settings->add(new admin_setting_heading('factor_iprange/description', '',
|
| 27 |
|
32 |
new lang_string('settings:description', 'factor_iprange')));
|
| 28 |
global $OUTPUT;
|
33 |
$settings->add(new admin_setting_heading('factor_iprange/settings', new lang_string('settings', 'moodle'), ''));
|
| 29 |
|
34 |
|
| 30 |
$enabled = new admin_setting_configcheckbox('factor_iprange/enabled',
|
35 |
$enabled = new admin_setting_configcheckbox('factor_iprange/enabled',
|
| 31 |
new lang_string('settings:enablefactor', 'tool_mfa'),
|
36 |
new lang_string('settings:enablefactor', 'tool_mfa'),
|
| 32 |
new lang_string('settings:enablefactor_help', 'tool_mfa'), 0);
|
37 |
new lang_string('settings:enablefactor_help', 'tool_mfa'), 0);
|
| 33 |
$enabled->set_updatedcallback(function () {
|
38 |
$enabled->set_updatedcallback(function () {
|
| 34 |
\tool_mfa\manager::do_factor_action('iprange', get_config('factor_iprange', 'enabled') ? 'enable' : 'disable');
|
39 |
\tool_mfa\manager::do_factor_action('iprange', get_config('factor_iprange', 'enabled') ? 'enable' : 'disable');
|
| 35 |
});
|
40 |
});
|
| 36 |
$settings->add($enabled);
|
41 |
$settings->add($enabled);
|
| 37 |
|
42 |
|
| 38 |
$settings->add(new admin_setting_configtext('factor_iprange/weight',
|
43 |
$settings->add(new admin_setting_configtext('factor_iprange/weight',
|
| 39 |
new lang_string('settings:weight', 'tool_mfa'),
|
44 |
new lang_string('settings:weight', 'tool_mfa'),
|
| 40 |
new lang_string('settings:weight_help', 'tool_mfa'), 100, PARAM_INT));
|
45 |
new lang_string('settings:weight_help', 'tool_mfa'), 100, PARAM_INT));
|
| 41 |
|
46 |
|
| 42 |
|
47 |
|
| 43 |
// Current IP validation against list for description.
|
48 |
// Current IP validation against list for description.
|
| 44 |
$allowedips = get_config('factor_iprange', 'safeips');
|
49 |
$allowedips = get_config('factor_iprange', 'safeips');
|
| 45 |
if (trim($allowedips) == '') {
|
50 |
if (trim($allowedips) == '') {
|
| 46 |
$message = 'allowedipsempty';
|
51 |
$message = 'allowedipsempty';
|
| 47 |
$type = 'notifyerror';
|
52 |
$type = 'notifyerror';
|
| 48 |
} else if (remoteip_in_list($allowedips)) {
|
53 |
} else if (remoteip_in_list($allowedips)) {
|
| 49 |
$message = 'allowedipshasmyip';
|
54 |
$message = 'allowedipshasmyip';
|
| 50 |
$type = 'notifysuccess';
|
55 |
$type = 'notifysuccess';
|
| 51 |
} else {
|
56 |
} else {
|
| 52 |
$message = 'allowedipshasntmyip';
|
57 |
$message = 'allowedipshasntmyip';
|
| 53 |
$type = 'notifyerror';
|
58 |
$type = 'notifyerror';
|
| 54 |
};
|
59 |
};
|
| 55 |
$info = $OUTPUT->notification(get_string($message, 'factor_iprange', ['ip' => getremoteaddr()]), $type);
|
60 |
$info = $OUTPUT->notification(get_string($message, 'factor_iprange', ['ip' => getremoteaddr()]), $type);
|
| 56 |
|
61 |
|
| 57 |
$settings->add(new admin_setting_configiplist('factor_iprange/safeips',
|
62 |
$settings->add(new admin_setting_configiplist('factor_iprange/safeips',
|
| 58 |
new lang_string('settings:safeips', 'factor_iprange'),
|
63 |
new lang_string('settings:safeips', 'factor_iprange'),
|