SF.net SVN: postfixadmin:[1034] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2011-04-10 20:19:23
|
Revision: 1034 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1034&view=rev Author: christian_boltz Date: 2011-04-10 20:19:17 +0000 (Sun, 10 Apr 2011) Log Message: ----------- list-virtual.php: use create_page_browser(). This will speed up pagebrowser creation by about 300 times. This fixes https://sourceforge.net/tracker/?func=detail&aid=2967410&group_id=191583&atid=937964 It also brings back the pagebrowser in search mode and therefore fixes https://sourceforge.net/tracker/?func=detail&aid=2782818&group_id=191583&atid=937964 Detailed changes: - create separate query parts for pagebrowser creation (without SELECT $fieldlist and LIMIT clause) - create pagebrowser arrays with create_page_browser() - cNav_bar class: parameter cleanup in constructor: use count() instead of relying on external counting - change cNav_bar calls accordingly functions.inc.php: - remove pagebrowser generation from get_domain_properties() (no longer needed, obsoleted by create_page_browser) Modified Paths: -------------- trunk/functions.inc.php trunk/list-virtual.php Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2011-04-10 19:20:31 UTC (rev 1033) +++ trunk/functions.inc.php 2011-04-10 20:19:17 UTC (rev 1034) @@ -449,88 +449,6 @@ $list['quota_sum'] = $row[0]; $list['alias_count'] = $list['alias_count'] - $list['mailbox_count']; - $list['alias_pgindex']=array (); - $list['mbox_pgindex']=array (); - $list['mbox_pgindex_count'] = 0; - //while loop to figure index names. use page_size and loop of queries - $i=0; - $current=0; - $page_size = (int) $CONF['page_size']; - if ($page_size < 1) die ("\$CONF['page_size'] = '$page_size' is invalid (it may only contain digits and must be >= 1)"); - $tmpstr=""; - $idxlabel=""; - $list['alias_pgindex_count'] = 0; - - 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']) { Modified: trunk/list-virtual.php =================================================================== --- trunk/list-virtual.php 2011-04-10 19:20:31 UTC (rev 1033) +++ trunk/list-virtual.php 2011-04-10 20:19:17 UTC (rev 1034) @@ -155,14 +155,18 @@ $sql_where = " AND ( address LIKE '%$search%' OR goto LIKE '%$search%' ) "; } - $query = "SELECT address, - goto, - modified, - active - FROM $table_alias - 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"; +$alias_pagebrowser_query = " + FROM $table_alias + WHERE $sql_domain AND NOT EXISTS(SELECT 1 FROM $table_mailbox WHERE username=$table_alias.address) $sql_where + ORDER BY address +"; +$query = " + SELECT address, goto, modified, active + $alias_pagebrowser_query + LIMIT $page_size OFFSET $fDisplay +"; + $result = db_query ($query); if ($result['rows'] > 0) { @@ -226,7 +230,8 @@ $sql_where .= " AND ( $table_quota.path='quota/storage' OR $table_quota.path IS NULL ) "; } -$query = "$sql_select\n$sql_from\n$sql_join\n$sql_where\n$sql_order\n$sql_limit"; +$mailbox_pagebrowser_query = "$sql_from\n$sql_join\n$sql_where\n$sql_order" ; +$query = "$sql_select\n$mailbox_pagebrowser_query\n$sql_limit"; $result = db_query ($query); @@ -267,17 +272,6 @@ $tCanAddAlias = false; $tCanAddMailbox = false; -# TODO: needs reworking for $search... -# TODO: (= bug: no page browser displayed in search mode!) - https://sourceforge.net/tracker/?func=detail&aid=2782818&group_id=191583&atid=937964 -# for non-search mode, get_domain_properties counts the aliases and mailboxes -# Options: -# a) -# if ($search == "") -> get_domain_properties -# else -> "manual count" -# b) -# "manual count" for all cases (not really more work, queries are similar) -# -# Note: get_domain_properties also creates the page browser (which needs performance tuning anyway...) $limit = get_domain_properties($fDomain); if (isset ($limit)) { if ($fDisplay >= $page_size) { @@ -342,9 +336,9 @@ var $url; //* manually var $fInit, $arr_prev, $arr_next, $arr_top; //* internal var $anchor; - function cNav_bar ($aCount, $aTitle, $aLimit, $aPage_size, $aPages, $aSearch) + function cNav_bar ($aTitle, $aLimit, $aPage_size, $aPages, $aSearch) { - $this->count = $aCount; + $this->count = count($aPages); $this->title = $aTitle; $this->limit = $aLimit; $this->page_size = $aPage_size; @@ -428,10 +422,12 @@ } } -$nav_bar_alias = new cNav_bar ($limit['alias_pgindex_count'], $PALANG['pOverview_alias_title'], $fDisplay, $CONF['page_size'], $limit['alias_pgindex'], $search); +$pagebrowser_alias = create_page_browser("$table_alias.address", $alias_pagebrowser_query); +$nav_bar_alias = new cNav_bar ($PALANG['pOverview_alias_title'], $fDisplay, $CONF['page_size'], $pagebrowser_alias, $search); $nav_bar_alias->url = '&domain='.$fDomain; -$nav_bar_mailbox = new cNav_bar ($limit['mbox_pgindex_count'], $PALANG['pOverview_mailbox_title'], $fDisplay, $CONF['page_size'], $limit['mbox_pgindex'], $search); +$pagebrowser_mailbox = create_page_browser("$table_mailbox.username", $mailbox_pagebrowser_query); +$nav_bar_mailbox = new cNav_bar ($PALANG['pOverview_mailbox_title'], $fDisplay, $CONF['page_size'], $pagebrowser_mailbox, $search); $nav_bar_mailbox->url = '&domain='.$fDomain; //print $nav_bar_alias->display_top (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |