r85725 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85724‎ | r85725 | r85726 >
Date:15:28, 9 April 2011
Author:ashley
Status:deferred
Tags:
Comment:
EmailCapture:
*minor coding style tweaks
*fix table name in EmailCaptureHooks.php
*check for MediaWiki environment in main setup file
*removed some pseudocode from SpecialEmailCapture.php in favor of real code
Modified paths:
  • /trunk/extensions/EmailCapture/EmailCapture.i18n.php (modified) (history)
  • /trunk/extensions/EmailCapture/EmailCapture.php (modified) (history)
  • /trunk/extensions/EmailCapture/EmailCaptureHooks.php (modified) (history)
  • /trunk/extensions/EmailCapture/SpecialEmailCapture.php (modified) (history)
  • /trunk/extensions/EmailCapture/api/ApiEmailCapture.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EmailCapture/EmailCapture.i18n.php
@@ -1,6 +1,6 @@
22 <?php
33 /**
4 - * Internationalisation for EmailCapture extension
 4+ * Internationalisation file for EmailCapture extension.
55 *
66 * @file
77 * @ingroup Extensions
@@ -14,6 +14,7 @@
1515 $messages['en'] = array(
1616 'emailcapture' => 'Email Capture',
1717 'emailcapture-desc' => 'Capture email addresses, and allow users to verify them through email',
 18+ 'emailcapture-failure' => "Your email was '''not''' verified.",
1819 'emailcapture-response-subject' => '{{SITENAME}} Email Verification',
1920 'emailcapture-response-body' => 'To verify your email address, following this link:
2021 $1
@@ -24,4 +25,5 @@
2526 $3
2627
2728 Thank you for verifying your email address.',
 29+ 'emailcapture-success' => 'Your email was successfully verified.',
2830 );
Index: trunk/extensions/EmailCapture/EmailCapture.php
@@ -1,17 +1,20 @@
22 <?php
33 /**
44 * EmailCapture extension
5 - *
 5+ *
66 * @file
77 * @ingroup Extensions
8 - *
 8+ * @version 0.3.0
99 * @author Trevor Parscal <trevor@wikimedia.org>
1010 * @license GPL v2 or later
11 - * @version 0.3.0
 11+ * @link http://www.mediawiki.org/wiki/Extension:EmailCapture Documentation
1212 */
1313
 14+if ( !defined( 'MEDIAWIKI' ) ) {
 15+ die( "This is not a valid entry point to MediaWiki.\n" );
 16+}
 17+
1418 /* Configuration */
15 -
1619 $wgEmailCaptureSendAutoResponse = true;
1720 $wgEmailCaptureAutoResponse = array(
1821 'from' => $wgPasswordSender,
@@ -21,16 +24,17 @@
2225 'content-type' => null,
2326 );
2427
25 -/* Setup */
26 -
 28+// Extension credits that will show up on Special:Version
2729 $wgExtensionCredits['other'][] = array(
2830 'path' => __FILE__,
2931 'name' => 'EmailCapture',
30 - 'author' => array( 'Trevor Parscal' ),
 32+ 'author' => 'Trevor Parscal',
3133 'version' => '0.3.0',
3234 'url' => 'http://www.mediawiki.org/wiki/Extension:EmailCapture',
3335 'descriptionmsg' => 'emailcapture-desc',
3436 );
 37+
 38+/* Setup */
3539 $dir = dirname( __FILE__ ) . '/';
3640 $wgExtensionMessagesFiles['EmailCapture'] = $dir . 'EmailCapture.i18n.php';
3741 // API
@@ -40,6 +44,6 @@
4145 $wgAutoloadClasses['EmailCaptureHooks'] = $dir . 'EmailCaptureHooks.php';
4246 $wgHooks['LoadExtensionSchemaUpdates'][] = 'EmailCaptureHooks::loadExtensionSchemaUpdates';
4347 $wgHooks['ParserTestTables'][] = 'EmailCaptureHooks::parserTestTables';
44 -// SpecialPage
45 -$wgAutoloadClasses['SpecialEmailCapture'] = $dir . "SpecialEmailCapture.php";
46 -$wgSpecialPages['EmailCapture'] = 'SpecialEmailCapture';
 48+// Special page
 49+$wgAutoloadClasses['SpecialEmailCapture'] = $dir . 'SpecialEmailCapture.php';
 50+$wgSpecialPages['EmailCapture'] = 'SpecialEmailCapture';
\ No newline at end of file
Index: trunk/extensions/EmailCapture/SpecialEmailCapture.php
@@ -1,23 +1,30 @@
22 <?php
 3+
34 class SpecialEmailCapture extends SpecialPage {
45
5 - function __construct() {
 6+ public function __construct() {
67 parent::__construct( 'EmailCapture', 'emailcapture' );
78 }
89
9 - function execute( $par ) {
 10+ public function execute( $par ) {
1011 global $wgOut, $wgRequest;
1112
1213 $this->setHeaders();
1314
1415 $code = $wgRequest->getVal( 'verify' );
1516 if ( $verify !== null ) {
16 - // $affectedRows = ( UPDATE email_capture SET (ec_veified = 1) WHERE ec_code = $code )
17 - // if ( $affectedRows ) {
18 - // show success
19 - // } else {
20 - // show failure
21 - // }
 17+ $dbw = wfGetDB( DB_MASTER );
 18+ $affectedRows = $dbw->update(
 19+ 'email_capture',
 20+ array( 'ec_verified' => 1 ),
 21+ array( 'ec_code' => $code ),
 22+ __METHOD__
 23+ );
 24+ if ( $affectedRows ) {
 25+ $wgOut->addWikiMsg( 'emailcapture-success' );
 26+ } else {
 27+ $wgOut->addWikiMsg( 'emailcapture-failure' );
 28+ }
2229 // exit
2330 }
2431 // Show simple form for submitting verification code
Index: trunk/extensions/EmailCapture/EmailCaptureHooks.php
@@ -1,8 +1,6 @@
22 <?php
33 /**
44 * Hooks for EmailCapture extension
5 - *
6 - * @author tparscal
75 */
86 class EmailCaptureHooks {
97 /**
@@ -18,7 +16,7 @@
1917 } else {
2018 $dir = dirname( __FILE__ );
2119 $db = $updater->getDB();
22 - if ( !$db->tableExists( 'article_feedback' ) ) {
 20+ if ( !$db->tableExists( 'email_capture' ) ) {
2321 // Initial install tables
2422 $updater->addExtensionUpdate( array(
2523 'addTable',
Index: trunk/extensions/EmailCapture/api/ApiEmailCapture.php
@@ -1,4 +1,5 @@
22 <?php
 3+
34 class ApiEmailCapture extends ApiBase {
45 public function __construct( $query, $moduleName ) {
56 parent::__construct( $query, $moduleName, '' );
@@ -10,7 +11,7 @@
1112 // Validation
1213 if ( !isset( $params['email'] ) ) {
1314 $this->dieUsageMsg( array( 'missingparam', 'email' ) );
14 - } else if ( !User:isValidEmailAddr( $params['email'] ) ) {
 15+ } elseif ( !User:isValidEmailAddr( $params['email'] ) ) {
1516 $this->dieUsage( 'The email address does not appear to be valid', 'invalidemail' );
1617 }
1718

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85707Creating new extension for collecting and verifying email addresses. This cod...tparscal00:40, 9 April 2011

Status & tagging log