From fd7b8b94792658c6e719423bd2cc9c8768324812 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 20 Jun 2009 23:42:35 +0000 Subject: [PATCH] Added activeuser list (bug 15456) (indexes should be there now) --- includes/DefaultSettings.php | 1 + includes/specials/SpecialActiveusers.php | 143 +++++++++++++++++++++++ languages/messages/MessagesEn.php | 7 ++ 3 files changed, 151 insertions(+) create mode 100644 includes/specials/SpecialActiveusers.php diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index c5233e3c50..de18f1e4f3 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3089,6 +3089,7 @@ $wgSpecialPageGroups = array( 'Filepath' => 'media', 'Listusers' => 'users', + 'Activeusers' => 'users', 'Listgrouprights' => 'users', 'Ipblocklist' => 'users', 'Contributions' => 'users', diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php new file mode 100644 index 0000000000..d4c6bfea3e --- /dev/null +++ b/includes/specials/SpecialActiveusers.php @@ -0,0 +1,143 @@ +getText( 'username' ); + $this->requestedUser = ''; + if ( $un != '' ) { + $username = Title::makeTitleSafe( NS_USER, $un ); + if( ! is_null( $username ) ) { + $this->requestedUser = $username->getText(); + } + } + parent::__construct(); + } + + + function getIndexField() { + return 'rc_user_text'; + } + + function getQueryInfo() { + $dbr = wfGetDB( DB_SLAVE ); + $conds = array(); + // don't show hidden names + $conds[] = 'ipb_deleted IS NULL'; + $useIndex = $dbr->useIndexClause('rc_user_text'); + if( $this->requestedUser != "" ) { + $conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser ); + } + $conds[] = 'rc_user > 0'; // Users - no anons + + list ($recentchanges,$ipblocks) = $dbr->tableNamesN('recentchanges','ipblocks'); + + $query = array( + 'tables' => " $recentchanges $useIndex + LEFT JOIN $ipblocks ON rc_user=ipb_user AND ipb_auto=0 AND ipb_deleted=1 ", + 'fields' => array('rc_user_text AS user_name', // inheritance + 'rc_user_text', // for Pager + 'MAX(rc_user) AS user_id', + 'COUNT(*) AS recentedits', + 'MAX(ipb_user) AS blocked'), + 'options' => array('GROUP BY' => 'user_name'), + 'conds' => $conds + ); + return $query; + } + + function formatRow( $row ) { + $userPage = Title::makeTitle( NS_USER, $row->rc_user_text ); + $name = $this->getSkin()->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) ); + + $list = array(); + foreach( self::getGroups( $row->user_id ) as $group ) + $list[] = self::buildGroupLink( $group ); + $groups = implode( ', ', $list ); + + $item = wfSpecialList( $name, $groups ); + $count = wfMsgExt( 'activeusers-count', array('parsemag'), $row->recentedits ); + $blocked = $row->blocked ? ' '.wfMsg('listusers-blocked') : ''; + + return "
  • {$item} [{$count}]{$blocked}
  • "; + } + + function getPageHeader() { + global $wgScript, $wgRequest; + $self = $this->getTitle(); + + # Form tag + $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . + '
    ' . + Xml::element( 'legend', array(), wfMsg( 'activeusers' ) ); + $out .= Xml::hidden( 'title', $self->getPrefixedDbKey() ); + + # Username field + $out .= Xml::label( wfMsg( 'activeusers-from' ), 'offset' ) . ' ' . + Xml::input( 'username', 20, $this->requestedUser, array( 'id' => 'offset' ) ) . ' '; + + # Submit button and form bottom + if( $this->mLimit ) + $out .= Xml::hidden( 'limit', $this->mLimit ); + $out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ); + + $out .= '
    ' . Xml::closeElement( 'form' ); + + return $out; + } +} + +/** + * constructor + * $par string (optional) A group to list users from + */ +function wfSpecialActiveusers( $par = null ) { + global $wgRequest, $wgOut; + + $up = new ActiveUsersPager(); + + # getBody() first to check, if empty + $usersbody = $up->getBody(); + $s = $up->getPageHeader(); + if( $usersbody ) { + $s .= $up->getNavigationBar(); + $s .= ''; + $s .= $up->getNavigationBar() ; + } else { + $s .= '

    ' . wfMsgHTML('activeusers-noresult') . '

    '; + }; + + $wgOut->addHTML( $s ); +} diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index b6424b3f86..5db9ee2a9a 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2238,6 +2238,8 @@ It now redirects to [[$2]].', 'listusers-creationsort' => 'Sort by creation date', 'usereditcount' => '$1 {{PLURAL:$1|edit|edits}}', 'usercreated' => 'Created on $1 at $2', +'activeusers' => 'Active user list', +'activeusers-count' => '$1 recent {{PLURAL:$1|edit|edits}}', 'newpages' => 'New pages', 'newpages-summary' => '', # do not translate or duplicate this message to other languages 'newpages-username' => 'Username:', @@ -2326,6 +2328,11 @@ Supported protocols: $1', 'listusersfrom' => 'Display users starting at:', 'listusers-submit' => 'Show', 'listusers-noresult' => 'No user found.', +'listusers-blocked' => '(blocked)', + +# Special:ActiveUsers +'activeusers-from' => 'Display users starting at:', +'activeusers-noresult' => 'No user found.', # Special:Log/newusers 'newuserlogpage' => 'User creation log', -- 2.20.1