mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-21 17:06:22 +00:00
Add a function to get the username from an e-mail address.
This commit is contained in:
parent
c429760384
commit
347045c4c4
@ -93,6 +93,13 @@ class CalDAVPrincipal
|
||||
else if ( isset($parameters['user_no']) ) {
|
||||
$usr = getUserByID($parameters['user_no']);
|
||||
}
|
||||
else if ( isset($parameters['email']) && isset($parameters['options']['allow_by_email']) ) {
|
||||
$parameters['options']['allow_by_email'] = false;
|
||||
if ( $username = $this->UsernameFromEMail($parameters['email']) ) {
|
||||
$usr = getUserByName($username);
|
||||
$this->by_email = true;
|
||||
}
|
||||
}
|
||||
else if ( isset($parameters['path']) ) {
|
||||
dbg_error_log( "principal", "Finding Principal from path: '%s', options.allow_by_email: '%s'", $parameters['path'], $parameters['options']['allow_by_email'] );
|
||||
if ( $username = $this->UsernameFromPath($parameters['path'], $parameters['options']) ) {
|
||||
@ -209,6 +216,21 @@ class CalDAVPrincipal
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Work out the username, based on the given e-mail
|
||||
* @param string $email The email address to be used.
|
||||
*/
|
||||
function UsernameFromEMail( $email ) {
|
||||
$qry = new PgQuery("SELECT user_no, username FROM usr WHERE email = ?;", $email );
|
||||
if ( $qry->Exec("principal") && $user = $qry->Fetch() ) {
|
||||
$user_no = $user->user_no;
|
||||
$username = $user->username;
|
||||
}
|
||||
|
||||
return $username;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the array of privilege names converted into XMLElements
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user