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 |
1 | 58 | + native |
Index: trunk/extensions/ConfirmAccount/ConfirmAccount.php |
— | — | @@ -31,51 +31,22 @@ |
32 | 32 | 'url' => 'http://www.mediawiki.org/wiki/Extension:ConfirmAccount', |
33 | 33 | ); |
34 | 34 | |
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 | | - |
42 | 35 | # Load default config variables |
43 | 36 | require( dirname( __FILE__ ) . '/ConfirmAccount.config.php' ); |
44 | 37 | |
| 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 | + |
45 | 46 | # Let some users confirm account requests and view credentials for created accounts |
46 | 47 | $wgAvailableRights[] = 'confirmaccount'; // user can confirm account requests |
47 | 48 | $wgAvailableRights[] = 'requestips'; // user can see IPs in request queue |
48 | 49 | $wgAvailableRights[] = 'lookupcredentials'; // user can lookup info on confirmed users |
49 | 50 | |
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 | | - |
80 | 51 | # Actually register special pages |
81 | 52 | ConfirmAccountUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups ); |
82 | 53 | |
— | — | @@ -94,3 +65,21 @@ |
95 | 66 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'ConfirmAccountUpdaterHooks::addSchemaUpdates'; |
96 | 67 | |
97 | 68 | # ####### 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 | +} |