* (bug 2625) Keep group & user settings when paging in Listusers
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 30 Jun 2005 07:37:04 +0000 (07:37 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 30 Jun 2005 07:37:04 +0000 (07:37 +0000)
RELEASE-NOTES
includes/QueryPage.php
includes/SpecialListusers.php

index 7f537f3..8e39a51 100644 (file)
@@ -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 ===
index 90d6eb9..2371444 100644 (file)
@@ -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( "<br />{$sl}</p>\n" );
                }
                if ( $num > 0 ) {
index 9c0efbb..8b26bed 100644 (file)
@@ -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;
-       }
+       }       
 }
 
 /**