Merge "RCFilters UI: Compare states instead of params when switching URL"
[lhc/web/wiklou.git] / includes / specials / pagers / NewFilesPager.php
index 4bf5dff..cce0323 100644 (file)
@@ -24,7 +24,7 @@
  */
 use MediaWiki\MediaWikiServices;
 
-class NewFilesPager extends ReverseChronologicalPager {
+class NewFilesPager extends RangeChronologicalPager {
 
        /**
         * @var ImageGalleryBase
@@ -41,11 +41,20 @@ class NewFilesPager extends ReverseChronologicalPager {
         * @param FormOptions $opts
         */
        function __construct( IContextSource $context, FormOptions $opts ) {
-               $this->opts = $opts;
+               parent::__construct( $context );
 
+               $this->opts = $opts;
                $this->setLimit( $opts->getValue( 'limit' ) );
 
-               parent::__construct( $context );
+               $startTimestamp = '';
+               $endTimestamp = '';
+               if ( $opts->getValue( 'start' ) ) {
+                       $startTimestamp = $opts->getValue( 'start' ) . ' 00:00:00';
+               }
+               if ( $opts->getValue( 'end' ) ) {
+                       $endTimestamp = $opts->getValue( 'end' ) . ' 23:59:59';
+               }
+               $this->getDateRangeCond( $startTimestamp, $endTimestamp );
        }
 
        function getQueryInfo() {
@@ -55,6 +64,16 @@ class NewFilesPager extends ReverseChronologicalPager {
                $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' );
 
@@ -67,9 +86,7 @@ class NewFilesPager extends ReverseChronologicalPager {
                                        [
                                                'ug_group' => $groupsWithBotPermission,
                                                'ug_user = img_user',
-                                               $this->getConfig()->get( 'DisableUserGroupExpiry' ) ?
-                                                       '1' :
-                                                       'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() )
+                                               'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() )
                                        ]
                                ];
                        }