$db = $this->getDB();
$params = $this->extractRequestParams();
+ $userId = !is_null( $params['user'] ) ? User::idFromName( $params['user'] ) : null;
// Table and return fields
$this->addTables( 'image' );
// Image filters
if ( !is_null( $params['user'] ) ) {
- $this->addWhereFld( 'img_user_text', $params['user'] );
+ if ( $userId ) {
+ $this->addWhereFld( 'img_user', $userId );
+ } else {
+ $this->addWhereFld( 'img_user_text', $params['user'] );
+ }
}
if ( $params['filterbots'] != 'all' ) {
$this->addTables( 'user_groups' );
if ( $params['sort'] == 'timestamp' ) {
$this->addOption( 'ORDER BY', 'img_timestamp' . $sortFlag );
if ( !is_null( $params['user'] ) ) {
- $this->addOption( 'USE INDEX', [ 'image' => 'img_usertext_timestamp' ] );
+ if ( $userId ) {
+ $this->addOption( 'USE INDEX', [ 'image' => 'img_user_timestamp' ] );
+ } else {
+ $this->addOption( 'USE INDEX', [ 'image' => 'img_usertext_timestamp' ] );
+ }
} else {
$this->addOption( 'USE INDEX', [ 'image' => 'img_timestamp' ] );
}
$opts = new FormOptions();
$opts->add( 'like', '' );
+ $opts->add( 'user', '' );
$opts->add( 'showbots', false );
$opts->add( 'hidepatrolled', false );
$opts->add( 'limit', 50 );
'name' => 'like',
],
+ 'user' => [
+ 'type' => 'text',
+ 'label-message' => 'newimages-user',
+ 'name' => 'user',
+ ],
+
'showbots' => [
'type' => 'check',
'label-message' => 'newimages-showbots',
}
$sortable = [ 'img_timestamp', 'img_name', 'img_size' ];
/* For reference, the indicies we can use for sorting are:
- * On the image table: img_usertext_timestamp, img_size, img_timestamp
+ * On the image table: img_user_timestamp, img_usertext_timestamp,
+ * img_size, img_timestamp
* On oldimage: oi_usertext_timestamp, oi_name_timestamp
*
* In particular that means we cannot sort by timestamp when not filtering
$fields = [ 'img_name', 'img_user', 'img_timestamp' ];
$options = [];
+ $user = $opts->getValue( 'user' );
+ if ( $user !== '' ) {
+ $userId = User::idFromName( $user );
+ if ( $userId ) {
+ $conds['img_user'] = $userId;
+ } else {
+ $conds['img_user_text'] = $user;
+ }
+ }
+
if ( !$opts->getValue( 'showbots' ) ) {
$groupsWithBotPermission = User::getGroupsWithPermission( 'bot' );
"newimages-summary": "This special page shows the last uploaded files.",
"newimages-legend": "Filter",
"newimages-label": "Filename (or a part of it):",
+ "newimages-user": "IP address or username",
"newimages-showbots": "Show uploads by bots",
"newimages-hidepatrolled": "Hide patrolled uploads",
"noimages": "Nothing to see.",
"newimages-summary": "This message is displayed at the top of [[Special:NewImages]] to explain what is shown on that special page.",
"newimages-legend": "Caption of the fieldset for the filter on [[Special:NewImages]]\n\n{{Identical|Filter}}",
"newimages-label": "Caption of the filter editbox on [[Special:NewImages]]",
+ "newimages-user": "Caption of the username/IP address editbox on [[Special:NewImages]]",
"newimages-showbots": "Used as label for a checkbox. When checked, [[Special:NewImages]] will also display uploads by users in the bots group.",
"newimages-hidepatrolled": "Used as label for a checkbox. When checked, [[Special:NewImages]] will not display patrolled uploads.\n\nCf. {{msg-mw|tog-hidepatrolled}} and {{msg-mw|apihelp-feedrecentchanges-param-hidepatrolled}}.",
"noimages": "This is shown on the special page [[Special:NewImages]], when there aren't any recently uploaded files.",