diff --git a/admin/list-virtual.php b/admin/list-virtual.php index af6c6d6b..ec7bc11b 100644 --- a/admin/list-virtual.php +++ b/admin/list-virtual.php @@ -48,89 +48,89 @@ else } - if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) if (empty ($fDomain)) $fDomain = $list_domains[0]; - - $limit = get_domain_properties ($fDomain); +if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) if (empty ($fDomain)) $fDomain = $list_domains[0]; - if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) if (empty ($fDomain)) $fDomain = $list_domains[1]; - - $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 ORDER BY $table_alias.address LIMIT $fDisplay, $page_size"; - if ('pgsql'==$CONF['database_type']) - { - $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) ORDER BY address LIMIT $page_size OFFSET $fDisplay"; - } +$limit = get_domain_properties ($fDomain); + +if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) if (empty ($fDomain)) $fDomain = $list_domains[1]; + +$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 ORDER BY $table_alias.address LIMIT $fDisplay, $page_size"; +if ('pgsql'==$CONF['database_type']) +{ + $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) ORDER BY address LIMIT $page_size OFFSET $fDisplay"; +} - $result = db_query ($query); - if ($result['rows'] > 0) +$result = db_query ($query); +if ($result['rows'] > 0) +{ + while ($row = db_array ($result['result'])) { - while ($row = db_array ($result['result'])) + if ('pgsql'==$CONF['database_type']) { - if ('pgsql'==$CONF['database_type']) - { - $row['modified']=gmstrftime('%c %Z',$row['modified']); - $row['active']=('t'==$row['active']) ? 1 : 0; - } - $tAlias[] = $row; + $row['modified']=gmstrftime('%c %Z',$row['modified']); + $row['active']=('t'==$row['active']) ? 1 : 0; } + $tAlias[] = $row; } +} - if ($CONF['vacation_control_admin'] == 'YES') +if ($CONF['vacation_control_admin'] == 'YES') +{ + $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 $fDisplay, $page_size"); + if ('pgsql'==$CONF['database_type']) { - $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 $fDisplay, $page_size"); - if ('pgsql'==$CONF['database_type']) - { - //FIXME: postgres query needs to be rewrited - $query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $page_size OFFSET $fDisplay"; - } + //FIXME: postgres query needs to be rewrited + $query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $page_size OFFSET $fDisplay"; } - else +} +else +{ + + $query = "SELECT * FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size"; + if ('pgsql'==$CONF['database_type']) { + $query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $page_size OFFSET $fDisplay"; + } - $query = "SELECT * FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size"; +} +$result = db_query ($query); +if ($result['rows'] > 0) +{ + while ($row = db_array ($result['result'])) + { if ('pgsql'==$CONF['database_type']) { - $query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $page_size OFFSET $fDisplay"; + $row['created']=gmstrftime('%c %Z',$row['uts_created']); + $row['modified']=gmstrftime('%c %Z',$row['uts_modified']); + $row['active']=('t'==$row['active']) ? 1 : 0; + $row['v_active']=('t'==$row['v_active']) ? 1 : 0; } - + $tMailbox[] = $row; } - $result = db_query ($query); - if ($result['rows'] > 0) +} + +if (isset ($limit)) +{ + if ($fDisplay >= $page_size) { - while ($row = db_array ($result['result'])) - { - if ('pgsql'==$CONF['database_type']) - { - $row['created']=gmstrftime('%c %Z',$row['uts_created']); - $row['modified']=gmstrftime('%c %Z',$row['uts_modified']); - $row['active']=('t'==$row['active']) ? 1 : 0; - $row['v_active']=('t'==$row['v_active']) ? 1 : 0; - } - $tMailbox[] = $row; - } + $tDisplay_back_show = 1; + $tDisplay_back = $fDisplay - $page_size; } - - if (isset ($limit)) + if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) { - if ($fDisplay >= $page_size) - { - $tDisplay_back_show = 1; - $tDisplay_back = $fDisplay - $page_size; - } - if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) - { - $tDisplay_up_show = 1; - } - if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count'])) - { - $tDisplay_next_show = 1; - $tDisplay_next = $fDisplay + $page_size; - } + $tDisplay_up_show = 1; + } + if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count'])) + { + $tDisplay_next_show = 1; + $tDisplay_next = $fDisplay + $page_size; } +} - include ("../templates/header.tpl"); - include ("../templates/admin_menu.tpl"); - include ("../templates/admin_list-virtual.tpl"); - include ("../templates/footer.tpl"); +include ("../templates/header.tpl"); +include ("../templates/admin_menu.tpl"); +include ("../templates/admin_list-virtual.tpl"); +include ("../templates/footer.tpl"); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?>