r85810 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85809‎ | r85810 | r85811 >
Date:18:29, 11 April 2011
Author:tparscal
Status:ok
Tags:
Comment:
Fixed schema issues, syntax errors in the schema update code, made path to SQL file absolute (by adding a true at the end of the array) and got the form working for verifying an email address.
Modified paths:
  • /trunk/extensions/EmailCapture/EmailCapture.i18n.php (modified) (history)
  • /trunk/extensions/EmailCapture/EmailCaptureHooks.php (modified) (history)
  • /trunk/extensions/EmailCapture/SpecialEmailCapture.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EmailCapture/EmailCapture.i18n.php
@@ -26,4 +26,7 @@
2727
2828 Thank you for verifying your email address.',
2929 'emailcapture-success' => 'Your email was successfully verified.',
 30+ 'emailcapture-instructions' => 'To verify your email address, enter the code that was emailed to you and click verify.',
 31+ 'emailcapture-verify' => 'Verification code:',
 32+ 'emailcapture-submit' => 'Verify email address',
3033 );
Index: trunk/extensions/EmailCapture/SpecialEmailCapture.php
@@ -7,26 +7,40 @@
88 }
99
1010 public function execute( $par ) {
11 - global $wgOut, $wgRequest;
 11+ global $wgOut, $wgUser, $wgRequest;
1212
1313 $this->setHeaders();
1414
1515 $code = $wgRequest->getVal( 'verify' );
16 - if ( $verify !== null ) {
 16+ if ( $code !== null ) {
1717 $dbw = wfGetDB( DB_MASTER );
18 - $affectedRows = $dbw->update(
 18+ $dbw->update(
1919 'email_capture',
2020 array( 'ec_verified' => 1 ),
2121 array( 'ec_code' => $code ),
2222 __METHOD__
2323 );
24 - if ( $affectedRows ) {
 24+ if ( $dbw->affectedRows() ) {
2525 $wgOut->addWikiMsg( 'emailcapture-success' );
2626 } else {
2727 $wgOut->addWikiMsg( 'emailcapture-failure' );
2828 }
29 - // exit
 29+ } else {
 30+ // Show simple form for submitting verification code
 31+ $o = Html::openElement( 'form', array(
 32+ 'action' => $this->getTitle()->getFullUrl(),
 33+ 'method' => 'post'
 34+ ) );
 35+ $o .= Html::element( 'p', array(), wfMsg( 'emailcapture-instructions' ) );
 36+ $o .= Html::openElement( 'blockquote' );
 37+ $o .= Html::element( 'label', array( 'for' => 'emailcapture-verify' ),
 38+ wfMsg( 'emailcapture-verify' ) );
 39+ $o .= Html::input( 'verify', '', 'text',
 40+ array( 'id' => 'emailcapture-verify', 'size' => 32 ) );
 41+ $o .= Html::input( 'submit', wfMsg( 'emailcapture-submit' ), 'submit' );
 42+ $o .= Html::closeElement( 'blockquote' );
 43+ $o .= Html::closeElement( 'form' );
 44+ $wgOut->addHtml( $o );
3045 }
31 - // Show simple form for submitting verification code
3246 }
3347 }
Index: trunk/extensions/EmailCapture/EmailCaptureHooks.php
@@ -6,16 +6,16 @@
77 /**
88 * LoadExtensionSchemaUpdates hook
99 */
10 - public static function loadExtensionSchemaUpdates( $updater = null ) {
11 - $dir = dirname( __FILE__ );
 10+ public static function loadExtensionSchemaUpdates( $updater ) {
1211 $db = $updater->getDB();
1312 if ( !$db->tableExists( 'email_capture' ) ) {
1413 // Initial install tables
1514 $updater->addExtensionUpdate( array(
1615 'addTable',
1716 'email_capture',
18 - dirname( __FILE__ ) . '/sql/CreateEmailCaptureTable.sql'
19 - );
 17+ dirname( __FILE__ ) . '/sql/CreateEmailCaptureTable.sql',
 18+ true
 19+ ) );
2020 }
2121 return true;
2222 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r85811(part 2 of 2 - see r85810) Fixed schema issues, syntax errors in the schema u...tparscal18:31, 11 April 2011

Status & tagging log