Replace deprecated print_error calls

This commit is contained in:
Dmitrii Metelkin 2022-08-19 09:42:23 +10:00
parent b07d17fbee
commit 0341b05f99
4 changed files with 9 additions and 9 deletions

View file

@ -157,7 +157,7 @@ class auth_plugin_userkey extends auth_plugin_base {
if (isloggedin()) {
require_logout();
}
print_error($exception->errorcode);
throw $exception;
}
if (isloggedin()) {
@ -653,7 +653,7 @@ class auth_plugin_userkey extends auth_plugin_base {
$this->redirect($redirect);
} else {
// If logged in with different auth type, then display an error.
print_error('incorrectlogout', 'auth_userkey', $CFG->wwwroot);
throw new moodle_exception('incorrectlogout', 'auth_userkey', $CFG->wwwroot);
}
}
}

View file

@ -115,17 +115,17 @@ class core_userkey_manager implements userkey_manager_interface {
);
if (!$key = $DB->get_record('user_private_key', $options)) {
print_error('invalidkey');
throw new \moodle_exception('invalidkey');
}
if (!empty($key->validuntil) and $key->validuntil < time()) {
print_error('expiredkey');
throw new \moodle_exception('expiredkey');
}
$this->validate_ip_address($key);
if (!$user = $DB->get_record('user', array('id' => $key->userid))) {
print_error('invaliduserid');
throw new \moodle_exception('invaliduserid');
}
return $key;
}
@ -145,7 +145,7 @@ class core_userkey_manager implements userkey_manager_interface {
$remoteaddr = getremoteaddr(null);
if (empty($remoteaddr)) {
print_error('noip', 'auth_userkey');
throw new \moodle_exception('noip', 'auth_userkey');
}
if (address_in_subnet($remoteaddr, $key->iprestriction)) {
@ -161,6 +161,6 @@ class core_userkey_manager implements userkey_manager_interface {
}
}
print_error('ipmismatch', 'error', '', null, "Remote address: $remoteaddr\nKey IP: $key->iprestriction");
throw new \moodle_exception('ipmismatch', 'error', '', null, "Remote address: $remoteaddr\nKey IP: $key->iprestriction");
}
}

View file

@ -25,7 +25,7 @@
require_once(dirname(__FILE__) . '/../../config.php');
if (!is_enabled_auth('userkey')) {
print_error(get_string('pluginisdisabled', 'auth_userkey'));
throw new moodle_exception(get_string('pluginisdisabled', 'auth_userkey'));
}
get_auth_plugin('userkey')->user_login_userkey();

View file

@ -25,7 +25,7 @@
require_once(dirname(__FILE__) . '/../../config.php');
if (!is_enabled_auth('userkey')) {
print_error(get_string('pluginisdisabled', 'auth_userkey'));
throw new moodle_exception(get_string('pluginisdisabled', 'auth_userkey'));
}
get_auth_plugin('userkey')->user_logout_userkey();