<?php
+
# Copyright (C) 2004 Brion Vibber, lcrocker, Tim Starling,
# Domas Mituzas, Ashar Voultoiz, Jens Frank, Zhengzhu.
#
+# © 2006 Rob Church <robchur@gmail.com>
+#
# http://www.mediawiki.org/
#
# This program is free software; you can redistribute it and/or modify
* @subpackage SpecialPage
*/
-/**
- *
- */
-require_once('QueryPage.php');
-
/**
* This class is used to get a list of user. The ones with specials
* rights (sysop, bureaucrat, developer) will have them displayed
* @todo localize
*/
function getPageHeader( ) {
- global $wgScript;
-
- // Various variables used for the form
- $action = htmlspecialchars( $wgScript );
- $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 = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) );
+
+ # Group drop-down list
+ $out .= wfElement( 'label', array( 'for' => 'group' ), wfMsg( 'group' ) ) . ' ';
+ $out .= wfOpenElement( 'select', array( 'name' => 'group' ) );
+ $out .= wfElement( 'option', array( 'value' => '' ), wfMsg( 'group-all' ) ); # 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 ) ) . ' ';
+
+ # 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 ) );
- $out .= wfMsgHtml( 'specialloguserlabel' ) . '<input type="text" name="username" /> ';
+ # 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;
}
"FROM $user ".
"LEFT JOIN $user_groups ON user_id=ug_user " .
$this->userQueryWhere( $dbr ) .
- " GROUP BY user_name, user_id";
+ " GROUP BY user_name";
return $sql;
}
function formatResult( $skin, $result ) {
$userPage = Title::makeTitle( $result->namespace, $result->title );
$name = $skin->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) );
+ $groups = null;
if( !isset( $result->numgroups ) || $result->numgroups > 0 ) {
$dbr =& wfGetDB( DB_SLAVE );
'ListUsersPage::formatResult' );
$groups = array();
while( $row = $dbr->fetchObject( $result ) ) {
- $groups[] = User::getGroupName( $row->ug_group );
+ $groups[$row->ug_group] = User::getGroupMember( $row->ug_group );
}
$dbr->freeResult( $result );
if( count( $groups ) > 0 ) {
- $name .= ' (' .
- $skin->makeLink( wfMsgForContent( 'administrators' ),
- htmlspecialchars( implode( ', ', $groups ) ) ) .
- ')';
- }
+ foreach( $groups as $group => $desc ) {
+ if( $page = User::getGroupPage( $group ) ) {
+ $list[] = $skin->makeLinkObj( $page, htmlspecialchars( $desc ) );
+ } else {
+ $list[] = htmlspecialchars( $desc );
+ }
+ }
+ $groups = implode( ', ', $list );
+ } else {
+ $groups = '';
+ }
+
}
- return $name;
+ return wfSpecialList( $name, $groups );
}
}
*/
$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 );
}