Special:Listfiles now supports a username parameter. This is indexed using the img_us...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Wed, 14 Apr 2010 09:03:28 +0000 (09:03 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Wed, 14 Apr 2010 09:03:28 +0000 (09:03 +0000)
RELEASE-NOTES
includes/specials/SpecialListfiles.php

index 253babf..d6cc0ba 100644 (file)
@@ -45,6 +45,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   viewing contributions of a blocked IP address
 * (bug 22474) {{urlencode:}} now takes an optional second paramter for type of
   escaping.
+* Special:Listfiles now supports a username parameter
 
 === Bug fixes in 1.17 ===
 * (bug 17560) Half-broken deletion moved image files to deletion archive
index 024f6f9..227adaa 100644 (file)
@@ -7,10 +7,10 @@
 /**
  *
  */
-function wfSpecialListfiles() {
+function wfSpecialListfiles( $par = null ) {
        global $wgOut;
 
-       $pager = new ImageListPager;
+       $pager = new ImageListPager( $par );
 
        $limit = $pager->getForm();
        $body = $pager->getBody();
@@ -24,21 +24,30 @@ function wfSpecialListfiles() {
 class ImageListPager extends TablePager {
        var $mFieldNames = null;
        var $mQueryConds = array();
-
-       function __construct() {
+       
+       function __construct( $par = null ) {
                global $wgRequest, $wgMiserMode;
                if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) {
                        $this->mDefaultDirection = true;
                } else {
                        $this->mDefaultDirection = false;
                }
+               
+               $userName = $wgRequest->getText( 'username', $par );
+               if ( $userName ) {
+                       $nt = Title::newFromText( $userName, NS_USER );
+                       if ( !is_null( $nt ) ) {
+                               $this->mQueryConds['img_user_text'] = $nt->getText();
+                       }
+               } 
+               
                $search = $wgRequest->getText( 'ilsearch' );
                if ( $search != '' && !$wgMiserMode ) {
                        $nt = Title::newFromURL( $search );
                        if( $nt ) {
                                $dbr = wfGetDB( DB_SLAVE );
-                               $this->mQueryConds = array( 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(), 
-                                       strtolower( $nt->getDBkey() ), $dbr->anyString() ) );
+                               $this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(), 
+                                       strtolower( $nt->getDBkey() ), $dbr->anyString() );
                        }
                }
 
@@ -63,7 +72,11 @@ class ImageListPager extends TablePager {
        }
 
        function isFieldSortable( $field ) {
-               static $sortable = array( 'img_timestamp', 'img_name', 'img_size' );
+               static $sortable = array( 'img_timestamp', 'img_name' );
+               if ( $field == 'img_size' ) {
+                       # No index for both img_size and img_user_text
+                       return !isset( $this->mQueryConds['img_user_text'] );
+               }
                return in_array( $field, $sortable );
        }