(bug 5716) Warn when a user tries to upload a file which was previously deleted
authorRob Church <robchurch@users.mediawiki.org>
Sat, 29 Apr 2006 22:01:21 +0000 (22:01 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sat, 29 Apr 2006 22:01:21 +0000 (22:01 +0000)
RELEASE-NOTES
includes/Image.php
includes/SpecialUpload.php
languages/Messages.php

index 299baa1..daac35b 100644 (file)
@@ -145,6 +145,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Rewrite reassignEdits script to be more efficient; support optional updates to
   recent changes table; add reporting and silent modes
 * Cleaned up formatNum usage in langfiles
+* (bug 5716) Warn when a user tries to upload a file which was previously deleted
 
 == Compatibility ==
 
index bb8ce4f..013cdba 100644 (file)
@@ -1641,6 +1641,17 @@ class Image
        function isLocal() {
                return !$this->fromSharedDirectory;
        }
+       
+       /**
+        * Was this image ever deleted from the wiki?
+        *
+        * @return bool
+        */
+       function wasDeleted() {
+               $dbw =& wfGetDB( DB_MASTER );
+               $del = $dbw->selectField( 'archive', 'COUNT(*) AS count', array( 'ar_namespace' => NS_IMAGE, 'ar_title' => $this->title->getDBkey() ), 'Image::wasDeleted' );
+               return $del > 0;
+       }
 
 } //class
 
index 1c486e6..f08b6e1 100644 (file)
@@ -48,7 +48,7 @@ class UploadForm {
                        return;
                }
 
-               $this->mIgnoreWarning     = $request->getCheck( 'wpIgnoreWarning');
+               $this->mIgnoreWarning     = $request->getCheck( 'wpIgnoreWarning' );
                $this->mReUpload          = $request->getCheck( 'wpReUpload' );
                $this->mUpload            = $request->getCheck( 'wpUpload' );
 
@@ -298,6 +298,16 @@ class UploadForm {
                                $sk = $wgUser->getSkin();
                                $dlink = $sk->makeKnownLinkObj( $nt );
                                $warning .= '<li>'.wfMsgHtml( 'fileexists', $dlink ).'</li>';
+                       } else {
+                               # If the file existed before and was deleted, warn the user of this
+                               # Don't bother doing so if the image exists now, however
+                               $image = new Image( $nt );
+                               if( $image->wasDeleted() ) {
+                                       $skin = $wgUser->getSkin();
+                                       $ltitle = Title::makeTitle( NS_SPECIAL, 'Log' );
+                                       $llink = $skin->makeKnownLinkObj( $ltitle, wfMsgHtml( 'deletionlog' ), 'type=delete&page=' . $nt->getPrefixedUrl() );
+                                       $warning .= wfOpenElement( 'li' ) . wfMsgHtml( 'filewasdeleted', $llink ) . wfCloseElement( 'li' );
+                               }
                        }
 
                        if( $warning != '' ) {
index 0c44f21..bb5dca4 100644 (file)
@@ -864,6 +864,7 @@ created and by whom, and anything else you may know about it. If this is an imag
 'uploadvirus' => 'The file contains a virus! Details: $1',
 'sourcefilename' => 'Source filename',
 'destfilename' => 'Destination filename',
+'filewasdeleted' => 'A file of this name has been previously uploaded and subsequently deleted. You should check the $1 before proceeding to upload it again.',
 
 'license' => 'Licensing',
 'nolicense' => 'None selected',