From cecbdd166019a42943adaba4bdba66c6c5b7f012 Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 31 Jul 2007 20:57:31 +0000 Subject: [PATCH] Greatly enhanced the multi-page experience for list-virtual.php and overview.php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@15 a1433add-5e2c-0410-b055-b7f2511e0802 --- functions.inc.php | 72 ++++++++++++++++++++++++++++++++ templates/admin_list-virtual.tpl | 43 ++++++++++++++++--- templates/overview.tpl | 36 ++++++++++++++-- 3 files changed, 142 insertions(+), 9 deletions(-) diff --git a/functions.inc.php b/functions.inc.php index 59b9f55f..5598cc01 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -260,6 +260,78 @@ function get_domain_properties ($domain) $list['quota_sum'] = $row[0]; $list['alias_count'] = $list['alias_count'] - $list['mailbox_count']; + $list['alias_pgindex']=array (); + $list['mbox_pgindex']=array (); + + //while loop to figure index names. use page_size and loop of queries + $i=0; + $current=0; + $page_size = $CONF['page_size']; + $tmpstr=""; + $idxlabel=""; + + if ( $list['alias_count'] > $page_size ) + { + while ( $current < $list['alias_count'] ) + { + $limitSql=('pgsql'==$CONF['database_type']) ? "1 OFFSET $current" : "$current, 1"; + $query = "SELECT $table_alias.address FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username WHERE $table_alias.domain='$domain' AND $table_mailbox.maildir IS NULL ORDER BY $table_alias.address LIMIT $limitSql"; + $result = db_query ("$query"); + $row = db_array ($result['result']); + $tmpstr = $row['address']; + //get first 2 chars + $idxlabel = $tmpstr[0] . $tmpstr[1] . "-"; + ($current + $page_size - 1 <= $list['alias_count']) ? $current = $current + $page_size - 1 : $current = $list['alias_count'] - 1; + $limitSql=('pgsql'==$CONF['database_type']) ? "1 OFFSET $current" : "$current, 1"; + $query = "SELECT $table_alias.address FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username WHERE $table_alias.domain='$domain' AND $table_mailbox.maildir IS NULL ORDER BY $table_alias.address LIMIT $limitSql"; + $result = db_query ("$query"); + $row = db_array ($result['result']); + $tmpstr = $row['address']; + $idxlabel = $idxlabel . $tmpstr[0] . $tmpstr[1]; + + $current = $current + 1; + + $list['alias_pgindex'][]=$idxlabel; + $i++; + } + $list['alias_pgindex_count']=$i; + } + + $i=0; + $current=0; + $page_size = $CONF['page_size']; + $tmpstr=""; + $idxlabel=""; + + if ( $list['mailbox_count'] > $page_size ) + { + while ( $current < $list['mailbox_count'] ) + { + $limitSql=('pgsql'==$CONF['database_type']) ? "1 OFFSET $current" : "$current, 1"; + $query = "SELECT $table_mailbox.username FROM $table_mailbox WHERE $table_mailbox.domain='$domain' ORDER BY $table_mailbox.username LIMIT $limitSql"; + $result = db_query ("$query"); + $row = db_array ($result['result']); + $tmpstr = $row['username']; + //get first 2 chars + $idxlabel = $tmpstr[0] . $tmpstr[1] . "-"; + ($current + $page_size - 1 <= $list['mailbox_count']) ? $current = $current + $page_size - 1 : $current = $list['mailbox_count'] - 1; + $limitSql=('pgsql'==$CONF['database_type']) ? "1 OFFSET $current" : "$current, 1"; + $query = "SELECT $table_mailbox.username FROM $table_mailbox WHERE $table_mailbox.domain='$domain' ORDER BY $table_mailbox.username LIMIT $limitSql"; + $result = db_query ("$query"); + $row = db_array ($result['result']); + $tmpstr = $row['username']; + $idxlabel = $idxlabel . $tmpstr[0] . $tmpstr[1]; + + $current = $current + 1; + + $list['mbox_pgindex'][]=$idxlabel; + $i++; + } + $list['mbox_pgindex_count']=$i; + } + +// end mod + $query="SELECT * FROM $table_domain WHERE domain='$domain'"; if ('pgsql'==$CONF['database_type']) { diff --git a/templates/admin_list-virtual.tpl b/templates/admin_list-virtual.tpl index 2e47110f..32387ea8 100644 --- a/templates/admin_list-virtual.tpl +++ b/templates/admin_list-virtual.tpl @@ -27,7 +27,22 @@ for ($i = 0; $i < sizeof ($list_domains); $i++) \n"; +print "
\n
"; +if ( $limit['alias_pgindex_count'] ) print "".$PALANG['pOverview_alias_title']."  "; +($tDisplay_back_show == 1) ? $highlight_at = $tDisplay_back / $CONF['page_size'] + 1 : $highlight_at = 0; +for ($i = 0; $i < $limit['alias_pgindex_count']; $i++) +{ + if ( $i == $highlight_at ) + { + print "" . $limit['alias_pgindex'][$i] . "\n"; + } + else + { + print "" . $limit['alias_pgindex'][$i] . "\n"; + } +} +print ""; + if ($tDisplay_back_show == 1) { print "\""\n"; @@ -40,7 +55,8 @@ if ($tDisplay_next_show == 1) { print "\""\n"; } -print "\n"; +print "
\n"; + if (sizeof ($tAlias) > 0) { @@ -77,9 +93,25 @@ if (sizeof ($tAlias) > 0) } print "\n"; } - print "

" . $PALANG['pMenu_create_alias'] . "\n"; +print "

" . $PALANG['pMenu_create_alias'] . "\n"; + + print "

\n
"; + if ( $limit['mbox_pgindex_count'] ) print "".$PALANG['pOverview_mailbox_title']."  "; + ($tDisplay_back_show == 1) ? $highlight_at = $tDisplay_back / $CONF['page_size'] + 1 : $highlight_at = 0; + for ($i = 0; $i < $limit['mbox_pgindex_count']; $i++) + { + if ( $i == $highlight_at ) + { + print "" . $limit['mbox_pgindex'][$i] . "\n"; + } + else + { + print "" . $limit['mbox_pgindex'][$i] . "\n"; + } + } + print ""; + -print "
\n"; if ($tDisplay_back_show == 1) { print "\""\n"; @@ -92,7 +124,8 @@ if ($tDisplay_next_show == 1) { print "\""\n"; } -print "
\n"; +print "
\n"; + if (sizeof ($tMailbox) > 0) { diff --git a/templates/overview.tpl b/templates/overview.tpl index 556c5cbc..eb097863 100644 --- a/templates/overview.tpl +++ b/templates/overview.tpl @@ -34,11 +34,25 @@ for ($i = 0; $i < sizeof ($list_domains); $i++) \n"; +print "
\n
"; +if ( $limit['alias_pgindex_count'] ) print "".$PALANG['pOverview_alias_title']."  "; +($tDisplay_back_show == 1) ? $highlight_at = $tDisplay_back / $CONF['page_size'] + 1 : $highlight_at = 0; +for ($i = 0; $i < $limit['alias_pgindex_count']; $i++) +{ + if ( $i == $highlight_at ) + { + print "" . $limit['alias_pgindex'][$i] . "\n"; + } + else + { + print "" . $limit['alias_pgindex'][$i] . "\n"; + } +} +print ""; if ($tDisplay_back_show == 1) print "\""\n"; if ($tDisplay_up_show == 1) print "\""\n"; if ($tDisplay_next_show == 1) print "\""\n"; -print "\n"; +print "
\n"; if (sizeof ($tAlias) > 0) { @@ -100,7 +114,21 @@ if (sizeof ($tAlias) > 0) } print "

" . $PALANG['pMenu_create_alias'] . "\n"; - print "

\n"; + print "\n"; if (sizeof ($tMailbox) > 0) {