/**
* @ingroup Pager
*/
+use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
+
class BlockListPager extends TablePager {
protected $conds;
];
foreach ( $keys as $key ) {
- $msg[$key] = $this->msg( $key )->escaped();
+ $msg[$key] = $this->msg( $key )->text();
}
}
- /** @var $row object */
+ /** @var object $row */
$row = $this->mCurrentRow;
$language = $this->getLanguage();
$formatted = '';
+ $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+
switch ( $name ) {
case 'ipb_timestamp':
$formatted = htmlspecialchars( $language->userTimeAndDate( $value, $this->getUser() ) );
) );
if ( $this->getUser()->isAllowed( 'block' ) ) {
if ( $row->ipb_auto ) {
- $links[] = Linker::linkKnown(
+ $links[] = $linkRenderer->makeKnownLink(
SpecialPage::getTitleFor( 'Unblock' ),
$msg['unblocklink'],
[],
[ 'wpTarget' => "#{$row->ipb_id}" ]
);
} else {
- $links[] = Linker::linkKnown(
+ $links[] = $linkRenderer->makeKnownLink(
SpecialPage::getTitleFor( 'Unblock', $row->ipb_address ),
$msg['unblocklink']
);
- $links[] = Linker::linkKnown(
+ $links[] = $linkRenderer->makeKnownLink(
SpecialPage::getTitleFor( 'Block', $row->ipb_address ),
$msg['change-blocklink']
);
break;
case 'ipb_reason':
+ $value = CommentStore::newKey( 'ipb_reason' )->getComment( $row )->text;
$formatted = Linker::formatComment( $value );
break;
case 'ipb_params':
$properties = [];
if ( $row->ipb_anon_only ) {
- $properties[] = $msg['anononlyblock'];
+ $properties[] = htmlspecialchars( $msg['anononlyblock'] );
}
if ( $row->ipb_create_account ) {
- $properties[] = $msg['createaccountblock'];
+ $properties[] = htmlspecialchars( $msg['createaccountblock'] );
}
if ( $row->ipb_user && !$row->ipb_enable_autoblock ) {
- $properties[] = $msg['noautoblockblock'];
+ $properties[] = htmlspecialchars( $msg['noautoblockblock'] );
}
if ( $row->ipb_block_email ) {
- $properties[] = $msg['emailblock'];
+ $properties[] = htmlspecialchars( $msg['emailblock'] );
}
if ( !$row->ipb_allow_usertalk ) {
- $properties[] = $msg['blocklist-nousertalk'];
+ $properties[] = htmlspecialchars( $msg['blocklist-nousertalk'] );
}
$formatted = $language->commaList( $properties );
}
function getQueryInfo() {
+ $commentQuery = CommentStore::newKey( 'ipb_reason' )->getJoin();
+
$info = [
- 'tables' => [ 'ipblocks', 'user' ],
+ 'tables' => [ 'ipblocks', 'user' ] + $commentQuery['tables'],
'fields' => [
'ipb_id',
'ipb_address',
'ipb_by',
'ipb_by_text',
'by_user_name' => 'user_name',
- 'ipb_reason',
'ipb_timestamp',
'ipb_auto',
'ipb_anon_only',
'ipb_deleted',
'ipb_block_email',
'ipb_allow_usertalk',
- ],
+ ] + $commentQuery['fields'],
'conds' => $this->conds,
- 'join_conds' => [ 'user' => [ 'LEFT JOIN', 'user_id = ipb_by' ] ]
+ 'join_conds' => [ 'user' => [ 'LEFT JOIN', 'user_id = ipb_by' ] ] + $commentQuery['joins']
];
# Filter out any expired blocks
return $info;
}
+ /**
+ * Get total number of autoblocks at any given time
+ *
+ * @return int Total number of unexpired active autoblocks
+ */
+ function getTotalAutoblocks() {
+ $dbr = $this->getDatabase();
+ $res = $dbr->selectField( 'ipblocks',
+ [ 'COUNT(*) AS totalautoblocks' ],
+ [
+ 'ipb_auto' => '1',
+ 'ipb_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() ),
+ ]
+ );
+ if ( $res ) {
+ return $res;
+ }
+ return 0; // We found nothing
+ }
+
protected function getTableClass() {
return parent::getTableClass() . ' mw-blocklist';
}