r35651 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35650‎ | r35651 | r35652 >
Date:14:32, 31 May 2008
Author:btongminh
Status:old
Tags:
Comment:
Hook to APIEditBeforeSave
Modified paths:
  • /trunk/extensions/AssertEdit/AssertEdit.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AssertEdit/AssertEdit.php
@@ -31,6 +31,7 @@
3232 $wgExtensionMessagesFiles['AssertEdit'] = $dir . 'AssertEdit.i18n.php';
3333 $wgAutoloadClasses['AssertEdit'] = $dir . 'AssertEdit_body.php';
3434 $wgHooks['AlternateEdit'][] = 'efAssertEditHook';
 35+$wgHooks['APIEditBeforeSave'][] = 'efAssertApiEditHook';
3536
3637 function efAssertEditHook( &$editpage ) {
3738 global $wgOut, $wgRequest;
@@ -70,3 +71,27 @@
7172 return false;
7273 }
7374 }
 75+function efAssertApiEditHook( &$editPage, $textBox, &$result ) {
 76+ global $wgOut, $wgRequest;
 77+
 78+ $assertName = $wgRequest->getVal( 'assert' );
 79+ $pass = true;
 80+
 81+ if ( $assertName != '' ) {
 82+ $pass = AssertEdit::callAssert( $assertName, false );
 83+ if ( !$pass )
 84+ $result['assert'] = $assertName;
 85+ }
 86+
 87+ //check for negative assert
 88+ if ( $pass ) {
 89+ $assertName = $wgRequest->getVal( 'nassert' );
 90+ if ( $assertName != '' ) {
 91+ $pass = AssertEdit::callAssert( $assertName, true );
 92+ }
 93+ if ( !$pass )
 94+ $result['nassert'] = $assertName;
 95+ }
 96+
 97+ return $pass == true;
 98+}

Status & tagging log