r102827 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102826‎ | r102827 | r102828 >
Date:00:23, 12 November 2011
Author:aaron
Status:deferred
Tags:
Comment:
* Deferred $wgEnableEmail check until after LocalSettings is full loaded, using efLoadConfirmAccount().
* Moved defining of source code paths to defineSourcePaths() in new ConfirmAccountSetup class.
Modified paths:
  • /trunk/extensions/ConfirmAccount/ConfirmAccount.php (modified) (history)
  • /trunk/extensions/ConfirmAccount/ConfirmAccount.setup.php (added) (history)

Diff [purge]

Index: trunk/extensions/ConfirmAccount/ConfirmAccount.setup.php
@@ -0,0 +1,56 @@
 2+<?php
 3+/**
 4+ * Class containing basic setup functions.
 5+ */
 6+class ConfirmAccountSetup {
 7+ /**
 8+ * Register source code paths.
 9+ * This function must NOT depend on any config vars.
 10+ *
 11+ * @param $classes Array $classes
 12+ * @param $messagesFiles Array $messagesFiles
 13+ * @param $aliasesFiles Array $aliasesFiles
 14+ * @return void
 15+ */
 16+ public static function defineSourcePaths(
 17+ array &$classes, array &$messagesFiles, array &$aliasesFiles
 18+ ) {
 19+ $dir = dirname( __FILE__ );
 20+
 21+ # Basic directory layout
 22+ $backendDir = "$dir/backend";
 23+ $schemaDir = "$dir/backend/schema";
 24+ $businessDir = "$dir/business";
 25+ $frontendDir = "$dir/frontend";
 26+ $langDir = "$dir/frontend/";
 27+ $spActionDir = "$dir/frontend/specialpages/actions";
 28+ $spReportDir = "$dir/frontend/specialpages/reports";
 29+
 30+ # Internationalization files
 31+ $messagesFiles['ConfirmAccount'] = "$langDir/ConfirmAccount.i18n.php";
 32+ $aliasesFiles['ConfirmAccount'] = "$langDir/ConfirmAccount.alias.php";
 33+
 34+ # UI setup class
 35+ $classes['ConfirmAccountUISetup'] = "$frontendDir/ConfirmAccountUI.setup.php";
 36+ # UI event handler classes
 37+ $classes['ConfirmAccountUIHooks'] = "$frontendDir/ConfirmAccountUI.hooks.php";
 38+
 39+ # UI to request an account
 40+ $classes['RequestAccountPage'] = "$spActionDir/RequestAccount_body.php";
 41+ # UI to confirm accounts
 42+ $classes['ConfirmAccountsPage'] = "$spActionDir/ConfirmAccount_body.php";
 43+ # UI to see account credentials
 44+ $classes['UserCredentialsPage'] = "$spActionDir/UserCredentials_body.php";
 45+
 46+ # Utility functions
 47+ $classes['ConfirmAccount'] = "$backendDir/ConfirmAccount.class.php";
 48+ # Data access objects
 49+ $classes['UserAccountRequest'] = "$backendDir/UserAccountRequest.php";
 50+
 51+ # Business logic
 52+ $classes['AccountRequestSubmission'] = "$businessDir/AccountRequestSubmission.php";
 53+
 54+ # Schema changes
 55+ $classes['ConfirmAccountUpdaterHooks'] = "$schemaDir/ConfirmAccountUpdater.hooks.php";
 56+ }
 57+}
Property changes on: trunk/extensions/ConfirmAccount/ConfirmAccount.setup.php
___________________________________________________________________
Added: svn:eol-style
158 + native
Index: trunk/extensions/ConfirmAccount/ConfirmAccount.php
@@ -31,51 +31,22 @@
3232 'url' => 'http://www.mediawiki.org/wiki/Extension:ConfirmAccount',
3333 );
3434
35 -# This extension needs email enabled!
36 -# Otherwise users can't get their passwords...
37 -if ( !$wgEnableEmail ) {
38 - echo "ConfirmAccount extension requires \$wgEnableEmail set to true \n";
39 - exit( 1 ) ;
40 -}
41 -
4235 # Load default config variables
4336 require( dirname( __FILE__ ) . '/ConfirmAccount.config.php' );
4437
 38+# Define were classes and i18n files are located
 39+require( dirname( __FILE__ ) . '/ConfirmAccount.setup.php' );
 40+ConfirmAccountSetup::defineSourcePaths(
 41+ $wgAutoloadClasses,
 42+ $wgExtensionMessagesFiles,
 43+ $wgExtensionAliasesFiles
 44+);
 45+
4546 # Let some users confirm account requests and view credentials for created accounts
4647 $wgAvailableRights[] = 'confirmaccount'; // user can confirm account requests
4748 $wgAvailableRights[] = 'requestips'; // user can see IPs in request queue
4849 $wgAvailableRights[] = 'lookupcredentials'; // user can lookup info on confirmed users
4950
50 -$dir = dirname( __FILE__ ) . '/frontend';
51 -$wgAutoloadClasses['ConfirmAccountUISetup'] = "$dir/ConfirmAccountUI.setup.php";
52 -# Internationalization files
53 -$wgExtensionMessagesFiles['ConfirmAccount'] = "$dir/ConfirmAccount.i18n.php";
54 -$wgExtensionAliasesFiles['ConfirmAccount'] = "$dir/ConfirmAccount.alias.php";
55 -# UI event handler classes
56 -$wgAutoloadClasses['ConfirmAccountUIHooks'] = "$dir/ConfirmAccountUI.hooks.php";
57 -
58 -$dir = dirname( __FILE__ ) . '/frontend/specialpages';
59 -# UI to request an account
60 -$wgAutoloadClasses['RequestAccountPage'] = "$dir/actions/RequestAccount_body.php";
61 -# UI to confirm accounts
62 -$wgAutoloadClasses['ConfirmAccountsPage'] = "$dir/actions/ConfirmAccount_body.php";
63 -# UI to see account credentials
64 -$wgAutoloadClasses['UserCredentialsPage'] = "$dir/actions/UserCredentials_body.php";
65 -
66 -$dir = dirname( __FILE__ ) . '/backend';
67 -# Utility functions
68 -$wgAutoloadClasses['ConfirmAccount'] = "$dir/ConfirmAccount.class.php";
69 -# Data access objects
70 -$wgAutoloadClasses['UserAccountRequest'] = "$dir/UserAccountRequest.php";
71 -
72 -$dir = dirname( __FILE__ ) . '/business';
73 -# Business logic
74 -$wgAutoloadClasses['AccountRequestSubmission'] = "$dir/AccountRequestSubmission.php";
75 -
76 -$dir = dirname( __FILE__ ) . '/backend/schema';
77 -# Schema changes
78 -$wgAutoloadClasses['ConfirmAccountUpdaterHooks'] = "$dir/ConfirmAccountUpdater.hooks.php";
79 -
8051 # Actually register special pages
8152 ConfirmAccountUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups );
8253
@@ -94,3 +65,21 @@
9566 $wgHooks['LoadExtensionSchemaUpdates'][] = 'ConfirmAccountUpdaterHooks::addSchemaUpdates';
9667
9768 # ####### END HOOK CALLBACK FUNCTIONS #########
 69+
 70+# Load the extension after setup is finished
 71+$wgExtensionFunctions[] = 'efLoadConfirmAccount';
 72+
 73+/**
 74+ * This function is for setup that has to happen in Setup.php
 75+ * when the functions in $wgExtensionFunctions get executed.
 76+ * @return void
 77+ */
 78+function efLoadConfirmAccount() {
 79+ global $wgEnableEmail;
 80+ # This extension needs email enabled!
 81+ # Otherwise users can't get their passwords...
 82+ if ( !$wgEnableEmail ) {
 83+ echo "ConfirmAccount extension requires \$wgEnableEmail set to true \n";
 84+ exit( 1 ) ;
 85+ }
 86+}

Status & tagging log