* Added $wgFlaggedRevsProtectLevels to allow for site defined review "protection...
authorAaron Schulz <aaron@users.mediawiki.org>
Fri, 2 Oct 2009 18:46:19 +0000 (18:46 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Fri, 2 Oct 2009 18:46:19 +0000 (18:46 +0000)
* Added three ProtectionForm hooks for the above
* Removed PHP4-ism from getPageVisibilitySettings()

docs/hooks.txt
includes/ProtectionForm.php

index 0ed4b0f..7c320e7 100644 (file)
@@ -1209,6 +1209,18 @@ $user: User (object) changing his passoword
 $newPass: new password
 $error: error (string) 'badretype', 'wrongpassword', 'error' or 'success'
 
+'ProtectionForm::buildForm': called after all protection type fieldsets are made in the form
+$article: the title being (un)protected
+$output: a string of the form HTML so far
+
+'ProtectionForm::showLogExtract': called after the protection log extract is shown
+$article: the page the form is shown for
+$out: OutputPage object
+
+'ProtectionForm::save': called when a protection form is submitted
+$article: the title being (un)protected
+$errorMsg: an html message string of an error
+
 'RawPageViewBeforeOutput': Right before the text is blown out in action=raw
 &$obj: RawPage object
 &$text: The text that's going to be the output
index 3d88420..e6b7dbe 100644 (file)
@@ -274,6 +274,16 @@ class ProtectionForm {
                        throw new FatalError( "Unknown error at restriction save time." );
                }
 
+               $errorMsg = '';
+               # Give extensions a change to handle added form items
+               if( !wfRunHooks( 'ProtectionForm::save', array($this->mArticle,&$errorMsg) ) ) {
+                       throw new FatalError( "Unknown hook error at restriction save time." );
+               }
+               if( $errorMsg != '' ) {
+                       $this->show( $errorMsg );
+                       return false;
+               }
+
                if( $wgRequest->getCheck( 'mwProtectWatch' ) ) {
                        $this->mArticle->doWatch();
                } elseif( $this->mTitle->userIsWatching() ) {
@@ -390,6 +400,8 @@ class ProtectionForm {
                        Xml::closeElement( 'fieldset' ) .
                        "</td></tr>";
                }
+               # Give extensions a chance to add items to the form
+               wfRunHooks( 'ProtectionForm::buildForm', array($this->mArticle,&$out) );
 
                $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
 
@@ -554,5 +566,7 @@ class ProtectionForm {
                # Show relevant lines from the protection log:
                $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'protect' ) ) );
                LogEventsList::showLogExtract( $out, 'protect', $this->mTitle->getPrefixedText() );
+               # Let extensions add other relevant log extracts
+               wfRunHooks( 'ProtectionForm::showLogExtract', array($this->mArticle,$out) );
        }
 }