From 0d833fe67177ee62e7695e5e9facdd7c3ec6e1a5 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 2 Oct 2009 18:46:19 +0000 Subject: [PATCH] * Added $wgFlaggedRevsProtectLevels to allow for site defined review "protection" levels. Disables stabilization and a small fieldset to the protection form with the options. * Added three ProtectionForm hooks for the above * Removed PHP4-ism from getPageVisibilitySettings() --- docs/hooks.txt | 12 ++++++++++++ includes/ProtectionForm.php | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/docs/hooks.txt b/docs/hooks.txt index 0ed4b0fb66..7c320e7491 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 3d88420730..e6b7dbe4bb 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -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' ) . ""; } + # 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) ); } } -- 2.20.1