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
postfixadmin-2.3
Greg 18 years ago
parent 3a240d9693
commit cecbdd1660

@ -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'])
{

@ -27,7 +27,22 @@ for ($i = 0; $i < sizeof ($list_domains); $i++)
</div>
<?php
print "<div id=\"nav_bar\">\n";
print "<div id=\"nav_bar\">\n<table width=730><colgroup span=\"1\"> <col width=\"550\"></col></colgroup> <tr><td align=left >";
if ( $limit['alias_pgindex_count'] ) print "<b>".$PALANG['pOverview_alias_title']."</b>&nbsp&nbsp";
($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 "<a href=\"list-virtual.php?domain=$fDomain&limit=" . $i * $CONF['page_size'] . "\"><b>" . $limit['alias_pgindex'][$i] . "</b></a>\n";
}
else
{
print "<a href=\"list-virtual.php?domain=$fDomain&limit=" . $i * $CONF['page_size'] . "\">" . $limit['alias_pgindex'][$i] . "</a>\n";
}
}
print "</td><td valign=middle align=right>";
if ($tDisplay_back_show == 1)
{
print "<a href=\"list-virtual.php?domain=$fDomain&limit=$tDisplay_back\"><img border=\"0\" src=\"../images/arrow-l.png\" title=\"" . $PALANG['pOverview_left_arrow'] . "\" alt=\"" . $PALANG['pOverview_left_arrow'] . "\" /></a>\n";
@ -40,7 +55,8 @@ if ($tDisplay_next_show == 1)
{
print "<a href=\"list-virtual.php?domain=$fDomain&limit=$tDisplay_next\"><img border=\"0\" src=\"../images/arrow-r.png\" title=\"" . $PALANG['pOverview_right_arrow'] . "\" alt=\"" . $PALANG['pOverview_right_arrow'] . "\" /></a>\n";
}
print "</div>\n";
print "</td></tr></table></div>\n";
if (sizeof ($tAlias) > 0)
{
@ -77,9 +93,25 @@ if (sizeof ($tAlias) > 0)
}
print "</table>\n";
}
print "<p><a href=\"create-alias.php?domain=$fDomain\">" . $PALANG['pMenu_create_alias'] . "</a>\n";
print "<p><a href=\"create-alias.php?domain=$fDomain\">" . $PALANG['pMenu_create_alias'] . "</a>\n";
print "<div id=\"nav_bar\"><a name=\"MidArrow\" /a>\n<table width=730><colgroup span=\"1\"> <col width=\"550\"></col></colgroup> <tr><td align=left >";
if ( $limit['mbox_pgindex_count'] ) print "<b>".$PALANG['pOverview_mailbox_title']."</b>&nbsp&nbsp";
($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 "<a href=\"list-virtual.php?domain=$fDomain&limit=" . $i * $CONF['page_size'] . "#MidArrow\"><b>" . $limit['mbox_pgindex'][$i] . "</b></a>\n";
}
else
{
print "<a href=\"list-virtual.php?domain=$fDomain&limit=" . $i * $CONF['page_size'] . "#MidArrow\">" . $limit['mbox_pgindex'][$i] . "</a>\n";
}
}
print "</td><td valign=middle align=right>";
print "<div id=\"nav_bar\"><a name=\"MidArrow\" /a>\n";
if ($tDisplay_back_show == 1)
{
print "<a href=\"list-virtual.php?domain=$fDomain&limit=$tDisplay_back#MidArrow\"><img border=\"0\" src=\"../images/arrow-l.png\" title=\"" . $PALANG['pOverview_left_arrow'] . "\" alt=\"" . $PALANG['pOverview_left_arrow'] . "\" /></a>\n";
@ -92,7 +124,8 @@ if ($tDisplay_next_show == 1)
{
print "<a href=\"list-virtual.php?domain=$fDomain&limit=$tDisplay_next#MidArrow\"><img border=\"0\" src=\"../images/arrow-r.png\" title=\"" . $PALANG['pOverview_right_arrow'] . "\" alt=\"" . $PALANG['pOverview_right_arrow'] . "\" /></a>\n";
}
print "</div>\n";
print "</td></tr></table></div>\n";
if (sizeof ($tMailbox) > 0)
{

@ -34,11 +34,25 @@ for ($i = 0; $i < sizeof ($list_domains); $i++)
</div>
<?php
print "<div id=\"nav_bar\">\n";
print "<div id=\"nav_bar\">\n<table width=730><colgroup span=\"1\"> <col width=\"550\"></col></colgroup> <tr><td align=left >";
if ( $limit['alias_pgindex_count'] ) print "<b>".$PALANG['pOverview_alias_title']."</b>&nbsp&nbsp";
($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 "<a href=\"overview.php?domain=$fDomain&limit=" . $i * $CONF['page_size'] . "\"><b>" . $limit['alias_pgindex'][$i] . "</b></a>\n";
}
else
{
print "<a href=\"overview.php?domain=$fDomain&limit=" . $i * $CONF['page_size'] . "\">" . $limit['alias_pgindex'][$i] . "</a>\n";
}
}
print "</td><td valign=middle align=right>";
if ($tDisplay_back_show == 1) print "<a href=\"overview.php?domain=$fDomain&limit=$tDisplay_back\"><img border=\"0\" src=\"images/arrow-l.png\" title=\"" . $PALANG['pOverview_left_arrow'] . "\" alt=\"" . $PALANG['pOverview_left_arrow'] . "\"></a>\n";
if ($tDisplay_up_show == 1) print "<a href=\"overview.php?domain=$fDomain&limit=0\"><img border=\"0\" src=\"images/arrow-u.png\" title=\"" . $PALANG['pOverview_up_arrow']."\" alt=\"" . $PALANG['pOverview_up_arrow'] . "\"></a>\n";
if ($tDisplay_next_show == 1) print "<a href=\"overview.php?domain=$fDomain&limit=$tDisplay_next\"><img border=\"0\" src=\"images/arrow-r.png\" title=\"" . $PALANG['pOverview_right_arrow'] . "\" alt=\"" . $PALANG['pOverview_right_arrow'] . "\"></a>\n";
print "</div>\n";
print "</td></tr></table></div>\n";
if (sizeof ($tAlias) > 0)
{
@ -100,7 +114,21 @@ if (sizeof ($tAlias) > 0)
}
print "<p><a href=\"create-alias.php?domain=$fDomain\">" . $PALANG['pMenu_create_alias'] . "</a>\n";
print "<div id=\"nav_bar\"><a name=\"MidArrow\" /a>\n";
print "<div id=\"nav_bar\"><a name=\"MidArrow\" /a>\n<table width=730><colgroup span=\"1\"> <col width=\"550\"></col></colgroup> <tr><td align=left >";
if ( $limit['mbox_pgindex_count'] ) print "<b>".$PALANG['pOverview_mailbox_title']."</b>&nbsp&nbsp";
($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 "<a href=\"overview.php?domain=$fDomain&limit=" . $i * $CONF['page_size'] . "#MidArrow\"><b>" . $limit['mbox_pgindex'][$i] . "</b></a>\n";
}
else
{
print "<a href=\"overview.php?domain=$fDomain&limit=" . $i * $CONF['page_size'] . "#MidArrow\">" . $limit['mbox_pgindex'][$i] . "</a>\n";
}
}
print "</td><td valign=middle align=right>";
if ($tDisplay_back_show == 1)
{
print "<a href=\"overview.php?domain=$fDomain&limit=$tDisplay_back#MidArrow\"><img border=\"0\" src=\"images/arrow-l.png\" title=\"" . $PALANG['pOverview_left_arrow'] . "\" alt=\"" . $PALANG['pOverview_left_arrow'] . "\" /></a>\n";
@ -113,7 +141,7 @@ if (sizeof ($tAlias) > 0)
{
print "<a href=\"overview.php?domain=$fDomain&limit=$tDisplay_next#MidArrow\"><img border=\"0\" src=\"images/arrow-r.png\" title=\"" . $PALANG['pOverview_right_arrow'] . "\" alt=\"" . $PALANG['pOverview_right_arrow'] . "\" /></a>\n";
}
print "</div>\n";
print "</td></tr></table></div>\n";
if (sizeof ($tMailbox) > 0)
{

Loading…
Cancel
Save