X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialListusers.php;h=49a3c11b8d416c6d7a59813b6b0d3e7ddb6b7a76;hb=09da7fb96c45255899fa0f4c62412d14b8575b3e;hp=756e92e61fe6278923854b2c24f07d132cc3003b;hpb=a8db64e877d98b0191e325f8a0aaff84c6cb3f30;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialListusers.php b/includes/SpecialListusers.php index 756e92e61f..49a3c11b8d 100644 --- a/includes/SpecialListusers.php +++ b/includes/SpecialListusers.php @@ -1,39 +1,229 @@ addHTML( "
{$top}\n" );
+ /**
+ * Fetch user page links and cache their existence
+ */
+ function preprocessResults( &$db, &$res ) {
+ global $wgLinkCache;
+
+ $batch = new LinkBatch;
+ while ( $row = $db->fetchObject( $res ) ) {
+ $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) );
+ }
+ $batch->execute( $wgLinkCache );
+
+ // Back to start for display
+ if( $db->numRows( $res ) > 0 ) {
+ // If there are no rows we get an error seeking.
+ $db->dataSeek( $res, 0 );
+ }
+ }
- $sl = wfViewPrevNext( $offset, $limit,
- $wgLang->specialPage( "Listusers" ) );
- $wgOut->addHTML( "
{$sl}
{$sl}
\n" ); + + function linkParameters() { + $conds = array(); + if( $this->requestedGroup != '' ) { + $conds['group'] = $this->requestedGroup; + } + if( $this->requestedUser != '' ) { + $conds['username'] = $this->requestedUser; + } + return $conds; + } + + function sortDescending() { + return false; + } + + function formatResult( $skin, $result ) { + + $userPage = Title::makeTitle( $result->namespace, $result->title ); + $name = $skin->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) ); + + if( !isset( $result->numgroups ) || $result->numgroups > 0 ) { + $dbr =& wfGetDB( DB_SLAVE ); + $result = $dbr->select( 'user_groups', + array( 'ug_group' ), + array( 'ug_user' => $result->user_id ), + 'ListUsersPage::formatResult' ); + $groups = array(); + while( $row = $dbr->fetchObject( $result ) ) { + $groups[] = User::getGroupName( $row->ug_group ); + } + $dbr->freeResult( $result ); + + if( count( $groups ) > 0 ) { + $name .= ' (' . + $skin->makeLink( wfMsgForContent( 'administrators' ), + htmlspecialchars( implode( ', ', $groups ) ) ) . + ')'; + } + } + + return $name; + } +} + +/** + * constructor + * $par string (optional) A group to list users from + */ +function wfSpecialListusers( $par = null ) { + global $wgRequest; + + list( $limit, $offset ) = wfCheckLimits(); + + + $slu = new ListUsersPage(); + + /** + * Get some parameters + */ + $groupTarget = isset($par) ? $par : $wgRequest->getVal( 'group' ); + $slu->requestedGroup = $groupTarget; + $slu->requestedUser = $wgRequest->getVal('username'); + + return $slu->doQuery( $offset, $limit ); } ?>