Patch from LeonWP: added UploadForm:BeforeProcessing hook in SpecialUpload.php
authorIlmari Karonen <vyznev@users.mediawiki.org>
Wed, 29 Nov 2006 18:21:56 +0000 (18:21 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Wed, 29 Nov 2006 18:21:56 +0000 (18:21 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/SpecialUpload.php

index 7133e79..a2031df 100644 (file)
@@ -226,6 +226,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Fix display of link in "already rolled back" message for image/category pages
 * (bug 6016) Left-aligned images should stack vertically, like right-aligned
   images, not horizontally.
+* Patch from LeonWP: added UploadForm:BeforeProcessing hook in SpecialUpload.php
 
 == Languages updated ==
 
index ab699e6..c7f900c 100644 (file)
@@ -443,6 +443,11 @@ You might set the member-variables $uploadFormTextTop and
 $uploadFormTextAfterSummary to inject text (HTML) either before
 or after the editform.
 
+'UploadForm:BeforeProcessing': at the beginning of processUpload()
+$form: UploadForm object
+Lets you poke at member variables like $mUploadDescription before the
+file is saved.
+
 'UploadVerification': additional chances to reject an uploaded file
 string $saveName: destination file name
 string $tempName: filesystem path to the temporary file for checks
index fc262e1..8a14146 100644 (file)
@@ -51,9 +51,9 @@ class UploadForm {
                        return;
                }
 
-        # Placeholders for text injection by hooks (empty per default)
-        $this->uploadFormTextTop = "";
-        $this->uploadFormTextAfterSummary = "";
+               # Placeholders for text injection by hooks (empty per default)
+               $this->uploadFormTextTop = "";
+               $this->uploadFormTextAfterSummary = "";
 
                $this->mIgnoreWarning     = $request->getCheck( 'wpIgnoreWarning' );
                $this->mReUpload          = $request->getCheck( 'wpReUpload' );
@@ -266,6 +266,12 @@ class UploadForm {
        function processUpload() {
                global $wgUser, $wgOut;
 
+               if( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) )
+               {
+                       wfDebug( "Hook 'UploadForm:BeforeProcessing' broke processing the file." );
+                       return false;
+               }
+
                /* Check for PHP error if any, requires php 4.2 or newer */
                if( $this->mUploadError == 1/*UPLOAD_ERR_INI_SIZE*/ ) {
                        $this->mainUploadForm( wfMsgHtml( 'largefileserver' ) );
@@ -701,11 +707,11 @@ class UploadForm {
                global $wgUseCopyrightUpload;
                global $wgRequest, $wgAllowCopyUploads;
 
-        if( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) )
-        {
-         wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" );
-         return false;
-        }
+               if( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) )
+               {
+                       wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" );
+                       return false;
+               }
 
                $cols = intval($wgUser->getOption( 'cols' ));
                $ew = $wgUser->getOption( 'editwidth' );