Index: trunk/extensions/AssertEdit/AssertEdit.php |
— | — | @@ -31,6 +31,7 @@ |
32 | 32 | $wgExtensionMessagesFiles['AssertEdit'] = $dir . 'AssertEdit.i18n.php'; |
33 | 33 | $wgAutoloadClasses['AssertEdit'] = $dir . 'AssertEdit_body.php'; |
34 | 34 | $wgHooks['AlternateEdit'][] = 'efAssertEditHook'; |
| 35 | +$wgHooks['APIEditBeforeSave'][] = 'efAssertApiEditHook'; |
35 | 36 | |
36 | 37 | function efAssertEditHook( &$editpage ) { |
37 | 38 | global $wgOut, $wgRequest; |
— | — | @@ -70,3 +71,27 @@ |
71 | 72 | return false; |
72 | 73 | } |
73 | 74 | } |
| 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 | +} |