r71884 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71883‎ | r71884 | r71885 >
Date:13:31, 29 August 2010
Author:platonides
Status:ok
Tags:
Comment:
(Bug 24730) - add a "delete on success" option.
Patch by infinity0x@gmail.com

I just added some spaces and added the FancyCaptcha.php definition.
Modified paths:
  • /trunk/extensions/ConfirmEdit/FancyCaptcha.class.php (modified) (history)
  • /trunk/extensions/ConfirmEdit/FancyCaptcha.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmEdit/FancyCaptcha.php
@@ -38,5 +38,13 @@
3939 global $wgCaptchaSecret;
4040 $wgCaptchaSecret = "CHANGE_THIS_SECRET!";
4141
 42+/**
 43+ * By default the FancyCaptcha rotates among all available captchas.
 44+ * Setting $wgCaptchaDeleteOnSolve to true will delete the captcha
 45+ * files when they are correctly solved. Thus the user will need
 46+ * something like a cron creating new thumbnails to avoid drying up.
 47+ */
 48+$wgCaptchaDeleteOnSolve = false;
 49+
4250 $wgExtensionMessagesFiles['FancyCaptcha'] = dirname( __FILE__ ) . '/FancyCaptcha.i18n.php';
4351 $wgAutoloadClasses['FancyCaptcha'] = dirname( __FILE__ ) . '/FancyCaptcha.class.php';
Index: trunk/extensions/ConfirmEdit/FancyCaptcha.class.php
@@ -227,4 +227,23 @@
228228 # the default for edits
229229 return wfEmptyMsg( $name, $text ) ? wfMsg( 'fancycaptcha-edit' ) : $text;
230230 }
 231+
 232+ /**
 233+ * Delete a solved captcha image, if $wgCaptchaDeleteOnSolve is true.
 234+ */
 235+ function passCaptcha() {
 236+ global $wgCaptchaDeleteOnSolve;
 237+
 238+ $info = $this->retrieveCaptcha(); // get the captcha info before it gets deleted
 239+ $pass = parent::passCaptcha();
 240+
 241+ if ( $pass && $wgCaptchaDeleteOnSolve ) {
 242+ $filename = $this->imagePath( $info['salt'], $info['hash'] );
 243+ if ( file_exists( $filename ) ) {
 244+ unlink( $filename );
 245+ }
 246+ }
 247+
 248+ return $pass;
 249+ }
231250 }

Status & tagging log