mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-01-27 00:33:34 +00:00
Add a getUserByEMail() function.
This commit is contained in:
parent
36dcdabcc6
commit
3300404912
@ -245,6 +245,24 @@ function getUserByName( $username, $use_cache = true ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a user record identified by e-mail address, caching it for any subsequent lookup
|
||||
* @param string $email The email address of the user record to retrieve
|
||||
* @param boolean $use_cache Whether or not to use the cache (default: yes)
|
||||
*/
|
||||
function getUserByEMail( $email, $use_cache = true ) {
|
||||
global $_known_users_name;
|
||||
|
||||
if ( $use_cache ) {
|
||||
/** We don't actually maintain a cache-access by e-mail, since it's rare */
|
||||
foreach( $_known_users_name AS $k => $v ) {
|
||||
if ( strtolower($email) == strtolower($v->email) ) return $v;
|
||||
}
|
||||
}
|
||||
return _davical_get_principal_query_cached( 'lower(email) = lower(:param)', $email );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a user record identified by a user_no, caching it for any subsequent lookup
|
||||
* @param int $user_no The ID of the record to retrieve
|
||||
|
||||
@ -245,6 +245,24 @@ function getUserByName( $username, $use_cache = true ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a user record identified by e-mail address, caching it for any subsequent lookup
|
||||
* @param string $email The email address of the user record to retrieve
|
||||
* @param boolean $use_cache Whether or not to use the cache (default: yes)
|
||||
*/
|
||||
function getUserByEMail( $email, $use_cache = true ) {
|
||||
global $_known_users_name;
|
||||
|
||||
if ( $use_cache ) {
|
||||
/** We don't actually maintain a cache-access by e-mail, since it's rare */
|
||||
foreach( $_known_users_name AS $k => $v ) {
|
||||
if ( strtolower($email) == strtolower($v->email) ) return $v;
|
||||
}
|
||||
}
|
||||
return _davical_get_principal_query_cached( 'lower(email) = lower(:param)', $email );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a user record identified by a user_no, caching it for any subsequent lookup
|
||||
* @param int $user_no The ID of the record to retrieve
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user