list-virtual.php:
- merge search functionality into list-virtual.php (even more performant
for domain admins now - search.php checked domain ownership after
querying all domains...)
(Use list-virtual.php?search=searchterm to test searching)
- allow to display mailbox alias targets in mailbox list
Fields added to the mailbox list array:
* goto_mailbox (mailbox (=1) or forward-only (=0))
* goto_other (array with aliases not pointing to the mailbox)
* (vacation alias is skipped)
open question: is $display_mailbox_aliases = boolconf('special_alias_control')
correct? I'm slightly confused with alias_control, alias_control_admin
and special_alias_control...
- build mailbox query step by step instead of having several variants
which overlap 90% (and include a high bug potential, as already
demonstrated by me ;-)
templates/list-virtual.php
- added search result highlighting
- added displaying of mailbox aliases (goto_mailbox and goto_other)
- removed ?domain= parameter for edit-alias.php, other edit-*.php have
to follow (otherwise we'll have to extract the domain from the address
to avoid incorrect parameters in search mode)
functions.inc.php
- added db_in_clause() which builds a "field in(x, y)" clause for
database queries
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@751 a1433add-5e2c-0410-b055-b7f2511e0802
$sql_where = " AND ( address LIKE '%$search%' OR goto LIKE '%$search%' ) ";
}
$query = "SELECT $table_alias.address,
$table_alias.goto,
$table_alias.modified,
$table_alias.active
FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username
WHERE ($table_alias.domain='$fDomain' AND $table_mailbox.maildir IS NULL)
WHERE ($sql_domain AND $table_mailbox.maildir IS NULL $sql_where)
ORDER BY $table_alias.address LIMIT $fDisplay, $page_size";
if ('pgsql'==$CONF['database_type'])
{
# TODO: is the different query for pgsql really needed? The mailbox query below also works with both...
$query = "SELECT address,
goto,
extract(epoch from modified) as modified,
active
FROM $table_alias
WHERE domain='$fDomain' AND NOT EXISTS(SELECT 1 FROM $table_mailbox WHERE username=$table_alias.address)
WHERE $sql_domain AND NOT EXISTS(SELECT 1 FROM $table_mailbox WHERE username=$table_alias.address $sql_where)
ORDER BY address LIMIT $page_size OFFSET $fDisplay";
}
$result = db_query ($query);
if ($result['rows'] > 0)
{
@ -158,66 +179,75 @@ if ($result['rows'] > 0)
}
}
# TODO: reduce number of different queries by not depending on too much config options
# (it probably won't hurt to include a field in the resultset that is not displayed later)
if ($CONF['vacation_control_admin'] == 'YES')
{
if (boolconf('used_quotas'))
{
if (boolconf('new_quota_table'))
{
$query = "SELECT $table_mailbox.*, $table_vacation.active AS v_active, $table_quota2.bytes as current FROM $table_mailbox
LEFT JOIN $table_vacation ON $table_mailbox.username=$table_vacation.email
LEFT JOIN $table_quota2 ON $table_mailbox.username=$table_quota2.username
WHERE $table_mailbox.domain='$fDomain'
ORDER BY $table_mailbox.username LIMIT $page_size OFFSET $fDisplay";
}
else
{
$query = "SELECT $table_mailbox.*, $table_vacation.active AS v_active, $table_quota.current FROM $table_mailbox
LEFT JOIN $table_vacation ON $table_mailbox.username=$table_vacation.email
LEFT JOIN $table_quota ON $table_mailbox.username=$table_quota.username
WHERE $table_mailbox.domain='$fDomain' AND
( $table_quota.path='quota/storage' OR $table_quota.path IS NULL )
ORDER BY $table_mailbox.username LIMIT $page_size OFFSET $fDisplay";
}
}
else # $CONF[used_quotas] = NO
{
$query = "SELECT $table_mailbox.*, $table_vacation.active AS v_active FROM $table_mailbox
LEFT JOIN $table_vacation ON $table_mailbox.username=$table_vacation.email
WHERE $table_mailbox.domain='$fDomain' ORDER BY $table_mailbox.username LIMIT $page_size OFFSET $fDisplay";
}
#
# mailboxes
#
$display_mailbox_aliases = boolconf('special_alias_control'); # TODO: is this condition correct? - I'm slightly confused with alias_control, alias_control_admin and special_alias_control
# build the sql query
$sql_select = " SELECT $table_mailbox.* ";
$sql_from = " FROM $table_mailbox ";
$sql_join = "";
$sql_where = " WHERE 1 ";
$sql_order = " ORDER BY $table_mailbox.username ";
# TODO: change all edit-*.php scripts not to require the domain parameter (and extract it from the address). This avoids superflous problems when using search.