Added hook 'EditPage::attemptSave' before an article is saved.
authorLeon Weber <leon@users.mediawiki.org>
Fri, 1 Dec 2006 21:18:40 +0000 (21:18 +0000)
committerLeon Weber <leon@users.mediawiki.org>
Fri, 1 Dec 2006 21:18:40 +0000 (21:18 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/EditPage.php

index 394e7ba..cb53f7f 100644 (file)
@@ -231,6 +231,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Fix regression in authentication hook auto-creation on login
 * (bug 8110) Allow spaces in ISBNs
 * (bug 8024) Introduce "send me copies of emails I send to others" preference
+* Added 'EditPage::attemptSave' hook before an article is saved.
 
 == Languages updated ==
 
index 445b2a4..104a665 100644 (file)
@@ -313,6 +313,10 @@ $diff: DifferenceEngine object that's calling
 $oldRev: Revision object of the "old" revision (may be null/invalid)
 $newRev: Revision object of the "new" revision
 
+'EditPage::attemptSave': called before an article is
+saved, that is before insertNewArticle() is called
+&$editpage_Obj: the current EditPage object
+
 'EditFormPreloadText': Allows population of the edit form when creating new pages
 &$text: Text to preload with
 &$title: Title object representing the page being created
index d2eeb73..d3ae6bf 100644 (file)
@@ -598,6 +598,12 @@ class EditPage {
                wfProfileIn( $fname );
                wfProfileIn( "$fname-checks" );
 
+               if( !wfRunHooks( 'EditPage::attemptSave', array( &$this ) ) )
+               {
+                       wfDebug( "Hook 'EditPage::attemptSave' aborted article saving" );
+                       return false;
+               }
+
                # Reintegrate metadata
                if ( $this->mMetaData != '' ) $this->textbox1 .= "\n" . $this->mMetaData ;
                $this->mMetaData = '' ;
@@ -684,6 +690,7 @@ class EditPage {
                # If article is new, insert it.
                $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
                if ( 0 == $aid ) {
+
                        // Late check for create permission, just in case *PARANOIA*
                        if ( !$this->mTitle->userCanCreate() ) {
                                wfDebug( "$fname: no create permission\n" );