Index: trunk/extensions/EmailCapture/EmailCapture.i18n.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Internationalisation for EmailCapture extension |
| 4 | + * Internationalisation file for EmailCapture extension. |
5 | 5 | * |
6 | 6 | * @file |
7 | 7 | * @ingroup Extensions |
— | — | @@ -14,6 +14,7 @@ |
15 | 15 | $messages['en'] = array( |
16 | 16 | 'emailcapture' => 'Email Capture', |
17 | 17 | 'emailcapture-desc' => 'Capture email addresses, and allow users to verify them through email', |
| 18 | + 'emailcapture-failure' => "Your email was '''not''' verified.", |
18 | 19 | 'emailcapture-response-subject' => '{{SITENAME}} Email Verification', |
19 | 20 | 'emailcapture-response-body' => 'To verify your email address, following this link: |
20 | 21 | $1 |
— | — | @@ -24,4 +25,5 @@ |
25 | 26 | $3 |
26 | 27 | |
27 | 28 | Thank you for verifying your email address.', |
| 29 | + 'emailcapture-success' => 'Your email was successfully verified.', |
28 | 30 | ); |
Index: trunk/extensions/EmailCapture/EmailCapture.php |
— | — | @@ -1,17 +1,20 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * EmailCapture extension |
5 | | - * |
| 5 | + * |
6 | 6 | * @file |
7 | 7 | * @ingroup Extensions |
8 | | - * |
| 8 | + * @version 0.3.0 |
9 | 9 | * @author Trevor Parscal <trevor@wikimedia.org> |
10 | 10 | * @license GPL v2 or later |
11 | | - * @version 0.3.0 |
| 11 | + * @link http://www.mediawiki.org/wiki/Extension:EmailCapture Documentation |
12 | 12 | */ |
13 | 13 | |
| 14 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 15 | + die( "This is not a valid entry point to MediaWiki.\n" ); |
| 16 | +} |
| 17 | + |
14 | 18 | /* Configuration */ |
15 | | - |
16 | 19 | $wgEmailCaptureSendAutoResponse = true; |
17 | 20 | $wgEmailCaptureAutoResponse = array( |
18 | 21 | 'from' => $wgPasswordSender, |
— | — | @@ -21,16 +24,17 @@ |
22 | 25 | 'content-type' => null, |
23 | 26 | ); |
24 | 27 | |
25 | | -/* Setup */ |
26 | | - |
| 28 | +// Extension credits that will show up on Special:Version |
27 | 29 | $wgExtensionCredits['other'][] = array( |
28 | 30 | 'path' => __FILE__, |
29 | 31 | 'name' => 'EmailCapture', |
30 | | - 'author' => array( 'Trevor Parscal' ), |
| 32 | + 'author' => 'Trevor Parscal', |
31 | 33 | 'version' => '0.3.0', |
32 | 34 | 'url' => 'http://www.mediawiki.org/wiki/Extension:EmailCapture', |
33 | 35 | 'descriptionmsg' => 'emailcapture-desc', |
34 | 36 | ); |
| 37 | + |
| 38 | +/* Setup */ |
35 | 39 | $dir = dirname( __FILE__ ) . '/'; |
36 | 40 | $wgExtensionMessagesFiles['EmailCapture'] = $dir . 'EmailCapture.i18n.php'; |
37 | 41 | // API |
— | — | @@ -40,6 +44,6 @@ |
41 | 45 | $wgAutoloadClasses['EmailCaptureHooks'] = $dir . 'EmailCaptureHooks.php'; |
42 | 46 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'EmailCaptureHooks::loadExtensionSchemaUpdates'; |
43 | 47 | $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 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | class SpecialEmailCapture extends SpecialPage { |
4 | 5 | |
5 | | - function __construct() { |
| 6 | + public function __construct() { |
6 | 7 | parent::__construct( 'EmailCapture', 'emailcapture' ); |
7 | 8 | } |
8 | 9 | |
9 | | - function execute( $par ) { |
| 10 | + public function execute( $par ) { |
10 | 11 | global $wgOut, $wgRequest; |
11 | 12 | |
12 | 13 | $this->setHeaders(); |
13 | 14 | |
14 | 15 | $code = $wgRequest->getVal( 'verify' ); |
15 | 16 | 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 | + } |
22 | 29 | // exit |
23 | 30 | } |
24 | 31 | // Show simple form for submitting verification code |
Index: trunk/extensions/EmailCapture/EmailCaptureHooks.php |
— | — | @@ -1,8 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * Hooks for EmailCapture extension |
5 | | - * |
6 | | - * @author tparscal |
7 | 5 | */ |
8 | 6 | class EmailCaptureHooks { |
9 | 7 | /** |
— | — | @@ -18,7 +16,7 @@ |
19 | 17 | } else { |
20 | 18 | $dir = dirname( __FILE__ ); |
21 | 19 | $db = $updater->getDB(); |
22 | | - if ( !$db->tableExists( 'article_feedback' ) ) { |
| 20 | + if ( !$db->tableExists( 'email_capture' ) ) { |
23 | 21 | // Initial install tables |
24 | 22 | $updater->addExtensionUpdate( array( |
25 | 23 | 'addTable', |
Index: trunk/extensions/EmailCapture/api/ApiEmailCapture.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | class ApiEmailCapture extends ApiBase { |
4 | 5 | public function __construct( $query, $moduleName ) { |
5 | 6 | parent::__construct( $query, $moduleName, '' ); |
— | — | @@ -10,7 +11,7 @@ |
11 | 12 | // Validation |
12 | 13 | if ( !isset( $params['email'] ) ) { |
13 | 14 | $this->dieUsageMsg( array( 'missingparam', 'email' ) ); |
14 | | - } else if ( !User:isValidEmailAddr( $params['email'] ) ) { |
| 15 | + } elseif ( !User:isValidEmailAddr( $params['email'] ) ) { |
15 | 16 | $this->dieUsage( 'The email address does not appear to be valid', 'invalidemail' ); |
16 | 17 | } |
17 | 18 | |