X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialListusers.php;h=460d4259cd8321dff78a662a20706c05bbeebffb;hb=2cdff4cf67b77a3a7bb54c656a05bfe8a529ae3d;hp=9183ea527ab7db1eebe3c54bd2de49ffd6de179e;hpb=a26d5a49d755ff4b8039b11d1f26abb5d7bc7e8c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialListusers.php b/includes/SpecialListusers.php index 9183ea527a..460d4259cd 100644 --- a/includes/SpecialListusers.php +++ b/includes/SpecialListusers.php @@ -1,7 +1,10 @@ +# # http://www.mediawiki.org/ # # This program is free software; you can redistribute it and/or modify @@ -16,189 +19,175 @@ # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # http://www.gnu.org/copyleft/gpl.html /** * - * @package MediaWiki - * @subpackage SpecialPage + * @addtogroup 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 * next to their names. * - * @package MediaWiki - * @subpackage SpecialPage + * @addtogroup SpecialPage */ -class ListUsersPage extends QueryPage { - var $requestedGroup = ''; - var $requestedUser = ''; - function getName() { - return 'Listusers'; +class UsersPager extends AlphabeticPager { + + function __construct($group=null) { + global $wgRequest; + $this->requestedGroup = $group != "" ? $group : $wgRequest->getVal( 'group' ); + $un = $wgRequest->getText( 'username' ); + $this->requestedUser = ''; + if ( $un != '' ) { + $username = Title::makeTitleSafe( NS_USER, $un ); + if( ! is_null( $username ) ) { + $this->requestedUser = $username->getText(); + } + } + parent::__construct(); } - function isSyndicated() { return false; } - /** - * Not expensive, this class won't work properly with the caching system anyway - */ - function isExpensive() { - return false; + + function getIndexField() { + return 'user_name'; } - /** - * Fetch user page links and cache their existence - */ - function preprocessResults( &$db, &$res ) { - $batch = new LinkBatch; - while ( $row = $db->fetchObject( $res ) ) { - $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) ); + function getQueryInfo() { + $conds=array(); + // don't show hidden names + $conds[]='ipb_deleted IS NULL OR ipb_deleted = 0'; + if ($this->requestedGroup != "") { + $conds['ug_group'] = $this->requestedGroup; } - $batch->execute(); - - // Back to start for display - if( $db->numRows( $res ) > 0 ) { - // If there are no rows we get an error seeking. - $db->dataSeek( $res, 0 ); + if ($this->requestedUser != "") { + $conds[] = 'user_name >= ' . wfGetDB()->addQuotes( $this->requestedUser ); } - } - /** - * Show a drop down list to select a group as well as a user name - * search box. - * @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 = '
'; - // congratulations the form is now build - return $out; } - function getSQL() { - $dbr =& wfGetDB( DB_SLAVE ); - $user = $dbr->tableName( 'user' ); - $user_groups = $dbr->tableName( 'user_groups' ); - - // We need to get an 'atomic' list of users, so that we - // don't break the list half-way through a user's group set - // and so that lists by group will show all group memberships. - // - // On MySQL 4.1 we could use GROUP_CONCAT to grab group - // assignments together with users pretty easily. On other - // versions, it's not so easy to do it consistently. - // For now we'll just grab the number of memberships, so - // we can then do targetted checks on those who are in - // non-default groups as we go down the list. - - $userspace = NS_USER; - $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 " . - $this->userQueryWhere( $dbr ) . - " GROUP BY user_name"; - - return $sql; - } + function formatRow( $row ) { + $userPage = Title::makeTitle( NS_USER, $row->user_name ); + $name = $this->getSkin()->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) ); + + if( $row->numgroups > 1 || ( $this->requestedGroup && $row->numgroups == 1 ) ) { + $list = array(); + foreach( self::getGroups( $row->user_id ) as $group ) + $list[] = self::buildGroupLink( $group ); + $groups = implode( ', ', $list ); + } elseif( $row->numgroups == 1 ) { + $groups = self::buildGroupLink( $row->singlegroup ); + } else { + $groups = ''; + } - function userQueryWhere( &$dbr ) { - $conds = $this->userQueryConditions(); - return empty( $conds ) - ? "" - : "WHERE " . $dbr->makeList( $conds, LIST_AND ); + return '' . wfMsgHTML('listusers-noresult') . '
'; + }; + + $wgOut->addHTML( $s ); } -?> +