From: Mark A. Hershberger Date: Sat, 17 Apr 2010 21:44:51 +0000 (+0000) Subject: for r65152: fixed web ui for UploadFromUrl X-Git-Tag: 1.31.0-rc.0~37073 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=f47ce6663cd049e0b787793d17eed55efe62dd88;p=lhc%2Fweb%2Fwiklou.git for r65152: fixed web ui for UploadFromUrl * Add watchlist and ignorewarnings params for job — not used yet * Add permissions check for isValidRequest --- diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index d236f12a68..cc4843d1c1 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -387,6 +387,10 @@ class SpecialUpload extends SpecialPage { return; } + if( $this->mUpload instanceOf UploadFromUrl ) { + return $this->showUploadError( wfMsg( 'uploadfromurl-queued' ) ); + } + // Fetch the file if required $status = $this->mUpload->fetchFile(); if( !$status->isOK() ) { diff --git a/includes/upload/UploadFromUrl.php b/includes/upload/UploadFromUrl.php index 9c2f0cc524..4392543106 100644 --- a/includes/upload/UploadFromUrl.php +++ b/includes/upload/UploadFromUrl.php @@ -10,7 +10,7 @@ */ class UploadFromUrl extends UploadBase { protected $mTempDownloadPath; - protected $comment, $watchList; + protected $comment, $watchList, $ignoreWarnings; /** * Checks if the user is allowed to use the upload-by-URL feature. If the @@ -35,7 +35,7 @@ class UploadFromUrl extends UploadBase { * Entry point for API upload * @return bool true on success */ - public function initialize( $name, $url, $comment, $watchlist ) { + public function initialize( $name, $url, $comment, $watchList, $ignoreWarn ) { global $wgUser; if( !Http::isValidURI( $url ) ) { @@ -47,7 +47,8 @@ class UploadFromUrl extends UploadBase { "url" => trim( $url ), "timestamp" => wfTimestampNow(), "comment" => $comment, - "watchlist" => $watchlist); + "watchlist" => $watchList, + "ignorewarnings" => $ignoreWarn); $title = Title::newFromText( $name ); /* // Check whether the user has the appropriate permissions to upload anyway */ @@ -81,6 +82,7 @@ class UploadFromUrl extends UploadBase { $this->mDesiredDestName = $job->title; $this->comment = $job->params['comment']; $this->watchList = $job->params['watchlist']; + $this->ignoreWarnings = $job->params['ignorewarnings']; $this->getTitle(); } @@ -95,8 +97,9 @@ class UploadFromUrl extends UploadBase { return $this->initialize( $desiredDestName, $request->getVal( 'wpUploadFileURL' ), - '', - false + $request->getVal( 'wpUploadDescription' ), + $request->getVal( 'wpWatchThis' ), + $request->getVal( 'wpIgnoreWarnings' ) ); } @@ -104,10 +107,12 @@ class UploadFromUrl extends UploadBase { * @param $request Object: WebRequest object */ public static function isValidRequest( $request ){ - if( !$request->getVal( 'wpUploadFileURL' ) ) - return false; - // check that is a valid url: - return Http::isValidURI( $request->getVal( 'wpUploadFileURL' ) ); + global $wgUser; + + $url = $request->getVal( 'wpUploadFileURL' ); + return !empty( $url ) + && Http::isValidURI( $url ) + && $wgUser->isAllowed( 'upload_by_url' ); } private function saveTempFile( $req ) { @@ -151,11 +156,6 @@ class UploadFromUrl extends UploadBase { /* $warnings = $this->checkForWarnings(); */ /* if( isset($warnings) ) return $warnings; */ - // Use comment as initial page text by default - if ( is_null( $this->mParams['text'] ) ) { - $this->mParams['text'] = $this->mParams['comment']; - } - $file = $this->getLocalFile(); // This comes from ApiBase /* $watch = $this->getWatchlistValue( $this->mParams['watchlist'], $file->getTitle() ); */ @@ -165,7 +165,7 @@ class UploadFromUrl extends UploadBase { } $status = $this->getLocalFile()->upload( $this->mTempPath, $this->comment, - $this->pageText, File::DELETE_SOURCE, $this->mFileProps, false, $wgUser ); + $this->comment, File::DELETE_SOURCE, $this->mFileProps, false, $wgUser ); return $status; } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 01c79cf8c1..f7f76fa17a 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2106,6 +2106,7 @@ You should check that file's deletion history before proceeding to re-upload it. 'overwroteimage' => 'uploaded a new version of "[[$1]]"', 'uploaddisabled' => 'Uploads disabled.', 'copyuploaddisabled' => 'Upload by URL disabled.', +'uploadfromurl-queued' => 'Your upload has been queued.', 'uploaddisabledtext' => 'File uploads are disabled.', 'php-uploaddisabledtext' => 'File uploads are disabled in PHP. Please check the file_uploads setting.',