* (bug 5801) Correct handling of underscores in Special:Listusers
authorRob Church <robchurch@users.mediawiki.org>
Wed, 3 May 2006 01:23:10 +0000 (01:23 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Wed, 3 May 2006 01:23:10 +0000 (01:23 +0000)
* Clean up Special:Listusers; add an "(all)" label to the group selection box

RELEASE-NOTES
includes/QueryPage.php
includes/SpecialListusers.php
languages/Messages.php

index dd6b33a..35070ad 100644 (file)
@@ -190,7 +190,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Add 'EmailConfirmed' hook
 * New findhooks.php script to find undocumented hooks.
 * Silently ignore errors on profiling table update.
-
+* (bug 5801) Correct handling of underscores in Special:Listusers
+* Clean up Special:Listusers; add an "(all)" label to the group selection box
 
 == Compatibility ==
 
index 1c9c250..7848c53 100644 (file)
@@ -90,6 +90,15 @@ class QueryPage {
                return '';
        }
 
+       /**
+        * Return title object representing this page
+        *
+        * @return Title
+        */
+       function getTitle() {
+               return Title::makeTitle( NS_SPECIAL, $this->getName() );
+       }
+
        /**
         * Subclasses return an SQL query here.
         *
index 46244a3..a35794c 100644 (file)
@@ -83,33 +83,39 @@ class ListUsersPage extends QueryPage {
                $title = Title::makeTitle( NS_SPECIAL, 'Listusers' );
                $special = htmlspecialchars( $title->getPrefixedDBkey() );
 
-               // form header
-               $out = '<form method="get" action="'.$action.'">' .
-                               '<input type="hidden" name="title" value="'.$special.'" />' .
-                               wfMsgHtml( 'groups-editgroup-name' ) . '<select name="group">';
-
-               // get group names
+               $self = $this->getTitle();
+
+               # Form tag
+               $out = wfElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) );
+               
+               # Group drop-down list
+               $out .= wfElement( 'label', array( 'for' => 'group' ), wfMsg( 'groups-editgroup-name' ) ) . ' ';
+               $out .= wfOpenElement( 'select', array( 'name' => 'group' ) );
+               $out .= wfElement( 'option', array( 'value' => '' ), '(' . wfMsg( 'groupsall' ) . ')' ); # Item for "all groups"
                $groups = User::getAllGroups();
-
-               // we want a default empty group
-               $out.= '<option value=""></option>';
-
-               // build the dropdown list menu using datas from the database
-               foreach ( $groups as $group ) {
-                       $selected = ($group == $this->requestedGroup);
-                       $out .= wfElement( 'option',
-                               array_merge(
-                                       array( 'value' => $group ),
-                                       $selected ? array( 'selected' => 'selected' ) : array() ),
-                               User::getGroupName( $group ) );
+               foreach( $groups as $group ) {
+                       $attribs = array( 'value' => $group );
+                       if( $group == $this->requestedGroup )
+                               $attribs['selected'] = 'selected';
+                       $out .= wfElement( 'option', $attribs, User::getGroupName( $group ) );
                }
-               $out .= '</select> ';
+               $out .= wfCloseElement( 'select' ) . ' ';;# . wfElement( 'br' );
+
+               # Username field
+               $out .= wfElement( 'label', array( 'for' => 'username' ), wfMsg( 'specialloguserlabel' ) ) . ' ';
+               $out .= wfElement( 'input', array( 'type' => 'text', 'id' => 'username', 'name' => 'username',
+                                                       'value' => $this->requestedUser ) ) . ' ';
 
-               $out .= wfMsgHtml( 'specialloguserlabel' ) . '<input type="text" name="username" /> ';
+               # Preserve offset and limit
+               if( $this->offset )
+                       $out .= wfElement( 'input', array( 'type' => 'hidden', 'name' => 'offset', 'value' => $this->offset ) );
+               if( $this->limit )
+                       $out .= wfElement( 'input', array( 'type' => 'hidden', 'name' => 'limit', 'value' => $this->limit ) );
+
+               # Submit button and form bottom
+               $out .= wfElement( 'input', array( 'type' => 'submit', 'value' => wfMsg( 'allpagessubmit' ) ) );
+               $out .= wfCloseElement( 'form' );
 
-               // OK button, end of form.
-               $out .= '<input type="submit" value="' . wfMsgHtml( 'allpagessubmit' ) . '" /></form>';
-               // congratulations the form is now build
                return $out;
        }
 
@@ -217,7 +223,11 @@ function wfSpecialListusers( $par = null ) {
         */
        $groupTarget = isset($par) ? $par : $wgRequest->getVal( 'group' );
        $slu->requestedGroup = $groupTarget;
-       $slu->requestedUser = $wgContLang->ucfirst( $wgRequest->getVal('username') );
+
+       # 'Validate' the username first
+       $username = $wgRequest->getText( 'username', '' );
+       $user = User::newFromName( $username );
+       $slu->requestedUser = is_object( $user ) ? $user->getName() : '';
 
        return $slu->doQuery( $offset, $limit );
 }
index 9a0bfe8..194e61d 100644 (file)
@@ -1943,6 +1943,7 @@ is collapsed. Others will be hidden by default.
 'watchlistall1' => 'all',
 'watchlistall2' => 'all',
 'namespacesall' => 'all',
+'groupsall' => 'all',
 
 # E-mail address confirmation
 'confirmemail' => 'Confirm E-mail address',