mirror of
https://github.com/moodle/moodle.git
synced 2025-03-22 08:30:04 +01:00
MDL-44918 libraries: Final deprecation of count_login_failures()
This commit is contained in:
parent
d87bcfb325
commit
26e4b0caff
@ -4378,42 +4378,12 @@ function can_use_html_editor() {
|
||||
|
||||
|
||||
/**
|
||||
* Returns an object with counts of failed login attempts
|
||||
* Returns an object with counts of failed login attempts.
|
||||
*
|
||||
* Returns information about failed login attempts. If the current user is
|
||||
* an admin, then two numbers are returned: the number of attempts and the
|
||||
* number of accounts. For non-admins, only the attempts on the given user
|
||||
* are shown.
|
||||
*
|
||||
* @deprecate since Moodle 2.7, use {@link user_count_login_failures()} instead.
|
||||
* @global moodle_database $DB
|
||||
* @uses CONTEXT_SYSTEM
|
||||
* @param string $mode Either 'admin' or 'everybody'
|
||||
* @param string $username The username we are searching for
|
||||
* @param string $lastlogin The date from which we are searching
|
||||
* @return int
|
||||
* @deprecated since Moodle 2.7, use {@link user_count_login_failures()} instead.
|
||||
*/
|
||||
function count_login_failures($mode, $username, $lastlogin) {
|
||||
global $DB;
|
||||
|
||||
debugging('This method has been deprecated. Please use user_count_login_failures() instead.', DEBUG_DEVELOPER);
|
||||
|
||||
$params = array('mode'=>$mode, 'username'=>$username, 'lastlogin'=>$lastlogin);
|
||||
$select = "module='login' AND action='error' AND time > :lastlogin";
|
||||
|
||||
$count = new stdClass();
|
||||
|
||||
if (is_siteadmin()) {
|
||||
if ($count->attempts = $DB->count_records_select('log', $select, $params)) {
|
||||
$count->accounts = $DB->count_records_select('log', $select, $params, 'COUNT(DISTINCT info)');
|
||||
return $count;
|
||||
}
|
||||
} else if ($mode == 'everybody') {
|
||||
if ($count->attempts = $DB->count_records_select('log', "$select AND info = :username", $params)) {
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
throw new coding_exception('count_login_failures() can not be used any more, please use user_count_login_failures().');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user