From: Brion Vibber Date: Thu, 30 Jun 2005 07:37:04 +0000 (+0000) Subject: * (bug 2625) Keep group & user settings when paging in Listusers X-Git-Tag: 1.5.0beta2~120 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=16a2275f54922a19dd41d70044401b07e5658607;p=lhc%2Fweb%2Fwiklou.git * (bug 2625) Keep group & user settings when paging in Listusers --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7f537f30ae..8e39a5113d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -429,6 +429,7 @@ Various bugfixes, small features, and a few experimental things: subpage parent links) on current-diff view. * (bug 2618) Fix regression from another fix; show initial preview for categories only if the page does not exist. +* (bug 2625) Keep group & user settings when paging in Listusers === Caveats === diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 90d6eb9198..2371444aba 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -112,11 +112,21 @@ class QueryPage { /** * The content returned by this function will be output before any result - */ + */ function getPageHeader( ) { return ''; } + /** + * If using extra form wheely-dealies, return a set of parameters here + * as an associative array. They will be encoded and added to the paging + * links (prev/next/lengths). + * @return array + */ + function linkParameters() { + return array(); + } + /** * Some special pages (for example SpecialListusers) might not return the * current object formatted, but return the previous one instead. @@ -239,7 +249,9 @@ class QueryPage { # often disable 'next' link when we reach the end if($num < $limit) { $atend = true; } else { $atend = false; } - $sl = wfViewPrevNext( $offset, $limit , $wgContLang->specialPage( $sname ), "" ,$atend ); + $sl = wfViewPrevNext( $offset, $limit , + $wgContLang->specialPage( $sname ), + wfArrayToCGI( $this->linkParameters() ), $atend ); $wgOut->addHTML( "
{$sl}

\n" ); } if ( $num > 0 ) { diff --git a/includes/SpecialListusers.php b/includes/SpecialListusers.php index 9c0efbb839..8b26bed04b 100644 --- a/includes/SpecialListusers.php +++ b/includes/SpecialListusers.php @@ -111,23 +111,42 @@ class ListUsersPage extends QueryPage { $sql = "SELECT 'Listusers' as type, $userspace AS namespace, user_name AS title, " . "user_name as value, user_id, COUNT(ug_group) as numgroups " . "FROM $user ". - "LEFT JOIN $user_groups ON user_id=ug_user "; - - if($this->requestedGroup != '') { - $sql .= 'WHERE ug_group = ' . $dbr->addQuotes( $this->requestedGroup ) . ' '; - if($this->requestedUser != '') { - $sql .= "AND user_name = " . $dbr->addQuotes( $this->requestedUser ) . ' '; - } - } else { - if($this->requestedUser !='') { - $sql .= "WHERE user_name = " . $dbr->addQuotes( $this->requestedUser ) . ' '; - } - } - $sql .= "GROUP BY user_name"; + "LEFT JOIN $user_groups ON user_id=ug_user " . + $this->userQueryWhere( $dbr ) . + " GROUP BY user_name"; return $sql; } + function userQueryWhere( &$dbr ) { + $conds = $this->userQueryConditions(); + return empty( $conds ) + ? "" + : "WHERE " . $dbr->makeList( $conds, LIST_AND ); + } + + function userQueryConditions() { + $conds = array(); + if( $this->requestedGroup != '' ) { + $conds['ug_group'] = $this->requestedGroup; + } + if( $this->requestedUser != '' ) { + $conds['user_name'] = $this->requestedUser; + } + return $conds; + } + + function linkParameters() { + $conds = array(); + if( $this->requestedGroup != '' ) { + $conds['group'] = $this->requestedGroup; + } + if( $this->requestedUser != '' ) { + $conds['username'] = $this->requestedUser; + } + return $conds; + } + function sortDescending() { return false; } @@ -159,7 +178,7 @@ class ListUsersPage extends QueryPage { } return $name; - } + } } /**