Index: trunk/extensions/AssertEdit/AssertEdit_body.php |
— | — | @@ -7,17 +7,16 @@ |
8 | 8 | /** |
9 | 9 | * methods for core assertions |
10 | 10 | */ |
11 | | - static function assert_user() { |
| 11 | + static function assert_user( $editPage ) { |
12 | 12 | global $wgUser; |
13 | 13 | return $wgUser->isLoggedIn(); |
14 | 14 | } |
15 | | - static function assert_bot() { |
| 15 | + static function assert_bot( $editPage ) { |
16 | 16 | global $wgUser; |
17 | 17 | return $wgUser->isAllowed( 'bot' ); |
18 | 18 | } |
19 | | - static function assert_exists() { |
20 | | - global $wgTitle; |
21 | | - return ( $wgTitle->getArticleID() != 0 ); |
| 19 | + static function assert_exists( $editPage ) { |
| 20 | + return $editPage->mTitle->exists(); |
22 | 21 | } |
23 | 22 | |
24 | 23 | /* |
— | — | @@ -56,12 +55,12 @@ |
57 | 56 | } |
58 | 57 | |
59 | 58 | // call the specified assertion |
60 | | - static function callAssert( $assertName, $negate ) { |
| 59 | + static function callAssert( $editPage, $assertName, $negate ) { |
61 | 60 | if ( isset( self::$msAssert[$assertName] ) ) { |
62 | 61 | if ( is_bool( self::$msAssert[$assertName] ) ) { |
63 | 62 | $pass = self::$msAssert[$assertName]; |
64 | 63 | } elseif ( is_callable( self::$msAssert[$assertName] ) ) { |
65 | | - $pass = call_user_func( self::$msAssert[$assertName] ); |
| 64 | + $pass = call_user_func( self::$msAssert[$assertName], $editPage ); |
66 | 65 | } |
67 | 66 | |
68 | 67 | if ( $negate && isset( $pass ) ) { |
Index: trunk/extensions/AssertEdit/AssertEdit.php |
— | — | @@ -37,14 +37,14 @@ |
38 | 38 | $pass = true; |
39 | 39 | |
40 | 40 | if ( $assertName != '' ) { |
41 | | - $pass = AssertEdit::callAssert( $assertName, false ); |
| 41 | + $pass = AssertEdit::callAssert( $editpage, $assertName, false ); |
42 | 42 | } |
43 | 43 | |
44 | 44 | // check for negative assert |
45 | 45 | if ( $pass ) { |
46 | 46 | $assertName = $wgRequest->getVal( 'nassert' ); |
47 | 47 | if ( $assertName != '' ) { |
48 | | - $pass = AssertEdit::callAssert( $assertName, true ); |
| 48 | + $pass = AssertEdit::callAssert( $editpage, $assertName, true ); |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | $pass = true; |
76 | 76 | |
77 | 77 | if ( $assertName != '' ) { |
78 | | - $pass = AssertEdit::callAssert( $assertName, false ); |
| 78 | + $pass = AssertEdit::callAssert( $editPage, $assertName, false ); |
79 | 79 | if ( !$pass ) { |
80 | 80 | $result['assert'] = $assertName; |
81 | 81 | } |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | if ( $pass ) { |
86 | 86 | $assertName = $wgRequest->getVal( 'nassert' ); |
87 | 87 | if ( $assertName != '' ) { |
88 | | - $pass = AssertEdit::callAssert( $assertName, true ); |
| 88 | + $pass = AssertEdit::callAssert( $editPage, $assertName, true ); |
89 | 89 | } |
90 | 90 | if ( !$pass ) { |
91 | 91 | $result['nassert'] = $assertName; |