* Image protection: if the image page is protected, uploading a new file is protected...
authorGabriel Wicke <gwicke@users.mediawiki.org>
Thu, 24 Jun 2004 22:02:59 +0000 (22:02 +0000)
committerGabriel Wicke <gwicke@users.mediawiki.org>
Thu, 24 Jun 2004 22:02:59 +0000 (22:02 +0000)
* Filename already exists warning: new key 'fileexists' with param $1 = link to the existing image page. Please translate.

includes/SpecialUpload.php
languages/Language.php

index 3b37ba5..41b8c44 100644 (file)
@@ -107,6 +107,7 @@ class UploadForm {
                                return;
                        }
                        $nt = Title::newFromText( $basename );
+                       $nt->setNamespace( Namespace::getImage() );
                        $this->mUploadSaveName = $nt->getDBkey();
 
                        /* Don't allow users to override the blacklist */
@@ -131,6 +132,15 @@ class UploadForm {
                          ( $this->mUploadSize > $wgUploadSizeWarning ) ) {
                                return $this->uploadWarning( wfMsg( "largefile" ) );
                        }
+                       if ( !$nt->userCanEdit() ) {
+                               return $this->uploadError( wfMsg( "protectedpage" ) );
+                       }
+                       if($nt->getArticleID()) {
+                               $sk = $wgUser->getSkin();
+                               $dname = $wgLang->getNsText( Namespace::getImage() ) . ":{$this->mUploadSaveName}";
+                               $dlink = $sk->makeKnownLink( $dname, $dname );
+                               return $this->uploadWarning( wfMsg( "fileexists", $dlink ) );
+                       }
                }
                if ( !is_null( $this->mUploadOldVersion ) ) {
                        $wgUploadOldVersion = $this->mUploadOldVersion;
index 670060c..dfff3d1 100644 (file)
@@ -804,6 +804,7 @@ agrees to license it under the terms of the $1.",
 'badfilename'  => "Image name has been changed to \"$1\".",
 'badfiletype'  => "\".$1\" is not a recommended image file format.",
 'largefile'            => 'It is recommended that images not exceed 100k in size.',
+'fileexists'           => 'A file with this name exists already, please check $1 if you are not sure if you want to change it.',
 'successfulupload' => 'Successful upload',
 'fileuploaded' => "File \"$1\" uploaded successfully.
 Please follow this link: $2 to the description page and fill