diff options
author | svncommit <devs@roundcube.net> | 2006-11-16 14:36:14 +0000 |
---|---|---|
committer | svncommit <devs@roundcube.net> | 2006-11-16 14:36:14 +0000 |
commit | e61145f246658a78af1d5b1068c5fc91190ee324 (patch) | |
tree | fc1d13d14cb8c51c2761e58d7add6b3a6354275f /program | |
parent | 2c92989663f2243af7136cefb9347eb4d0ba3b30 (diff) |
Fetch all identities if virtuser_query is used; limitations can be done in SQL.
Diffstat (limited to 'program')
-rw-r--r-- | program/include/main.inc | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/program/include/main.inc b/program/include/main.inc index 676883305..da449c64c 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -550,21 +550,28 @@ function rcmail_create_user($user, $host) $user_name = $user!=$user_email ? $user : ''; // try to resolve the e-mail address from the virtuser table - if (!empty($CONFIG['virtuser_query'])) - { - $sql_result = $DB->query(preg_replace('/%u/', $user, $CONFIG['virtuser_query'])); - if ($sql_arr = $DB->fetch_array($sql_result)) - $user_email = $sql_arr[0]; + if (!empty($CONFIG['virtuser_query']) && + ($sql_result = $DB->query(preg_replace('/%u/', $user, $CONFIG['virtuser_query']))) && + ($DB->num_rows()>0)) + while ($sql_arr = $DB->fetch_array($sql_result)) + { + $DB->query("INSERT INTO ".get_table_name('identities')." + (user_id, del, standard, name, email) + VALUES (?, 0, 1, ?, ?)", + $user_id, + $user_name, + preg_replace('/^@/', $user . '@', $sql_arr[0])); + } + else + { + // also create new identity records + $DB->query("INSERT INTO ".get_table_name('identities')." + (user_id, del, standard, name, email) + VALUES (?, 0, 1, ?, ?)", + $user_id, + $user_name, + $user_email); } - - // also create new identity records - $DB->query("INSERT INTO ".get_table_name('identities')." - (user_id, del, standard, name, email) - VALUES (?, 0, 1, ?, ?)", - $user_id, - $user_name, - $user_email); - // get existing mailboxes $a_mailboxes = $IMAP->list_mailboxes(); |