From 2a5ed9d45a53ba3666297e4441abf4de8546267d Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Fri, 22 Dec 2006 07:51:47 +1300 Subject: [PATCH] Allow for user URL to be specified by email address. --- inc/CalDAVRequest.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index 2621f801..3fddf86e 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -25,13 +25,16 @@ define('DEPTH_INFINITY', 9999); */ class CalDAVRequest { + var $options; /** * Create a new CalDAVRequest object. */ - function CalDAVRequest( ) { + function CalDAVRequest( $options = array() ) { global $session, $c, $debugging; + $this->options = $options; + $this->raw_post = file_get_contents ( 'php://input'); if ( isset($debugging) && isset($_GET['method']) ) { @@ -109,7 +112,13 @@ class CalDAVRequest else { $this->username = $path_split[1]; @dbg_error_log( "caldav", "Path split into at least /// %s /// %s /// %s", $path_split[1], $path_split[2], $path_split[3] ); - $qry = new PgQuery( "SELECT * FROM usr WHERE username = ?;", $this->username ); + if ( isset($this->options['allow_by_email']) && preg_match( '#/(\S+@\S+[.]\S+)$#', $this->path, $matches) ) { + $this->by_email = $matches[1]; + $qry = new PgQuery("SELECT user_no FROM usr WHERE email = ? AND get_permissions(?,user_no) ~ '[FRA]';", $this->by_email, $session->user_no ); + } + else { + $qry = new PgQuery( "SELECT * FROM usr WHERE username = ?;", $this->username ); + } if ( $qry->Exec("caldav") && $user = $qry->Fetch() ) { $this->user_no = $user->user_no; }