summaryrefslogtreecommitdiff
path: root/program/include/rcube_user.php
diff options
context:
space:
mode:
Diffstat (limited to 'program/include/rcube_user.php')
-rw-r--r--program/include/rcube_user.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php
index 24ded3d2d..d5421526b 100644
--- a/program/include/rcube_user.php
+++ b/program/include/rcube_user.php
@@ -397,15 +397,22 @@ class rcube_user
*/
static function query($user, $host)
{
- $dbh = rcube::get_instance()->get_dbh();
+ $dbh = rcube::get_instance()->get_dbh();
+ $config = rcube::get_instance()->config;
// query for matching user name
- $query = "SELECT * FROM ".$dbh->table_name('users')." WHERE mail_host = ? AND %s = ?";
- $sql_result = $dbh->query(sprintf($query, 'username'), $host, $user);
+ $sql_result = $dbh->query("SELECT * FROM " . $dbh->table_name('users')
+ ." WHERE mail_host = ? AND username = ?", $host, $user);
+
+ $sql_arr = $dbh->fetch_assoc($sql_result);
+
+ // username not found, try aliases from identities
+ if (empty($sql_arr) && $config->get('user_aliases') && strpos($user, '@')) {
+ $sql_result = $dbh->limitquery("SELECT u.*"
+ ." FROM " . $dbh->table_name('users') . " u"
+ ." JOIN " . $dbh->table_name('identities') . " i ON (i.user_id = u.user_id)"
+ ." WHERE email = ? AND del <> 1", 0, 1, $user);
- // query for matching alias
- if (!($sql_arr = $dbh->fetch_assoc($sql_result))) {
- $sql_result = $dbh->query(sprintf($query, 'alias'), $host, $user);
$sql_arr = $dbh->fetch_assoc($sql_result);
}