Fix description for UploadComplete hook. New hooks: FileDeleteComplete, FileUndeleteC...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 1 Mar 2008 13:35:01 +0000 (13:35 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 1 Mar 2008 13:35:01 +0000 (13:35 +0000)
docs/hooks.txt
includes/FileDeleteForm.php
includes/SpecialUndelete.php

index 0d99832..dd47ab6 100644 (file)
@@ -562,9 +562,23 @@ $text: text of the mail
 &$list: List object (defaults to NULL, change it to an object instance and return
 false override the list derivative used)
 
+'FileDeleteComplete': When a file is deleted
+$file: reference to the deleted file
+$oldimage: in case of the deletion of an old image, the name of the old file
+$article: in case all revisions of the file are deleted a reference to the article 
+         associated with the file.
+$user: user who performed the deletion
+$reason: reason
+
 'FileUpload': When a file upload occurs
 $file : Image object representing the file that was uploaded
 
+'FileUndeleteComplete': When a file is undeleted
+$title: title object to the file
+$fileVersions: array of undeleted versions. Empty if all versions were restored
+$user: user who performed the undeletion
+$reason: reason
+
 'GetBlockedStatus': after loading blocking status of an user from the database
 $user: user (object) being checked
 
@@ -1025,7 +1039,7 @@ string $tempName: filesystem path to the temporary file for checks
 string &$error: output: HTML error to show if upload canceled by returning false
 
 'UploadComplete': Upon completion of a file upload
-$image: Image object representing the file that was uploaded
+$uploadForm: Upload form object. File can be accessed by $uploadForm->mLocalFile.
 
 'userCan': To interrupt/advise the "user can do X to Y article" check.
        If you want to display an error message, try getUserPermissionsErrors.
index 71e2c1a..757affb 100644 (file)
@@ -72,6 +72,8 @@ class FileDeleteForm {
                        } elseif ( $reason == 'other' ) {
                                $reason = $this->DeleteReason;
                        }
+                               
+                       $article = null;
                        if( $this->oldimage ) {
                                $status = $this->file->deleteOld( $this->oldimage, $reason );
                                if( $status->ok ) {
@@ -90,6 +92,9 @@ class FileDeleteForm {
                                        $article->doDeleteArticle( $reason );
                                }
                        }
+                       if( $status->isGood() ) wfRunHooks('FileDeleteComplete', array( 
+                               &$this->file, &$this->oldimage, &$article, &$wgUser, &$reason));
+                       
                        if( !$status->isGood() )
                                $wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) );
                        if( $status->ok ) {
index e6f6298..51b71d0 100644 (file)
@@ -1055,6 +1055,11 @@ class UndeleteForm {
                                $this->mFileVersions );
 
                        if( is_array($ok) ) {
+                               if ( $ok[1] ) // Undeleted file count
+                                       wfRunHooks( 'FileUndeleteComplete', array(
+                                               $this->mTargetObj, $this->mFileVersions, 
+                                               $wgUser, $this->mComment) );
+                       
                                $skin = $wgUser->getSkin();
                                $link = $skin->makeKnownLinkObj( $this->mTargetObj );
                                $wgOut->addHtml( wfMsgWikiHtml( 'undeletedpage', $link ) );