MediaWiki r37174 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r37173‎ | r37174 (on ViewVC)‎ | r37175 >
Date:14:23, 6 July 2008
Author:daniel
Status:old
Tags:
Comment:
fixed skipchaptcha behavior
Modified paths:

Diff [purge]

Index: trunk/extensions/ContactPage/SpecialContact.php
@@ -104,7 +104,7 @@
105105 */
106106 function EmailContactForm( $target ) {
107107 global $wgRequest, $wgUser;
108 - global $wgCaptchaClass, $wgCaptchaTriggers;
 108+ global $wgCaptchaClass;
109109
110110 $this->target = $target;
111111 $this->text = $wgRequest->getText( 'wpText' );
@@ -120,7 +120,7 @@
121121 }
122122
123123 //prepare captcha if applicable
124 - if ( $wgCaptchaClass && @$wgCaptchaTriggers['contactpage'] ) {
 124+ if ( $this->useCaptcha() ) {
125125 $captcha = ConfirmEditHooks::getInstance();
126126 $captcha->trigger = 'contactpage';
127127 $captcha->action = 'contact';
@@ -215,16 +215,23 @@
216216
217217 }
218218
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
223223
224224 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;
227227 }
228228
 229+ return true;
 230+ }
 231+
 232+ function getCaptcha() {
 233+ global $wgCaptcha;
 234+ if ( !$this->useCaptcha() ) return "";
 235+
229236 wfSetupSession(); #NOTE: make sure we have a session. May be required for captchas to work.
230237
231238 return "<div class='captcha'>" .
@@ -234,9 +241,8 @@
235242 }
236243
237244 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;
241247
242248 return $wgCaptcha->passCaptcha();
243249 }

Status & tagging log

  • 15:28, 12 September 2011 Meno25 (talk | contribs) changed the status of r37174 [removed: ok added: old]