| Index: trunk/extensions/ContactPage/SpecialContact.php |
| — | — | @@ -104,7 +104,7 @@ |
| 105 | 105 | */ |
| 106 | 106 | function EmailContactForm( $target ) { |
| 107 | 107 | global $wgRequest, $wgUser; |
| 108 | | - global $wgCaptchaClass, $wgCaptchaTriggers; |
| | 108 | + global $wgCaptchaClass; |
| 109 | 109 | |
| 110 | 110 | $this->target = $target; |
| 111 | 111 | $this->text = $wgRequest->getText( 'wpText' ); |
| — | — | @@ -120,7 +120,7 @@ |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | //prepare captcha if applicable |
| 124 | | - if ( $wgCaptchaClass && @$wgCaptchaTriggers['contactpage'] ) { |
| | 124 | + if ( $this->useCaptcha() ) { |
| 125 | 125 | $captcha = ConfirmEditHooks::getInstance(); |
| 126 | 126 | $captcha->trigger = 'contactpage'; |
| 127 | 127 | $captcha->action = 'contact'; |
| — | — | @@ -215,16 +215,23 @@ |
| 216 | 216 | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | | - function getCaptcha() { |
| 220 | | - global $wgCaptcha, $wgCaptchaTriggers, $wgUser; |
| 221 | | - if ( !$wgCaptcha ) return ""; //no captcha installed |
| 222 | | - if ( !@$wgCaptchaTriggers['contactpage'] ) return ""; //don't trigger on contact form |
| | 219 | + function useCaptcha() { |
| | 220 | + global $wgCaptchaClass, $wgCaptchaTriggers, $wgUser; |
| | 221 | + if ( !$wgCaptchaClass ) return false; //no captcha installed |
| | 222 | + if ( !@$wgCaptchaTriggers['contactpage'] ) return false; //don't trigger on contact form |
| 223 | 223 | |
| 224 | 224 | if( $wgUser->isAllowed( 'skipcaptcha' ) ) { |
| 225 | | - wfDebug( "EmailContactForm::getCaptcha: user group allows skipping captcha\n" ); |
| 226 | | - return ""; |
| | 225 | + wfDebug( "EmailContactForm::useCaptcha: user group allows skipping captcha\n" ); |
| | 226 | + return false; |
| 227 | 227 | } |
| 228 | 228 | |
| | 229 | + return true; |
| | 230 | + } |
| | 231 | + |
| | 232 | + function getCaptcha() { |
| | 233 | + global $wgCaptcha; |
| | 234 | + if ( !$this->useCaptcha() ) return ""; |
| | 235 | + |
| 229 | 236 | wfSetupSession(); #NOTE: make sure we have a session. May be required for captchas to work. |
| 230 | 237 | |
| 231 | 238 | return "<div class='captcha'>" . |
| — | — | @@ -234,9 +241,8 @@ |
| 235 | 242 | } |
| 236 | 243 | |
| 237 | 244 | function passCaptcha() { |
| 238 | | - global $wgCaptcha, $wgCaptchaTriggers; |
| 239 | | - if ( !$wgCaptcha ) return true; //no captcha installed |
| 240 | | - if ( !@$wgCaptchaTriggers['contactpage'] ) return true; //don't trigger on contact form |
| | 245 | + global $wgCaptcha; |
| | 246 | + if ( !$this->useCaptcha() ) return true; |
| 241 | 247 | |
| 242 | 248 | return $wgCaptcha->passCaptcha(); |
| 243 | 249 | } |