2017-12-16 00:26:25 +00:00
|
|
|
<?php
|
|
|
|
|
2020-12-03 14:11:19 +00:00
|
|
|
namespace MediaWiki\Extension\AbuseFilter\Pager;
|
|
|
|
|
2021-01-03 11:12:16 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseFilterChangesList;
|
2020-11-29 10:53:29 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewExamine;
|
2020-12-03 14:11:19 +00:00
|
|
|
use RecentChange;
|
|
|
|
use ReverseChronologicalPager;
|
|
|
|
use stdClass;
|
|
|
|
use Title;
|
2020-11-29 10:53:29 +00:00
|
|
|
|
2017-12-16 00:26:25 +00:00
|
|
|
class AbuseFilterExaminePager extends ReverseChronologicalPager {
|
2018-11-08 14:34:32 +00:00
|
|
|
/**
|
|
|
|
* @var AbuseFilterChangesList Our changes list
|
|
|
|
*/
|
|
|
|
public $mChangesList;
|
|
|
|
/**
|
|
|
|
* @var AbuseFilterViewExamine The associated view
|
|
|
|
*/
|
|
|
|
public $mPage;
|
2020-10-31 14:27:20 +00:00
|
|
|
/**
|
|
|
|
* @var int Line number of the row, see RecentChange::$counter
|
|
|
|
*/
|
|
|
|
public $rcCounter;
|
2018-04-29 17:52:45 +00:00
|
|
|
|
2017-12-16 00:26:25 +00:00
|
|
|
/**
|
|
|
|
* @param AbuseFilterViewExamine $page
|
|
|
|
* @param AbuseFilterChangesList $changesList
|
|
|
|
*/
|
2018-10-17 05:15:21 +00:00
|
|
|
public function __construct( AbuseFilterViewExamine $page, AbuseFilterChangesList $changesList ) {
|
2017-12-16 00:26:25 +00:00
|
|
|
parent::__construct();
|
|
|
|
$this->mChangesList = $changesList;
|
|
|
|
$this->mPage = $page;
|
2020-10-31 14:27:20 +00:00
|
|
|
$this->rcCounter = 1;
|
2017-12-16 00:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-04-04 21:14:25 +00:00
|
|
|
public function getQueryInfo() {
|
2017-12-16 00:26:25 +00:00
|
|
|
$dbr = wfGetDB( DB_REPLICA );
|
|
|
|
$conds = [];
|
2021-04-19 05:18:47 +00:00
|
|
|
$rcQuery = RecentChange::getQueryInfo();
|
2018-03-09 21:23:38 +00:00
|
|
|
|
|
|
|
if ( (string)$this->mPage->mSearchUser !== '' ) {
|
2021-04-19 05:18:47 +00:00
|
|
|
$conds[$rcQuery['fields']['rc_user_text']] = $this->mPage->mSearchUser;
|
2018-03-09 21:23:38 +00:00
|
|
|
}
|
2017-12-16 00:26:25 +00:00
|
|
|
|
|
|
|
$startTS = strtotime( $this->mPage->mSearchPeriodStart );
|
|
|
|
if ( $startTS ) {
|
|
|
|
$conds[] = 'rc_timestamp>=' . $dbr->addQuotes( $dbr->timestamp( $startTS ) );
|
|
|
|
}
|
|
|
|
$endTS = strtotime( $this->mPage->mSearchPeriodEnd );
|
|
|
|
if ( $endTS ) {
|
|
|
|
$conds[] = 'rc_timestamp<=' . $dbr->addQuotes( $dbr->timestamp( $endTS ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
$conds[] = $this->mPage->buildTestConditions( $dbr );
|
2021-03-11 10:50:44 +00:00
|
|
|
$conds = array_merge( $conds, $this->mPage->buildVisibilityConditions( $dbr, $this->getAuthority() ) );
|
2017-12-16 00:26:25 +00:00
|
|
|
|
|
|
|
$info = [
|
|
|
|
'tables' => $rcQuery['tables'],
|
|
|
|
'fields' => $rcQuery['fields'],
|
2021-03-09 22:09:41 +00:00
|
|
|
'conds' => $conds,
|
2017-12-16 00:26:25 +00:00
|
|
|
'join_conds' => $rcQuery['joins'],
|
|
|
|
];
|
|
|
|
|
|
|
|
return $info;
|
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @param stdClass $row
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function formatRow( $row ) {
|
2017-12-16 00:26:25 +00:00
|
|
|
$rc = RecentChange::newFromRow( $row );
|
2020-10-31 14:27:20 +00:00
|
|
|
$rc->counter = $this->rcCounter++;
|
2017-12-16 00:26:25 +00:00
|
|
|
return $this->mChangesList->recentChangesLine( $rc, false );
|
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
2021-01-17 11:54:43 +00:00
|
|
|
* @codeCoverageIgnore Merely declarative
|
|
|
|
* @inheritDoc
|
2018-04-04 21:14:25 +00:00
|
|
|
*/
|
|
|
|
public function getIndexField() {
|
2017-12-16 00:26:25 +00:00
|
|
|
return 'rc_id';
|
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @return Title
|
|
|
|
*/
|
|
|
|
public function getTitle() {
|
2017-12-16 00:26:25 +00:00
|
|
|
return $this->mPage->getTitle( 'examine' );
|
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getEmptyBody() {
|
2017-12-16 00:26:25 +00:00
|
|
|
return $this->msg( 'abusefilter-examine-noresults' )->parseAsBlock();
|
|
|
|
}
|
|
|
|
}
|