Parameter fix for single user search; note that there is now ambiguity with the ...
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Sat, 31 Dec 2005 20:51:43 +0000 (20:51 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Sat, 31 Dec 2005 20:51:43 +0000 (20:51 +0000)
includes/SpecialNewimages.php

index 4123a16..a84c923 100644 (file)
@@ -20,7 +20,12 @@ function wfSpecialNewimages( $par, $specialPage ) {
        $sk = $wgUser->getSkin();
        $shownav = !$specialPage->including();
        $hidebots = $wgRequest->getBool('hidebots',1);
-       $singleUser = $wgRequest->getInt('user',0); # Limit images to a single user?
+
+       # Show only for a single user?
+       $targetUser = isset($par) ? $par : $wgRequest->getVal( 'target' );
+       if ( $targetUser != "" ) { #AND !is_numeric ( $targetUser ) ) { # There might be some ambiguity between this and the $limit later on!
+               $singleUser = User::newFromName ( $targetUser ) ;
+       }
 
        if($hidebots) {
 
@@ -88,12 +93,11 @@ function wfSpecialNewimages( $par, $specialPage ) {
                }
        }
 
-       # Single user only?
-       if ( $singleUser > 0 ) {
-               $where[] .= "img_user='{$singleUser}'" ;
+       # SQL for single user only?
+       if ( isset ( $singleUser ) ) {
+               $where[] .= "img_user='" . $singleUser->getID() . "'" ;
        }
        
-       
        $invertSort = false;
        if( $until = $wgRequest->getVal( 'until' ) ) {
                $where[] = 'img_timestamp < ' . $dbr->timestamp( $until );
@@ -163,15 +167,13 @@ function wfSpecialNewimages( $par, $specialPage ) {
                $wgOut->addHTML( "<p>{$text}\n</p>" );
        }
 
-       if ( $singleUser > 0 ) {
-               $u = new User ;
-               $u->setID ( $singleUser ) ;
-               $u->loadFromDatabase () ;
-               $t = $u->getUserPage() ;
+       # Single user search note
+       if ( isset ( $singleUser ) ) {
+               $t = $singleUser->getUserPage() ;
                $uPage = $sk->makeLinkObj( $t ) ;
-               $wgOut->addHTML ( wfMsgForContent ( 'imagelistforuser' , $uPage ) ) ;
+               $wgOut->addHTML ( wfMsg ( 'imagelistforuser' , $uPage ) ) ;
        }
-       
+
        $sub = wfMsg( 'ilsubmit' );
        $titleObj = Title::makeTitle( NS_SPECIAL, 'Newimages' );
        $action = $titleObj->escapeLocalURL();