Index: trunk/extensions/ConfirmEdit/ReCaptcha.php |
— | — | @@ -52,13 +52,12 @@ |
53 | 53 | |
54 | 54 | |
55 | 55 | class ReCaptcha extends SimpleCaptcha { |
56 | | - |
| 56 | + |
57 | 57 | //reCAPTHCA error code returned from recaptcha_check_answer |
58 | 58 | private $recaptcha_error = null; |
59 | 59 | |
60 | | - |
61 | | - /** |
62 | | - * Displays the reCAPTCHA widget. |
| 60 | + /** |
| 61 | + * Displays the reCAPTCHA widget. |
63 | 62 | * If $this->recaptcha_error is set, it will display an error in the widget. |
64 | 63 | * |
65 | 64 | */ |
— | — | @@ -68,12 +67,10 @@ |
69 | 68 | recaptcha_get_html($wgReCaptchaPublicKey, $this->recaptcha_error); |
70 | 69 | } |
71 | 70 | |
72 | | - |
73 | | - |
74 | 71 | /** |
75 | 72 | * Calls the library function recaptcha_check_answer to verify the users input. |
76 | 73 | * Sets $this->recaptcha_error if the user is incorrect. |
77 | | - * @return boolean |
| 74 | + * @return boolean |
78 | 75 | * |
79 | 76 | */ |
80 | 77 | function passCaptcha() { |
— | — | @@ -91,37 +88,33 @@ |
92 | 89 | |
93 | 90 | } |
94 | 91 | |
| 92 | + /** |
| 93 | + * Called on all edit page saves. (EditFilter events) |
| 94 | + * @return boolean - true if page save should continue, false if should display Captcha widget. |
| 95 | + */ |
| 96 | + function confirmEdit( $editPage, $newtext, $section, $merged = false ) { |
| 97 | + if( $this->shouldCheck( $editPage, $newtext, $section ) ) { |
95 | 98 | |
| 99 | + if (!isset($_POST['recaptcha_response_field'])) { |
| 100 | + //User has not yet been presented with Captcha, show the widget. |
| 101 | + $editPage->showEditForm( array( &$this, 'editCallback' ) ); |
| 102 | + return false; |
| 103 | + } |
96 | 104 | |
97 | | - /** |
98 | | - * Called on all edit page saves. (EditFilter events) |
99 | | - * @return boolean - true if page save should continue, false if should display Captcha widget. |
100 | | - */ |
101 | | - function confirmEdit( $editPage, $newtext, $section ) { |
102 | | - if( $this->shouldCheck( $editPage, $newtext, $section ) ) { |
| 105 | + if( $this->passCaptcha() ) { |
| 106 | + return true; |
| 107 | + } else { |
| 108 | + //Try again - show the widget |
| 109 | + $editPage->showEditForm( array( &$this, 'editCallback' ) ); |
| 110 | + return false; |
| 111 | + } |
103 | 112 | |
104 | | - if (!isset($_POST['recaptcha_response_field'])) { |
105 | | - //User has not yet been presented with Captcha, show the widget. |
106 | | - $editPage->showEditForm( array( &$this, 'editCallback' ) ); |
107 | | - return false; |
108 | | - } |
| 113 | + } else { |
| 114 | + wfDebug( "ConfirmEdit: no need to show captcha.\n" ); |
| 115 | + return true; |
| 116 | + } |
| 117 | + } |
109 | 118 | |
110 | | - if( $this->passCaptcha() ) { |
111 | | - return true; |
112 | | - } else { |
113 | | - //Try again - show the widget |
114 | | - $editPage->showEditForm( array( &$this, 'editCallback' ) ); |
115 | | - return false; |
116 | | - } |
117 | | - |
118 | | - } else { |
119 | | - wfDebug( "ConfirmEdit: no need to show captcha.\n" ); |
120 | | - return true; |
121 | | - } |
122 | | - } |
123 | | - |
124 | | - |
125 | | - |
126 | 119 | /** |
127 | 120 | * Show a message asking the user to enter a captcha on edit |
128 | 121 | * The result will be treated as wiki text |