From: Rob Church Date: Sat, 29 Apr 2006 22:01:21 +0000 (+0000) Subject: (bug 5716) Warn when a user tries to upload a file which was previously deleted X-Git-Tag: 1.31.0-rc.0~57327 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=7518139ca5402e3a37716b97d52ff499752b8bc3;p=lhc%2Fweb%2Fwiklou.git (bug 5716) Warn when a user tries to upload a file which was previously deleted --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 299baa1be6..daac35bd42 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/Image.php b/includes/Image.php index bb8ce4f1a9..013cdbaf1e 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -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 diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 1c486e605f..f08b6e1c7e 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -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 .= '
  • '.wfMsgHtml( 'fileexists', $dlink ).'
  • '; + } 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 != '' ) { diff --git a/languages/Messages.php b/languages/Messages.php index 0c44f21cab..bb5dca40b7 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -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',