From: Bryan Tong Minh Date: Sat, 1 Mar 2008 13:35:01 +0000 (+0000) Subject: Fix description for UploadComplete hook. New hooks: FileDeleteComplete, FileUndeleteC... X-Git-Tag: 1.31.0-rc.0~49297 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=29248e7a4f866f9cb4f7925b8b6b9120c0b2d422;p=lhc%2Fweb%2Fwiklou.git Fix description for UploadComplete hook. New hooks: FileDeleteComplete, FileUndeleteComplete --- diff --git a/docs/hooks.txt b/docs/hooks.txt index 0d99832eaa..dd47ab6c84 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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. diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 71e2c1aec0..757affbb2b 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -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 ) { diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index e6f6298c2f..51b71d0865 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -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 ) );