X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialActiveusers.php;h=8f4a9431ce54366b2f5d64f120ac377bd86fce23;hb=c94d9162fcf544d94052654b414d0249861c9695;hp=7212468900432ae70f2c90f6541a7cd0d343797a;hpb=3700d98d86b2b50ef0c7360953613f4edeb0826b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index 7212468900..8f4a9431ce 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -1,38 +1,59 @@ RCMaxAge = ceil( $wgRCMaxAge / ( 3600 * 24 ) ); // Constant + /** + * @var FormOptions + */ + protected $opts; + + /** + * @var Array + */ + protected $groups; - $un = $wgRequest->getText( 'username' ); + /** + * @param $context IContextSource + * @param $group null Unused + * @param $par string Parameter passed to the page + */ + function __construct( IContextSource $context = null, $group = null, $par = null ) { + global $wgActiveUserDays; + + parent::__construct( $context ); + + $this->RCMaxAge = $wgActiveUserDays; + $un = $this->getRequest()->getText( 'username', $par ); $this->requestedUser = ''; if ( $un != '' ) { $username = Title::makeTitleSafe( NS_USER, $un ); @@ -40,7 +61,25 @@ class ActiveUsersPager extends UsersPager { $this->requestedUser = $username->getText(); } } - parent::__construct(); + + $this->setupOptions(); + } + + public function setupOptions() { + $this->opts = new FormOptions(); + + $this->opts->add( 'hidebots', false, FormOptions::BOOL ); + $this->opts->add( 'hidesysops', false, FormOptions::BOOL ); + + $this->opts->fetchValuesFromRequest( $this->getRequest() ); + + $this->groups = array(); + if ( $this->opts->getValue( 'hidebots' ) == 1 ) { + $this->groups['bot'] = true; + } + if ( $this->opts->getValue( 'hidesysops' ) == 1 ) { + $this->groups['sysop'] = true; + } } function getIndexField() { @@ -52,6 +91,8 @@ class ActiveUsersPager extends UsersPager { $conds = array( 'rc_user > 0' ); // Users - no anons $conds[] = 'ipb_deleted IS NULL'; // don't show hidden names $conds[] = "rc_log_type IS NULL OR rc_log_type != 'newusers'"; + $conds[] = "rc_timestamp >= '{$dbr->timestamp( wfTimestamp( TS_UNIX ) - $this->RCMaxAge*24*3600 )}'"; + if( $this->requestedUser != '' ) { $conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser ); } @@ -60,12 +101,12 @@ class ActiveUsersPager extends UsersPager { 'tables' => array( 'recentchanges', 'user', 'ipblocks' ), 'fields' => array( 'rc_user_text AS user_name', // inheritance 'rc_user_text', // for Pager - 'MAX(user_id) AS user_id', + 'user_id', 'COUNT(*) AS recentedits', 'MAX(ipb_user) AS blocked' ), 'options' => array( - 'GROUP BY' => 'rc_user_text', + 'GROUP BY' => 'rc_user_text, user_id', 'USE INDEX' => array( 'recentchanges' => 'rc_user_text' ) ), 'join_conds' => array( @@ -78,43 +119,54 @@ class ActiveUsersPager extends UsersPager { } function formatRow( $row ) { - global $wgLang; $userName = $row->user_name; - - $ulinks = $this->getSkin()->userLink( $row->user_id, $userName ); - $ulinks .= $this->getSkin()->userToolLinks( $row->user_id, $userName ); + + $ulinks = Linker::userLink( $row->user_id, $userName ); + $ulinks .= Linker::userToolLinks( $row->user_id, $userName ); + + $lang = $this->getLanguage(); $list = array(); foreach( self::getGroups( $row->user_id ) as $group ) { - $list[] = self::buildGroupLink( $group ); + if ( isset( $this->groups[$group] ) ) { + return ''; + } + $list[] = self::buildGroupLink( $group, $userName ); } - $groups = $wgLang->commaList( $list ); - - $item = wfSpecialList( $ulinks, $groups ); - $count = wfMsgExt( 'activeusers-count', - array( 'parsemag' ), - $wgLang->formatNum( $row->recentedits ), - $userName, - $wgLang->formatNum ( $this->RCMaxAge ) - ); - $blocked = $row->blocked ? ' ' . wfMsgExt( 'listusers-blocked', array( 'parsemag' ), $userName ) : ''; + $groups = $lang->commaList( $list ); + + $item = $lang->specialList( $ulinks, $groups ); + $count = $this->msg( 'activeusers-count' )->numParams( $row->recentedits ) + ->params( $userName )->numParams( $this->RCMaxAge )->escaped(); + $blocked = $row->blocked ? ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : ''; return Html::rawElement( 'li', array(), "{$item} [{$count}]{$blocked}" ); } function getPageHeader() { - global $wgScript, $wgRequest; + global $wgScript; + $self = $this->getTitle(); - $limit = $this->mLimit ? Xml::hidden( 'limit', $this->mLimit ) : ''; - - return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . # Form tag - Xml::fieldset( wfMsg( 'activeusers' ) ) . "\n" . - Xml::hidden( 'title', $self->getPrefixedDBkey() ) . - $limit . "\n" . - Xml::inputLabel( wfMsg( 'activeusers-from' ), 'username', 'offset', 20, $this->requestedUser ) . ' ' . # Username field - Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .# Submit button and form bottom - Xml::closeElement( 'fieldset' ) . - Xml::closeElement( 'form' ); + $limit = $this->mLimit ? Html::hidden( 'limit', $this->mLimit ) : ''; + + $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); # Form tag + $out .= Xml::fieldset( $this->msg( 'activeusers' )->text() ) . "\n"; + $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . "\n"; + + $out .= Xml::inputLabel( $this->msg( 'activeusers-from' )->text(), + 'username', 'offset', 20, $this->requestedUser ) . '
';# Username field + + $out .= Xml::checkLabel( $this->msg( 'activeusers-hidebots' )->text(), + 'hidebots', 'hidebots', $this->opts->getValue( 'hidebots' ) ); + + $out .= Xml::checkLabel( $this->msg( 'activeusers-hidesysops' )->text(), + 'hidesysops', 'hidesysops', $this->opts->getValue( 'hidesysops' ) ) . '
'; + + $out .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n";# Submit button and form bottom + $out .= Xml::closeElement( 'fieldset' ); + $out .= Xml::closeElement( 'form' ); + + return $out; } } @@ -126,7 +178,7 @@ class SpecialActiveUsers extends SpecialPage { /** * Constructor */ - public function __construct() { + public function __construct() { parent::__construct( 'Activeusers' ); } @@ -136,24 +188,30 @@ class SpecialActiveUsers extends SpecialPage { * @param $par Mixed: parameter passed to the page or null */ public function execute( $par ) { - global $wgOut; + global $wgActiveUserDays; $this->setHeaders(); + $this->outputHeader(); + + $out = $this->getOutput(); + $out->wrapWikiMsg( "
\n$1\n
", + array( 'activeusers-intro', $this->getLanguage()->formatNum( $wgActiveUserDays ) ) ); - $up = new ActiveUsersPager(); + $up = new ActiveUsersPager( $this->getContext(), null, $par ); # getBody() first to check, if empty $usersbody = $up->getBody(); - $s = $up->getPageHeader(); - if( $usersbody ) { - $s .= $up->getNavigationBar(); - $s .= Html::rawElement( 'ul', array(), $usersbody ); - $s .= $up->getNavigationBar(); + + $out->addHTML( $up->getPageHeader() ); + if ( $usersbody ) { + $out->addHTML( + $up->getNavigationBar() . + Html::rawElement( 'ul', array(), $usersbody ) . + $up->getNavigationBar() + ); } else { - $s .= Html::element( 'p', array(), wfMsg( 'activeusers-noresult' ) ); + $out->addWikiMsg( 'activeusers-noresult' ); } - - $wgOut->addHTML( $s ); } }