Clean up some handling of URLs where the username is an e-mail address.

This commit is contained in:
Andrew McMillan 2009-08-29 17:18:33 +12:00
parent 809cfb78c6
commit a3676d3d40
2 changed files with 3 additions and 7 deletions

View File

@ -113,8 +113,7 @@ 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;
else if ( isset($parameters['email']) && $parameters['options']['allow_by_email'] ) {
if ( $username = $this->UsernameFromEMail($parameters['email']) ) {
$usr = getUserByName($username);
$this->by_email = true;
@ -124,9 +123,6 @@ class CalDAVPrincipal
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']) ) {
$usr = getUserByName($username);
if ( isset($parameters['options']['allow_by_email']) && is_object($usr) && preg_match( '#/(\S+@\S+[.]\S+)$#', $parameters['path']) ) {
$this->by_email = true;
}
}
}
else if ( isset($parameters['principal-property-search']) ) {
@ -252,7 +248,7 @@ class CalDAVPrincipal
$username = $path_split[1];
if ( substr($username,0,1) == '~' ) $username = substr($username,1);
if ( isset($options['allow_by_email']) && preg_match( '#/(\S+@\S+[.]\S+)$#', $path, $matches) ) {
if ( isset($options['allow_by_email']) && $options['allow_by_email'] && preg_match( '#/(\S+@\S+[.]\S+)$#', $path, $matches) ) {
$email = $matches[1];
$qry = new PgQuery("SELECT user_no, username FROM usr WHERE email = ?;", $email );
if ( $qry->Exec("principal") && $user = $qry->Fetch() ) {

View File

@ -266,7 +266,7 @@ EOSQL;
header( "Content-Location: ".ConstructURL($this->path) );
}
}
else if ( preg_match( '#^/(\S+@\S+[.]\S+)/?$#', $this->path) ) {
else if ( $this->options['allow_by_email'] && preg_match( '#^/(\S+@\S+[.]\S+)/?$#', $this->path) ) {
/** @TODO: we should deprecate this now that Evolution 2.27 can do scheduling extensions */
$this->collection_id = -1;
$this->collection_type = 'email';